[cogl] framebuffer: lazily allocate framebuffers as needed
- From: Robert Bragg <rbragg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cogl] framebuffer: lazily allocate framebuffers as needed
- Date: Fri, 12 Aug 2011 14:45:46 +0000 (UTC)
commit 8e8690a562395d96485115a7f437a55f8db2af77
Author: Robert Bragg <robert linux intel com>
Date: Wed Aug 3 17:03:09 2011 +0100
framebuffer: lazily allocate framebuffers as needed
If the user doesn't explicitly allocate a CoglFramebuffer then Cogl
should automatically allocate the framebuffer when the user starts to
draw to the framebuffer. So this way calling cogl_framebuffer_allocate
is only required if you are explicitly interested in checking for and
gracefully handling failures to allocate a framebuffer. If automatic
allocation fails then application behaviour becomes undefined.
Reviewed-by: Neil Roberts <neil linux intel com>
cogl/cogl-framebuffer.c | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
---
diff --git a/cogl/cogl-framebuffer.c b/cogl/cogl-framebuffer.c
index 48a4218..a7a442c 100644
--- a/cogl/cogl-framebuffer.c
+++ b/cogl/cogl-framebuffer.c
@@ -301,8 +301,6 @@ cogl_framebuffer_clear4f (CoglFramebuffer *framebuffer,
int scissor_x1;
int scissor_y1;
- g_return_if_fail (framebuffer->allocated);
-
_cogl_clip_stack_get_bounds (clip_stack,
&scissor_x0, &scissor_y0,
&scissor_x1, &scissor_y1);
@@ -452,8 +450,6 @@ cogl_framebuffer_clear (CoglFramebuffer *framebuffer,
unsigned long buffers,
const CoglColor *color)
{
- g_return_if_fail (framebuffer->allocated);
-
cogl_framebuffer_clear4f (framebuffer, buffers,
cogl_color_get_red_float (color),
cogl_color_get_green_float (color),
@@ -618,6 +614,8 @@ _cogl_framebuffer_init_bits (CoglFramebuffer *framebuffer)
{
CoglContext *ctx = framebuffer->context;
+ cogl_framebuffer_allocate (framebuffer, NULL);
+
if (G_LIKELY (!framebuffer->dirty_bitmasks))
return;
@@ -1383,6 +1381,10 @@ _cogl_framebuffer_flush_state (CoglFramebuffer *draw_buffer,
{
CoglContext *ctx = draw_buffer->context;
+ /* Lazily ensure the framebuffer has been allocated */
+ cogl_framebuffer_allocate (draw_buffer, NULL);
+ cogl_framebuffer_allocate (read_buffer, NULL);
+
if (ctx->dirty_bound_framebuffer)
{
if (draw_buffer == read_buffer)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]