[mutter] [mutter-shaped-texture] Use a base material for all instances
- From: Adel Gadllah <agadllah src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] [mutter-shaped-texture] Use a base material for all instances
- Date: Sun, 19 Sep 2010 14:18:07 +0000 (UTC)
commit 3fed2ab64df76daacadc7f1e1a6398dd70263188
Author: Adel Gadllah <adel gadllah gmail com>
Date: Sun Sep 19 16:17:36 2010 +0200
[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
src/compositor/mutter-shaped-texture.c | 23 +++++++++++++++++------
1 files changed, 17 insertions(+), 6 deletions(-)
---
diff --git a/src/compositor/mutter-shaped-texture.c b/src/compositor/mutter-shaped-texture.c
index 206dd9c..3ba3bd5 100644
--- a/src/compositor/mutter-shaped-texture.c
+++ b/src/compositor/mutter-shaped-texture.c
@@ -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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]