diff options
Diffstat (limited to 'gfx/cairo/libpixman/src/pixman-access.c')
-rw-r--r-- | gfx/cairo/libpixman/src/pixman-access.c | 297 |
1 files changed, 182 insertions, 115 deletions
diff --git a/gfx/cairo/libpixman/src/pixman-access.c b/gfx/cairo/libpixman/src/pixman-access.c index 00a02140ae..7c5ce783f9 100644 --- a/gfx/cairo/libpixman/src/pixman-access.c +++ b/gfx/cairo/libpixman/src/pixman-access.c @@ -68,14 +68,14 @@ #ifdef WORDS_BIGENDIAN #define FETCH_24(img,l,o) \ - ((READ (img, (((uint8_t *)(l)) + ((o) * 3) + 0)) << 16) | \ - (READ (img, (((uint8_t *)(l)) + ((o) * 3) + 1)) << 8) | \ - (READ (img, (((uint8_t *)(l)) + ((o) * 3) + 2)) << 0)) + ((uint32_t)(READ (img, (((uint8_t *)(l)) + ((o) * 3) + 0)) << 16) | \ + (uint32_t)(READ (img, (((uint8_t *)(l)) + ((o) * 3) + 1)) << 8) | \ + (uint32_t)(READ (img, (((uint8_t *)(l)) + ((o) * 3) + 2)) << 0)) #else #define FETCH_24(img,l,o) \ - ((READ (img, (((uint8_t *)(l)) + ((o) * 3) + 0)) << 0) | \ - (READ (img, (((uint8_t *)(l)) + ((o) * 3) + 1)) << 8) | \ - (READ (img, (((uint8_t *)(l)) + ((o) * 3) + 2)) << 16)) + ((uint32_t)(READ (img, (((uint8_t *)(l)) + ((o) * 3) + 0)) << 0) | \ + (uint32_t)(READ (img, (((uint8_t *)(l)) + ((o) * 3) + 1)) << 8) | \ + (uint32_t)(READ (img, (((uint8_t *)(l)) + ((o) * 3) + 2)) << 16)) #endif /* Store macros */ @@ -87,7 +87,7 @@ uint32_t *__d = ((uint32_t *)(l)) + ((o) >> 5); \ uint32_t __m, __v; \ \ - __m = 1 << (0x1f - ((o) & 0x1f)); \ + __m = 1U << (0x1f - ((o) & 0x1f)); \ __v = (v)? __m : 0; \ \ WRITE((img), __d, (READ((img), __d) & ~__m) | __v); \ @@ -100,7 +100,7 @@ uint32_t *__d = ((uint32_t *)(l)) + ((o) >> 5); \ uint32_t __m, __v; \ \ - __m = 1 << ((o) & 0x1f); \ + __m = 1U << ((o) & 0x1f); \ __v = (v)? __m : 0; \ \ WRITE((img), __d, (READ((img), __d) & ~__m) | __v); \ @@ -294,14 +294,14 @@ convert_pixel (pixman_format_code_t from, pixman_format_code_t to, uint32_t pixe } static force_inline uint32_t -convert_pixel_to_a8r8g8b8 (pixman_image_t *image, +convert_pixel_to_a8r8g8b8 (bits_image_t *image, pixman_format_code_t format, uint32_t pixel) { if (PIXMAN_FORMAT_TYPE (format) == PIXMAN_TYPE_GRAY || PIXMAN_FORMAT_TYPE (format) == PIXMAN_TYPE_COLOR) { - return image->bits.indexed->rgba[pixel]; + return image->indexed->rgba[pixel]; } else { @@ -332,7 +332,7 @@ convert_pixel_from_a8r8g8b8 (pixman_image_t *image, } static force_inline uint32_t -fetch_and_convert_pixel (pixman_image_t * image, +fetch_and_convert_pixel (bits_image_t * image, const uint8_t * bits, int offset, pixman_format_code_t format) @@ -417,7 +417,7 @@ convert_and_store_pixel (bits_image_t * image, #define MAKE_ACCESSORS(format) \ static void \ - fetch_scanline_ ## format (pixman_image_t *image, \ + fetch_scanline_ ## format (bits_image_t *image, \ int x, \ int y, \ int width, \ @@ -425,7 +425,7 @@ convert_and_store_pixel (bits_image_t * image, const uint32_t *mask) \ { \ uint8_t *bits = \ - (uint8_t *)(image->bits.bits + y * image->bits.rowstride); \ + (uint8_t *)(image->bits + y * image->rowstride); \ int i; \ \ for (i = 0; i < width; ++i) \ @@ -461,8 +461,8 @@ convert_and_store_pixel (bits_image_t * image, uint8_t *bits = \ (uint8_t *)(image->bits + line * image->rowstride); \ \ - return fetch_and_convert_pixel ((pixman_image_t *)image, \ - bits, offset, PIXMAN_ ## format); \ + return fetch_and_convert_pixel ( \ + image, bits, offset, PIXMAN_ ## format); \ } \ \ static const void *const __dummy__ ## format @@ -583,14 +583,14 @@ to_srgb (float f) } static void -fetch_scanline_a8r8g8b8_sRGB_float (pixman_image_t *image, +fetch_scanline_a8r8g8b8_sRGB_float (bits_image_t * image, int x, int y, int width, uint32_t * b, const uint32_t *mask) { - const uint32_t *bits = image->bits.bits + y * image->bits.rowstride; + const uint32_t *bits = image->bits + y * image->rowstride; const uint32_t *pixel = bits + x; const uint32_t *end = pixel + width; argb_t *buffer = (argb_t *)b; @@ -612,14 +612,14 @@ fetch_scanline_a8r8g8b8_sRGB_float (pixman_image_t *image, /* Expects a float buffer */ static void -fetch_scanline_a2r10g10b10_float (pixman_image_t *image, +fetch_scanline_a2r10g10b10_float (bits_image_t * image, int x, int y, int width, uint32_t * b, const uint32_t *mask) { - const uint32_t *bits = image->bits.bits + y * image->bits.rowstride; + const uint32_t *bits = image->bits + y * image->rowstride; const uint32_t *pixel = bits + x; const uint32_t *end = pixel + width; argb_t *buffer = (argb_t *)b; @@ -642,15 +642,57 @@ fetch_scanline_a2r10g10b10_float (pixman_image_t *image, } /* Expects a float buffer */ +#ifndef PIXMAN_FB_ACCESSORS +static void +fetch_scanline_rgbf_float (bits_image_t *image, + int x, + int y, + int width, + uint32_t * b, + const uint32_t *mask) +{ + const float *bits = (float *)image->bits + y * image->rowstride; + const float *pixel = bits + x * 3; + argb_t *buffer = (argb_t *)b; + + for (; width--; buffer++) { + buffer->r = *pixel++; + buffer->g = *pixel++; + buffer->b = *pixel++; + buffer->a = 1.f; + } +} + +static void +fetch_scanline_rgbaf_float (bits_image_t *image, + int x, + int y, + int width, + uint32_t * b, + const uint32_t *mask) +{ + const float *bits = (float *)image->bits + y * image->rowstride; + const float *pixel = bits + x * 4; + argb_t *buffer = (argb_t *)b; + + for (; width--; buffer++) { + buffer->r = *pixel++; + buffer->g = *pixel++; + buffer->b = *pixel++; + buffer->a = *pixel++; + } +} +#endif + static void -fetch_scanline_x2r10g10b10_float (pixman_image_t *image, +fetch_scanline_x2r10g10b10_float (bits_image_t *image, int x, int y, int width, uint32_t * b, const uint32_t *mask) { - const uint32_t *bits = image->bits.bits + y * image->bits.rowstride; + const uint32_t *bits = image->bits + y * image->rowstride; const uint32_t *pixel = (uint32_t *)bits + x; const uint32_t *end = pixel + width; argb_t *buffer = (argb_t *)b; @@ -673,14 +715,14 @@ fetch_scanline_x2r10g10b10_float (pixman_image_t *image, /* Expects a float buffer */ static void -fetch_scanline_a2b10g10r10_float (pixman_image_t *image, +fetch_scanline_a2b10g10r10_float (bits_image_t *image, int x, int y, int width, uint32_t * b, const uint32_t *mask) { - const uint32_t *bits = image->bits.bits + y * image->bits.rowstride; + const uint32_t *bits = image->bits + y * image->rowstride; const uint32_t *pixel = bits + x; const uint32_t *end = pixel + width; argb_t *buffer = (argb_t *)b; @@ -704,14 +746,14 @@ fetch_scanline_a2b10g10r10_float (pixman_image_t *image, /* Expects a float buffer */ static void -fetch_scanline_x2b10g10r10_float (pixman_image_t *image, +fetch_scanline_x2b10g10r10_float (bits_image_t *image, int x, int y, int width, uint32_t * b, const uint32_t *mask) { - const uint32_t *bits = image->bits.bits + y * image->bits.rowstride; + const uint32_t *bits = image->bits + y * image->rowstride; const uint32_t *pixel = (uint32_t *)bits + x; const uint32_t *end = pixel + width; argb_t *buffer = (argb_t *)b; @@ -733,14 +775,14 @@ fetch_scanline_x2b10g10r10_float (pixman_image_t *image, } static void -fetch_scanline_yuy2 (pixman_image_t *image, +fetch_scanline_yuy2 (bits_image_t *image, int x, int line, int width, uint32_t * buffer, const uint32_t *mask) { - const uint32_t *bits = image->bits.bits + image->bits.rowstride * line; + const uint32_t *bits = image->bits + image->rowstride * line; int i; for (i = 0; i < width; i++) @@ -767,7 +809,7 @@ fetch_scanline_yuy2 (pixman_image_t *image, } static void -fetch_scanline_yv12 (pixman_image_t *image, +fetch_scanline_yv12 (bits_image_t *image, int x, int line, int width, @@ -805,6 +847,40 @@ fetch_scanline_yv12 (pixman_image_t *image, /**************************** Pixel wise fetching *****************************/ +#ifndef PIXMAN_FB_ACCESSORS +static argb_t +fetch_pixel_rgbf_float (bits_image_t *image, + int offset, + int line) +{ + float *bits = (float *)image->bits + line * image->rowstride; + argb_t argb; + + argb.r = bits[offset * 3]; + argb.g = bits[offset * 3 + 1]; + argb.b = bits[offset * 3 + 2]; + argb.a = 1.f; + + return argb; +} + +static argb_t +fetch_pixel_rgbaf_float (bits_image_t *image, + int offset, + int line) +{ + float *bits = (float *)image->bits + line * image->rowstride; + argb_t argb; + + argb.r = bits[offset * 4]; + argb.g = bits[offset * 4 + 1]; + argb.b = bits[offset * 4 + 2]; + argb.a = bits[offset * 4 + 3]; + + return argb; +} +#endif + static argb_t fetch_pixel_x2r10g10b10_float (bits_image_t *image, int offset, @@ -962,6 +1038,45 @@ fetch_pixel_yv12 (bits_image_t *image, /*********************************** Store ************************************/ +#ifndef PIXMAN_FB_ACCESSORS +static void +store_scanline_rgbaf_float (bits_image_t * image, + int x, + int y, + int width, + const uint32_t *v) +{ + float *bits = (float *)image->bits + image->rowstride * y + 4 * x; + const argb_t *values = (argb_t *)v; + + for (; width; width--, values++) + { + *bits++ = values->r; + *bits++ = values->g; + *bits++ = values->b; + *bits++ = values->a; + } +} + +static void +store_scanline_rgbf_float (bits_image_t * image, + int x, + int y, + int width, + const uint32_t *v) +{ + float *bits = (float *)image->bits + image->rowstride * y + 3 * x; + const argb_t *values = (argb_t *)v; + + for (; width; width--, values++) + { + *bits++ = values->r; + *bits++ = values->g; + *bits++ = values->b; + } +} +#endif + static void store_scanline_a2r10g10b10_float (bits_image_t * image, int x, @@ -976,7 +1091,7 @@ store_scanline_a2r10g10b10_float (bits_image_t * image, for (i = 0; i < width; ++i) { - uint16_t a, r, g, b; + uint32_t a, r, g, b; a = pixman_float_to_unorm (values[i].a, 2); r = pixman_float_to_unorm (values[i].r, 10); @@ -1002,7 +1117,7 @@ store_scanline_x2r10g10b10_float (bits_image_t * image, for (i = 0; i < width; ++i) { - uint16_t r, g, b; + uint32_t r, g, b; r = pixman_float_to_unorm (values[i].r, 10); g = pixman_float_to_unorm (values[i].g, 10); @@ -1027,7 +1142,7 @@ store_scanline_a2b10g10r10_float (bits_image_t * image, for (i = 0; i < width; ++i) { - uint16_t a, r, g, b; + uint32_t a, r, g, b; a = pixman_float_to_unorm (values[i].a, 2); r = pixman_float_to_unorm (values[i].r, 10); @@ -1053,7 +1168,7 @@ store_scanline_x2b10g10r10_float (bits_image_t * image, for (i = 0; i < width; ++i) { - uint16_t r, g, b; + uint32_t r, g, b; r = pixman_float_to_unorm (values[i].r, 10); g = pixman_float_to_unorm (values[i].g, 10); @@ -1078,7 +1193,7 @@ store_scanline_a8r8g8b8_sRGB_float (bits_image_t * image, for (i = 0; i < width; ++i) { - uint8_t a, r, g, b; + uint32_t a, r, g, b; a = pixman_float_to_unorm (values[i].a, 8); r = to_srgb (values[i].r); @@ -1090,44 +1205,6 @@ store_scanline_a8r8g8b8_sRGB_float (bits_image_t * image, } } -static void -store_scanline_16 (bits_image_t * image, - int x, - int y, - int width, - const uint32_t *v) -{ - uint16_t *bits = (uint16_t*)(image->bits + image->rowstride * y); - uint16_t *values = (uint16_t *)v; - uint16_t *pixel = bits + x; - int i; - - for (i = 0; i < width; ++i) - { - WRITE (image, pixel++, values[i]); - } -} - -static void -fetch_scanline_16 (pixman_image_t *image, - int x, - int y, - int width, - uint32_t * b, - const uint32_t *mask) -{ - const uint16_t *bits = (uint16_t*)(image->bits.bits + y * image->bits.rowstride); - const uint16_t *pixel = bits + x; - int i; - uint16_t *buffer = (uint16_t *)b; - - for (i = 0; i < width; ++i) - { - *buffer++ = READ (image, pixel++); - } -} - - /* * Contracts a floating point image to 32bpp and then stores it using a * regular 32-bit store proc. Despite the type, this function expects an @@ -1159,37 +1236,37 @@ store_scanline_generic_float (bits_image_t * image, } static void -fetch_scanline_generic_float (pixman_image_t *image, +fetch_scanline_generic_float (bits_image_t * image, int x, int y, int width, uint32_t * buffer, const uint32_t *mask) { - image->bits.fetch_scanline_32 (image, x, y, width, buffer, NULL); + image->fetch_scanline_32 (image, x, y, width, buffer, NULL); - pixman_expand_to_float ((argb_t *)buffer, buffer, image->bits.format, width); + pixman_expand_to_float ((argb_t *)buffer, buffer, image->format, width); } /* The 32_sRGB paths should be deleted after narrow processing * is no longer invoked for formats that are considered wide. * (Also see fetch_pixel_generic_lossy_32) */ static void -fetch_scanline_a8r8g8b8_32_sRGB (pixman_image_t *image, +fetch_scanline_a8r8g8b8_32_sRGB (bits_image_t *image, int x, int y, int width, uint32_t *buffer, const uint32_t *mask) { - const uint32_t *bits = image->bits.bits + y * image->bits.rowstride; + const uint32_t *bits = image->bits + y * image->rowstride; const uint32_t *pixel = (uint32_t *)bits + x; const uint32_t *end = pixel + width; uint32_t tmp; while (pixel < end) { - uint8_t a, r, g, b; + uint32_t a, r, g, b; tmp = READ (image, pixel++); @@ -1213,7 +1290,7 @@ fetch_pixel_a8r8g8b8_32_sRGB (bits_image_t *image, { uint32_t *bits = image->bits + line * image->rowstride; uint32_t tmp = READ (image, bits + offset); - uint8_t a, r, g, b; + uint32_t a, r, g, b; a = (tmp >> 24) & 0xff; r = (tmp >> 16) & 0xff; @@ -1242,7 +1319,7 @@ store_scanline_a8r8g8b8_32_sRGB (bits_image_t *image, for (i = 0; i < width; ++i) { - uint8_t a, r, g, b; + uint32_t a, r, g, b; tmp = values[i]; @@ -1294,12 +1371,10 @@ fetch_pixel_generic_lossy_32 (bits_image_t *image, typedef struct { pixman_format_code_t format; - fetch_scanline_t fetch_scanline_16; fetch_scanline_t fetch_scanline_32; fetch_scanline_t fetch_scanline_float; fetch_pixel_32_t fetch_pixel_32; fetch_pixel_float_t fetch_pixel_float; - store_scanline_t store_scanline_16; store_scanline_t store_scanline_32; store_scanline_t store_scanline_float; } format_info_t; @@ -1307,29 +1382,14 @@ typedef struct #define FORMAT_INFO(format) \ { \ PIXMAN_ ## format, \ - NULL, \ fetch_scanline_ ## format, \ fetch_scanline_generic_float, \ fetch_pixel_ ## format, \ fetch_pixel_generic_float, \ - NULL, \ - store_scanline_ ## format, \ - store_scanline_generic_float \ - } -#define FORMAT_INFO16(format) \ - { \ - PIXMAN_ ## format, \ - fetch_scanline_16, \ - fetch_scanline_ ## format, \ - fetch_scanline_generic_float, \ - fetch_pixel_ ## format, \ - fetch_pixel_generic_float, \ - store_scanline_16, \ store_scanline_ ## format, \ store_scanline_generic_float \ } - static const format_info_t accessors[] = { /* 32 bpp formats */ @@ -1345,10 +1405,8 @@ static const format_info_t accessors[] = /* sRGB formats */ { PIXMAN_a8r8g8b8_sRGB, - NULL, fetch_scanline_a8r8g8b8_32_sRGB, fetch_scanline_a8r8g8b8_sRGB_float, fetch_pixel_a8r8g8b8_32_sRGB, fetch_pixel_a8r8g8b8_sRGB_float, - NULL, store_scanline_a8r8g8b8_32_sRGB, store_scanline_a8r8g8b8_sRGB_float, }, @@ -1357,8 +1415,8 @@ static const format_info_t accessors[] = FORMAT_INFO (b8g8r8), /* 16bpp formats */ - FORMAT_INFO16 (r5g6b5), - FORMAT_INFO16 (b5g6r5), + FORMAT_INFO (r5g6b5), + FORMAT_INFO (b5g6r5), FORMAT_INFO (a1r5g5b5), FORMAT_INFO (x1r5g5b5), @@ -1408,37 +1466,48 @@ static const format_info_t accessors[] = FORMAT_INFO (g1), /* Wide formats */ - +#ifndef PIXMAN_FB_ACCESSORS + { PIXMAN_rgba_float, + NULL, fetch_scanline_rgbaf_float, + fetch_pixel_generic_lossy_32, fetch_pixel_rgbaf_float, + NULL, store_scanline_rgbaf_float }, + + { PIXMAN_rgb_float, + NULL, fetch_scanline_rgbf_float, + fetch_pixel_generic_lossy_32, fetch_pixel_rgbf_float, + NULL, store_scanline_rgbf_float }, +#endif + { PIXMAN_a2r10g10b10, - NULL, NULL, fetch_scanline_a2r10g10b10_float, + NULL, fetch_scanline_a2r10g10b10_float, fetch_pixel_generic_lossy_32, fetch_pixel_a2r10g10b10_float, - NULL, NULL, store_scanline_a2r10g10b10_float }, + NULL, store_scanline_a2r10g10b10_float }, { PIXMAN_x2r10g10b10, - NULL, NULL, fetch_scanline_x2r10g10b10_float, + NULL, fetch_scanline_x2r10g10b10_float, fetch_pixel_generic_lossy_32, fetch_pixel_x2r10g10b10_float, - NULL, NULL, store_scanline_x2r10g10b10_float }, + NULL, store_scanline_x2r10g10b10_float }, { PIXMAN_a2b10g10r10, - NULL, NULL, fetch_scanline_a2b10g10r10_float, + NULL, fetch_scanline_a2b10g10r10_float, fetch_pixel_generic_lossy_32, fetch_pixel_a2b10g10r10_float, - NULL, NULL, store_scanline_a2b10g10r10_float }, + NULL, store_scanline_a2b10g10r10_float }, { PIXMAN_x2b10g10r10, - NULL, NULL, fetch_scanline_x2b10g10r10_float, + NULL, fetch_scanline_x2b10g10r10_float, fetch_pixel_generic_lossy_32, fetch_pixel_x2b10g10r10_float, - NULL, NULL, store_scanline_x2b10g10r10_float }, + NULL, store_scanline_x2b10g10r10_float }, /* YUV formats */ { PIXMAN_yuy2, - NULL, fetch_scanline_yuy2, fetch_scanline_generic_float, + fetch_scanline_yuy2, fetch_scanline_generic_float, fetch_pixel_yuy2, fetch_pixel_generic_float, - NULL, NULL, NULL }, + NULL, NULL }, { PIXMAN_yv12, - NULL, fetch_scanline_yv12, fetch_scanline_generic_float, + fetch_scanline_yv12, fetch_scanline_generic_float, fetch_pixel_yv12, fetch_pixel_generic_float, - NULL, NULL, NULL }, + NULL, NULL }, { PIXMAN_null }, }; @@ -1452,12 +1521,10 @@ setup_accessors (bits_image_t *image) { if (info->format == image->format) { - image->fetch_scanline_16 = info->fetch_scanline_16; image->fetch_scanline_32 = info->fetch_scanline_32; image->fetch_scanline_float = info->fetch_scanline_float; image->fetch_pixel_32 = info->fetch_pixel_32; image->fetch_pixel_float = info->fetch_pixel_float; - image->store_scanline_16 = info->store_scanline_16; image->store_scanline_32 = info->store_scanline_32; image->store_scanline_float = info->store_scanline_float; |