From 153f843ea68f5ec78274596da8f361f08cb9cafa Mon Sep 17 00:00:00 2001 From: Giovanni Campagna Date: Mon, 24 Feb 2014 22:00:12 +0100 Subject: [PATCH] MetaSurfaceActor: move freeze accounting to MetaWindowActor Turns out we only ever need to freeze/thaw whole windows, not surfaces or subsurfaces. This will allow removing the surface actor without losing the count. --- src/compositor/meta-surface-actor.c | 36 ++++++++--------------------- src/compositor/meta-surface-actor.h | 5 ++-- src/compositor/meta-window-actor.c | 21 ++++++++++++----- 3 files changed, 26 insertions(+), 36 deletions(-) diff --git a/src/compositor/meta-surface-actor.c b/src/compositor/meta-surface-actor.c index f82a6a9b8..1c795d52f 100644 --- a/src/compositor/meta-surface-actor.c +++ b/src/compositor/meta-surface-actor.c @@ -26,8 +26,8 @@ struct _MetaSurfaceActorPrivate cairo_region_t *input_region; /* Freeze/thaw accounting */ - guint freeze_count; guint needs_damage_all : 1; + guint frozen : 1; }; static void cullable_iface_init (MetaCullableInterface *iface); @@ -223,7 +223,7 @@ static gboolean is_frozen (MetaSurfaceActor *self) { MetaSurfaceActorPrivate *priv = self->priv; - return (priv->freeze_count > 0); + return priv->frozen; } void @@ -274,31 +274,19 @@ meta_surface_actor_is_visible (MetaSurfaceActor *self) } void -meta_surface_actor_freeze (MetaSurfaceActor *self) +meta_surface_actor_set_frozen (MetaSurfaceActor *self, + gboolean frozen) { MetaSurfaceActorPrivate *priv = self->priv; - priv->freeze_count ++; -} + priv->frozen = frozen; -void -meta_surface_actor_thaw (MetaSurfaceActor *self) -{ - MetaSurfaceActorPrivate *priv = self->priv; - - if (priv->freeze_count == 0) + if (!frozen && priv->needs_damage_all) { - g_critical ("Error in freeze/thaw accounting."); - return; - } + /* Since we ignore damage events while a window is frozen for certain effects + * we may need to issue an update_area() covering the whole pixmap if we + * don't know what real damage has happened. */ - priv->freeze_count --; - - /* Since we ignore damage events while a window is frozen for certain effects - * we may need to issue an update_area() covering the whole pixmap if we - * don't know what real damage has happened. */ - if (priv->needs_damage_all) - { meta_surface_actor_process_damage (self, 0, 0, clutter_actor_get_width (CLUTTER_ACTOR (priv->texture)), clutter_actor_get_height (CLUTTER_ACTOR (priv->texture))); @@ -306,12 +294,6 @@ meta_surface_actor_thaw (MetaSurfaceActor *self) } } -gboolean -meta_surface_actor_is_frozen (MetaSurfaceActor *self) -{ - return is_frozen (self); -} - gboolean meta_surface_actor_should_unredirect (MetaSurfaceActor *self) { diff --git a/src/compositor/meta-surface-actor.h b/src/compositor/meta-surface-actor.h index 763f91d72..a92f6f717 100644 --- a/src/compositor/meta-surface-actor.h +++ b/src/compositor/meta-surface-actor.h @@ -69,9 +69,8 @@ void meta_surface_actor_pre_paint (MetaSurfaceActor *actor); gboolean meta_surface_actor_is_argb32 (MetaSurfaceActor *actor); gboolean meta_surface_actor_is_visible (MetaSurfaceActor *actor); -void meta_surface_actor_freeze (MetaSurfaceActor *actor); -void meta_surface_actor_thaw (MetaSurfaceActor *actor); -gboolean meta_surface_actor_is_frozen (MetaSurfaceActor *actor); +void meta_surface_actor_set_frozen (MetaSurfaceActor *actor, + gboolean frozen); gboolean meta_surface_actor_should_unredirect (MetaSurfaceActor *actor); void meta_surface_actor_set_unredirected (MetaSurfaceActor *actor, diff --git a/src/compositor/meta-window-actor.c b/src/compositor/meta-window-actor.c index d2c16b1cf..14c12ee92 100644 --- a/src/compositor/meta-window-actor.c +++ b/src/compositor/meta-window-actor.c @@ -84,6 +84,7 @@ struct _MetaWindowActorPrivate /* List of FrameData for recent frames */ GList *frames; + guint freeze_count; guint visible : 1; guint disposed : 1; @@ -269,14 +270,19 @@ static gboolean is_frozen (MetaWindowActor *self) { MetaWindowActorPrivate *priv = self->priv; - return meta_surface_actor_is_frozen (priv->surface); + + return priv->freeze_count > 0; } static void meta_window_actor_freeze (MetaWindowActor *self) { MetaWindowActorPrivate *priv = self->priv; - meta_surface_actor_freeze (priv->surface); + + if (priv->freeze_count == 0) + meta_surface_actor_set_frozen (priv->surface, TRUE); + + priv->freeze_count ++; } static void @@ -284,11 +290,15 @@ meta_window_actor_thaw (MetaWindowActor *self) { MetaWindowActorPrivate *priv = self->priv; - meta_surface_actor_thaw (priv->surface); + if (priv->freeze_count <= 0) + g_error ("Error in freeze/thaw accounting"); - if (is_frozen (self)) + priv->freeze_count--; + if (priv->freeze_count > 0) return; + meta_surface_actor_set_frozen (priv->surface, FALSE); + /* We sometimes ignore moves and resizes on frozen windows */ meta_window_actor_sync_actor_geometry (self, FALSE); @@ -326,8 +336,7 @@ set_surface (MetaWindowActor *self, /* If the previous surface actor was frozen, start out * frozen as well... */ - if (priv->updates_frozen) - meta_surface_actor_freeze (priv->surface); + meta_surface_actor_set_frozen (priv->surface, priv->freeze_count > 0); meta_window_actor_update_shape (self); }