[mutter/wip/bg-fixes: 4/5] background: share snippets between pipelines



commit 2177450b1b105574aa40c15f938060b307a2e3c0
Author: Ray Strode <rstrode redhat com>
Date:   Mon Mar 25 13:29:36 2013 -0400

    background: share snippets between pipelines
    
    Cogl automatically caches pipelines with no eviction policy,
    so we need to make sure to reuse snippets to prevent
    identical pipelines from getting cached separately.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=696157

 src/compositor/meta-background.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/src/compositor/meta-background.c b/src/compositor/meta-background.c
index 4d8f1fb..3380957 100644
--- a/src/compositor/meta-background.c
+++ b/src/compositor/meta-background.c
@@ -99,7 +99,6 @@ G_DEFINE_TYPE_WITH_CODE (MetaBackground, meta_background, G_TYPE_OBJECT,
                          G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_CONTENT,
                                                 clutter_content_iface_init))
 
-
 static gboolean
 meta_background_get_preferred_size (ClutterContent *content,
                                     gfloat         *width,
@@ -535,13 +534,18 @@ static void
 add_vignette (MetaBackground *self)
 {
   MetaBackgroundPrivate *priv = self->priv;
-  CoglSnippet *snippet;
+  static CoglSnippet *snippet = NULL;
 
   ensure_pipeline (self);
 
-  snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_FRAGMENT, FRAGMENT_SHADER_DECLARATIONS, VIGNETTE_CODE);
+  /* Cogl automatically caches pipelines with no eviction policy,
+   * so we need to prevent identical pipelines from getting cached
+   * separately, by reusing the same fragement shader snippet.
+   */
+  if (snippet == NULL)
+    snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_FRAGMENT, FRAGMENT_SHADER_DECLARATIONS, VIGNETTE_CODE);
+
   cogl_pipeline_add_snippet (priv->pipeline, snippet);
-  cogl_object_unref (snippet);
 
   cogl_pipeline_set_uniform_1f (priv->pipeline,
                                 cogl_pipeline_get_uniform_location (priv->pipeline,


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