Advertisement
Guest User

Untitled

a guest
Apr 21st, 2014
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.56 KB | None | 0 0
  1. --- Mesa-10.0.2/src/mesa/main/readpix.c 2014-02-03 12:42:39.000000000 -0500
  2. +++ Mesa-10.0.2/src/mesa/main/readpix.c 2014-02-06 09:14:09.886460677 -0500
  3. @@ -422,7 +422,19 @@ read_rgba_pixels_swizzle(struct gl_conte
  4. GLubyte *dst, *map;
  5. int dstStride, stride, j;
  6. GLboolean swizzle_rb = GL_FALSE, copy_xrgb = GL_FALSE;
  7. + GLboolean klconvert_888_to_argb_v1 = GL_FALSE;
  8. + GLboolean klconvert_888_to_argb_v2 = GL_FALSE;
  9. + GLboolean klconvert_x888_to_argb = GL_FALSE;
  10.  
  11. + //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);
  12. +
  13. + if (rb->Format == MESA_FORMAT_XRGB8888 && format == GL_BGRA && type == GL_UNSIGNED_BYTE) {
  14. + klconvert_x888_to_argb = GL_TRUE;
  15. + } else
  16. + if (rb->Format == MESA_FORMAT_RGB888 && format == GL_BGRA && type == GL_UNSIGNED_BYTE) {
  17. + klconvert_888_to_argb_v2 = GL_TRUE;
  18. + //klconvert_888_to_argb_v1 = GL_TRUE;
  19. + } else
  20. /* XXX we could check for other swizzle/special cases here as needed */
  21. if (rb->Format == MESA_FORMAT_RGBA8888_REV &&
  22. format == GL_BGRA &&
  23. @@ -465,6 +477,63 @@ read_rgba_pixels_swizzle(struct gl_conte
  24. dst += dstStride;
  25. map += stride;
  26. }
  27. + } else if (klconvert_888_to_argb_v1) {
  28. + /* KL: convert rgb -> argb, faster - but not fast enough */
  29. + unsigned char *psrc = map;
  30. + unsigned char *pdst = dst;
  31. + for (j = 0; j < height; j++) {
  32. + for (int k = 0; k < width; k++) {
  33. + *(pdst++) /* B */ = *(psrc++);
  34. + *(pdst++) /* G */ = *(psrc++);
  35. + *(pdst++) /* R */ = *(psrc++);
  36. + *(pdst++) /* A */ = 0x00;
  37. + }
  38. + }
  39. + } else if (klconvert_888_to_argb_v2) {
  40. + /* KL: convert rgb -> argb, faster again */
  41. + /* KL: Vectored SIMD move would improve */
  42. + unsigned char *psrc = map;
  43. + unsigned int *ddst = (unsigned int *)dst;
  44. + register unsigned int p[12];
  45. + register unsigned int a, b, c, d;
  46. + for (j = 0; j < (height * width); j += 4) {
  47. +
  48. + /* read 4 pixels as BGRBGRBGRBGR */
  49. + p[0] = *(psrc++);
  50. + p[1] = *(psrc++);
  51. + p[2] = *(psrc++);
  52. + p[3] = *(psrc++);
  53. + p[4] = *(psrc++);
  54. + p[5] = *(psrc++);
  55. + p[6] = *(psrc++);
  56. + p[7] = *(psrc++);
  57. + p[8] = *(psrc++);
  58. + p[9] = *(psrc++);
  59. + p[10] = *(psrc++);
  60. + p[11] = *(psrc++);
  61. +
  62. + /* Alpha channel defaults to 0 */
  63. + a = p[0] | p[1] << 8 | p[2] << 16;
  64. + b = p[3] | p[4] << 8 | p[5] << 16;
  65. + c = p[6] | p[7] << 8 | p[8] << 16;
  66. + d = p[9] | p[10] << 8 | p[11] << 16;
  67. +
  68. + *(ddst++) = a;
  69. + *(ddst++) = b;
  70. + *(ddst++) = c;
  71. + *(ddst++) = d;
  72. + }
  73. + } else if (klconvert_x888_to_argb) {
  74. + if (dstStride == stride) {
  75. + /* Special case, convert identical strides into a single memcpy. */
  76. + width = width * height;
  77. + height = 1;
  78. + }
  79. + for (j = 0; j < height; j++) {
  80. + memcpy(dst, map, width * 4);
  81. + dst += dstStride;
  82. + map += stride;
  83. + }
  84. } else if (copy_xrgb) {
  85. /* convert xrgb -> argb */
  86. for (j = 0; j < height; j++) {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement