x11: Use has_allocation() in TfP actor
authorOwen W. Taylor <otaylor@fishsoup.net>
Fri, 26 Mar 2010 00:41:46 +0000 (00:41 +0000)
committerEmmanuele Bassi <ebassi@linux.intel.com>
Fri, 26 Mar 2010 00:46:43 +0000 (00:46 +0000)
ClutterX11TexturePixmap calls get_allocation_box() when queueing a
clipped redraw. If the allocation is not valid, and if we queue a
lot of redraws in response to a series of damage events, the net
result is that we spend all our time in a re-layout. We can
short-circuit this by checking if the actor has a valid allocation, and
if not, just queue a redraw - the actor will be allocated by the time it
is going to be painted.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
clutter/x11/clutter-x11-texture-pixmap.c

index e290dba..036419a 100644 (file)
@@ -435,14 +435,18 @@ clutter_x11_texture_pixmap_real_queue_damage_redraw (
    * actor coordinates...
    */
 
-  /* XXX: we don't care if we get an out of date allocation here because
-   * clutter_actor_queue_clipped_redraw knows to ignore the clip if the
-   * actor's allocation is invalid.
-   *
-   * This is noted because clutter_actor_get_allocation_box does some
-   * unnecessary work to support buggy code with a comment suggesting that
-   * it could be changed later which would be good for this use case!
+  /* Calling clutter_actor_get_allocation_box() is enormously expensive
+   * if the actor has an out-of-date allocation, since it triggers
+   * a full redraw. clutter_actor_queue_clipped_redraw() would redraw
+   * the whole stage anyways in that case, so just go ahead and do
+   * it here.
    */
+  if (!clutter_actor_has_allocation (self))
+    {
+      clutter_actor_queue_redraw (self);
+      return;
+    }
+
   clutter_actor_get_allocation_box (self, &allocation);
 
   g_object_get (self,