1
0
Fork 0

[mutter-shaped-texture] Use a base material for all instances

Use a base material for all textures rather than recreating it for every instance,
this should allow Cogl to optimize the program generation.

Idea 'stolen' from:

http://git.clutter-project.org/clutter/commit/?id=7e56a98413817479d0501ce8af9fad3e6411104d

https://bugzilla.gnome.org/show_bug.cgi?id=629350
This commit is contained in:
Adel Gadllah 2010-09-19 16:17:36 +02:00
parent 476652da0a
commit 3fed2ab64d

View file

@ -297,6 +297,10 @@ mutter_shaped_texture_paint (ClutterActor *actor)
CoglHandle paint_tex;
guint tex_width, tex_height;
ClutterActorBox alloc;
static CoglHandle material_template = COGL_INVALID_HANDLE;
static CoglHandle material_unshaped_template = COGL_INVALID_HANDLE;
CoglHandle material;
if (priv->clip_region && meta_region_is_empty (priv->clip_region))
@ -339,8 +343,12 @@ mutter_shaped_texture_paint (ClutterActor *actor)
/* If there are no rectangles use a single-layer texture */
if (priv->material_unshaped == COGL_INVALID_HANDLE)
priv->material_unshaped = cogl_material_new ();
{
if (G_UNLIKELY (material_unshaped_template == COGL_INVALID_HANDLE))
material_unshaped_template = cogl_material_new ();
priv->material_unshaped = cogl_material_copy (material_unshaped_template);
}
material = priv->material_unshaped;
}
else
@ -349,12 +357,15 @@ mutter_shaped_texture_paint (ClutterActor *actor)
if (priv->material == COGL_INVALID_HANDLE)
{
priv->material = cogl_material_new ();
cogl_material_set_layer_combine (priv->material, 1,
if (G_UNLIKELY (material_template == COGL_INVALID_HANDLE))
{
material_template = cogl_material_new ();
cogl_material_set_layer_combine (material_template, 1,
"RGBA = MODULATE (PREVIOUS, TEXTURE[A])",
NULL);
}
priv->material = cogl_material_copy (material_template);
}
material = priv->material;
cogl_material_set_layer (material, 1, priv->mask_texture);