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.
This commit is contained in:
Neil Roberts 2011-02-02 15:17:50 +00:00
parent 3afa732bce
commit 2ee7052d89

View File

@ -587,7 +587,6 @@ _cogl_framebuffer_remove_all_dependencies (CoglFramebuffer *framebuffer)
void
_cogl_framebuffer_flush_journal (CoglFramebuffer *framebuffer)
{
if (framebuffer)
_cogl_journal_flush (framebuffer->journal, framebuffer);
}
@ -1057,7 +1056,10 @@ 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. */
* 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);
}