Avoid needlessly queue redraws for invisible actors
authorEmmanuele Bassi <ebassi@linux.intel.com>
Thu, 22 Jan 2009 13:58:50 +0000 (13:58 +0000)
committerEmmanuele Bassi <ebassi@linux.intel.com>
Thu, 22 Jan 2009 13:58:50 +0000 (13:58 +0000)
If an actor is not set as visible, or if it is in a section of
the scenegraph that it's set as not visible (e.g. one of the
parents is not visible) then we should not queue a redraw for
it.

Patch based on code from Michael Boccara <michael@graphtech.co.il>

clutter/clutter-actor.c

index be36037..d532471 100644 (file)
@@ -3082,6 +3082,9 @@ clutter_actor_destroy (ClutterActor *self)
  *
  * Applications rarely need to call this, as redraws are handled
  * automatically by modification functions.
+ *
+ * This function will not do anything if @self is not visible, or
+ * if the actor is inside an invisible part of the scenegraph.
  */
 void
 clutter_actor_queue_redraw (ClutterActor *self)
@@ -3090,7 +3093,16 @@ clutter_actor_queue_redraw (ClutterActor *self)
 
   g_return_if_fail (CLUTTER_IS_ACTOR (self));
 
-  /* FIXME: should we check we're visible here? */
+  /* short-circuit the trivial case */
+  if (!CLUTTER_ACTOR_IS_VISIBLE (self))
+    return;
+
+  /* check if any part of the scenegraph we're in
+   * is not visible
+   */
+  if (!clutter_actor_get_paint_visibility (self))
+    return;
+
   if ((stage = clutter_actor_get_stage (self)) != NULL)
     clutter_stage_queue_redraw (CLUTTER_STAGE (stage));
 }