[mutter] frames.c: Do not create pixmaps when there's nothing to draw



commit ecf812db833db5bf663c5e6b2fa02856f890a47e
Author: Benjamin Otte <otte redhat com>
Date:   Mon Sep 20 20:44:23 2010 +0200

    frames.c: Do not create pixmaps when there's nothing to draw
    
    https://bugzilla.gnome.org/show_bug.cgi?id=630203
    
    Take advantage of existing handling for CachedFramePiece.piece == NULL
    to avoid generating pixmaps when width/height are 0

 src/ui/frames.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/src/ui/frames.c b/src/ui/frames.c
index e2efea6..bb37c20 100644
--- a/src/ui/frames.c
+++ b/src/ui/frames.c
@@ -2115,13 +2115,17 @@ generate_pixmap (MetaFrames *frames,
   MetaRegion *region;
   GdkPixmap *result;
 
+  /* do not create a pixmap for nonexisting areas */
+  if (rect.width <= 0 || rect.height <= 0)
+    return NULL;
+
   rectangle.x = rect.x;
   rectangle.y = rect.y;
-  rectangle.width = MAX (rect.width, 1);
-  rectangle.height = MAX (rect.height, 1);
+  rectangle.width = rect.width;
+  rectangle.height = rect.height;
   
   result = gdk_pixmap_new (frame->window,
-                           rectangle.width, rectangle.height, -1);
+                           rect.width, rect.height, -1);
   
   clear_backing (result, frame->window, rectangle.x, rectangle.y);
 
@@ -2200,6 +2204,8 @@ populate_cache (MetaFrames *frames,
   for (i = 0; i < 4; i++)
     {
       CachedFramePiece *piece = &pixels->piece[i];
+      /* generate_pixmap() returns NULL for 0 width/height pieces, but
+       * does so cheaply so we don't need to cache the NULL return */
       if (!piece->pixmap)
         piece->pixmap = generate_pixmap (frames, frame, piece->rect);
     }



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