[mutter] window-actor: Don't create a mask texture unnecessarily



commit 7938458eb8b5e9f0aa7380e2b1fc0559631d83a3
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Sun Aug 12 18:02:06 2012 -0300

    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 files changed, 12 insertions(+), 6 deletions(-)
---
diff --git a/src/compositor/meta-window-actor.c b/src/compositor/meta-window-actor.c
index f74b8c6..371233f 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;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]