[cogl/cogl-1.10] Fix removing layers when the pipeline is not the owner
- From: Neil Roberts <nroberts src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cogl/cogl-1.10] Fix removing layers when the pipeline is not the owner
- Date: Wed, 20 Jun 2012 10:58:41 +0000 (UTC)
commit 1f7a1bba9b259d1dd286b407602e6412afc92f33
Author: Neil Roberts <neil linux intel com>
Date: Thu May 24 12:54:44 2012 +0100
Fix removing layers when the pipeline is not the owner
If cogl_pipeline_remove_layer is called on a copied pipeline to remove
a parent layer then it will still end up calling
_cogl_pipeline_remove_layer_difference on the layer. This function
was directly trying to remove the layer from the pipeline's list of
layer differences. However in the child pipeline the layer isn't in
the list because it is unchanged from its parent. The function had an
assertion to verify that this situation wasn't hit so in a debug build
it would just bail out.
This patch removes the assertion and changes it to only remove the
layer if it is owned by the pipeline. Otherwise it just sets the
COGL_PIPELINE_STATE_LAYERS difference as normal and decrements the
number of layers. This will cause it to successfully remove the layer
because either it is the last layer in which case it will be ignored
after n_layers is decreased or if it is in the middle of the list then
the subsequent layers will all be shifted down so there will be a
replacement layer difference.
Reviewed-by: Robert Bragg <robert linux intel com>
(cherry picked from commit 88e73dd93fa09a158064a946ab229591a5888b97)
cogl/cogl-pipeline.c | 22 +++++++++++++++-------
1 files changed, 15 insertions(+), 7 deletions(-)
---
diff --git a/cogl/cogl-pipeline.c b/cogl/cogl-pipeline.c
index 7ee1b29..9f21c2f 100644
--- a/cogl/cogl-pipeline.c
+++ b/cogl/cogl-pipeline.c
@@ -1404,8 +1404,6 @@ _cogl_pipeline_remove_layer_difference (CoglPipeline *pipeline,
CoglPipelineLayer *layer,
gboolean dec_n_layers)
{
- _COGL_RETURN_IF_FAIL (layer->owner == pipeline);
-
/* - Flush journal primitives referencing the current state.
* - Make sure the pipeline has no dependants so it may be modified.
* - If the pipeline isn't currently an authority for the state being
@@ -1421,13 +1419,23 @@ _cogl_pipeline_remove_layer_difference (CoglPipeline *pipeline,
NULL,
!dec_n_layers);
- layer->owner = NULL;
- cogl_object_unref (layer);
+ /* We only need to remove the layer difference if the pipeline is
+ * currently the owner. If it is not the owner then one of two
+ * things will happen to make sure this layer is replaced. If it is
+ * the last layer being removed then decrementing n_layers will
+ * ensure that the last layer is skipped. If it is any other layer
+ * then the subsequent layers will have been shifted down and cause
+ * it be replaced */
+ if (layer->owner == pipeline)
+ {
+ layer->owner = NULL;
+ cogl_object_unref (layer);
- pipeline->differences |= COGL_PIPELINE_STATE_LAYERS;
+ pipeline->layer_differences =
+ g_list_remove (pipeline->layer_differences, layer);
+ }
- pipeline->layer_differences =
- g_list_remove (pipeline->layer_differences, layer);
+ pipeline->differences |= COGL_PIPELINE_STATE_LAYERS;
if (dec_n_layers)
pipeline->n_layers--;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]