diff options
author | Neil Roberts <neil@linux.intel.com> | 2011-02-02 15:17:50 +0000 |
---|---|---|
committer | Neil Roberts <neil@linux.intel.com> | 2011-02-10 20:19:01 +0000 |
commit | ef1b4000424698faebc59172d3fd181584d2a366 (patch) | |
tree | e94a41a5c519c2521fb769f7ff424ce11a9c2aab /cogl/cogl-framebuffer.c | |
parent | 4d2878d4b259ccbe3b5472d0bdbd8685ae7ec57d (diff) | |
download | cogl-ef1b4000424698faebc59172d3fd181584d2a366.tar.gz |
cogl-framebuffer: Fix flushing the framebuffer on push
When pushing a framebuffer it would previously push
COGL_INVALID_HANDLE to the top of the framebuffer stack so that when
it later calls cogl_set_framebuffer it will recognise that the
framebuffer is different and replace the top with the new
pointer. This isn't ideal because it breaks the code to flush the
journal because _cogl_framebuffer_flush_journal is called with the
value of the old pointer which is NULL. That function was checking for
a NULL pointer so it wouldn't actually flush. It also would mean that
if you pushed the same framebuffer twice we would end up dirtying
state unnecessarily. To fix this cogl_push_framebuffer now pushes a
reference to the current framebuffer instead.
Diffstat (limited to 'cogl/cogl-framebuffer.c')
-rw-r--r-- | cogl/cogl-framebuffer.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/cogl/cogl-framebuffer.c b/cogl/cogl-framebuffer.c index dc5205ca..23b85111 100644 --- a/cogl/cogl-framebuffer.c +++ b/cogl/cogl-framebuffer.c @@ -587,8 +587,7 @@ _cogl_framebuffer_remove_all_dependencies (CoglFramebuffer *framebuffer) void _cogl_framebuffer_flush_journal (CoglFramebuffer *framebuffer) { - if (framebuffer) - _cogl_journal_flush (framebuffer->journal, framebuffer); + _cogl_journal_flush (framebuffer->journal, framebuffer); } void @@ -1057,8 +1056,11 @@ cogl_set_framebuffer (CoglFramebuffer *framebuffer) /* XXX: eventually we want to remove this implicit journal flush * so we can log into the journal beyond framebuffer changes to * support batching scenes that depend on the results of - * mid-scene renders to textures. */ - _cogl_framebuffer_flush_journal (current); + * mid-scene renders to textures. Current will be NULL when the + * framebuffer stack is first created so we need to guard + * against that here */ + if (current) + _cogl_framebuffer_flush_journal (current); _cogl_set_framebuffer_real (framebuffer); } } @@ -1093,8 +1095,11 @@ cogl_push_framebuffer (CoglFramebuffer *buffer) g_return_if_fail (_cogl_is_framebuffer (buffer)); g_assert (ctx->framebuffer_stack); + /* Copy the top of the stack so that when we call cogl_set_framebuffer + it will still know what the old framebuffer was */ ctx->framebuffer_stack = - g_slist_prepend (ctx->framebuffer_stack, COGL_INVALID_HANDLE); + g_slist_prepend (ctx->framebuffer_stack, + cogl_object_ref (_cogl_get_framebuffer ())); cogl_set_framebuffer (buffer); } |