From 35af45d5e3d3f893ccaa4ab2f947100eb9d840ac Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=B8ren=20Sandmann=20Pedersen?= Date: Mon, 22 Feb 2010 06:06:22 -0500 Subject: [PATCH] Turn need_workaround into another flag. Instead of storing it as a boolean in the image struct, just use another flag for it. --- pixman/pixman-bits-image.c | 6 +++-- pixman/pixman-image.c | 11 ++++++--- pixman/pixman-private.h | 4 ++-- pixman/pixman.c | 60 +++++++++++++++++++++------------------------- 4 files changed, 41 insertions(+), 40 deletions(-) diff --git a/pixman/pixman-bits-image.c b/pixman/pixman-bits-image.c index 6befcbb..90d6ad9 100644 --- a/pixman/pixman-bits-image.c +++ b/pixman/pixman-bits-image.c @@ -986,8 +986,10 @@ bits_image_property_changed (pixman_image_t *image) bits->store_scanline_64 = bits_image_store_scanline_64; bits->store_scanline_32 = bits_image_store_scanline_32; - bits->common.need_workaround = - source_image_needs_out_of_bounds_workaround (bits); + if (source_image_needs_out_of_bounds_workaround (bits)) + bits->common.flags |= FAST_PATH_NEEDS_WORKAROUND; + else + bits->common.flags &= ~FAST_PATH_NEEDS_WORKAROUND; } static uint32_t * diff --git a/pixman/pixman-image.c b/pixman/pixman-image.c index 1014e64..ef02993 100644 --- a/pixman/pixman-image.c +++ b/pixman/pixman-image.c @@ -117,7 +117,6 @@ _pixman_image_allocate (void) common->client_clip = FALSE; common->destroy_func = NULL; common->destroy_data = NULL; - common->need_workaround = FALSE; common->dirty = TRUE; } @@ -373,10 +372,16 @@ _pixman_image_validate (pixman_image_t *image) { if (image->common.dirty) { - image->common.property_changed (image); - compute_image_info (image); + /* It is important that property_changed is + * called *after* compute_image_info() because + * the NEEDS_WORKAROUND flag is computed in + * property_changed(). And compute_image_info() + * completely overwrites the flags field + */ + image->common.property_changed (image); + image->common.dirty = FALSE; } diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h index d08440e..94451d3 100644 --- a/pixman/pixman-private.h +++ b/pixman/pixman-private.h @@ -86,7 +86,6 @@ struct image_common * the image is used as a source */ pixman_bool_t dirty; - pixman_bool_t need_workaround; pixman_transform_t * transform; pixman_repeat_t repeat; pixman_filter_t filter; @@ -559,7 +558,7 @@ _pixman_choose_implementation (void); #define PIXMAN_pixbuf PIXMAN_FORMAT (0, 2, 0, 0, 0, 0) #define PIXMAN_rpixbuf PIXMAN_FORMAT (0, 3, 0, 0, 0, 0) #define PIXMAN_unknown PIXMAN_FORMAT (0, 4, 0, 0, 0, 0) -#define PIXMAN_any PIXMAN_FORMAT (0, 5, 0, 0, 0, 0) +#define PIXMAN_any PIXMAN_FORMAT (0, 5, 0, 0, 0, 0) #define PIXMAN_OP_any (PIXMAN_N_OPERATORS + 1) @@ -577,6 +576,7 @@ _pixman_choose_implementation (void); #define FAST_PATH_NEAREST_FILTER (1 << 11) #define FAST_PATH_SIMPLE_REPEAT (1 << 12) #define FAST_PATH_IS_OPAQUE (1 << 13) +#define FAST_PATH_NEEDS_WORKAROUND (1 << 14) #define _FAST_PATH_STANDARD_FLAGS \ (FAST_PATH_ID_TRANSFORM | \ diff --git a/pixman/pixman.c b/pixman/pixman.c index 905c7b2..c0a985e 100644 --- a/pixman/pixman.c +++ b/pixman/pixman.c @@ -116,7 +116,7 @@ apply_workaround (pixman_image_t *image, int * save_dx, int * save_dy) { - if (image && image->common.need_workaround) + if (image && (image->common.flags & FAST_PATH_NEEDS_WORKAROUND)) { /* Some X servers generate images that point to the * wrong place in memory, but then set the clip region @@ -152,7 +152,7 @@ apply_workaround (pixman_image_t *image, static void unapply_workaround (pixman_image_t *image, uint32_t *bits, int dx, int dy) { - if (image && image->common.need_workaround) + if (image && (image->common.flags & FAST_PATH_NEEDS_WORKAROUND)) { image->bits.bits = bits; pixman_region32_translate (&image->common.clip_region, dx, dy); @@ -486,6 +486,13 @@ do_composite (pixman_implementation_t *imp, uint32_t src_flags, mask_flags, dest_flags; pixman_region32_t region; pixman_box32_t *extents; + uint32_t *src_bits; + int src_dx, src_dy; + uint32_t *mask_bits; + int mask_dx, mask_dy; + uint32_t *dest_bits; + int dest_dx, dest_dy; + pixman_bool_t need_workaround; src_format = src->common.extended_format_code; src_flags = src->common.flags; @@ -515,7 +522,17 @@ do_composite (pixman_implementation_t *imp, else if (src_format == PIXMAN_x8r8g8b8) src_format = mask_format = PIXMAN_rpixbuf; } - + + /* Check for workaround */ + need_workaround = (src_flags | mask_flags | dest_flags) & FAST_PATH_NEEDS_WORKAROUND; + + if (need_workaround) + { + apply_workaround (src, &src_x, &src_y, &src_bits, &src_dx, &src_dy); + apply_workaround (mask, &mask_x, &mask_y, &mask_bits, &mask_dx, &mask_dy); + apply_workaround (dest, &dest_x, &dest_y, &dest_bits, &dest_dx, &dest_dy); + } + pixman_region32_init (®ion); if (!pixman_compute_composite_region32 ( @@ -571,6 +588,13 @@ do_composite (pixman_implementation_t *imp, } done: + if (need_workaround) + { + unapply_workaround (src, src_bits, src_dx, src_dy); + unapply_workaround (mask, mask_bits, mask_dx, mask_dy); + unapply_workaround (dest, dest_bits, dest_dx, dest_dy); + } + pixman_region32_fini (®ion); } @@ -625,14 +649,6 @@ pixman_image_composite32 (pixman_op_t op, int32_t width, int32_t height) { - uint32_t *src_bits; - int src_dx, src_dy; - uint32_t *mask_bits; - int mask_dx, mask_dy; - uint32_t *dest_bits; - int dest_dx, dest_dy; - pixman_bool_t need_workaround; - _pixman_image_validate (src); if (mask) _pixman_image_validate (mask); @@ -654,34 +670,12 @@ pixman_image_composite32 (pixman_op_t op, if (!imp) imp = _pixman_choose_implementation (); - need_workaround = - (src->common.need_workaround) || - (mask && mask->common.need_workaround) || - (dest->common.need_workaround); - - if (need_workaround) - { - apply_workaround (src, &src_x, &src_y, &src_bits, &src_dx, &src_dy); - apply_workaround (mask, &mask_x, &mask_y, &mask_bits, &mask_dx, &mask_dy); - apply_workaround (dest, &dest_x, &dest_y, &dest_bits, &dest_dx, &dest_dy); - } - do_composite (imp, op, src, mask, dest, src_x, src_y, mask_x, mask_y, dest_x, dest_y, width, height); - - if (need_workaround) - { - if (src->common.need_workaround) - unapply_workaround (src, src_bits, src_dx, src_dy); - if (mask && mask->common.need_workaround) - unapply_workaround (mask, mask_bits, mask_dx, mask_dy); - if (dest->common.need_workaround) - unapply_workaround (dest, dest_bits, dest_dx, dest_dy); - } } PIXMAN_EXPORT pixman_bool_t -- 2.7.4