[clutter/clutter-1.10] actor: Minor optimization to avoid get_preferred_*



commit 699f4f8d2ee1adf94bbea9f5965694650222bd87
Author: Emmanuele Bassi <ebassi linux intel com>
Date:   Wed Mar 28 18:07:06 2012 +0100

    actor: Minor optimization to avoid get_preferred_*
    
    When the easing state has a duration of zero milliseconds we can skip
    the entire create_transition() call inside set_width() and set_height(),
    to avoid what may be a costly call to get_preferred_*.

 clutter/clutter-actor.c |   36 ++++++++++++++++++++++++++++++++++--
 1 files changed, 34 insertions(+), 2 deletions(-)
---
diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c
index bfc71c5..7acb5f1 100644
--- a/clutter/clutter-actor.c
+++ b/clutter/clutter-actor.c
@@ -9473,7 +9473,25 @@ clutter_actor_set_width (ClutterActor *self,
 
   if (_clutter_actor_get_transition (self, obj_props[PROP_WIDTH]) == NULL)
     {
-      float cur_size = clutter_actor_get_width (self);
+      float cur_size;
+
+      /* minor optimization: if we don't have a duration
+       * then we can skip the get_width() below, to avoid
+       * the chance of going through get_preferred_width()
+       * just to jump to a new desired width.
+       */
+      if (clutter_actor_get_easing_duration (self) == 0)
+        {
+          g_object_freeze_notify (G_OBJECT (self));
+
+          clutter_actor_set_width_internal (self, width);
+
+          g_object_thaw_notify (G_OBJECT (self));
+
+          return;
+        }
+      else
+        cur_size = clutter_actor_get_width (self);
 
       _clutter_actor_create_transition (self,
                                         obj_props[PROP_WIDTH],
@@ -9509,7 +9527,21 @@ clutter_actor_set_height (ClutterActor *self,
 
   if (_clutter_actor_get_transition (self, obj_props[PROP_HEIGHT]) == NULL)
     {
-      float cur_size = clutter_actor_get_height (self);
+      float cur_size;
+
+      /* see the comment in clutter_actor_set_width() above */
+      if (clutter_actor_get_easing_duration (self) == 0)
+        {
+          g_object_freeze_notify (G_OBJECT (self));
+
+          clutter_actor_set_height_internal (self, height);
+
+          g_object_thaw_notify (G_OBJECT (self));
+
+          return;
+        }
+      else
+        cur_size = clutter_actor_get_height (self);
 
       _clutter_actor_create_transition (self,
                                         obj_props[PROP_HEIGHT],



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]