summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Bragg <robert@linux.intel.com>2011-08-03 17:03:09 +0100
committerRobert Bragg <robert@linux.intel.com>2011-08-12 15:28:43 +0100
commit8e8690a562395d96485115a7f437a55f8db2af77 (patch)
treecb2f47bf2025bcfb52267df7120d6078b7b4921a
parenta3ad808f57f1ce4535b885c81a64a0934e859a36 (diff)
downloadcogl-8e8690a562395d96485115a7f437a55f8db2af77.tar.gz
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>
-rw-r--r--cogl/cogl-framebuffer.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/cogl/cogl-framebuffer.c b/cogl/cogl-framebuffer.c
index 48a42187..a7a442c1 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)