framebuffer: Handle a NULL previous framebuffer when flushing

_cogl_framebuffer_flush_state needs to handle the case where
ctx->current_draw_buffer is NULL because this will be set in the
destructor for CoglFramebuffer if the framebuffer being destroyed is
the current framebuffer. This patch just makes it assume all state has
changed in that case.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
This commit is contained in:
Neil Roberts 2011-12-01 18:46:37 +00:00 committed by Robert Bragg
parent 7283e0a49c
commit 0c82c296bf

View File

@ -1615,12 +1615,21 @@ _cogl_framebuffer_flush_state (CoglFramebuffer *draw_buffer,
if (ctx->current_draw_buffer != draw_buffer) if (ctx->current_draw_buffer != draw_buffer)
{ {
/* NB: we only need to compare the state we're being asked to flush /* If the previous draw buffer is NULL then we'll assume
* and we don't need to compare the state we've already decided everything has changed. This can happen if a framebuffer is
* we will definitely flush... */ destroyed while it is the last flushed draw buffer. In that
differences |= _cogl_framebuffer_compare (ctx->current_draw_buffer, case the framebuffer destructor will set
draw_buffer, ctx->current_draw_buffer to NULL */
state & ~differences); if (ctx->current_draw_buffer == NULL)
differences |= state;
else
/* NB: we only need to compare the state we're being asked to flush
* and we don't need to compare the state we've already decided
* we will definitely flush... */
differences |= _cogl_framebuffer_compare (ctx->current_draw_buffer,
draw_buffer,
state & ~differences);
/* NB: we don't take a reference here, to avoid a circular /* NB: we don't take a reference here, to avoid a circular
* reference. */ * reference. */
ctx->current_draw_buffer = draw_buffer; ctx->current_draw_buffer = draw_buffer;