[gnome-shell] st: Adapt the mutter implementation for create_texture_material
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] st: Adapt the mutter implementation for create_texture_material
- Date: Thu, 7 Aug 2014 18:50:16 +0000 (UTC)
commit 05f9f991d8d5796b77def6c096a36786b5307351
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Thu Aug 7 14:06:40 2014 -0400
st: Adapt the mutter implementation for create_texture_material
This is the new API that uses set_null_texture instead of a dummy texture.
src/st/st-private.c | 48 +++++++++++++++++++++---------------------------
1 files changed, 21 insertions(+), 27 deletions(-)
---
diff --git a/src/st/st-private.c b/src/st/st-private.c
index e3307b0..7a846dd 100644
--- a/src/st/st-private.c
+++ b/src/st/st-private.c
@@ -171,38 +171,32 @@ _st_set_text_from_style (ClutterText *text,
CoglHandle
_st_create_texture_material (CoglHandle src_texture)
{
- static CoglHandle texture_material_template = COGL_INVALID_HANDLE;
- CoglHandle material;
-
- g_return_val_if_fail (src_texture != COGL_INVALID_HANDLE,
- COGL_INVALID_HANDLE);
-
- /* We use a material that has a dummy texture as a base for all
- texture materials. The idea is that only the Cogl texture object
- would be different in the children so it is likely that Cogl will
- be able to share GL programs between all the textures. */
- if (G_UNLIKELY (texture_material_template == COGL_INVALID_HANDLE))
+ static CoglPipeline *texture_pipeline_template = NULL;
+ CoglPipeline *pipeline;
+
+ /* The only state used in the pipeline that would affect the shader
+ generation is the texture type on the layer. Therefore we create
+ a template pipeline which sets this state and all texture
+ pipelines are created as a copy of this. That way Cogl can find
+ the shader state for the pipeline more quickly by looking at the
+ pipeline ancestry instead of resorting to the shader cache. */
+ if (G_UNLIKELY (texture_pipeline_template == NULL))
{
- static const guint8 white_pixel[] = { 0xff, 0xff, 0xff, 0xff };
- CoglHandle dummy_texture;
-
- dummy_texture =
- cogl_texture_new_from_data (1, 1,
- COGL_TEXTURE_NONE,
- COGL_PIXEL_FORMAT_RGBA_8888_PRE,
- COGL_PIXEL_FORMAT_ANY,
- 4, white_pixel);
-
- texture_material_template = cogl_material_new ();
- cogl_material_set_layer (texture_material_template, 0, dummy_texture);
- cogl_handle_unref (dummy_texture);
+ CoglContext *ctx =
+ clutter_backend_get_cogl_context (clutter_get_default_backend ());
+
+ texture_pipeline_template = cogl_pipeline_new (ctx);
+ cogl_pipeline_set_layer_null_texture (texture_pipeline_template,
+ 0, /* layer */
+ COGL_TEXTURE_TYPE_2D);
}
- material = cogl_material_copy (texture_material_template);
+ pipeline = cogl_pipeline_copy (texture_pipeline_template);
- cogl_material_set_layer (material, 0, src_texture);
+ if (src_texture != NULL)
+ cogl_pipeline_set_layer_texture (pipeline, 0, src_texture);
- return material;
+ return pipeline;
}
/*****
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]