Bail early in clutter_texture_paint if opacity == 0
authorØyvind Kolås <pippin@linux.intel.com>
Thu, 19 Feb 2009 15:44:16 +0000 (15:44 +0000)
committerØyvind Kolås <pippin@linux.intel.com>
Thu, 19 Feb 2009 15:44:16 +0000 (15:44 +0000)
This causes clutter to skip all the GL work of state changes and
texturing if the opacity was 0. This is done in ClutterTexture and not
ClutterActor to ensure that pre and post paint signals work correctly.
Other expensive actors should be doing the same thing.

clutter/clutter-texture.c

index 4406422..6d4349e 100644 (file)
@@ -503,6 +503,15 @@ clutter_texture_paint (ClutterActor *self)
   gint            x_1, y_1, x_2, y_2;
   CoglColor       transparent_col;
   ClutterFixed    t_w, t_h;
+  guint8          paint_opacity = clutter_actor_get_paint_opacity (self);
+
+  if (clutter_actor_get_paint_opacity (self) == 0)
+    {
+      /* Bail early if painting the actor would be a no-op, custom actors that
+       * might cause a lot of work/state changes should all do this.
+       */
+      return;
+    }
 
   if (!CLUTTER_ACTOR_IS_REALIZED (CLUTTER_ACTOR(texture)))
     clutter_actor_realize (CLUTTER_ACTOR(texture));
@@ -595,8 +604,7 @@ clutter_texture_paint (ClutterActor *self)
                clutter_actor_get_name (self) ? clutter_actor_get_name (self)
                                               : "unknown");
 
-  cogl_material_set_color4ub (priv->material, 0xff, 0xff, 0xff,
-                              clutter_actor_get_paint_opacity (self));
+  cogl_material_set_color4ub (priv->material, 0xff, 0xff, 0xff, paint_opacity);
 
   clutter_actor_get_allocation_coords (self, &x_1, &y_1, &x_2, &y_2);