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
This commit is contained in:
Jasper St. Pierre 2012-08-12 18:02:06 -03:00
parent 165e117028
commit 7938458eb8

View File

@ -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;