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;
}
}