diff options
author | Søren Sandmann Pedersen <ssp@redhat.com> | 2012-12-18 14:22:56 -0500 |
---|---|---|
committer | Søren Sandmann Pedersen <ssp@redhat.com> | 2012-12-24 13:16:48 -0500 |
commit | e8ecf09e3167273474d50b05ef5c804d6cb5e45a (patch) | |
tree | ff55cd4cbb9dbe0ffe7e21cbfbe5bc95001659df | |
parent | 1bf3a8259ab4e62c022092fe40efb67e734a8acb (diff) |
get rid rid of all pixel fetchersnopixels
-rw-r--r-- | pixman/pixman-access.c | 310 | ||||
-rw-r--r-- | pixman/pixman-bits-image.c | 16 | ||||
-rw-r--r-- | pixman/pixman-noop.c | 4 | ||||
-rw-r--r-- | pixman/pixman-private.h | 10 |
4 files changed, 56 insertions, 284 deletions
diff --git a/pixman/pixman-access.c b/pixman/pixman-access.c index b5c8e401..23fb91b2 100644 --- a/pixman/pixman-access.c +++ b/pixman/pixman-access.c @@ -453,18 +453,6 @@ convert_and_store_pixel (bits_image_t * image, } \ } \ \ - static uint32_t \ - fetch_pixel_ ## format (bits_image_t *image, \ - int offset, \ - int line) \ - { \ - uint8_t *bits = \ - (uint8_t *)(image->bits + line * image->rowstride); \ - \ - return fetch_and_convert_pixel ((pixman_image_t *)image, \ - bits, offset, PIXMAN_ ## format); \ - } \ - \ static const void *const __dummy__ ## format MAKE_ACCESSORS(a8r8g8b8); @@ -803,163 +791,6 @@ fetch_scanline_yv12 (pixman_image_t *image, } } -/**************************** Pixel wise fetching *****************************/ - -static argb_t -fetch_pixel_x2r10g10b10_float (bits_image_t *image, - int offset, - int line) -{ - uint32_t *bits = image->bits + line * image->rowstride; - uint32_t p = READ (image, bits + offset); - uint64_t r = (p >> 20) & 0x3ff; - uint64_t g = (p >> 10) & 0x3ff; - uint64_t b = p & 0x3ff; - argb_t argb; - - argb.a = 1.0; - argb.r = pixman_unorm_to_float (r, 10); - argb.g = pixman_unorm_to_float (g, 10); - argb.b = pixman_unorm_to_float (b, 10); - - return argb; -} - -static argb_t -fetch_pixel_a2r10g10b10_float (bits_image_t *image, - int offset, - int line) -{ - uint32_t *bits = image->bits + line * image->rowstride; - uint32_t p = READ (image, bits + offset); - uint64_t a = p >> 30; - uint64_t r = (p >> 20) & 0x3ff; - uint64_t g = (p >> 10) & 0x3ff; - uint64_t b = p & 0x3ff; - argb_t argb; - - argb.a = pixman_unorm_to_float (a, 2); - argb.r = pixman_unorm_to_float (r, 10); - argb.g = pixman_unorm_to_float (g, 10); - argb.b = pixman_unorm_to_float (b, 10); - - return argb; -} - -static argb_t -fetch_pixel_a2b10g10r10_float (bits_image_t *image, - int offset, - int line) -{ - uint32_t *bits = image->bits + line * image->rowstride; - uint32_t p = READ (image, bits + offset); - uint64_t a = p >> 30; - uint64_t b = (p >> 20) & 0x3ff; - uint64_t g = (p >> 10) & 0x3ff; - uint64_t r = p & 0x3ff; - argb_t argb; - - argb.a = pixman_unorm_to_float (a, 2); - argb.r = pixman_unorm_to_float (r, 10); - argb.g = pixman_unorm_to_float (g, 10); - argb.b = pixman_unorm_to_float (b, 10); - - return argb; -} - -static argb_t -fetch_pixel_x2b10g10r10_float (bits_image_t *image, - int offset, - int line) -{ - uint32_t *bits = image->bits + line * image->rowstride; - uint32_t p = READ (image, bits + offset); - uint64_t b = (p >> 20) & 0x3ff; - uint64_t g = (p >> 10) & 0x3ff; - uint64_t r = p & 0x3ff; - argb_t argb; - - argb.a = 1.0; - argb.r = pixman_unorm_to_float (r, 10); - argb.g = pixman_unorm_to_float (g, 10); - argb.b = pixman_unorm_to_float (b, 10); - - return argb; -} - -static argb_t -fetch_pixel_a8r8g8b8_sRGB_float (bits_image_t *image, - int offset, - int line) -{ - uint32_t *bits = image->bits + line * image->rowstride; - uint32_t p = READ (image, bits + offset); - argb_t argb; - - argb.a = pixman_unorm_to_float ((p >> 24) & 0xff, 8); - - argb.r = to_linear [(p >> 16) & 0xff]; - argb.g = to_linear [(p >> 8) & 0xff]; - argb.b = to_linear [(p >> 0) & 0xff]; - - return argb; -} - -static uint32_t -fetch_pixel_yuy2 (bits_image_t *image, - int offset, - int line) -{ - const uint32_t *bits = image->bits + image->rowstride * line; - - int16_t y, u, v; - int32_t r, g, b; - - y = ((uint8_t *) bits)[offset << 1] - 16; - u = ((uint8_t *) bits)[((offset << 1) & - 4) + 1] - 128; - v = ((uint8_t *) bits)[((offset << 1) & - 4) + 3] - 128; - - /* R = 1.164(Y - 16) + 1.596(V - 128) */ - r = 0x012b27 * y + 0x019a2e * v; - - /* G = 1.164(Y - 16) - 0.813(V - 128) - 0.391(U - 128) */ - g = 0x012b27 * y - 0x00d0f2 * v - 0x00647e * u; - - /* B = 1.164(Y - 16) + 2.018(U - 128) */ - b = 0x012b27 * y + 0x0206a2 * u; - - return 0xff000000 | - (r >= 0 ? r < 0x1000000 ? r & 0xff0000 : 0xff0000 : 0) | - (g >= 0 ? g < 0x1000000 ? (g >> 8) & 0x00ff00 : 0x00ff00 : 0) | - (b >= 0 ? b < 0x1000000 ? (b >> 16) & 0x0000ff : 0x0000ff : 0); -} - -static uint32_t -fetch_pixel_yv12 (bits_image_t *image, - int offset, - int line) -{ - YV12_SETUP (image); - int16_t y = YV12_Y (line)[offset] - 16; - int16_t u = YV12_U (line)[offset >> 1] - 128; - int16_t v = YV12_V (line)[offset >> 1] - 128; - int32_t r, g, b; - - /* R = 1.164(Y - 16) + 1.596(V - 128) */ - r = 0x012b27 * y + 0x019a2e * v; - - /* G = 1.164(Y - 16) - 0.813(V - 128) - 0.391(U - 128) */ - g = 0x012b27 * y - 0x00d0f2 * v - 0x00647e * u; - - /* B = 1.164(Y - 16) + 2.018(U - 128) */ - b = 0x012b27 * y + 0x0206a2 * u; - - return 0xff000000 | - (r >= 0 ? r < 0x1000000 ? r & 0xff0000 : 0xff0000 : 0) | - (g >= 0 ? g < 0x1000000 ? (g >> 8) & 0x00ff00 : 0x00ff00 : 0) | - (b >= 0 ? b < 0x1000000 ? (b >> 16) & 0x0000ff : 0x0000ff : 0); -} - /*********************************** Store ************************************/ static void @@ -1120,73 +951,39 @@ store_scanline_generic_float (bits_image_t * image, free (argb8_pixels); } +/* Takes a 32 bit buffer and expands it to float. Then + * uses the float store function to store the buffer to the image + */ static void -fetch_scanline_generic_float (pixman_image_t *image, - int x, - int y, - int width, - uint32_t * buffer, - const uint32_t *mask) +store_scanline_generic_32 (bits_image_t * image, + int x, + int y, + int width, + const uint32_t *values) { - image->bits.fetch_scanline_32 (image, x, y, width, buffer, NULL); + argb_t *argb; - pixman_expand_to_float ((argb_t *)buffer, buffer, image->bits.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, - 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 *pixel = (uint32_t *)bits + x; - const uint32_t *end = pixel + width; - uint32_t tmp; - - while (pixel < end) + if ((argb = pixman_malloc_ab (sizeof (argb_t), width))) { - uint8_t a, r, g, b; - - tmp = READ (image, pixel++); - - a = (tmp >> 24) & 0xff; - r = (tmp >> 16) & 0xff; - g = (tmp >> 8) & 0xff; - b = (tmp >> 0) & 0xff; + pixman_expand_to_float (argb, values, PIXMAN_a8r8g8b8, width); - r = to_linear[r] * 255.0f + 0.5f; - g = to_linear[g] * 255.0f + 0.5f; - b = to_linear[b] * 255.0f + 0.5f; + image->store_scanline_float (image, x, y, width, (uint32_t *)argb); - *buffer++ = (a << 24) | (r << 16) | (g << 8) | (b << 0); + free (argb); } } -static uint32_t -fetch_pixel_a8r8g8b8_32_sRGB (bits_image_t *image, - int offset, - int line) +static void +fetch_scanline_generic_float (pixman_image_t *image, + int x, + int y, + int width, + uint32_t * buffer, + const uint32_t *mask) { - uint32_t *bits = image->bits + line * image->rowstride; - uint32_t tmp = READ (image, bits + offset); - uint8_t a, r, g, b; - - a = (tmp >> 24) & 0xff; - r = (tmp >> 16) & 0xff; - g = (tmp >> 8) & 0xff; - b = (tmp >> 0) & 0xff; - - r = to_linear[r] * 255.0f + 0.5f; - g = to_linear[g] * 255.0f + 0.5f; - b = to_linear[b] * 255.0f + 0.5f; + image->bits.fetch_scanline_32 (image, x, y, width, buffer, NULL); - return (a << 24) | (r << 16) | (g << 8) | (b << 0); + pixman_expand_to_float ((argb_t *)buffer, buffer, image->bits.format, width); } static void @@ -1221,45 +1018,37 @@ store_scanline_a8r8g8b8_32_sRGB (bits_image_t *image, } } -static argb_t -fetch_pixel_generic_float (bits_image_t *image, - int offset, - int line) -{ - uint32_t pixel32 = image->fetch_pixel_32 (image, offset, line); - argb_t f; - - pixman_expand_to_float (&f, &pixel32, image->format, 1); - - return f; -} - /* * XXX: The transformed fetch path only works at 32-bpp so far. When all * paths have wide versions, this can be removed. * * WARNING: This function loses precision! */ -static uint32_t -fetch_pixel_generic_lossy_32 (bits_image_t *image, - int offset, - int line) +static void +fetch_scanline_generic_lossy_32 (pixman_image_t *image, + int x, + int y, + int width, + uint32_t *buffer, + const uint32_t *mask) { - argb_t pixel64 = image->fetch_pixel_float (image, offset, line); - uint32_t result; + argb_t *argb; + + if ((argb = pixman_malloc_ab (sizeof (argb_t), width))) + { + image->bits.fetch_scanline_float (image, x, y, width, (uint32_t *)argb, NULL); - pixman_contract_from_float (&result, &pixel64, 1); + pixman_contract_from_float (buffer, argb, width); - return result; -} + free (argb); + } +} typedef struct { pixman_format_code_t format; 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_32; store_scanline_t store_scanline_float; } format_info_t; @@ -1269,8 +1058,6 @@ typedef struct PIXMAN_ ## format, \ fetch_scanline_ ## format, \ fetch_scanline_generic_float, \ - fetch_pixel_ ## format, \ - fetch_pixel_generic_float, \ store_scanline_ ## format, \ store_scanline_generic_float \ } @@ -1290,8 +1077,7 @@ static const format_info_t accessors[] = /* sRGB formats */ { PIXMAN_a8r8g8b8_sRGB, - fetch_scanline_a8r8g8b8_32_sRGB, fetch_scanline_a8r8g8b8_sRGB_float, - fetch_pixel_a8r8g8b8_32_sRGB, fetch_pixel_a8r8g8b8_sRGB_float, + fetch_scanline_generic_lossy_32, fetch_scanline_a8r8g8b8_sRGB_float, store_scanline_a8r8g8b8_32_sRGB, store_scanline_a8r8g8b8_sRGB_float, }, @@ -1353,34 +1139,28 @@ static const format_info_t accessors[] = /* Wide formats */ { PIXMAN_a2r10g10b10, - NULL, fetch_scanline_a2r10g10b10_float, - fetch_pixel_generic_lossy_32, fetch_pixel_a2r10g10b10_float, - NULL, store_scanline_a2r10g10b10_float }, + fetch_scanline_generic_lossy_32, fetch_scanline_a2r10g10b10_float, + store_scanline_generic_32, store_scanline_a2r10g10b10_float }, { PIXMAN_x2r10g10b10, - NULL, fetch_scanline_x2r10g10b10_float, - fetch_pixel_generic_lossy_32, fetch_pixel_x2r10g10b10_float, + fetch_scanline_generic_lossy_32, fetch_scanline_x2r10g10b10_float, NULL, store_scanline_x2r10g10b10_float }, { PIXMAN_a2b10g10r10, - NULL, fetch_scanline_a2b10g10r10_float, - fetch_pixel_generic_lossy_32, fetch_pixel_a2b10g10r10_float, + fetch_scanline_generic_lossy_32, fetch_scanline_a2b10g10r10_float, NULL, store_scanline_a2b10g10r10_float }, { PIXMAN_x2b10g10r10, - NULL, fetch_scanline_x2b10g10r10_float, - fetch_pixel_generic_lossy_32, fetch_pixel_x2b10g10r10_float, + fetch_scanline_generic_lossy_32, fetch_scanline_x2b10g10r10_float, NULL, store_scanline_x2b10g10r10_float }, /* YUV formats */ { PIXMAN_yuy2, fetch_scanline_yuy2, fetch_scanline_generic_float, - fetch_pixel_yuy2, fetch_pixel_generic_float, NULL, NULL }, { PIXMAN_yv12, fetch_scanline_yv12, fetch_scanline_generic_float, - fetch_pixel_yv12, fetch_pixel_generic_float, NULL, NULL }, { PIXMAN_null }, @@ -1397,8 +1177,6 @@ setup_accessors (bits_image_t *image) { 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_32 = info->store_scanline_32; image->store_scanline_float = info->store_scanline_float; diff --git a/pixman/pixman-bits-image.c b/pixman/pixman-bits-image.c index 75a39a11..6f248be0 100644 --- a/pixman/pixman-bits-image.c +++ b/pixman/pixman-bits-image.c @@ -56,13 +56,17 @@ static force_inline uint32_t fetch_pixel_no_alpha (bits_image_t *image, int x, int y, pixman_bool_t check_bounds) { + uint32_t c; + if (check_bounds && (x < 0 || x >= image->width || y < 0 || y >= image->height)) { return 0; } - return image->fetch_pixel_32 (image, x, y); + image->fetch_scanline_32 ((pixman_image_t *)image, x, y, 1, &c, NULL); + + return c; } typedef uint32_t (* get_pixel_t) (bits_image_t *image, @@ -622,7 +626,7 @@ fetch_pixel_general (bits_image_t *image, int x, int y, pixman_bool_t check_boun return 0; } - pixel = image->fetch_pixel_32 (image, x, y); + image->fetch_scanline_32 ((pixman_image_t *)image, x, y, 1, &pixel, NULL); if (image->common.alpha_map) { @@ -638,8 +642,8 @@ fetch_pixel_general (bits_image_t *image, int x, int y, pixman_bool_t check_boun } else { - pixel_a = image->common.alpha_map->fetch_pixel_32 ( - image->common.alpha_map, x, y); + image->common.alpha_map->fetch_scanline_32 ( + (pixman_image_t *)image->common.alpha_map, x, y, 1, &pixel_a, NULL); pixel_a = ALPHA_8 (pixel_a); } @@ -1196,7 +1200,7 @@ replicate_pixel_32 (bits_image_t * bits, uint32_t color; uint32_t *end; - color = bits->fetch_pixel_32 (bits, x, y); + bits->fetch_scanline_32 ((pixman_image_t *)bits, x, y, 1, &color, NULL); end = buffer + width; while (buffer < end) @@ -1214,7 +1218,7 @@ replicate_pixel_float (bits_image_t * bits, argb_t *buffer = (argb_t *)b; argb_t *end; - color = bits->fetch_pixel_float (bits, x, y); + bits->fetch_scanline_float ((pixman_image_t *)bits, x, y, 1, (uint32_t *)&color, NULL); end = buffer + width; while (buffer < end) diff --git a/pixman/pixman-noop.c b/pixman/pixman-noop.c index e39996d9..2257d1c7 100644 --- a/pixman/pixman-noop.c +++ b/pixman/pixman-noop.c @@ -89,7 +89,7 @@ noop_src_iter_init (pixman_implementation_t *imp, pixman_iter_t *iter) if (image->type == SOLID) color = image->solid.color_32; else - color = image->bits.fetch_pixel_32 (&image->bits, 0, 0); + image->bits.fetch_scanline_32 (image, 0, 0, 1, &color, NULL); while (buffer < end) *(buffer++) = color; @@ -103,7 +103,7 @@ noop_src_iter_init (pixman_implementation_t *imp, pixman_iter_t *iter) if (image->type == SOLID) color = image->solid.color_float; else - color = image->bits.fetch_pixel_float (&image->bits, 0, 0); + image->bits.fetch_scanline_float (image, 0, 0, 1, (uint32_t *)&color, NULL); while (buffer < end) *(buffer++) = color; diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h index e5ab873e..ce9ce9fc 100644 --- a/pixman/pixman-private.h +++ b/pixman/pixman-private.h @@ -62,14 +62,6 @@ typedef void (*fetch_scanline_t) (pixman_image_t *image, uint32_t *buffer, const uint32_t *mask); -typedef uint32_t (*fetch_pixel_32_t) (bits_image_t *image, - int x, - int y); - -typedef argb_t (*fetch_pixel_float_t) (bits_image_t *image, - int x, - int y); - typedef void (*store_scanline_t) (bits_image_t * image, int x, int y, @@ -180,11 +172,9 @@ struct bits_image int rowstride; /* in number of uint32_t's */ fetch_scanline_t fetch_scanline_32; - fetch_pixel_32_t fetch_pixel_32; store_scanline_t store_scanline_32; fetch_scanline_t fetch_scanline_float; - fetch_pixel_float_t fetch_pixel_float; store_scanline_t store_scanline_float; /* Used for indirect access to the bits */ |