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
This commit is contained in:
Jonas Ådahl 2016-10-20 15:48:42 +08:00
parent 11783ffdd0
commit 7c31fb2450
2 changed files with 27 additions and 0 deletions

View File

@ -34,6 +34,8 @@ void meta_shaped_texture_set_texture (MetaShapedTexture *stex,
CoglTexture *texture); CoglTexture *texture);
void meta_shaped_texture_set_is_y_inverted (MetaShapedTexture *stex, void meta_shaped_texture_set_is_y_inverted (MetaShapedTexture *stex,
gboolean is_y_inverted); gboolean is_y_inverted);
void meta_shaped_texture_set_snippet (MetaShapedTexture *stex,
CoglSnippet *snippet);
void meta_shaped_texture_set_fallback_size (MetaShapedTexture *stex, void meta_shaped_texture_set_fallback_size (MetaShapedTexture *stex,
guint fallback_width, guint fallback_width,
guint fallback_height); guint fallback_height);

View File

@ -77,6 +77,7 @@ struct _MetaShapedTexturePrivate
CoglTexture *texture; CoglTexture *texture;
CoglTexture *mask_texture; CoglTexture *mask_texture;
CoglSnippet *snippet;
CoglPipeline *base_pipeline; CoglPipeline *base_pipeline;
CoglPipeline *masked_pipeline; CoglPipeline *masked_pipeline;
@ -202,6 +203,8 @@ meta_shaped_texture_dispose (GObject *object)
meta_shaped_texture_reset_pipelines (self); meta_shaped_texture_reset_pipelines (self);
g_clear_pointer (&priv->snippet, cogl_object_unref);
G_OBJECT_CLASS (meta_shaped_texture_parent_class)->dispose (object); 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); cogl_pipeline_set_layer_matrix (pipeline, 0, &matrix);
} }
if (priv->snippet)
cogl_pipeline_add_layer_snippet (pipeline, 0, priv->snippet);
priv->base_pipeline = pipeline; priv->base_pipeline = pipeline;
return priv->base_pipeline; return priv->base_pipeline;
@ -812,6 +818,25 @@ meta_shaped_texture_set_is_y_inverted (MetaShapedTexture *stex,
priv->is_y_inverted = is_y_inverted; priv->is_y_inverted = is_y_inverted;
} }
/**
* 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: * meta_shaped_texture_get_texture:
* @stex: The #MetaShapedTexture * @stex: The #MetaShapedTexture