mirror of
https://github.com/brl/mutter.git
synced 2024-11-29 03:20:46 -05:00
[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:
parent
476652da0a
commit
3fed2ab64d
@ -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))
|
||||
@ -338,10 +342,14 @@ 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 (priv->material_unshaped == COGL_INVALID_HANDLE)
|
||||
{
|
||||
if (G_UNLIKELY (material_unshaped_template == COGL_INVALID_HANDLE))
|
||||
material_unshaped_template = cogl_material_new ();
|
||||
|
||||
material = priv->material_unshaped;
|
||||
priv->material_unshaped = cogl_material_copy (material_unshaped_template);
|
||||
}
|
||||
material = priv->material_unshaped;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -349,11 +357,14 @@ 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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user