summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Bragg <robert@linux.intel.com>2011-11-21 17:58:45 +0000
committerRobert Bragg <robert@linux.intel.com>2011-11-29 12:38:45 +0000
commit075ef89e756603f11d0ac5934ee8911504d0e37c (patch)
treedaefa87d9de7e73ef03a6102b2ef695bd1c54213
parentbf8dc36353b9ce0dd09449a67f0847b9bf088cb1 (diff)
downloadcogl-075ef89e756603f11d0ac5934ee8911504d0e37c.tar.gz
stash: track fb color mask like other fb state
-rw-r--r--cogl/cogl-framebuffer-private.h6
-rw-r--r--cogl/cogl-framebuffer.c54
2 files changed, 41 insertions, 19 deletions
diff --git a/cogl/cogl-framebuffer-private.h b/cogl/cogl-framebuffer-private.h
index 7fbab5c0..9fbf54be 100644
--- a/cogl/cogl-framebuffer-private.h
+++ b/cogl/cogl-framebuffer-private.h
@@ -71,7 +71,8 @@ typedef enum _CoglFramebufferStateIndex
COGL_FRAMEBUFFER_STATE_INDEX_DITHER = 3,
COGL_FRAMEBUFFER_STATE_INDEX_MODELVIEW = 4,
COGL_FRAMEBUFFER_STATE_INDEX_PROJECTION = 5,
- COGL_FRAMEBUFFER_STATE_INDEX_MAX = 6
+ COGL_FRAMEBUFFER_STATE_INDEX_COLOR_MASK = 6,
+ COGL_FRAMEBUFFER_STATE_INDEX_MAX = 7
} CoglFramebufferStateIndex;
typedef enum _CoglFramebufferState
@@ -81,7 +82,8 @@ typedef enum _CoglFramebufferState
COGL_FRAMEBUFFER_STATE_CLIP = 1<<2,
COGL_FRAMEBUFFER_STATE_DITHER = 1<<3,
COGL_FRAMEBUFFER_STATE_MODELVIEW = 1<<4,
- COGL_FRAMEBUFFER_STATE_PROJECTION = 1<<5
+ COGL_FRAMEBUFFER_STATE_PROJECTION = 1<<5,
+ COGL_FRAMEBUFFER_STATE_COLOR_MASK = 1<<6
} CoglFramebufferState;
#define COGL_FRAMEBUFFER_STATE_ALL ((1<<COGL_FRAMEBUFFER_STATE_INDEX_MAX) - 1)
diff --git a/cogl/cogl-framebuffer.c b/cogl/cogl-framebuffer.c
index f996d3c9..388711e2 100644
--- a/cogl/cogl-framebuffer.c
+++ b/cogl/cogl-framebuffer.c
@@ -1108,17 +1108,6 @@ notify_buffers_changed (CoglFramebuffer *old_draw_buffer,
if (old_draw_buffer && new_draw_buffer)
{
- /* If the two draw framebuffers have a different color mask then
- we need to ensure the logic ops are reflushed the next time
- something is drawn */
- if (cogl_framebuffer_get_color_mask (old_draw_buffer) !=
- cogl_framebuffer_get_color_mask (new_draw_buffer))
- {
- ctx->current_pipeline_changes_since_flush |=
- COGL_PIPELINE_STATE_LOGIC_OPS;
- ctx->current_pipeline_age--;
- }
-
/* If we're switching from onscreen to offscreen and the last
flush pipeline is using backface culling then we also need to
reflush the cull face state because the winding order of the
@@ -1429,6 +1418,17 @@ _cogl_framebuffer_compare_projection_state (CoglFramebuffer *a,
}
static unsigned long
+_cogl_framebuffer_compare_color_mask_state (CoglFramebuffer *a,
+ CoglFramebuffer *b)
+{
+ if (cogl_framebuffer_get_color_mask (a) !=
+ cogl_framebuffer_get_color_mask (b))
+ return COGL_FRAMEBUFFER_STATE_COLOR_MASK;
+ else
+ return 0;
+}
+
+static unsigned long
_cogl_framebuffer_compare (CoglFramebuffer *a,
CoglFramebuffer *b,
unsigned long state)
@@ -1468,6 +1468,10 @@ _cogl_framebuffer_compare (CoglFramebuffer *a,
differences |=
_cogl_framebuffer_compare_projection_state (a, b);
break;
+ case COGL_FRAMEBUFFER_STATE_INDEX_COLOR_MASK:
+ differences |=
+ _cogl_framebuffer_compare_color_mask_state (a, b);
+ break;
default:
g_warn_if_reached ();
}
@@ -1547,6 +1551,20 @@ _cogl_framebuffer_flush_projection_state (CoglFramebuffer *framebuffer)
COGL_MATRIX_PROJECTION);
}
+static void
+_cogl_framebuffer_flush_color_mask_state (CoglFramebuffer *framebuffer)
+{
+ CoglContext *context = framebuffer->context;
+
+ /* The color mask state is really owned by a CoglPipeline so to
+ * ensure the color mask is updated the next time we draw something
+ * we need to make sure the logic ops for the pipeline are
+ * re-flushed... */
+ context->current_pipeline_changes_since_flush |=
+ COGL_PIPELINE_STATE_LOGIC_OPS;
+ context->current_pipeline_age--;
+}
+
void
_cogl_framebuffer_flush_state (CoglFramebuffer *draw_buffer,
CoglFramebuffer *read_buffer,
@@ -1649,6 +1667,9 @@ _cogl_framebuffer_flush_state (CoglFramebuffer *draw_buffer,
case COGL_FRAMEBUFFER_STATE_INDEX_PROJECTION:
_cogl_framebuffer_flush_projection_state (draw_buffer);
break;
+ case COGL_FRAMEBUFFER_STATE_INDEX_COLOR_MASK:
+ _cogl_framebuffer_flush_color_mask_state (draw_buffer);
+ break;
default:
g_warn_if_reached ();
}
@@ -1701,15 +1722,14 @@ void
cogl_framebuffer_set_color_mask (CoglFramebuffer *framebuffer,
CoglColorMask color_mask)
{
- _COGL_GET_CONTEXT (ctx, NO_RETVAL);
+ /* XXX: Currently color mask changes don't go through the journal */
+ _cogl_framebuffer_flush_journal (framebuffer);
- cogl_flush (); /* XXX: Currently color mask changes don't go through the journal */
framebuffer->color_mask = color_mask;
- /* Make sure the ColorMask is updated when the next primitive is drawn */
- ctx->current_pipeline_changes_since_flush |=
- COGL_PIPELINE_STATE_LOGIC_OPS;
- ctx->current_pipeline_age--;
+ if (framebuffer->context->current_draw_buffer == framebuffer)
+ framebuffer->context->current_draw_buffer_changes |=
+ COGL_FRAMEBUFFER_STATE_COLOR_MASK;
}
gboolean