[mutter/wip/cb2eb3: 29/55] window-actor: Use cairo to paint regular shape region



commit f2d8e3266b2645841a826a7c0d74d42edb5ce25b
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Sun Apr 29 03:56:57 2012 -0400

    window-actor: Use cairo to paint regular shape region

 src/compositor/meta-window-actor.c |   50 +++++++++--------------------------
 1 files changed, 13 insertions(+), 37 deletions(-)
---
diff --git a/src/compositor/meta-window-actor.c b/src/compositor/meta-window-actor.c
index 7f5d9f7..ff63703 100644
--- a/src/compositor/meta-window-actor.c
+++ b/src/compositor/meta-window-actor.c
@@ -2034,9 +2034,9 @@ build_and_scan_frame_mask (MetaWindowActor       *self,
   guchar *mask_data;
   guint tex_width, tex_height;
   CoglHandle paint_tex, mask_texture;
-  int i;
-  int n_rects;
   int stride;
+  cairo_t *cr;
+  cairo_surface_t *surface;
 
   paint_tex = meta_shaped_texture_get_texture (META_SHAPED_TEXTURE (priv->actor));
   if (paint_tex == COGL_INVALID_HANDLE)
@@ -2050,35 +2050,18 @@ build_and_scan_frame_mask (MetaWindowActor       *self,
   /* Create data for an empty image */
   mask_data = g_malloc0 (stride * tex_height);
 
-  n_rects = cairo_region_num_rectangles (shape_region);
+  surface = cairo_image_surface_create_for_data (mask_data,
+                                                 CAIRO_FORMAT_A8,
+                                                 tex_width,
+                                                 tex_height,
+                                                 stride);
+  cr = cairo_create (surface);
 
-  /* Fill in each rectangle. */
-  for (i = 0; i < n_rects; i ++)
-    {
-      cairo_rectangle_int_t rect;
-      cairo_region_get_rectangle (shape_region, i, &rect);
-
-      gint x1 = rect.x, x2 = x1 + rect.width;
-      gint y1 = rect.y, y2 = y1 + rect.height;
-      guchar *p;
-
-      /* Clip the rectangle to the size of the texture */
-      x1 = CLAMP (x1, 0, (gint) tex_width - 1);
-      x2 = CLAMP (x2, x1, (gint) tex_width);
-      y1 = CLAMP (y1, 0, (gint) tex_height - 1);
-      y2 = CLAMP (y2, y1, (gint) tex_height);
-
-      /* Fill the rectangle */
-      for (p = mask_data + y1 * stride + x1;
-           y1 < y2;
-           y1++, p += stride)
-        memset (p, 255, x2 - x1);
-    }
+  gdk_cairo_region (cr, shape_region);
+  cairo_fill (cr);
 
   if (priv->window->frame != NULL)
     {
-      cairo_t *cr;
-      cairo_surface_t *surface;
       cairo_region_t *frame_paint_region;
       cairo_rectangle_int_t rect = { 0, 0, tex_width, tex_height };
 
@@ -2086,13 +2069,6 @@ build_and_scan_frame_mask (MetaWindowActor       *self,
       frame_paint_region = cairo_region_create_rectangle (&rect);
       cairo_region_subtract_rectangle (frame_paint_region, client_area);
 
-      surface = cairo_image_surface_create_for_data (mask_data,
-                                                     CAIRO_FORMAT_A8,
-                                                     tex_width,
-                                                     tex_height,
-                                                     stride);
-      cr = cairo_create (surface);
-
       gdk_cairo_region (cr, frame_paint_region);
       cairo_clip (cr);
 
@@ -2108,11 +2084,11 @@ build_and_scan_frame_mask (MetaWindowActor       *self,
 
       cairo_surface_flush (surface);
       scan_visible_region (mask_data, stride, frame_paint_region, shape_region);
-
-      cairo_destroy (cr);
-      cairo_surface_destroy (surface);
     }
 
+  cairo_destroy (cr);
+  cairo_surface_destroy (surface);
+
   if (meta_texture_rectangle_check (paint_tex))
     {
       mask_texture = meta_texture_rectangle_new (tex_width, tex_height,


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