Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- Mesa-10.0.2/src/mesa/main/readpix.c 2014-02-03 12:42:39.000000000 -0500
- +++ Mesa-10.0.2/src/mesa/main/readpix.c 2014-02-06 09:14:09.886460677 -0500
- @@ -422,7 +422,19 @@ read_rgba_pixels_swizzle(struct gl_conte
- GLubyte *dst, *map;
- int dstStride, stride, j;
- GLboolean swizzle_rb = GL_FALSE, copy_xrgb = GL_FALSE;
- + GLboolean klconvert_888_to_argb_v1 = GL_FALSE;
- + GLboolean klconvert_888_to_argb_v2 = GL_FALSE;
- + GLboolean klconvert_x888_to_argb = GL_FALSE;
- + //printf("[glReadPixels]%s(%d, %d, %s[%s - 0x%x], %s, %p)\n", __func__, width, height, _mesa_lookup_enum_by_nr(format), _mesa_lookup_enum_by_nr(rb->Format), rb->Format, _mesa_lookup_enum_by_nr(type), pixels);
- +
- + if (rb->Format == MESA_FORMAT_XRGB8888 && format == GL_BGRA && type == GL_UNSIGNED_BYTE) {
- + klconvert_x888_to_argb = GL_TRUE;
- + } else
- + if (rb->Format == MESA_FORMAT_RGB888 && format == GL_BGRA && type == GL_UNSIGNED_BYTE) {
- + klconvert_888_to_argb_v2 = GL_TRUE;
- + //klconvert_888_to_argb_v1 = GL_TRUE;
- + } else
- /* XXX we could check for other swizzle/special cases here as needed */
- if (rb->Format == MESA_FORMAT_RGBA8888_REV &&
- format == GL_BGRA &&
- @@ -465,6 +477,63 @@ read_rgba_pixels_swizzle(struct gl_conte
- dst += dstStride;
- map += stride;
- }
- + } else if (klconvert_888_to_argb_v1) {
- + /* KL: convert rgb -> argb, faster - but not fast enough */
- + unsigned char *psrc = map;
- + unsigned char *pdst = dst;
- + for (j = 0; j < height; j++) {
- + for (int k = 0; k < width; k++) {
- + *(pdst++) /* B */ = *(psrc++);
- + *(pdst++) /* G */ = *(psrc++);
- + *(pdst++) /* R */ = *(psrc++);
- + *(pdst++) /* A */ = 0x00;
- + }
- + }
- + } else if (klconvert_888_to_argb_v2) {
- + /* KL: convert rgb -> argb, faster again */
- + /* KL: Vectored SIMD move would improve */
- + unsigned char *psrc = map;
- + unsigned int *ddst = (unsigned int *)dst;
- + register unsigned int p[12];
- + register unsigned int a, b, c, d;
- + for (j = 0; j < (height * width); j += 4) {
- +
- + /* read 4 pixels as BGRBGRBGRBGR */
- + p[0] = *(psrc++);
- + p[1] = *(psrc++);
- + p[2] = *(psrc++);
- + p[3] = *(psrc++);
- + p[4] = *(psrc++);
- + p[5] = *(psrc++);
- + p[6] = *(psrc++);
- + p[7] = *(psrc++);
- + p[8] = *(psrc++);
- + p[9] = *(psrc++);
- + p[10] = *(psrc++);
- + p[11] = *(psrc++);
- +
- + /* Alpha channel defaults to 0 */
- + a = p[0] | p[1] << 8 | p[2] << 16;
- + b = p[3] | p[4] << 8 | p[5] << 16;
- + c = p[6] | p[7] << 8 | p[8] << 16;
- + d = p[9] | p[10] << 8 | p[11] << 16;
- +
- + *(ddst++) = a;
- + *(ddst++) = b;
- + *(ddst++) = c;
- + *(ddst++) = d;
- + }
- + } else if (klconvert_x888_to_argb) {
- + if (dstStride == stride) {
- + /* Special case, convert identical strides into a single memcpy. */
- + width = width * height;
- + height = 1;
- + }
- + for (j = 0; j < height; j++) {
- + memcpy(dst, map, width * 4);
- + dst += dstStride;
- + map += stride;
- + }
- } else if (copy_xrgb) {
- /* convert xrgb -> argb */
- for (j = 0; j < height; j++) {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement