[mutter] MetaShapedTexture: Add support for setting a custom CoglSnippet



commit 7c31fb245015b69759771c1bf3ddd6c524e9dca4
Author: Jonas Ådahl <jadahl gmail com>
Date:   Thu Oct 20 15:48:42 2016 +0800

    MetaShapedTexture: Add support for setting a custom CoglSnippet
    
    To support special types of buffer types, add support for setting a
    CoglSnippet on the shaped texture which will then be added to the
    pipeline.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=773629

 src/compositor/meta-shaped-texture-private.h |    2 ++
 src/compositor/meta-shaped-texture.c         |   25 +++++++++++++++++++++++++
 2 files changed, 27 insertions(+), 0 deletions(-)
---
diff --git a/src/compositor/meta-shaped-texture-private.h b/src/compositor/meta-shaped-texture-private.h
index 83eb964..5b3f283 100644
--- a/src/compositor/meta-shaped-texture-private.h
+++ b/src/compositor/meta-shaped-texture-private.h
@@ -34,6 +34,8 @@ void meta_shaped_texture_set_texture (MetaShapedTexture *stex,
                                       CoglTexture       *texture);
 void meta_shaped_texture_set_is_y_inverted (MetaShapedTexture *stex,
                                             gboolean           is_y_inverted);
+void meta_shaped_texture_set_snippet (MetaShapedTexture *stex,
+                                      CoglSnippet       *snippet);
 void meta_shaped_texture_set_fallback_size (MetaShapedTexture *stex,
                                             guint              fallback_width,
                                             guint              fallback_height);
diff --git a/src/compositor/meta-shaped-texture.c b/src/compositor/meta-shaped-texture.c
index cc79d7d..7a9e6fa 100644
--- a/src/compositor/meta-shaped-texture.c
+++ b/src/compositor/meta-shaped-texture.c
@@ -77,6 +77,7 @@ struct _MetaShapedTexturePrivate
 
   CoglTexture *texture;
   CoglTexture *mask_texture;
+  CoglSnippet *snippet;
 
   CoglPipeline *base_pipeline;
   CoglPipeline *masked_pipeline;
@@ -202,6 +203,8 @@ meta_shaped_texture_dispose (GObject *object)
 
   meta_shaped_texture_reset_pipelines (self);
 
+  g_clear_pointer (&priv->snippet, cogl_object_unref);
+
   G_OBJECT_CLASS (meta_shaped_texture_parent_class)->dispose (object);
 }
 
@@ -234,6 +237,9 @@ get_base_pipeline (MetaShapedTexture *stex,
       cogl_pipeline_set_layer_matrix (pipeline, 0, &matrix);
     }
 
+  if (priv->snippet)
+    cogl_pipeline_add_layer_snippet (pipeline, 0, priv->snippet);
+
   priv->base_pipeline = pipeline;
 
   return priv->base_pipeline;
@@ -813,6 +819,25 @@ meta_shaped_texture_set_is_y_inverted (MetaShapedTexture *stex,
 }
 
 /**
+ * meta_shaped_texture_set_snippet: (skip)
+ */
+void
+meta_shaped_texture_set_snippet (MetaShapedTexture *stex,
+                                 CoglSnippet       *snippet)
+{
+  MetaShapedTexturePrivate *priv = stex->priv;
+
+  if (priv->snippet == snippet)
+    return;
+
+  meta_shaped_texture_reset_pipelines (stex);
+
+  g_clear_pointer (&priv->snippet, cogl_object_unref);
+  if (snippet)
+    priv->snippet = cogl_object_ref (snippet);
+}
+
+/**
  * meta_shaped_texture_get_texture:
  * @stex: The #MetaShapedTexture
  *


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