From 596bd530205e9835ede0bc8816c9b2dfff75e921 Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=B8ren=20Sandmann?= Date: Thu, 14 Jun 2007 12:59:15 -0400 Subject: [PATCH] Reset clip regions correctly when NULL is passed --- pixman/pixman-image.c | 25 ++++++++++++++++++++----- pixman/pixman-trap.c | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 5 deletions(-) diff --git a/pixman/pixman-image.c b/pixman/pixman-image.c index 8483068..1eee840 100644 --- a/pixman/pixman-image.c +++ b/pixman/pixman-image.c @@ -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; } } diff --git a/pixman/pixman-trap.c b/pixman/pixman-trap.c index 31f08d8..204ca04 100644 --- a/pixman/pixman-trap.c +++ b/pixman/pixman-trap.c @@ -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 -- 2.7.4