Use the allocation to get the pick area
authorEmmanuele Bassi <ebassi@linux.intel.com>
Thu, 22 Jan 2009 15:55:43 +0000 (15:55 +0000)
committerEmmanuele Bassi <ebassi@linux.intel.com>
Thu, 22 Jan 2009 15:55:43 +0000 (15:55 +0000)
Since a pick is really a paint operation, we can safely get
the allocation box, instead of using get_width() and get_height().

This should help cutting down the function calls. If we were
feeling adventurous, we could even use the allocation directly
from the private data structure.

Based on a patch by Gwenole Beauchesne <gbeauchesne@splitted-desktop.org>

clutter/clutter-actor.c

index d532471..c8b90c8 100644 (file)
@@ -610,13 +610,20 @@ clutter_actor_real_pick (ClutterActor       *self,
    */
   if (clutter_actor_should_pick_paint (self))
     {
+      ClutterActorBox box = { 0, };
+      float width, height;
+
+      clutter_actor_get_allocation_box (self, &box);
+
+      width = CLUTTER_UNITS_TO_FLOAT (box.x2 - box.x1);
+      height = CLUTTER_UNITS_TO_FLOAT (box.y2 - box.y1);
+
       cogl_set_source_color4ub (color->red,
                                 color->green,
                                 color->blue,
                                 color->alpha);
-      cogl_rectangle (0, 0,
-                      clutter_actor_get_width (self),
-                      clutter_actor_get_height (self));
+
+      cogl_rectangle (0, 0, width, height);
     }
 }