From d8c66077f01617168a05932558dc0b5386e8cf51 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Thu, 21 Nov 2013 15:13:18 -0500 Subject: [PATCH] window-actor: Move the operations we need to do when we cull out here Soon, we'll move this into a generic MetaCullable interface, but for now, just put hardcoded knowledge in MetaWindowGroup. https://bugzilla.gnome.org/show_bug.cgi?id=714706 --- src/compositor/meta-window-actor-private.h | 11 +++---- src/compositor/meta-window-actor.c | 37 +++++++++++++++++++--- src/compositor/meta-window-group.c | 26 ++------------- 3 files changed, 39 insertions(+), 35 deletions(-) diff --git a/src/compositor/meta-window-actor-private.h b/src/compositor/meta-window-actor-private.h index c05343d7e..f10276b0f 100644 --- a/src/compositor/meta-window-actor-private.h +++ b/src/compositor/meta-window-actor-private.h @@ -55,13 +55,10 @@ void meta_window_actor_set_updates_frozen (MetaWindowActor *self, void meta_window_actor_queue_frame_drawn (MetaWindowActor *self, gboolean no_delay_frame); -cairo_region_t *meta_window_actor_get_obscured_region (MetaWindowActor *self); - -void meta_window_actor_set_clip_region (MetaWindowActor *self, - cairo_region_t *clip_region); -void meta_window_actor_set_clip_region_beneath (MetaWindowActor *self, - cairo_region_t *beneath_region); -void meta_window_actor_reset_clip_regions (MetaWindowActor *self); +void meta_window_actor_cull_out (MetaWindowActor *self, + cairo_region_t *unobscured_region, + cairo_region_t *clip_region); +void meta_window_actor_reset_culling (MetaWindowActor *self); void meta_window_actor_set_unobscured_region (MetaWindowActor *self, cairo_region_t *unobscured_region); diff --git a/src/compositor/meta-window-actor.c b/src/compositor/meta-window-actor.c index 9274d2cf9..2a45b4196 100644 --- a/src/compositor/meta-window-actor.c +++ b/src/compositor/meta-window-actor.c @@ -1717,7 +1717,7 @@ meta_window_actor_unmapped (MetaWindowActor *self) * Return value: (transfer none): the area obscured by the window, * %NULL is the same as an empty region. */ -cairo_region_t * +static cairo_region_t * meta_window_actor_get_obscured_region (MetaWindowActor *self) { MetaWindowActorPrivate *priv = self->priv; @@ -1806,7 +1806,7 @@ meta_window_actor_set_unobscured_region (MetaWindowActor *self, * not drawn in this frame. * This will be set before painting then unset afterwards. */ -void +static void meta_window_actor_set_clip_region (MetaWindowActor *self, cairo_region_t *clip_region) { @@ -1828,7 +1828,7 @@ meta_window_actor_set_clip_region (MetaWindowActor *self, * shadow hid by the window itself. This will be set before painting * then unset afterwards. */ -void +static void meta_window_actor_set_clip_region_beneath (MetaWindowActor *self, cairo_region_t *beneath_region) { @@ -1848,15 +1848,42 @@ meta_window_actor_set_clip_region_beneath (MetaWindowActor *self, } } +void +meta_window_actor_cull_out (MetaWindowActor *self, + cairo_region_t *unobscured_region, + cairo_region_t *clip_region) +{ + MetaCompScreen *info = meta_screen_get_compositor_data (self->priv->screen); + + /* Don't do any culling for the unredirected window */ + if (self == info->unredirected_window) + return; + + meta_window_actor_set_unobscured_region (self, unobscured_region); + meta_window_actor_set_clip_region (self, clip_region); + + if (clutter_actor_get_paint_opacity (CLUTTER_ACTOR (self)) == 0xff) + { + cairo_region_t *obscured_region = meta_window_actor_get_obscured_region (self); + if (obscured_region) + { + cairo_region_subtract (unobscured_region, obscured_region); + cairo_region_subtract (clip_region, obscured_region); + } + } + + meta_window_actor_set_clip_region_beneath (self, clip_region); +} + /** - * meta_window_actor_reset_clip_regions: + * meta_window_actor_reset_culling: * @self: a #MetaWindowActor * * Unsets the regions set by meta_window_actor_set_clip_region() and * meta_window_actor_set_clip_region_beneath() */ void -meta_window_actor_reset_clip_regions (MetaWindowActor *self) +meta_window_actor_reset_culling (MetaWindowActor *self) { MetaWindowActorPrivate *priv = self->priv; diff --git a/src/compositor/meta-window-group.c b/src/compositor/meta-window-group.c index 12c5f2d5d..1af5a2e61 100644 --- a/src/compositor/meta-window-group.c +++ b/src/compositor/meta-window-group.c @@ -102,15 +102,9 @@ meta_window_group_cull_out (MetaWindowGroup *group, clutter_actor_iter_init (&iter, actor); while (clutter_actor_iter_prev (&iter, &child)) { - MetaCompScreen *info = meta_screen_get_compositor_data (group->screen); - if (!CLUTTER_ACTOR_IS_VISIBLE (child)) continue; - if (info->unredirected_window != NULL && - child == CLUTTER_ACTOR (info->unredirected_window)) - continue; - /* If an actor has effects applied, then that can change the area * it paints and the opacity, so we no longer can figure out what * portion of the actor is obscured and what portion of the screen @@ -132,30 +126,16 @@ meta_window_group_cull_out (MetaWindowGroup *group, if (META_IS_WINDOW_ACTOR (child)) { - MetaWindowActor *window_actor = META_WINDOW_ACTOR (child); int x, y; - if (!meta_actor_is_untransformed (CLUTTER_ACTOR (window_actor), &x, &y)) + if (!meta_actor_is_untransformed (child, &x, &y)) continue; /* Temporarily move to the coordinate system of the actor */ cairo_region_translate (unobscured_region, - x, - y); cairo_region_translate (clip_region, - x, - y); - meta_window_actor_set_unobscured_region (window_actor, unobscured_region); - meta_window_actor_set_clip_region (window_actor, clip_region); - - if (clutter_actor_get_paint_opacity (CLUTTER_ACTOR (window_actor)) == 0xff) - { - cairo_region_t *obscured_region = meta_window_actor_get_obscured_region (window_actor); - if (obscured_region) - { - cairo_region_subtract (unobscured_region, obscured_region); - cairo_region_subtract (clip_region, obscured_region); - } - } - - meta_window_actor_set_clip_region_beneath (window_actor, clip_region); + meta_window_actor_cull_out (META_WINDOW_ACTOR (child), unobscured_region, clip_region); cairo_region_translate (unobscured_region, x, y); cairo_region_translate (clip_region, x, y); @@ -196,7 +176,7 @@ meta_window_group_reset_culling (MetaWindowGroup *group) if (META_IS_WINDOW_ACTOR (child)) { MetaWindowActor *window_actor = META_WINDOW_ACTOR (child); - meta_window_actor_reset_clip_regions (window_actor); + meta_window_actor_reset_culling (window_actor); } else if (META_IS_BACKGROUND_ACTOR (child)) {