[cogl] pipeline: Assume blend enabled when there are snippets
- From: Robert Bragg <rbragg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cogl] pipeline: Assume blend enabled when there are snippets
- Date: Tue, 6 Dec 2011 19:16:11 +0000 (UTC)
commit 5be5a033431597efc1f3b368a51a59e5b84e66ec
Author: Neil Roberts <neil linux intel com>
Date: Fri Nov 25 17:59:52 2011 +0000
pipeline: Assume blend enabled when there are snippets
Whenever snippets are enabled we can't determine whether the final
color will be fully opaque so we just have to assume blending should
be enabled.
Reviewed-by: Robert Bragg <robert linux intel com>
cogl/cogl-pipeline-layer.c | 7 +++++++
cogl/cogl-pipeline-state-private.h | 6 ++++++
cogl/cogl-pipeline-state.c | 23 ++++++++++++++++++-----
cogl/cogl-pipeline.c | 12 ++++++++++++
4 files changed, 43 insertions(+), 5 deletions(-)
---
diff --git a/cogl/cogl-pipeline-layer.c b/cogl/cogl-pipeline-layer.c
index 86e0750..76d17e7 100644
--- a/cogl/cogl-pipeline-layer.c
+++ b/cogl/cogl-pipeline-layer.c
@@ -78,6 +78,7 @@ _cogl_pipeline_layer_has_alpha (CoglPipelineLayer *layer)
COGL_PIPELINE_LAYER_STATE_COMBINE);
CoglPipelineLayerBigState *big_state = combine_authority->big_state;
CoglPipelineLayer *tex_authority;
+ CoglPipelineLayer *snippets_authority;
/* has_alpha maintains the alpha status for the GL_PREVIOUS layer */
@@ -112,6 +113,12 @@ _cogl_pipeline_layer_has_alpha (CoglPipelineLayer *layer)
return TRUE;
}
+ /* All bets are off if the layer contains any snippets */
+ snippets_authority = _cogl_pipeline_layer_get_authority
+ (layer, COGL_PIPELINE_LAYER_STATE_FRAGMENT_SNIPPETS);
+ if (!COGL_LIST_EMPTY (&snippets_authority->big_state->fragment_snippets))
+ return TRUE;
+
return FALSE;
}
diff --git a/cogl/cogl-pipeline-state-private.h b/cogl/cogl-pipeline-state-private.h
index 9a38e11..2bc162d 100644
--- a/cogl/cogl-pipeline-state-private.h
+++ b/cogl/cogl-pipeline-state-private.h
@@ -37,6 +37,12 @@ _cogl_pipeline_has_vertex_snippets (CoglPipeline *pipeline);
gboolean
_cogl_pipeline_has_fragment_snippets (CoglPipeline *pipeline);
+gboolean
+_cogl_pipeline_has_non_layer_vertex_snippets (CoglPipeline *pipeline);
+
+gboolean
+_cogl_pipeline_has_non_layer_fragment_snippets (CoglPipeline *pipeline);
+
void
_cogl_pipeline_set_fog_state (CoglPipeline *pipeline,
const CoglPipelineFogState *fog_state);
diff --git a/cogl/cogl-pipeline-state.c b/cogl/cogl-pipeline-state.c
index 04caa91..3477820 100644
--- a/cogl/cogl-pipeline-state.c
+++ b/cogl/cogl-pipeline-state.c
@@ -1632,7 +1632,7 @@ cogl_pipeline_add_fragment_hook (CoglPipeline *pipeline,
}
gboolean
-_cogl_pipeline_has_vertex_snippets (CoglPipeline *pipeline)
+_cogl_pipeline_has_non_layer_vertex_snippets (CoglPipeline *pipeline)
{
CoglPipeline *authority =
_cogl_pipeline_get_authority (pipeline,
@@ -1641,6 +1641,22 @@ _cogl_pipeline_has_vertex_snippets (CoglPipeline *pipeline)
return !COGL_LIST_EMPTY (&authority->big_state->vertex_snippets);
}
+gboolean
+_cogl_pipeline_has_vertex_snippets (CoglPipeline *pipeline)
+{
+ return _cogl_pipeline_has_non_layer_vertex_snippets (pipeline);
+}
+
+gboolean
+_cogl_pipeline_has_non_layer_fragment_snippets (CoglPipeline *pipeline)
+{
+ CoglPipeline *authority =
+ _cogl_pipeline_get_authority (pipeline,
+ COGL_PIPELINE_STATE_FRAGMENT_SNIPPETS);
+
+ return !COGL_LIST_EMPTY (&authority->big_state->fragment_snippets);
+}
+
static gboolean
check_layer_has_fragment_snippet (CoglPipelineLayer *layer,
void *user_data)
@@ -1662,12 +1678,9 @@ check_layer_has_fragment_snippet (CoglPipelineLayer *layer,
gboolean
_cogl_pipeline_has_fragment_snippets (CoglPipeline *pipeline)
{
- CoglPipeline *authority =
- _cogl_pipeline_get_authority (pipeline,
- COGL_PIPELINE_STATE_FRAGMENT_SNIPPETS);
gboolean found_fragment_snippet = FALSE;
- if (!COGL_LIST_EMPTY (&authority->big_state->fragment_snippets))
+ if (_cogl_pipeline_has_non_layer_fragment_snippets (pipeline))
return TRUE;
_cogl_pipeline_foreach_layer_internal (pipeline,
diff --git a/cogl/cogl-pipeline.c b/cogl/cogl-pipeline.c
index 2831b55..026c9c6 100644
--- a/cogl/cogl-pipeline.c
+++ b/cogl/cogl-pipeline.c
@@ -761,6 +761,18 @@ _cogl_pipeline_needs_blending_enabled (CoglPipeline *pipeline,
return TRUE;
}
+ if (changes & COGL_PIPELINE_STATE_FRAGMENT_SNIPPETS)
+ {
+ if (!_cogl_pipeline_has_non_layer_fragment_snippets (pipeline))
+ return TRUE;
+ }
+
+ if (changes & COGL_PIPELINE_STATE_VERTEX_SNIPPETS)
+ {
+ if (!_cogl_pipeline_has_non_layer_vertex_snippets (pipeline))
+ return TRUE;
+ }
+
/* XXX: we should only need to look at these if lighting is enabled
*/
if (changes & COGL_PIPELINE_STATE_LIGHTING)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]