Reset clip regions correctly when NULL is passed
authorSøren Sandmann <sandmann@redhat.com>
Thu, 14 Jun 2007 16:59:15 +0000 (12:59 -0400)
committerSøren Sandmann <sandmann@redhat.com>
Thu, 14 Jun 2007 16:59:15 +0000 (12:59 -0400)
pixman/pixman-image.c
pixman/pixman-trap.c

index 8483068..1eee840 100644 (file)
@@ -283,6 +283,23 @@ create_bits (pixman_format_code_t format,
     return calloc (buf_size, 1);
 }
 
+static void
+reset_clip_region (pixman_image_t *image)
+{
+    pixman_region_fini (&image->common.clip_region);
+    
+    if (image->type == BITS)
+    {
+       pixman_region_init_rect (&image->common.clip_region, 0, 0,
+                                image->bits.width, image->bits.height);
+       
+    }
+    else
+    {
+       pixman_region_init (&image->common.clip_region);
+    }
+}
+
 pixman_image_t *
 pixman_image_create_bits (pixman_format_code_t  format,
                          int                   width,
@@ -319,8 +336,7 @@ pixman_image_create_bits (pixman_format_code_t  format,
                                                                  */
     image->bits.indexed = NULL;
 
-    pixman_region_fini (&image->common.clip_region);
-    pixman_region_init_rect (&image->common.clip_region, 0, 0, width, height);
+    reset_clip_region (image);
 
     return image;
 }
@@ -337,9 +353,8 @@ pixman_image_set_clip_region (pixman_image_t    *image,
     }
     else
     {
-       pixman_region_fini (&common->clip_region);
-       pixman_region_init (&common->clip_region);
-
+       reset_clip_region (image);
+       
        return TRUE;
     }
 }
index 31f08d8..204ca04 100644 (file)
@@ -86,6 +86,36 @@ pixman_add_traps (pixman_image_t *   image,
     fbFinishAccess (pPicture->pDrawable);
 }
 
+static void
+dump_image (pixman_image_t *image,
+           const char *title)
+{
+    int i, j;
+    
+    if (!image->type == BITS)
+    {
+       printf ("%s is not a regular image\n", title);
+    }
+
+    if (!image->bits.format == PIXMAN_a8)
+    {
+       printf ("%s is not an alpha mask\n", title);
+    }
+
+    printf ("\n\n\n%s: \n", title);
+    
+    for (i = 0; i < image->bits.height; ++i)
+    {
+       uint8_t *line =
+           (uint8_t *)&(image->bits.bits[i * image->bits.rowstride]);
+           
+       for (j = 0; j < image->bits.width; ++j)
+           printf ("%c", line[j]? '#' : ' ');
+
+       printf ("\n");
+    }
+}
+
 void
 pixman_add_trapezoids       (pixman_image_t      *image,
                             int16_t              x_off,
@@ -95,6 +125,10 @@ pixman_add_trapezoids       (pixman_image_t      *image,
 {
     int i;
 
+#if 0
+    dump_image (image, "before");
+#endif
+    
     for (i = 0; i < ntraps; ++i)
     {
        const pixman_trapezoid_t *trap = &(traps[i]);
@@ -104,6 +138,10 @@ pixman_add_trapezoids       (pixman_image_t      *image,
        
        pixman_rasterize_trapezoid (image, trap, x_off, y_off);
     }
+
+#if 0
+    dump_image (image, "after");
+#endif
 }
 
 void