st: Adapt the mutter implementation for create_texture_material

This is the new API that uses set_null_texture instead of a dummy texture.
This commit is contained in:
Jasper St. Pierre 2014-08-07 14:06:40 -04:00
parent 3df7ef6ce6
commit 05f9f991d8

View File

@ -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;
static CoglPipeline *texture_pipeline_template = NULL;
CoglPipeline *pipeline;
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))
/* 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;
CoglContext *ctx =
clutter_backend_get_cogl_context (clutter_get_default_backend ());
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);
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;
}
/*****