From 2018b5b16750b090c5592ebd5262fc66d809183e Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Fri, 12 Feb 2010 16:24:27 +0000 Subject: [PATCH] actor: Split get_paint_opacity() from the type check Since get_paint_opacity() recurses through the hierarchy it might lead to a lot of type checks while we walk the parent-child chain. We can split the recursive function from the public entry point and perform the type check just once. --- clutter/clutter-actor.c | 55 ++++++++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 20 deletions(-) diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c index 22e30409d..fb4441a37 100644 --- a/clutter/clutter-actor.c +++ b/clutter/clutter-actor.c @@ -6261,6 +6261,40 @@ clutter_actor_set_opacity (ClutterActor *self, } } +/* + * clutter_actor_get_paint_opacity_internal: + * @self: a #ClutterActor + * + * Retrieves the absolute opacity of the actor, as it appears on the stage + * + * This function does not do type checks + * + * Return value: the absolute opacity of the actor + */ +static guint8 +clutter_actor_get_paint_opacity_internal (ClutterActor *self) +{ + ClutterActorPrivate *priv = self->priv; + ClutterActor *parent; + + if (priv->opacity_parent != NULL) + return clutter_actor_get_paint_opacity_internal (priv->opacity_parent); + + parent = priv->parent_actor; + + /* Factor in the actual actors opacity with parents */ + if (parent != NULL) + { + guint8 opacity = clutter_actor_get_paint_opacity_internal (parent); + + if (opacity != 0xff) + return (opacity * priv->opacity) / 0xff; + } + + return priv->opacity; + +} + /** * clutter_actor_get_paint_opacity: * @self: A #ClutterActor @@ -6280,28 +6314,9 @@ clutter_actor_set_opacity (ClutterActor *self, guint8 clutter_actor_get_paint_opacity (ClutterActor *self) { - ClutterActorPrivate *priv; - ClutterActor *parent; - g_return_val_if_fail (CLUTTER_IS_ACTOR (self), 0); - priv = self->priv; - - if (priv->opacity_parent != NULL) - return clutter_actor_get_paint_opacity (priv->opacity_parent); - - parent = priv->parent_actor; - - /* Factor in the actual actors opacity with parents */ - if (G_LIKELY (parent != NULL)) - { - guint8 opacity = clutter_actor_get_paint_opacity (parent); - - if (opacity != 0xff) - return (opacity * priv->opacity) / 0xff; - } - - return priv->opacity; + return clutter_actor_get_paint_opacity_internal (self); } /**