diff options
author | Søren Sandmann Pedersen <sandmann@redhat.com> | 2009-09-18 03:54:36 -0400 |
---|---|---|
committer | Søren Sandmann Pedersen <ssp@redhat.com> | 2010-02-24 23:20:27 -0500 |
commit | a7ad9c7c9dcb78e0c5ad00145b119dfe929eb307 (patch) | |
tree | ef5338c4bc3c64bfb042b0ddcbc141d44ad6c232 | |
parent | 7bc4cd42c3549f3f2354f50a7cf21ce9ccc8de7b (diff) |
Compute the image flags at validation time instead of composite time
Instead of computing all the image flags at composite time, we compute
them once in _pixman_image_validate() and cache them in the image.
-rw-r--r-- | pixman/pixman-image.c | 57 | ||||
-rw-r--r-- | pixman/pixman-private.h | 2 | ||||
-rw-r--r-- | pixman/pixman.c | 52 |
3 files changed, 61 insertions, 50 deletions
diff --git a/pixman/pixman-image.c b/pixman/pixman-image.c index 6036c56..880c49f 100644 --- a/pixman/pixman-image.c +++ b/pixman/pixman-image.c @@ -243,12 +243,69 @@ _pixman_image_reset_clip_region (pixman_image_t *image) image->common.have_clip_region = FALSE; } +static void +compute_flags (pixman_image_t *image) +{ + uint32_t flags = 0; + + if (!image->common.transform) + { + flags |= FAST_PATH_ID_TRANSFORM; + } + else if (image->common.transform && + image->common.transform->matrix[0][1] == 0 && + image->common.transform->matrix[1][0] == 0 && + image->common.transform->matrix[2][0] == 0 && + image->common.transform->matrix[2][1] == 0 && + image->common.transform->matrix[2][2] == pixman_fixed_1) + { + flags |= FAST_PATH_SCALE_TRANSFORM; + } + + if (!image->common.alpha_map) + flags |= FAST_PATH_NO_ALPHA_MAP; + + if (image->common.filter != PIXMAN_FILTER_CONVOLUTION) + { + flags |= FAST_PATH_NO_CONVOLUTION_FILTER; + + if (image->common.filter == PIXMAN_FILTER_NEAREST) + flags |= FAST_PATH_NEAREST_FILTER; + } + + if (image->common.repeat != PIXMAN_REPEAT_PAD) + flags |= FAST_PATH_NO_PAD_REPEAT; + + if (image->common.repeat != PIXMAN_REPEAT_REFLECT) + flags |= FAST_PATH_NO_REFLECT_REPEAT; + + flags |= (FAST_PATH_NO_ACCESSORS | FAST_PATH_NO_WIDE_FORMAT); + if (image->common.type == BITS) + { + if (image->bits.read_func || image->bits.write_func) + flags &= ~FAST_PATH_NO_ACCESSORS; + + if (PIXMAN_FORMAT_IS_WIDE (image->bits.format)) + flags &= ~FAST_PATH_NO_WIDE_FORMAT; + } + + if (image->common.component_alpha) + flags |= FAST_PATH_COMPONENT_ALPHA; + else + flags |= FAST_PATH_UNIFIED_ALPHA; + + image->common.flags = flags; +} + void _pixman_image_validate (pixman_image_t *image) { if (image->common.dirty) { image->common.property_changed (image); + + compute_flags (image); + image->common.dirty = FALSE; } diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h index 7ed8aa7..2cafe3a 100644 --- a/pixman/pixman-private.h +++ b/pixman/pixman-private.h @@ -103,6 +103,8 @@ struct image_common pixman_image_destroy_func_t destroy_func; void * destroy_data; + + uint32_t flags; }; struct source_image diff --git a/pixman/pixman.c b/pixman/pixman.c index 6a260ed..c7d3bcc 100644 --- a/pixman/pixman.c +++ b/pixman/pixman.c @@ -453,56 +453,8 @@ get_image_info (pixman_image_t *image, pixman_format_code_t *code, uint32_t *flags) { - *flags = 0; - - if (!image->common.transform) - { - *flags |= FAST_PATH_ID_TRANSFORM; - } - else - { - if (image->common.transform->matrix[0][1] == 0 && - image->common.transform->matrix[1][0] == 0 && - image->common.transform->matrix[2][0] == 0 && - image->common.transform->matrix[2][1] == 0 && - image->common.transform->matrix[2][2] == pixman_fixed_1) - { - *flags |= FAST_PATH_SCALE_TRANSFORM; - } - } - - if (!image->common.alpha_map) - *flags |= FAST_PATH_NO_ALPHA_MAP; - - if (image->common.filter != PIXMAN_FILTER_CONVOLUTION) - { - *flags |= FAST_PATH_NO_CONVOLUTION_FILTER; - - if (image->common.filter == PIXMAN_FILTER_NEAREST) - *flags |= FAST_PATH_NEAREST_FILTER; - } - - if (image->common.repeat != PIXMAN_REPEAT_PAD) - *flags |= FAST_PATH_NO_PAD_REPEAT; - - if (image->common.repeat != PIXMAN_REPEAT_REFLECT) - *flags |= FAST_PATH_NO_REFLECT_REPEAT; - - *flags |= (FAST_PATH_NO_ACCESSORS | FAST_PATH_NO_WIDE_FORMAT); - if (image->type == BITS) - { - if (image->bits.read_func || image->bits.write_func) - *flags &= ~FAST_PATH_NO_ACCESSORS; - - if (PIXMAN_FORMAT_IS_WIDE (image->bits.format)) - *flags &= ~FAST_PATH_NO_WIDE_FORMAT; - } - - if (image->common.component_alpha) - *flags |= FAST_PATH_COMPONENT_ALPHA; - else - *flags |= FAST_PATH_UNIFIED_ALPHA; - + *flags = image->common.flags; + if (_pixman_image_is_solid (image)) *code = PIXMAN_solid; else if (image->common.type == BITS) |