[cogl] pipeline: Ensure the pipeline layer cache is freed when	pruning layers
- From: Neil Roberts <nroberts src gnome org>
 
- To: commits-list gnome org
 
- Cc: 
 
- Subject: [cogl] pipeline: Ensure the pipeline layer cache is freed when	pruning layers
 
- Date: Fri,  7 Sep 2012 10:42:48 +0000 (UTC)
 
commit 1c8efdc838cc5ace380365cb54e0741645856edf
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>
 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 429e46a..4d1e30d 100644
--- a/cogl/cogl-pipeline.c
+++ b/cogl/cogl-pipeline.c
@@ -1412,17 +1412,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]