mirror of
https://github.com/brl/mutter.git
synced 2024-11-23 08:30:42 -05:00
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.
This commit is contained in:
parent
37d51cb78e
commit
2018b5b167
@ -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:
|
* clutter_actor_get_paint_opacity:
|
||||||
* @self: A #ClutterActor
|
* @self: A #ClutterActor
|
||||||
@ -6280,28 +6314,9 @@ clutter_actor_set_opacity (ClutterActor *self,
|
|||||||
guint8
|
guint8
|
||||||
clutter_actor_get_paint_opacity (ClutterActor *self)
|
clutter_actor_get_paint_opacity (ClutterActor *self)
|
||||||
{
|
{
|
||||||
ClutterActorPrivate *priv;
|
|
||||||
ClutterActor *parent;
|
|
||||||
|
|
||||||
g_return_val_if_fail (CLUTTER_IS_ACTOR (self), 0);
|
g_return_val_if_fail (CLUTTER_IS_ACTOR (self), 0);
|
||||||
|
|
||||||
priv = self->priv;
|
return clutter_actor_get_paint_opacity_internal (self);
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user