From: Søren Sandmann Pedersen <s...@redhat.com> Add support for 16bpp pixels to fetch_and_convert_pixel() and convert_and_store_pixel(), then use MAKE_ACCESSORS() to generate accessors for all the 16bpp formats:
r5g6b5 b5g6r5 a1r5g5b5 x1r5g5b5 a1b5g5r5 x1b5g5r5 a4r4g4b4 x4r4g4b4 a4b4g4r4 x4b4g4r4 --- pixman/pixman-access.c | 658 ++---------------------------------------------- 1 files changed, 18 insertions(+), 640 deletions(-) diff --git a/pixman/pixman-access.c b/pixman/pixman-access.c index f8d6082..7295a22 100644 --- a/pixman/pixman-access.c +++ b/pixman/pixman-access.c @@ -207,6 +207,10 @@ fetch_and_convert_pixel (pixman_image_t * image, switch (PIXMAN_FORMAT_BPP (format)) { + case 16: + pixel = READ (image, (uint16_t *)bits); + break; + case 32: pixel = READ (image, (uint32_t *)bits); break; @@ -229,6 +233,10 @@ convert_and_store_pixel (bits_image_t * image, switch (PIXMAN_FORMAT_BPP (format)) { + case 16: + WRITE (image, (uint16_t *)dest, converted & 0xffff); + break; + case 32: WRITE (image, (uint32_t *)dest, converted); break; @@ -316,6 +324,16 @@ MAKE_ACCESSORS(b8g8r8a8); MAKE_ACCESSORS(b8g8r8x8); MAKE_ACCESSORS(r8g8b8x8); MAKE_ACCESSORS(r8g8b8a8); +MAKE_ACCESSORS(r5g6b5); +MAKE_ACCESSORS(b5g6r5); +MAKE_ACCESSORS(a1r5g5b5); +MAKE_ACCESSORS(x1r5g5b5); +MAKE_ACCESSORS(a1b5g5r5); +MAKE_ACCESSORS(x1b5g5r5); +MAKE_ACCESSORS(a4r4g4b4); +MAKE_ACCESSORS(x4r4g4b4); +MAKE_ACCESSORS(a4b4g4r4); +MAKE_ACCESSORS(x4b4g4r4); /********************************** Fetch ************************************/ @@ -506,261 +524,6 @@ fetch_scanline_b8g8r8 (pixman_image_t *image, } static void -fetch_scanline_r5g6b5 (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 uint16_t *pixel = (const uint16_t *)bits + x; - const uint16_t *end = pixel + width; - - while (pixel < end) - { - uint32_t p = READ (image, pixel++); - uint32_t r = (((p) << 3) & 0xf8) | - (((p) << 5) & 0xfc00) | - (((p) << 8) & 0xf80000); - - r |= (r >> 5) & 0x70007; - r |= (r >> 6) & 0x300; - - *buffer++ = 0xff000000 | r; - } -} - -static void -fetch_scanline_b5g6r5 (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 uint16_t *pixel = (const uint16_t *)bits + x; - const uint16_t *end = pixel + width; - - while (pixel < end) - { - uint32_t p = READ (image, pixel++); - uint32_t r, g, b; - - b = ((p & 0xf800) | ((p & 0xe000) >> 5)) >> 8; - g = ((p & 0x07e0) | ((p & 0x0600) >> 6)) << 5; - r = ((p & 0x001c) | ((p & 0x001f) << 5)) << 14; - - *buffer++ = 0xff000000 | r | g | b; - } -} - -static void -fetch_scanline_a1r5g5b5 (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 uint16_t *pixel = (const uint16_t *)bits + x; - const uint16_t *end = pixel + width; - - while (pixel < end) - { - uint32_t p = READ (image, pixel++); - uint32_t r, g, b, a; - - a = (uint32_t) ((uint8_t) (0 - ((p & 0x8000) >> 15))) << 24; - r = ((p & 0x7c00) | ((p & 0x7000) >> 5)) << 9; - g = ((p & 0x03e0) | ((p & 0x0380) >> 5)) << 6; - b = ((p & 0x001c) | ((p & 0x001f) << 5)) >> 2; - - *buffer++ = a | r | g | b; - } -} - -static void -fetch_scanline_x1r5g5b5 (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 uint16_t *pixel = (const uint16_t *)bits + x; - const uint16_t *end = pixel + width; - - while (pixel < end) - { - uint32_t p = READ (image, pixel++); - uint32_t r, g, b; - - r = ((p & 0x7c00) | ((p & 0x7000) >> 5)) << 9; - g = ((p & 0x03e0) | ((p & 0x0380) >> 5)) << 6; - b = ((p & 0x001c) | ((p & 0x001f) << 5)) >> 2; - - *buffer++ = 0xff000000 | r | g | b; - } -} - -static void -fetch_scanline_a1b5g5r5 (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 uint16_t *pixel = (const uint16_t *)bits + x; - const uint16_t *end = pixel + width; - uint32_t r, g, b, a; - - while (pixel < end) - { - uint32_t p = READ (image, pixel++); - - a = (uint32_t) ((uint8_t) (0 - ((p & 0x8000) >> 15))) << 24; - b = ((p & 0x7c00) | ((p & 0x7000) >> 5)) >> 7; - g = ((p & 0x03e0) | ((p & 0x0380) >> 5)) << 6; - r = ((p & 0x001c) | ((p & 0x001f) << 5)) << 14; - - *buffer++ = a | r | g | b; - } -} - -static void -fetch_scanline_x1b5g5r5 (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 uint16_t *pixel = (const uint16_t *)bits + x; - const uint16_t *end = pixel + width; - - while (pixel < end) - { - uint32_t p = READ (image, pixel++); - uint32_t r, g, b; - - b = ((p & 0x7c00) | ((p & 0x7000) >> 5)) >> 7; - g = ((p & 0x03e0) | ((p & 0x0380) >> 5)) << 6; - r = ((p & 0x001c) | ((p & 0x001f) << 5)) << 14; - - *buffer++ = 0xff000000 | r | g | b; - } -} - -static void -fetch_scanline_a4r4g4b4 (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 uint16_t *pixel = (const uint16_t *)bits + x; - const uint16_t *end = pixel + width; - - while (pixel < end) - { - uint32_t p = READ (image, pixel++); - uint32_t r, g, b, a; - - a = ((p & 0xf000) | ((p & 0xf000) >> 4)) << 16; - r = ((p & 0x0f00) | ((p & 0x0f00) >> 4)) << 12; - g = ((p & 0x00f0) | ((p & 0x00f0) >> 4)) << 8; - b = ((p & 0x000f) | ((p & 0x000f) << 4)); - - *buffer++ = a | r | g | b; - } -} - -static void -fetch_scanline_x4r4g4b4 (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 uint16_t *pixel = (const uint16_t *)bits + x; - const uint16_t *end = pixel + width; - - while (pixel < end) - { - uint32_t p = READ (image, pixel++); - uint32_t r, g, b; - - r = ((p & 0x0f00) | ((p & 0x0f00) >> 4)) << 12; - g = ((p & 0x00f0) | ((p & 0x00f0) >> 4)) << 8; - b = ((p & 0x000f) | ((p & 0x000f) << 4)); - - *buffer++ = 0xff000000 | r | g | b; - } -} - -static void -fetch_scanline_a4b4g4r4 (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 uint16_t *pixel = (const uint16_t *)bits + x; - const uint16_t *end = pixel + width; - - while (pixel < end) - { - uint32_t p = READ (image, pixel++); - uint32_t r, g, b, a; - - a = ((p & 0xf000) | ((p & 0xf000) >> 4)) << 16; - b = ((p & 0x0f00) | ((p & 0x0f00) >> 4)) >> 4; - g = ((p & 0x00f0) | ((p & 0x00f0) >> 4)) << 8; - r = ((p & 0x000f) | ((p & 0x000f) << 4)) << 16; - - *buffer++ = a | r | g | b; - } -} - -static void -fetch_scanline_x4b4g4r4 (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 uint16_t *pixel = (const uint16_t *)bits + x; - const uint16_t *end = pixel + width; - - while (pixel < end) - { - uint32_t p = READ (image, pixel++); - uint32_t r, g, b; - - b = ((p & 0x0f00) | ((p & 0x0f00) >> 4)) >> 4; - g = ((p & 0x00f0) | ((p & 0x00f0) >> 4)) << 8; - r = ((p & 0x000f) | ((p & 0x000f) << 4)) << 16; - - *buffer++ = 0xff000000 | r | g | b; - } -} - -static void fetch_scanline_a8 (pixman_image_t *image, int x, int y, @@ -1342,170 +1105,6 @@ fetch_pixel_b8g8r8 (bits_image_t *image, } static uint32_t -fetch_pixel_r5g6b5 (bits_image_t *image, - int offset, - int line) -{ - uint32_t *bits = image->bits + line * image->rowstride; - uint32_t pixel = READ (image, (uint16_t *) bits + offset); - uint32_t r, g, b; - - r = ((pixel & 0xf800) | ((pixel & 0xe000) >> 5)) << 8; - g = ((pixel & 0x07e0) | ((pixel & 0x0600) >> 6)) << 5; - b = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) >> 2; - - return (0xff000000 | r | g | b); -} - -static uint32_t -fetch_pixel_b5g6r5 (bits_image_t *image, - int offset, - int line) -{ - uint32_t r, g, b; - uint32_t *bits = image->bits + line * image->rowstride; - uint32_t pixel = READ (image, (uint16_t *) bits + offset); - - b = ((pixel & 0xf800) | ((pixel & 0xe000) >> 5)) >> 8; - g = ((pixel & 0x07e0) | ((pixel & 0x0600) >> 6)) << 5; - r = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) << 14; - - return (0xff000000 | r | g | b); -} - -static uint32_t -fetch_pixel_a1r5g5b5 (bits_image_t *image, - int offset, - int line) -{ - uint32_t *bits = image->bits + line * image->rowstride; - uint32_t pixel = READ (image, (uint16_t *) bits + offset); - uint32_t a, r, g, b; - - a = (uint32_t) ((uint8_t) (0 - ((pixel & 0x8000) >> 15))) << 24; - r = ((pixel & 0x7c00) | ((pixel & 0x7000) >> 5)) << 9; - g = ((pixel & 0x03e0) | ((pixel & 0x0380) >> 5)) << 6; - b = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) >> 2; - - return (a | r | g | b); -} - -static uint32_t -fetch_pixel_x1r5g5b5 (bits_image_t *image, - int offset, - int line) -{ - uint32_t *bits = image->bits + line * image->rowstride; - uint32_t pixel = READ (image, (uint16_t *) bits + offset); - uint32_t r, g, b; - - r = ((pixel & 0x7c00) | ((pixel & 0x7000) >> 5)) << 9; - g = ((pixel & 0x03e0) | ((pixel & 0x0380) >> 5)) << 6; - b = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) >> 2; - - return (0xff000000 | r | g | b); -} - -static uint32_t -fetch_pixel_a1b5g5r5 (bits_image_t *image, - int offset, - int line) -{ - uint32_t *bits = image->bits + line * image->rowstride; - uint32_t pixel = READ (image, (uint16_t *) bits + offset); - uint32_t a, r, g, b; - - a = (uint32_t) ((uint8_t) (0 - ((pixel & 0x8000) >> 15))) << 24; - b = ((pixel & 0x7c00) | ((pixel & 0x7000) >> 5)) >> 7; - g = ((pixel & 0x03e0) | ((pixel & 0x0380) >> 5)) << 6; - r = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) << 14; - - return (a | r | g | b); -} - -static uint32_t -fetch_pixel_x1b5g5r5 (bits_image_t *image, - int offset, - int line) -{ - uint32_t *bits = image->bits + line * image->rowstride; - uint32_t pixel = READ (image, (uint16_t *) bits + offset); - uint32_t r, g, b; - - b = ((pixel & 0x7c00) | ((pixel & 0x7000) >> 5)) >> 7; - g = ((pixel & 0x03e0) | ((pixel & 0x0380) >> 5)) << 6; - r = ((pixel & 0x001c) | ((pixel & 0x001f) << 5)) << 14; - - return (0xff000000 | r | g | b); -} - -static uint32_t -fetch_pixel_a4r4g4b4 (bits_image_t *image, - int offset, - int line) -{ - uint32_t *bits = image->bits + line * image->rowstride; - uint32_t pixel = READ (image, (uint16_t *) bits + offset); - uint32_t a, r, g, b; - - a = ((pixel & 0xf000) | ((pixel & 0xf000) >> 4)) << 16; - r = ((pixel & 0x0f00) | ((pixel & 0x0f00) >> 4)) << 12; - g = ((pixel & 0x00f0) | ((pixel & 0x00f0) >> 4)) << 8; - b = ((pixel & 0x000f) | ((pixel & 0x000f) << 4)); - - return (a | r | g | b); -} - -static uint32_t -fetch_pixel_x4r4g4b4 (bits_image_t *image, - int offset, - int line) -{ - uint32_t *bits = image->bits + line * image->rowstride; - uint32_t pixel = READ (image, (uint16_t *) bits + offset); - uint32_t r, g, b; - - r = ((pixel & 0x0f00) | ((pixel & 0x0f00) >> 4)) << 12; - g = ((pixel & 0x00f0) | ((pixel & 0x00f0) >> 4)) << 8; - b = ((pixel & 0x000f) | ((pixel & 0x000f) << 4)); - - return (0xff000000 | r | g | b); -} - -static uint32_t -fetch_pixel_a4b4g4r4 (bits_image_t *image, - int offset, - int line) -{ - uint32_t *bits = image->bits + line * image->rowstride; - uint32_t pixel = READ (image, (uint16_t *) bits + offset); - uint32_t a, r, g, b; - - a = ((pixel & 0xf000) | ((pixel & 0xf000) >> 4)) << 16; - b = ((pixel & 0x0f00) | ((pixel & 0x0f00) >> 4)) >> 4; - g = ((pixel & 0x00f0) | ((pixel & 0x00f0) >> 4)) << 8; - r = ((pixel & 0x000f) | ((pixel & 0x000f) << 4)) << 16; - - return (a | r | g | b); -} - -static uint32_t -fetch_pixel_x4b4g4r4 (bits_image_t *image, - int offset, - int line) -{ - uint32_t *bits = image->bits + line * image->rowstride; - uint32_t pixel = READ (image, (uint16_t *) bits + offset); - uint32_t r, g, b; - - b = ((pixel & 0x0f00) | ((pixel & 0x0f00) >> 4)) >> 4; - g = ((pixel & 0x00f0) | ((pixel & 0x00f0) >> 4)) << 8; - r = ((pixel & 0x000f) | ((pixel & 0x000f) << 4)) << 16; - - return (0xff000000 | r | g | b); -} - -static uint32_t fetch_pixel_a8 (bits_image_t *image, int offset, int line) @@ -1966,227 +1565,6 @@ store_scanline_b8g8r8 (bits_image_t * image, } static void -store_scanline_r5g6b5 (bits_image_t * image, - int x, - int y, - int width, - const uint32_t *values) -{ - uint32_t *bits = image->bits + image->rowstride * y; - uint16_t *pixel = ((uint16_t *) bits) + x; - int i; - - for (i = 0; i < width; ++i) - { - uint32_t s = values[i]; - - WRITE (image, pixel++, - ((s >> 3) & 0x001f) | - ((s >> 5) & 0x07e0) | - ((s >> 8) & 0xf800)); - } -} - -static void -store_scanline_b5g6r5 (bits_image_t * image, - int x, - int y, - int width, - const uint32_t *values) -{ - uint32_t *bits = image->bits + image->rowstride * y; - uint16_t *pixel = ((uint16_t *) bits) + x; - int i; - - for (i = 0; i < width; ++i) - { - SPLIT (values[i]); - - WRITE (image, pixel++, - ((b << 8) & 0xf800) | - ((g << 3) & 0x07e0) | - ((r >> 3) )); - } -} - -static void -store_scanline_a1r5g5b5 (bits_image_t * image, - int x, - int y, - int width, - const uint32_t *values) -{ - uint32_t *bits = image->bits + image->rowstride * y; - uint16_t *pixel = ((uint16_t *) bits) + x; - int i; - - for (i = 0; i < width; ++i) - { - SPLIT_A (values[i]); - - WRITE (image, pixel++, - ((a << 8) & 0x8000) | - ((r << 7) & 0x7c00) | - ((g << 2) & 0x03e0) | - ((b >> 3) )); - } -} - -static void -store_scanline_x1r5g5b5 (bits_image_t * image, - int x, - int y, - int width, - const uint32_t *values) -{ - uint32_t *bits = image->bits + image->rowstride * y; - uint16_t *pixel = ((uint16_t *) bits) + x; - int i; - - for (i = 0; i < width; ++i) - { - SPLIT (values[i]); - - WRITE (image, pixel++, - ((r << 7) & 0x7c00) | - ((g << 2) & 0x03e0) | - ((b >> 3) )); - } -} - -static void -store_scanline_a1b5g5r5 (bits_image_t * image, - int x, - int y, - int width, - const uint32_t *values) -{ - uint32_t *bits = image->bits + image->rowstride * y; - uint16_t *pixel = ((uint16_t *) bits) + x; - int i; - - for (i = 0; i < width; ++i) - { - SPLIT_A (values[i]); - - WRITE (image, pixel++, - ((a << 8) & 0x8000) | - ((b << 7) & 0x7c00) | - ((g << 2) & 0x03e0) | - ((r >> 3) )); - } -} - -static void -store_scanline_x1b5g5r5 (bits_image_t * image, - int x, - int y, - int width, - const uint32_t *values) -{ - uint32_t *bits = image->bits + image->rowstride * y; - uint16_t *pixel = ((uint16_t *) bits) + x; - int i; - - for (i = 0; i < width; ++i) - { - SPLIT (values[i]); - - WRITE (image, pixel++, ((b << 7) & 0x7c00) | - ((g << 2) & 0x03e0) | - ((r >> 3) )); - } -} - -static void -store_scanline_a4r4g4b4 (bits_image_t * image, - int x, - int y, - int width, - const uint32_t *values) -{ - uint32_t *bits = image->bits + image->rowstride * y; - uint16_t *pixel = ((uint16_t *) bits) + x; - int i; - - for (i = 0; i < width; ++i) - { - SPLIT_A (values[i]); - - WRITE (image, pixel++, - ((a << 8) & 0xf000) | - ((r << 4) & 0x0f00) | - ((g ) & 0x00f0) | - ((b >> 4) )); - } -} - -static void -store_scanline_x4r4g4b4 (bits_image_t * image, - int x, - int y, - int width, - const uint32_t *values) -{ - uint32_t *bits = image->bits + image->rowstride * y; - uint16_t *pixel = ((uint16_t *) bits) + x; - int i; - - for (i = 0; i < width; ++i) - { - SPLIT (values[i]); - - WRITE (image, pixel++, - ((r << 4) & 0x0f00) | - ((g ) & 0x00f0) | - ((b >> 4) )); - } -} - -static void -store_scanline_a4b4g4r4 (bits_image_t * image, - int x, - int y, - int width, - const uint32_t *values) -{ - uint32_t *bits = image->bits + image->rowstride * y; - uint16_t *pixel = ((uint16_t *) bits) + x; - int i; - - for (i = 0; i < width; ++i) - { - SPLIT_A (values[i]); - WRITE (image, pixel++, ((a << 8) & 0xf000) | - ((b << 4) & 0x0f00) | - ((g ) & 0x00f0) | - ((r >> 4) )); - } -} - -static void -store_scanline_x4b4g4r4 (bits_image_t * image, - int x, - int y, - int width, - const uint32_t *values) -{ - uint32_t *bits = image->bits + image->rowstride * y; - uint16_t *pixel = ((uint16_t *) bits) + x; - int i; - - for (i = 0; i < width; ++i) - { - SPLIT (values[i]); - - WRITE (image, pixel++, - ((b << 4) & 0x0f00) | - ((g ) & 0x00f0) | - ((r >> 4) )); - } -} - -static void store_scanline_a8 (bits_image_t * image, int x, int y, -- 1.7.4 _______________________________________________ Pixman mailing list Pixman@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/pixman