summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeil Roberts <neil@linux.intel.com>2011-12-01 18:46:37 +0000
committerRobert Bragg <robert@linux.intel.com>2011-12-06 19:02:05 +0000
commit0c82c296bf15d40b54739d46d82f38d40e58f522 (patch)
tree1b5f429ccd99c302eea97bc2967c086cae6be926
parent7283e0a49c5eeee9242ccd5857e2a51d6934b792 (diff)
downloadcogl-0c82c296bf15d40b54739d46d82f38d40e58f522.tar.gz
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>
-rw-r--r--cogl/cogl-framebuffer.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/cogl/cogl-framebuffer.c b/cogl/cogl-framebuffer.c
index f8fc101c..eaa0be78 100644
--- a/cogl/cogl-framebuffer.c
+++ b/cogl/cogl-framebuffer.c
@@ -1615,12 +1615,21 @@ _cogl_framebuffer_flush_state (CoglFramebuffer *draw_buffer,
if (ctx->current_draw_buffer != draw_buffer)
{
- /* 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);
+ /* If the previous draw buffer is NULL then we'll assume
+ everything has changed. This can happen if a framebuffer is
+ destroyed while it is the last flushed draw buffer. In that
+ case the framebuffer destructor will set
+ ctx->current_draw_buffer to NULL */
+ 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
* reference. */
ctx->current_draw_buffer = draw_buffer;