clutter/actor: Make has_mapped_clones() factor in parent actors

All existing users of clutter_actor_has_mapped_clones() actually want to
know whether the actor is being cloned by a visible clone, it doesn't
matter to them if that clone is attached to an actor somewhere else in
the tree or to the actor itself.

So make clutter_actor_has_mapped_clones() a bit more convenient to use
and also check the clones of the parent-actors in that function.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1235
This commit is contained in:
Jonas Dreßler 2020-05-05 16:19:46 +02:00
parent e68bb27df2
commit 2791f5b466
2 changed files with 29 additions and 30 deletions

View File

@ -8847,25 +8847,21 @@ _clutter_actor_queue_redraw_full (ClutterActor *self,
if (CLUTTER_ACTOR_IN_DESTRUCTION (self)) if (CLUTTER_ACTOR_IN_DESTRUCTION (self))
return; return;
/* we can ignore unmapped actors, unless they have at least one /* we can ignore unmapped actors, unless they are inside a cloned branch
* mapped clone or they are inside a cloned branch of the scene * of the scene graph, as unmapped actors will simply be left unpainted.
* graph, as unmapped actors will simply be left unpainted.
* *
* this allows us to ignore redraws queued on leaf nodes when one * this allows us to ignore redraws queued on leaf nodes when one
* of their parents has been hidden * of their parents has been hidden
*/ */
if (!CLUTTER_ACTOR_IS_MAPPED (self) && if (!CLUTTER_ACTOR_IS_MAPPED (self) &&
self->priv->in_cloned_branch == 0 &&
!clutter_actor_has_mapped_clones (self)) !clutter_actor_has_mapped_clones (self))
{ {
CLUTTER_NOTE (PAINT, CLUTTER_NOTE (PAINT,
"Skipping queue_redraw('%s'): mapped=%s, " "Skipping queue_redraw('%s'): mapped=%s, "
"mapped_clones=%s, " "has_mapped_clones=%s",
"in_cloned_branch=%s",
_clutter_actor_get_debug_name (self), _clutter_actor_get_debug_name (self),
CLUTTER_ACTOR_IS_MAPPED (self) ? "yes" : "no", CLUTTER_ACTOR_IS_MAPPED (self) ? "yes" : "no",
clutter_actor_has_mapped_clones (self) ? "yes" : "no", clutter_actor_has_mapped_clones (self) ? "yes" : "no");
self->priv->in_cloned_branch != 0 ? "yes" : "no");
return; return;
} }
@ -19084,7 +19080,6 @@ should_skip_implicit_transition (ClutterActor *self,
* when those transitions happen * when those transitions happen
*/ */
if (!CLUTTER_ACTOR_IS_MAPPED (self) && if (!CLUTTER_ACTOR_IS_MAPPED (self) &&
priv->in_cloned_branch == 0 &&
!clutter_actor_has_mapped_clones (self)) !clutter_actor_has_mapped_clones (self))
return TRUE; return TRUE;
@ -20704,32 +20699,42 @@ _clutter_actor_queue_relayout_on_clones (ClutterActor *self)
* clutter_actor_has_mapped_clones: * clutter_actor_has_mapped_clones:
* @self: a #ClutterActor * @self: a #ClutterActor
* *
* Returns whether a #ClutterActor has any mapped clones. * Returns whether a #ClutterActor or any parent actors have mapped clones
* that are clone-painting @self.
* *
* Return: %TRUE if the actor has mapped clones, and %FALSE otherwise * Returns: %TRUE if the actor has mapped clones, %FALSE otherwise
*
* Since: 1.16
*/ */
gboolean gboolean
clutter_actor_has_mapped_clones (ClutterActor *self) clutter_actor_has_mapped_clones (ClutterActor *self)
{ {
ClutterActorPrivate *priv; ClutterActor *actor;
GHashTableIter iter; GHashTableIter iter;
gpointer key; gpointer key;
g_return_val_if_fail (CLUTTER_IS_ACTOR (self), FALSE); g_return_val_if_fail (CLUTTER_IS_ACTOR (self), FALSE);
priv = self->priv; if (self->priv->in_cloned_branch == 0)
if (priv->clones == NULL)
return FALSE; return FALSE;
g_hash_table_iter_init (&iter, priv->clones); for (actor = self; actor; actor = actor->priv->parent)
{
if (actor->priv->clones)
{
g_hash_table_iter_init (&iter, actor->priv->clones);
while (g_hash_table_iter_next (&iter, &key, NULL)) while (g_hash_table_iter_next (&iter, &key, NULL))
{ {
if (CLUTTER_ACTOR_IS_MAPPED (key)) if (CLUTTER_ACTOR_IS_MAPPED (key))
return TRUE; return TRUE;
} }
}
/* Clones will force-show their own source actor but not children of
* it, so if we're hidden and an actor up the hierarchy has a clone,
* we won't be visisble.
*/
if (!CLUTTER_ACTOR_IS_VISIBLE (actor))
return FALSE;
}
return FALSE; return FALSE;
} }

View File

@ -63,17 +63,11 @@ effective_unobscured_region (MetaSurfaceActor *surface_actor)
{ {
MetaSurfaceActorPrivate *priv = MetaSurfaceActorPrivate *priv =
meta_surface_actor_get_instance_private (surface_actor); meta_surface_actor_get_instance_private (surface_actor);
ClutterActor *actor; ClutterActor *actor = CLUTTER_ACTOR (surface_actor);
/* Fail if we have any mapped clones. */ /* Fail if we have any mapped clones. */
actor = CLUTTER_ACTOR (surface_actor);
do
{
if (clutter_actor_has_mapped_clones (actor)) if (clutter_actor_has_mapped_clones (actor))
return NULL; return NULL;
actor = clutter_actor_get_parent (actor);
}
while (actor != NULL);
return priv->unobscured_region; return priv->unobscured_region;
} }