[cogl/cogl-1.12] pipeline: Ensure the pipeline layer cache is freed when pruning layers



commit a18c97798f7e69fa6c01c35514d0eb63b24b79b1
Author: Neil Roberts <neil linux intel com>
Date:   Wed Sep 5 14:30:55 2012 +0100

    pipeline: Ensure the pipeline layer cache is freed when pruning layers
    
    When pruning layers from a pipeline the pipeline cache would once be
    freed due to the call to pre_change_notify but it would immediately be
    recreated again when foreach_layer_internal is called. When n_layers
    is later set to 0 it would end up with an invalid cache lying around.
    This patch changes the order so that it will iterate the layers first
    before triggering the pre-change notify so that the cache will be
    cleared correctly.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=683414
    
    Reviewed-by: Robert Bragg <robert linux intel com>
    
    (cherry picked from commit 1c8efdc838cc5ace380365cb54e0741645856edf)

 cogl/cogl-pipeline.c |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)
---
diff --git a/cogl/cogl-pipeline.c b/cogl/cogl-pipeline.c
index 1e1173e..3cc8c50 100644
--- a/cogl/cogl-pipeline.c
+++ b/cogl/cogl-pipeline.c
@@ -1521,17 +1521,21 @@ _cogl_pipeline_prune_to_n_layers (CoglPipeline *pipeline, int n)
   if (authority->n_layers <= n)
     return;
 
-  _cogl_pipeline_pre_change_notify (pipeline,
-                                    COGL_PIPELINE_STATE_LAYERS,
-                                    NULL,
-                                    FALSE);
-
+  /* This call to foreach_layer_internal needs to be done before
+   * calling pre_change_notify because it recreates the layer cache.
+   * We are relying on pre_change_notify to clear the layer cache
+   * before we change the number of layers */
   state.keep_n = n;
   state.current_pos = 0;
   _cogl_pipeline_foreach_layer_internal (pipeline,
                                          update_prune_layers_info_cb,
                                          &state);
 
+  _cogl_pipeline_pre_change_notify (pipeline,
+                                    COGL_PIPELINE_STATE_LAYERS,
+                                    NULL,
+                                    FALSE);
+
   pipeline->differences |= COGL_PIPELINE_STATE_LAYERS;
   pipeline->n_layers = n;
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]