From: Søren Sandmann Pedersen Date: Sat, 11 Dec 2010 13:10:04 +0000 (-0500) Subject: Skip fetching pixels when possible X-Git-Tag: pixman-0.21.4~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fffeda703e40ced90ec5ad6d6cd37a44294d3fe4;p=platform%2Fupstream%2Fpixman.git Skip fetching pixels when possible Add two new iterator flags, ITER_IGNORE_ALPHA and ITER_IGNORE_RGB that are set when the alpha and rgb values are not needed. If both are set, then we can skip fetching entirely and just use _pixman_iter_get_scanline_noop. --- diff --git a/pixman/pixman-bits-image.c b/pixman/pixman-bits-image.c index 8d4e4f5..8cabfdc 100644 --- a/pixman/pixman-bits-image.c +++ b/pixman/pixman-bits-image.c @@ -1466,7 +1466,16 @@ _pixman_bits_image_dest_iter_init (pixman_image_t *image, } else { - iter->get_scanline = dest_get_scanline_narrow; + if ((flags & (ITER_IGNORE_RGB | ITER_IGNORE_ALPHA)) == + (ITER_IGNORE_RGB | ITER_IGNORE_ALPHA)) + { + iter->get_scanline = _pixman_iter_get_scanline_noop; + } + else + { + iter->get_scanline = dest_get_scanline_narrow; + } + iter->write_back = dest_write_back_narrow; } } diff --git a/pixman/pixman-general.c b/pixman/pixman-general.c index e7a7283..16ea3a4 100644 --- a/pixman/pixman-general.c +++ b/pixman/pixman-general.c @@ -107,6 +107,34 @@ general_dest_iter_init (pixman_implementation_t *imp, } } +typedef struct op_info_t op_info_t; +struct op_info_t +{ + uint8_t src, dst; +}; + +#define ITER_IGNORE_BOTH \ + (ITER_IGNORE_ALPHA | ITER_IGNORE_RGB | ITER_LOCALIZED_ALPHA) + +static const op_info_t op_flags[PIXMAN_N_OPERATORS] = +{ + /* Src Dst */ + { ITER_IGNORE_BOTH, ITER_IGNORE_BOTH }, /* CLEAR */ + { ITER_LOCALIZED_ALPHA, ITER_IGNORE_BOTH }, /* SRC */ + { ITER_IGNORE_BOTH, ITER_LOCALIZED_ALPHA }, /* DST */ + { 0, ITER_LOCALIZED_ALPHA }, /* OVER */ + { ITER_LOCALIZED_ALPHA, 0 }, /* OVER_REVERSE */ + { ITER_LOCALIZED_ALPHA, ITER_IGNORE_RGB }, /* IN */ + { ITER_IGNORE_RGB, ITER_LOCALIZED_ALPHA }, /* IN_REVERSE */ + { ITER_LOCALIZED_ALPHA, ITER_IGNORE_RGB }, /* OUT */ + { ITER_IGNORE_RGB, ITER_LOCALIZED_ALPHA }, /* OUT_REVERSE */ + { 0, 0 }, /* ATOP */ + { 0, 0 }, /* ATOP_REVERSE */ + { 0, 0 }, /* XOR */ + { ITER_LOCALIZED_ALPHA, ITER_LOCALIZED_ALPHA }, /* ADD */ + { 0, 0 }, /* SATURATE */ +}; + #define SCANLINE_BUFFER_LENGTH 8192 static void @@ -130,7 +158,7 @@ general_composite_rect (pixman_implementation_t *imp, pixman_iter_t src_iter, mask_iter, dest_iter; pixman_combine_32_func_t compose; pixman_bool_t component_alpha; - iter_flags_t narrow, dest_flags; + iter_flags_t narrow, src_flags; int Bpp; int i; @@ -159,39 +187,39 @@ general_composite_rect (pixman_implementation_t *imp, mask_buffer = src_buffer + width * Bpp; dest_buffer = mask_buffer + width * Bpp; + /* src iter */ + src_flags = narrow | op_flags[op].src; + _pixman_implementation_src_iter_init (imp->toplevel, &src_iter, src, src_x, src_y, width, height, - src_buffer, narrow); - - _pixman_implementation_src_iter_init (imp->toplevel, &mask_iter, mask, - mask_x, mask_y, width, height, - mask_buffer, narrow); - - if (op == PIXMAN_OP_CLEAR || - op == PIXMAN_OP_SRC || - op == PIXMAN_OP_DST || - op == PIXMAN_OP_OVER || - op == PIXMAN_OP_IN_REVERSE || - op == PIXMAN_OP_OUT_REVERSE || - op == PIXMAN_OP_ADD) - { - dest_flags = narrow | ITER_LOCALIZED_ALPHA; - } - else + src_buffer, src_flags); + + /* mask iter */ + if ((src_flags & (ITER_IGNORE_ALPHA | ITER_IGNORE_RGB)) == + (ITER_IGNORE_ALPHA | ITER_IGNORE_RGB)) { - dest_flags = narrow; + /* If it doesn't matter what the source is, then it doesn't matter + * what the mask is + */ + mask = NULL; } - _pixman_implementation_dest_iter_init (imp->toplevel, &dest_iter, dest, - dest_x, dest_y, width, height, - dest_buffer, dest_flags); - component_alpha = mask && mask->common.type == BITS && mask->common.component_alpha && PIXMAN_FORMAT_RGB (mask->bits.format); + _pixman_implementation_src_iter_init ( + imp->toplevel, &mask_iter, mask, mask_x, mask_y, width, height, + mask_buffer, narrow | (component_alpha? 0 : ITER_IGNORE_RGB)); + + /* dest iter */ + _pixman_implementation_dest_iter_init (imp->toplevel, &dest_iter, dest, + dest_x, dest_y, width, height, + dest_buffer, + narrow | op_flags[op].dst); + if (narrow) { if (component_alpha) diff --git a/pixman/pixman-implementation.c b/pixman/pixman-implementation.c index e633432..adaf9c6 100644 --- a/pixman/pixman-implementation.c +++ b/pixman/pixman-implementation.c @@ -278,6 +278,11 @@ _pixman_implementation_src_iter_init (pixman_implementation_t *imp, { iter->get_scanline = get_scanline_null; } + else if ((flags & (ITER_IGNORE_ALPHA | ITER_IGNORE_RGB)) == + (ITER_IGNORE_ALPHA | ITER_IGNORE_RGB)) + { + iter->get_scanline = _pixman_iter_get_scanline_noop; + } else { (*imp->src_iter_init) ( diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h index 0aeae2e..1662d2c 100644 --- a/pixman/pixman-private.h +++ b/pixman/pixman-private.h @@ -202,7 +202,9 @@ typedef enum * we can treat it as if it were ARGB, which means in some cases we can * avoid copying it to a temporary buffer. */ - ITER_LOCALIZED_ALPHA = (1 << 1) + ITER_LOCALIZED_ALPHA = (1 << 1), + ITER_IGNORE_ALPHA = (1 << 2), + ITER_IGNORE_RGB = (1 << 3) } iter_flags_t; struct pixman_iter_t