From 45006e5e648b85df65b922f893c9802c9ecce38e Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=B8ren=20Sandmann=20Pedersen?= Date: Fri, 18 Sep 2009 04:06:30 -0400 Subject: [PATCH] Move computation of extended format code to validate. Instead of computing the extended format on every composite, just compute it once and store it in the image. --- pixman/pixman-image.c | 25 +++++++++++++++++++++++-- pixman/pixman-private.h | 1 + pixman/pixman.c | 37 +++++++++---------------------------- 3 files changed, 33 insertions(+), 30 deletions(-) diff --git a/pixman/pixman-image.c b/pixman/pixman-image.c index 880c49f..89a5a09 100644 --- a/pixman/pixman-image.c +++ b/pixman/pixman-image.c @@ -244,8 +244,9 @@ _pixman_image_reset_clip_region (pixman_image_t *image) } static void -compute_flags (pixman_image_t *image) +compute_image_info (pixman_image_t *image) { + pixman_format_code_t code; uint32_t flags = 0; if (!image->common.transform) @@ -294,7 +295,27 @@ compute_flags (pixman_image_t *image) else flags |= FAST_PATH_UNIFIED_ALPHA; + if (_pixman_image_is_solid (image)) + { + code = PIXMAN_solid; + } + else if (image->common.type == BITS) + { + code = image->bits.format; + + if (!image->common.transform && + image->common.repeat == PIXMAN_REPEAT_NORMAL) + { + flags |= FAST_PATH_SIMPLE_REPEAT; + } + } + else + { + code = PIXMAN_unknown; + } + image->common.flags = flags; + image->common.extended_format_code = code; } void @@ -304,7 +325,7 @@ _pixman_image_validate (pixman_image_t *image) { image->common.property_changed (image); - compute_flags (image); + compute_image_info (image); image->common.dirty = FALSE; } diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h index f4f0397..edee738 100644 --- a/pixman/pixman-private.h +++ b/pixman/pixman-private.h @@ -105,6 +105,7 @@ struct image_common void * destroy_data; uint32_t flags; + pixman_format_code_t extended_format_code; }; struct source_image diff --git a/pixman/pixman.c b/pixman/pixman.c index 09fc7e1..e1bef17 100644 --- a/pixman/pixman.c +++ b/pixman/pixman.c @@ -448,30 +448,6 @@ walk_region_internal (pixman_implementation_t *imp, } } -static void -get_image_info (pixman_image_t *image, - pixman_format_code_t *code, - uint32_t *flags) -{ - *flags = image->common.flags; - - if (_pixman_image_is_solid (image)) - { - *code = PIXMAN_solid; - } - else if (image->common.type == BITS) - { - *code = image->bits.format; - - if (!image->common.transform && image->common.repeat == PIXMAN_REPEAT_NORMAL) - *flags |= FAST_PATH_SIMPLE_REPEAT; - } - else - { - *code = PIXMAN_unknown; - } -} - static force_inline pixman_bool_t image_covers (pixman_image_t *image, pixman_box32_t *extents, @@ -512,18 +488,23 @@ do_composite (pixman_implementation_t *imp, pixman_region32_t region; pixman_box32_t *extents; - get_image_info (src, &src_format, &src_flags); + src_format = src->common.extended_format_code; + src_flags = src->common.flags; + if (mask) { - get_image_info (mask, &mask_format, &mask_flags); + mask_format = mask->common.extended_format_code; + mask_flags = mask->common.flags; } else { mask_format = PIXMAN_null; mask_flags = 0; } - get_image_info (dest, &dest_format, &dest_flags); - + + dest_format = dest->common.extended_format_code; + dest_flags = dest->common.flags; + /* Check for pixbufs */ if ((mask_format == PIXMAN_a8r8g8b8 || mask_format == PIXMAN_a8b8g8r8) && (src->type == BITS && src->bits.bits == mask->bits.bits) && -- 2.7.4