[gnome-shell] st: Use template material for transitions



commit 862f1ea18ceee3e652c02303beee35a7c82120f5
Author: Florian Müllner <fmuellner gnome org>
Date:   Sun Sep 12 00:18:52 2010 +0200

    st: Use template material for transitions
    
    To avoid compiling a new shader each time a transition is started,
    use a copy of a static template material.
    
    See http://bugzilla.clutter-project.org/show_bug.cgi?id=2280#c5.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=629384

 src/st/st-theme-node-transition.c |   39 ++++++++++++++++++++++--------------
 1 files changed, 24 insertions(+), 15 deletions(-)
---
diff --git a/src/st/st-theme-node-transition.c b/src/st/st-theme-node-transition.c
index 884f806..e523c5c 100644
--- a/src/st/st-theme-node-transition.c
+++ b/src/st/st-theme-node-transition.c
@@ -55,6 +55,9 @@ struct _StThemeNodeTransitionPrivate {
 
 static guint signals[LAST_SIGNAL] = { 0 };
 
+/* template material to avoid unnecessary shader compilation */
+static CoglHandle global_material = COGL_INVALID_HANDLE;
+
 G_DEFINE_TYPE (StThemeNodeTransition, st_theme_node_transition, G_TYPE_OBJECT);
 
 
@@ -244,21 +247,27 @@ setup_framebuffers (StThemeNodeTransition *transition,
   g_return_val_if_fail (priv->old_offscreen != COGL_INVALID_HANDLE, FALSE);
   g_return_val_if_fail (priv->new_offscreen != COGL_INVALID_HANDLE, FALSE);
 
-  if (priv->material)
-    cogl_handle_unref (priv->material);
-  priv->material = cogl_material_new ();
-
-  cogl_material_set_layer_combine (priv->material, 0,
-                                   "RGBA = REPLACE (TEXTURE)",
-                                   NULL);
-  cogl_material_set_layer_combine (priv->material, 1,
-                                   "RGBA = INTERPOLATE (PREVIOUS, "
-                                                       "TEXTURE, "
-                                                       "CONSTANT[A])",
-                                   NULL);
-  cogl_material_set_layer_combine (priv->material, 2,
-                                   "RGBA = MODULATE (PREVIOUS, PRIMARY)",
-                                   NULL);
+  if (priv->material == NULL)
+    {
+      if (G_UNLIKELY (global_material == COGL_INVALID_HANDLE))
+        {
+          global_material = cogl_material_new ();
+
+          cogl_material_set_layer_combine (global_material, 0,
+                                           "RGBA = REPLACE (TEXTURE)",
+                                           NULL);
+          cogl_material_set_layer_combine (global_material, 1,
+                                           "RGBA = INTERPOLATE (PREVIOUS, "
+                                                               "TEXTURE, "
+                                                               "CONSTANT[A])",
+                                           NULL);
+          cogl_material_set_layer_combine (global_material, 2,
+                                           "RGBA = MODULATE (PREVIOUS, "
+                                                            "PRIMARY)",
+                                           NULL);
+        }
+      priv->material = cogl_material_copy (global_material);
+    }
 
   cogl_material_set_layer (priv->material, 0, priv->new_texture);
   cogl_material_set_layer (priv->material, 1, priv->old_texture);



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