From 7938458eb8b5e9f0aa7380e2b1fc0559631d83a3 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Sun, 12 Aug 2012 18:02:06 -0300 Subject: [PATCH] window-actor: Don't create a mask texture unnecessarily Mask texture resources may be expensive. Don't create one if we don't need to, like on an unshaped window without a frame. https://bugzilla.gnome.org/show_bug.cgi?id=681676 --- src/compositor/meta-window-actor.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/compositor/meta-window-actor.c b/src/compositor/meta-window-actor.c index f74b8c677..371233f45 100644 --- a/src/compositor/meta-window-actor.c +++ b/src/compositor/meta-window-actor.c @@ -2219,6 +2219,7 @@ check_needs_reshape (MetaWindowActor *self) MetaFrameBorders borders; cairo_region_t *region = NULL; cairo_rectangle_int_t client_area; + gboolean needs_mask; if (!priv->needs_reshape) return; @@ -2270,6 +2271,8 @@ check_needs_reshape (MetaWindowActor *self) } #endif + needs_mask = (region != NULL) || (priv->window->frame != NULL); + if (region == NULL) { /* If we don't have a shape on the server, that means that @@ -2278,13 +2281,16 @@ check_needs_reshape (MetaWindowActor *self) region = cairo_region_create_rectangle (&client_area); } - /* This takes the region, generates a mask using GTK+ - * and scans the mask looking for all opaque pixels, - * adding it to region. - */ - build_and_scan_frame_mask (self, &borders, &client_area, region); - meta_window_actor_update_shape_region (self, region); + if (needs_mask) + { + /* This takes the region, generates a mask using GTK+ + * and scans the mask looking for all opaque pixels, + * adding it to region. + */ + build_and_scan_frame_mask (self, &borders, &client_area, region); + } + meta_window_actor_update_shape_region (self, region); cairo_region_destroy (region); priv->needs_reshape = FALSE;