From 161d2540e659fa8ed5efc74f350a741b2430417d Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 29 Apr 2017 13:43:33 +0200 Subject: [PATCH] ClutterActor: Preserve valid paint volumes till the next relayout/repaint Cuts down approximately all paint volume calculations when there's windows that redraw frequently, but don't move. https://bugzilla.gnome.org/show_bug.cgi?id=782344 --- clutter/clutter/clutter-actor.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/clutter/clutter/clutter-actor.c b/clutter/clutter/clutter-actor.c index 3e00a11db..2ba61ba9e 100644 --- a/clutter/clutter/clutter-actor.c +++ b/clutter/clutter/clutter-actor.c @@ -840,6 +840,7 @@ struct _ClutterActorPrivate guint needs_compute_expand : 1; guint needs_x_expand : 1; guint needs_y_expand : 1; + guint needs_paint_volume_update : 1; }; enum @@ -1504,6 +1505,8 @@ clutter_actor_real_map (ClutterActor *self) CLUTTER_ACTOR_SET_FLAGS (self, CLUTTER_ACTOR_MAPPED); + self->priv->needs_paint_volume_update = TRUE; + stage = _clutter_actor_get_stage_internal (self); priv->pick_id = _clutter_stage_acquire_pick_id (CLUTTER_STAGE (stage), self); @@ -2737,6 +2740,7 @@ clutter_actor_real_queue_relayout (ClutterActor *self) priv->needs_width_request = TRUE; priv->needs_height_request = TRUE; priv->needs_allocation = TRUE; + priv->needs_paint_volume_update = TRUE; /* reset the cached size requests */ memset (priv->width_requests, 0, @@ -8518,6 +8522,7 @@ clutter_actor_init (ClutterActor *self) priv->needs_width_request = TRUE; priv->needs_height_request = TRUE; priv->needs_allocation = TRUE; + priv->needs_paint_volume_update = TRUE; priv->cached_width_age = 1; priv->cached_height_age = 1; @@ -10084,6 +10089,9 @@ clutter_actor_allocate (ClutterActor *self, return; } + if (CLUTTER_ACTOR_IS_MAPPED (self)) + self->priv->needs_paint_volume_update = TRUE; + if (!stage_allocation_changed) { /* If the actor didn't move but needs_allocation is set, we just @@ -12972,6 +12980,9 @@ clutter_actor_add_child_internal (ClutterActor *self, child->priv->needs_height_request = TRUE; child->priv->needs_allocation = TRUE; + if (CLUTTER_ACTOR_IS_MAPPED (child)) + child->priv->needs_paint_volume_update = TRUE; + /* we only queue a relayout here, because any possible * redraw has already been queued either by show() or * by our call to queue_redraw() above @@ -17514,11 +17525,16 @@ _clutter_actor_get_paint_volume_mutable (ClutterActor *self) priv = self->priv; if (priv->paint_volume_valid) - clutter_paint_volume_free (&priv->paint_volume); + { + if (!priv->needs_paint_volume_update) + return &priv->paint_volume; + clutter_paint_volume_free (&priv->paint_volume); + } if (_clutter_actor_get_paint_volume_real (self, &priv->paint_volume)) { priv->paint_volume_valid = TRUE; + priv->needs_paint_volume_update = FALSE; return &priv->paint_volume; } else