summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@linux.intel.com>2010-11-15 16:30:12 +0000
committerEmmanuele Bassi <ebassi@linux.intel.com>2010-11-29 18:52:55 +0000
commit41df5d7070551daf5b3178c940ff60f7f86668d3 (patch)
tree30a4df6a17af2ca1836beaeea6ddcf615485ccee
parent2e30c29c5cefc7c765da36d1c8d3a5d4d235b613 (diff)
downloadclutter-41df5d7070551daf5b3178c940ff60f7f86668d3.tar.gz
actor: Simple show/hide optimizations
Showing a visible (and hiding an invisible) actor is far less cheap than it should be. http://bugzilla.clutter-project.org/show_bug.cgi?id=2422 (cherry picked from commit a731682ac394d1b54b78dec1083d158a71e10f89) Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
-rw-r--r--clutter/clutter-actor.c65
1 files changed, 45 insertions, 20 deletions
diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c
index f66c67d8b..91ae2d3c2 100644
--- a/clutter/clutter-actor.c
+++ b/clutter/clutter-actor.c
@@ -1153,6 +1153,25 @@ clutter_actor_real_show (ClutterActor *self)
}
}
+static inline void
+set_show_on_set_parent (ClutterActor *self,
+ gboolean set_show)
+{
+ ClutterActorPrivate *priv = self->priv;
+
+ set_show = !!set_show;
+
+ if (priv->show_on_set_parent == set_show)
+ return;
+
+ if (priv->parent_actor == NULL)
+ {
+ priv->show_on_set_parent = set_show;
+ _clutter_notify_by_pspec (G_OBJECT (self),
+ obj_props[PROP_SHOW_ON_SET_PARENT]);
+ }
+}
+
/**
* clutter_actor_show:
* @self: A #ClutterActor
@@ -1173,6 +1192,16 @@ clutter_actor_show (ClutterActor *self)
g_return_if_fail (CLUTTER_IS_ACTOR (self));
+ /* simple optimization */
+ if (CLUTTER_ACTOR_IS_VISIBLE (self))
+ {
+ /* we still need to set the :show-on-set-parent property, in
+ * case show() is called on an unparented actor
+ */
+ set_show_on_set_parent (self, TRUE);
+ return;
+ }
+
#ifdef CLUTTER_ENABLE_DEBUG
clutter_actor_verify_map_state (self);
#endif
@@ -1181,17 +1210,10 @@ clutter_actor_show (ClutterActor *self)
g_object_freeze_notify (G_OBJECT (self));
- if (!priv->show_on_set_parent && !priv->parent_actor)
- {
- priv->show_on_set_parent = TRUE;
- _clutter_notify_by_pspec (G_OBJECT (self), obj_props[PROP_SHOW_ON_SET_PARENT]);
- }
+ set_show_on_set_parent (self, TRUE);
- if (!CLUTTER_ACTOR_IS_VISIBLE (self))
- {
- g_signal_emit (self, actor_signals[SHOW], 0);
- _clutter_notify_by_pspec (G_OBJECT (self), obj_props[PROP_VISIBLE]);
- }
+ g_signal_emit (self, actor_signals[SHOW], 0);
+ _clutter_notify_by_pspec (G_OBJECT (self), obj_props[PROP_VISIBLE]);
if (priv->parent_actor)
clutter_actor_queue_redraw (priv->parent_actor);
@@ -1263,6 +1285,16 @@ clutter_actor_hide (ClutterActor *self)
g_return_if_fail (CLUTTER_IS_ACTOR (self));
+ /* simple optimization */
+ if (!CLUTTER_ACTOR_IS_VISIBLE (self))
+ {
+ /* we still need to set the :show-on-set-parent property, in
+ * case hide() is called on an unparented actor
+ */
+ set_show_on_set_parent (self, FALSE);
+ return;
+ }
+
#ifdef CLUTTER_ENABLE_DEBUG
clutter_actor_verify_map_state (self);
#endif
@@ -1271,17 +1303,10 @@ clutter_actor_hide (ClutterActor *self)
g_object_freeze_notify (G_OBJECT (self));
- if (priv->show_on_set_parent && !priv->parent_actor)
- {
- priv->show_on_set_parent = FALSE;
- _clutter_notify_by_pspec (G_OBJECT (self), obj_props[PROP_SHOW_ON_SET_PARENT]);
- }
+ set_show_on_set_parent (self, FALSE);
- if (CLUTTER_ACTOR_IS_VISIBLE (self))
- {
- g_signal_emit (self, actor_signals[HIDE], 0);
- _clutter_notify_by_pspec (G_OBJECT (self), obj_props[PROP_VISIBLE]);
- }
+ g_signal_emit (self, actor_signals[HIDE], 0);
+ _clutter_notify_by_pspec (G_OBJECT (self), obj_props[PROP_VISIBLE]);
if (priv->parent_actor)
clutter_actor_queue_redraw (priv->parent_actor);