[Mesa-dev] [PATCH 2/2] mesa: Speedup the xrgb -> argb special case in fast_read_rgba_pixels_memcpy

Martin Andersson g02maran at gmail.com
Sun Mar 10 15:05:04 PDT 2013


---
 src/mesa/main/readpix.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/mesa/main/readpix.c b/src/mesa/main/readpix.c
index 349b0bc..0f5c84c 100644
--- a/src/mesa/main/readpix.c
+++ b/src/mesa/main/readpix.c
@@ -285,11 +285,12 @@ fast_read_rgba_pixels_memcpy( struct gl_context *ctx,
       }
    } else if (copy_xrgb) {
       /* convert xrgb -> argb */
+      int alphaOffset = texelBytes - 1;
       for (j = 0; j < height; j++) {
-         GLuint *dst4 = (GLuint *) dst, *map4 = (GLuint *) map;
+         memcpy(dst, map, width * texelBytes);
          int i;
          for (i = 0; i < width; i++) {
-            dst4[i] = map4[i] | 0xff000000;  /* set A=0xff */
+            dst[i * texelBytes + alphaOffset] = 0xff;  /* set A=0xff */
          }
          dst += dstStride;
          map += stride;
-- 
1.8.1.5



More information about the mesa-dev mailing list