summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSøren Sandmann Pedersen <ssp@redhat.com>2013-09-01 01:18:28 -0400
committerSøren Sandmann Pedersen <ssp@redhat.com>2013-09-13 23:52:59 -0400
commiteb155ba0eb15a05eeb10c6b255a84ae52a271e1e (patch)
treecbacb61b02d271daabc43b6e8689b2c7a911d671
parente2b21f965786ef91bcce69cc64b73e5eaf9b3036 (diff)
Add dest iteratorsmore-iters
Notes on this / FIXME: - This adds another 565 iterator, but we already have one. The new one is likely worse, so it should just go away. - Maybe noop variants should be generated - Maybe they should also be used as COVER_CLIP_NEAREST source fetchers. Finally, maybe the macros from pixman-access.c should be moved to pixman-inline.h so that they can be used here. That would make it possible to generate fast path iters for basically any format.
-rw-r--r--pixman/pixman-fast-path-iters.c96
1 files changed, 89 insertions, 7 deletions
diff --git a/pixman/pixman-fast-path-iters.c b/pixman/pixman-fast-path-iters.c
index dd72b11b..bb8acd87 100644
--- a/pixman/pixman-fast-path-iters.c
+++ b/pixman/pixman-fast-path-iters.c
@@ -952,29 +952,53 @@ bits_image_fetch_nearest_affine (pixman_image_t * image,
}
static force_inline uint32_t
-convert_a8r8g8b8 (const uint8_t *row, int x)
+convert_from_a8r8g8b8 (const uint8_t *row, int x)
{
return *(((uint32_t *)row) + x);
}
static force_inline uint32_t
-convert_x8r8g8b8 (const uint8_t *row, int x)
+convert_from_x8r8g8b8 (const uint8_t *row, int x)
{
return *(((uint32_t *)row) + x);
}
static force_inline uint32_t
-convert_a8 (const uint8_t *row, int x)
+convert_from_a8 (const uint8_t *row, int x)
{
return *(row + x) << 24;
}
static force_inline uint32_t
-convert_r5g6b5 (const uint8_t *row, int x)
+convert_from_r5g6b5 (const uint8_t *row, int x)
{
return convert_0565_to_0888 (*((uint16_t *)row + x));
}
+static force_inline void
+convert_to_r5g6b5 (uint8_t *row, int x, uint32_t pixel)
+{
+ *((uint16_t *)row + x) = convert_8888_to_0565 (pixel);
+}
+
+static force_inline void
+convert_to_a8r8g8b8 (uint8_t *row, int x, uint32_t pixel)
+{
+ *(((uint32_t *)row) + x) = pixel;
+}
+
+static force_inline void
+convert_to_x8r8g8b8 (uint8_t *row, int x, uint32_t pixel)
+{
+ *(((uint32_t *)row) + x) = pixel;
+}
+
+static force_inline void
+convert_to_a8 (uint8_t *row, int x, uint32_t pixel)
+{
+ *(row + x) = pixel >> 24;
+}
+
#define MAKE_SEPARABLE_CONVOLUTION_FETCHER(name, format, repeat_mode) \
static uint32_t * \
bits_image_fetch_separable_convolution_affine_ ## name (pixman_iter_t *iter, \
@@ -985,7 +1009,7 @@ convert_r5g6b5 (const uint8_t *row, int x)
iter->x, iter->y++, \
iter->width, \
iter->buffer, mask, \
- convert_ ## format, \
+ convert_from_ ## format, \
PIXMAN_ ## format, \
repeat_mode); \
\
@@ -1001,7 +1025,7 @@ convert_r5g6b5 (const uint8_t *row, int x)
iter->x, iter->y++, \
iter->width, \
iter->buffer, mask, \
- convert_ ## format, \
+ convert_from_ ## format, \
PIXMAN_ ## format, \
repeat_mode); \
return iter->buffer; \
@@ -1016,7 +1040,7 @@ convert_r5g6b5 (const uint8_t *row, int x)
iter->x, iter->y++, \
iter->width, \
iter->buffer, mask, \
- convert_ ## format, \
+ convert_from_ ## format, \
PIXMAN_ ## format, \
repeat_mode); \
return iter->buffer; \
@@ -1220,6 +1244,39 @@ bits_image_fetch_untransformed_float (pixman_iter_t * iter,
return buffer;
}
+#define MAKE_DEST_ITER(format) \
+ static uint32_t * \
+ fetch_ ## format (pixman_iter_t *iter, const uint32_t *m) \
+ { \
+ uint32_t *buffer = iter->buffer; \
+ uint8_t *bits = (uint8_t *)iter->bits; \
+ uint32_t mask = PIXMAN_FORMAT_A (PIXMAN_ ## format)? 0 : 0xff000000; \
+ int i; \
+ \
+ for (i = 0; i < iter->width; ++i) \
+ buffer[i] = mask | convert_from_ ## format (bits, i); \
+ \
+ return iter->buffer; \
+ } \
+ \
+ static void \
+ write_back_ ## format (pixman_iter_t *iter) \
+ { \
+ uint32_t *buffer = iter->buffer; \
+ uint8_t *bits = (uint8_t *)iter->bits; \
+ int i; \
+ \
+ for (i = 0; i < iter->width; ++i) \
+ convert_to_ ## format (bits, i, buffer[i]); \
+ \
+ iter->bits += iter->stride; \
+ }
+
+MAKE_DEST_ITER (a8r8g8b8)
+MAKE_DEST_ITER (x8r8g8b8)
+MAKE_DEST_ITER (a8)
+MAKE_DEST_ITER (r5g6b5)
+
#define IMAGE_FLAGS \
(FAST_PATH_STANDARD_FLAGS | FAST_PATH_ID_TRANSFORM | \
FAST_PATH_BITS_IMAGE | FAST_PATH_SAMPLES_COVER_CLIP_NEAREST)
@@ -1239,6 +1296,31 @@ static const pixman_iter_info_t fast_iters[] =
_pixman_iter_init_bits_stride,
fast_dest_fetch_noop, fast_write_back_r5g6b5 },
+ { PIXMAN_a8, FAST_PATH_STD_DEST_FLAGS,
+ ITER_NARROW | ITER_DEST,
+ _pixman_iter_init_bits_stride,
+ fetch_a8, write_back_a8,
+ },
+
+ { PIXMAN_a8r8g8b8, FAST_PATH_STD_DEST_FLAGS,
+ ITER_NARROW | ITER_DEST,
+ _pixman_iter_init_bits_stride,
+ fetch_a8r8g8b8, write_back_a8r8g8b8,
+ },
+
+ { PIXMAN_x8r8g8b8, FAST_PATH_STD_DEST_FLAGS,
+ ITER_NARROW | ITER_DEST,
+ _pixman_iter_init_bits_stride,
+ fetch_x8r8g8b8, write_back_x8r8g8b8,
+ },
+
+ /* FIXME: We already have a better version of this */
+ { PIXMAN_r5g6b5, FAST_PATH_STD_DEST_FLAGS,
+ ITER_NARROW | ITER_DEST,
+ _pixman_iter_init_bits_stride,
+ fetch_r5g6b5, write_back_r5g6b5,
+ },
+
{ PIXMAN_any,
(FAST_PATH_NO_ALPHA_MAP |
FAST_PATH_ID_TRANSFORM |