From bf7cfb877c9d88e9995b56e6e82fa103bad39015 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Sat, 11 Jul 2020 11:59:47 +0200 Subject: [PATCH] clutter/actor: Introduce counter for painting in an unmapped branch Just like the existing in_cloned_branch counter, add a property which tracks whether the actor is part of a subtree that's being painted while unmapped. This is going to be useful for a few things, for example changing the clutter_actor_is_in_clone_paint() API to use enable_paint_unmapped instead of in_clone_paint. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1366 --- clutter/clutter/clutter-actor.c | 49 ++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/clutter/clutter/clutter-actor.c b/clutter/clutter/clutter-actor.c index df13566b3..ec8537c9c 100644 --- a/clutter/clutter/clutter-actor.c +++ b/clutter/clutter/clutter-actor.c @@ -805,6 +805,8 @@ struct _ClutterActorPrivate */ gulong in_cloned_branch; + guint unmapped_paint_branch_counter; + GListModel *child_model; ClutterActorCreateChildFunc create_child_func; gpointer create_child_data; @@ -1084,6 +1086,11 @@ static void clutter_actor_pop_in_cloned_branch (ClutterActor *self, gulong count); static void ensure_valid_actor_transform (ClutterActor *actor); +static void push_in_paint_unmapped_branch (ClutterActor *self, + guint count); +static void pop_in_paint_unmapped_branch (ClutterActor *self, + guint count); + static GQuark quark_actor_layout_info = 0; static GQuark quark_actor_transform_info = 0; static GQuark quark_actor_animation_info = 0; @@ -4351,6 +4358,9 @@ clutter_actor_remove_child_internal (ClutterActor *self, if (self->priv->in_cloned_branch) clutter_actor_pop_in_cloned_branch (child, self->priv->in_cloned_branch); + if (self->priv->unmapped_paint_branch_counter) + pop_in_paint_unmapped_branch (child, self->priv->unmapped_paint_branch_counter); + /* if the child that got removed was visible and set to * expand then we want to reset the parent's state in * case the child was the only thing that was making it @@ -12010,6 +12020,9 @@ clutter_actor_add_child_internal (ClutterActor *self, if (self->priv->in_cloned_branch) clutter_actor_push_in_cloned_branch (child, self->priv->in_cloned_branch); + if (self->priv->unmapped_paint_branch_counter) + push_in_paint_unmapped_branch (child, self->priv->unmapped_paint_branch_counter); + /* children may cause their parent to expand, if they are set * to expand; if a child is not expanded then it cannot change * its parent's state. any further change later on will queue @@ -14607,10 +14620,15 @@ _clutter_actor_set_enable_paint_unmapped (ClutterActor *self, priv = self->priv; + if (priv->enable_paint_unmapped == enable) + return; + priv->enable_paint_unmapped = enable; - if (priv->enable_paint_unmapped) + if (enable) { + push_in_paint_unmapped_branch (self, 1); + /* Make sure that the parents of the widget are realized first; * otherwise checks in clutter_actor_update_map_state() will * fail. @@ -14626,6 +14644,7 @@ _clutter_actor_set_enable_paint_unmapped (ClutterActor *self, else { clutter_actor_update_map_state (self, MAP_STATE_CHECK); + pop_in_paint_unmapped_branch (self, 1); } } @@ -19612,6 +19631,34 @@ clutter_actor_has_mapped_clones (ClutterActor *self) return FALSE; } +static void +push_in_paint_unmapped_branch (ClutterActor *self, + guint count) +{ + ClutterActor *iter; + + for (iter = self->priv->first_child; + iter != NULL; + iter = iter->priv->next_sibling) + push_in_paint_unmapped_branch (iter, count); + + self->priv->unmapped_paint_branch_counter += count; +} + +static void +pop_in_paint_unmapped_branch (ClutterActor *self, + guint count) +{ + ClutterActor *iter; + + self->priv->unmapped_paint_branch_counter -= count; + + for (iter = self->priv->first_child; + iter != NULL; + iter = iter->priv->next_sibling) + pop_in_paint_unmapped_branch (iter, count); +} + static void clutter_actor_child_model__items_changed (GListModel *model, guint position,