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.
This commit is contained in:
Giovanni Campagna 2014-02-24 22:00:12 +01:00
parent f0cd9b0687
commit 153f843ea6
3 changed files with 26 additions and 36 deletions

View File

@ -26,8 +26,8 @@ struct _MetaSurfaceActorPrivate
cairo_region_t *input_region; cairo_region_t *input_region;
/* Freeze/thaw accounting */ /* Freeze/thaw accounting */
guint freeze_count;
guint needs_damage_all : 1; guint needs_damage_all : 1;
guint frozen : 1;
}; };
static void cullable_iface_init (MetaCullableInterface *iface); static void cullable_iface_init (MetaCullableInterface *iface);
@ -223,7 +223,7 @@ static gboolean
is_frozen (MetaSurfaceActor *self) is_frozen (MetaSurfaceActor *self)
{ {
MetaSurfaceActorPrivate *priv = self->priv; MetaSurfaceActorPrivate *priv = self->priv;
return (priv->freeze_count > 0); return priv->frozen;
} }
void void
@ -274,31 +274,19 @@ meta_surface_actor_is_visible (MetaSurfaceActor *self)
} }
void void
meta_surface_actor_freeze (MetaSurfaceActor *self) meta_surface_actor_set_frozen (MetaSurfaceActor *self,
gboolean frozen)
{ {
MetaSurfaceActorPrivate *priv = self->priv; MetaSurfaceActorPrivate *priv = self->priv;
priv->freeze_count ++; priv->frozen = frozen;
}
void if (!frozen && priv->needs_damage_all)
meta_surface_actor_thaw (MetaSurfaceActor *self)
{
MetaSurfaceActorPrivate *priv = self->priv;
if (priv->freeze_count == 0)
{ {
g_critical ("Error in freeze/thaw accounting."); /* Since we ignore damage events while a window is frozen for certain effects
return; * 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, meta_surface_actor_process_damage (self, 0, 0,
clutter_actor_get_width (CLUTTER_ACTOR (priv->texture)), clutter_actor_get_width (CLUTTER_ACTOR (priv->texture)),
clutter_actor_get_height (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 gboolean
meta_surface_actor_should_unredirect (MetaSurfaceActor *self) meta_surface_actor_should_unredirect (MetaSurfaceActor *self)
{ {

View File

@ -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_argb32 (MetaSurfaceActor *actor);
gboolean meta_surface_actor_is_visible (MetaSurfaceActor *actor); gboolean meta_surface_actor_is_visible (MetaSurfaceActor *actor);
void meta_surface_actor_freeze (MetaSurfaceActor *actor); void meta_surface_actor_set_frozen (MetaSurfaceActor *actor,
void meta_surface_actor_thaw (MetaSurfaceActor *actor); gboolean frozen);
gboolean meta_surface_actor_is_frozen (MetaSurfaceActor *actor);
gboolean meta_surface_actor_should_unredirect (MetaSurfaceActor *actor); gboolean meta_surface_actor_should_unredirect (MetaSurfaceActor *actor);
void meta_surface_actor_set_unredirected (MetaSurfaceActor *actor, void meta_surface_actor_set_unredirected (MetaSurfaceActor *actor,

View File

@ -84,6 +84,7 @@ struct _MetaWindowActorPrivate
/* List of FrameData for recent frames */ /* List of FrameData for recent frames */
GList *frames; GList *frames;
guint freeze_count;
guint visible : 1; guint visible : 1;
guint disposed : 1; guint disposed : 1;
@ -269,14 +270,19 @@ static gboolean
is_frozen (MetaWindowActor *self) is_frozen (MetaWindowActor *self)
{ {
MetaWindowActorPrivate *priv = self->priv; MetaWindowActorPrivate *priv = self->priv;
return meta_surface_actor_is_frozen (priv->surface);
return priv->freeze_count > 0;
} }
static void static void
meta_window_actor_freeze (MetaWindowActor *self) meta_window_actor_freeze (MetaWindowActor *self)
{ {
MetaWindowActorPrivate *priv = self->priv; 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 static void
@ -284,11 +290,15 @@ meta_window_actor_thaw (MetaWindowActor *self)
{ {
MetaWindowActorPrivate *priv = self->priv; 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; return;
meta_surface_actor_set_frozen (priv->surface, FALSE);
/* We sometimes ignore moves and resizes on frozen windows */ /* We sometimes ignore moves and resizes on frozen windows */
meta_window_actor_sync_actor_geometry (self, FALSE); 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 /* If the previous surface actor was frozen, start out
* frozen as well... */ * frozen as well... */
if (priv->updates_frozen) meta_surface_actor_set_frozen (priv->surface, priv->freeze_count > 0);
meta_surface_actor_freeze (priv->surface);
meta_window_actor_update_shape (self); meta_window_actor_update_shape (self);
} }