From 78f437d61e20476fa1c2324b14744aa62a232a43 Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=B8ren=20Sandmann=20Pedersen?= Date: Tue, 21 May 2013 03:29:09 -0400 Subject: [PATCH] sse2: Replace the fetcher_info_t table with a pixman_iter_info_t table Similar to the changes to noop, put all the iterators into a table of pixman_iter_info_t and then do a generic search of that table during iterator initialization. --- pixman/pixman-sse2.c | 64 ++++++++++++++++++++++++++++------------------------ 1 file changed, 35 insertions(+), 29 deletions(-) diff --git a/pixman/pixman-sse2.c b/pixman/pixman-sse2.c index 863bc18..344cc46 100644 --- a/pixman/pixman-sse2.c +++ b/pixman/pixman-sse2.c @@ -6340,47 +6340,53 @@ sse2_fetch_a8 (pixman_iter_t *iter, const uint32_t *mask) return iter->buffer; } -typedef struct +static void +iter_init_bits_stride (pixman_iter_t *iter, const pixman_iter_info_t *info) { - pixman_format_code_t format; - pixman_iter_get_scanline_t get_scanline; -} fetcher_info_t; + pixman_image_t *image = iter->image; + uint8_t *b = (uint8_t *)image->bits.bits; + int s = image->bits.rowstride * 4; + + iter->bits = b + s * iter->y + iter->x * PIXMAN_FORMAT_BPP (info->format) / 8; + iter->stride = s; +} -static const fetcher_info_t fetchers[] = +#define IMAGE_FLAGS \ + (FAST_PATH_STANDARD_FLAGS | FAST_PATH_ID_TRANSFORM | \ + FAST_PATH_BITS_IMAGE | FAST_PATH_SAMPLES_COVER_CLIP_NEAREST) + +static const pixman_iter_info_t sse2_iters[] = { - { PIXMAN_x8r8g8b8, sse2_fetch_x8r8g8b8 }, - { PIXMAN_r5g6b5, sse2_fetch_r5g6b5 }, - { PIXMAN_a8, sse2_fetch_a8 }, - { PIXMAN_null } + { PIXMAN_x8r8g8b8, IMAGE_FLAGS, ITER_NARROW, + iter_init_bits_stride, sse2_fetch_x8r8g8b8, NULL + }, + { PIXMAN_r5g6b5, IMAGE_FLAGS, ITER_NARROW, + iter_init_bits_stride, sse2_fetch_r5g6b5, NULL + }, + { PIXMAN_a8, IMAGE_FLAGS, ITER_NARROW, + iter_init_bits_stride, sse2_fetch_a8, NULL + }, + { PIXMAN_null }, }; static pixman_bool_t sse2_src_iter_init (pixman_implementation_t *imp, pixman_iter_t *iter) { - pixman_image_t *image = iter->image; + const pixman_iter_info_t *info; -#define FLAGS \ - (FAST_PATH_STANDARD_FLAGS | FAST_PATH_ID_TRANSFORM | \ - FAST_PATH_BITS_IMAGE | FAST_PATH_SAMPLES_COVER_CLIP_NEAREST) - - if ((iter->iter_flags & ITER_NARROW) && - (iter->image_flags & FLAGS) == FLAGS) + for (info = sse2_iters; info->format != PIXMAN_null; ++info) { - const fetcher_info_t *f; - - for (f = &fetchers[0]; f->format != PIXMAN_null; f++) + if ((info->format == PIXMAN_any || + info->format == iter->image->common.extended_format_code) && + (info->image_flags & iter->image_flags) == info->image_flags && + (info->iter_flags & iter->iter_flags) == info->iter_flags) { - if (image->common.extended_format_code == f->format) - { - uint8_t *b = (uint8_t *)image->bits.bits; - int s = image->bits.rowstride * 4; - - iter->bits = b + s * iter->y + iter->x * PIXMAN_FORMAT_BPP (f->format) / 8; - iter->stride = s; + iter->get_scanline = info->get_scanline; + iter->write_back = info->write_back; - iter->get_scanline = f->get_scanline; - return TRUE; - } + if (info->initializer) + info->initializer (iter, info); + return TRUE; } } -- 2.7.4