[Mesa-dev] [PATCH 25/37] mesa: Switch ycbcr glGetTexImage() to using MapTextureImage().

Eric Anholt eric at anholt.net
Mon Aug 15 11:53:55 PDT 2011


From: Brian Paul <brianp at vmware.com>

---
 src/mesa/main/texgetimage.c |   18 +++++++++++++-----
 1 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c
index a4e466c..aeff0da 100644
--- a/src/mesa/main/texgetimage.c
+++ b/src/mesa/main/texgetimage.c
@@ -196,21 +196,27 @@ get_tex_depth_stencil(struct gl_context *ctx, GLuint dimensions,
 static void
 get_tex_ycbcr(struct gl_context *ctx, GLuint dimensions,
               GLenum format, GLenum type, GLvoid *pixels,
-              const struct gl_texture_image *texImage)
+              struct gl_texture_image *texImage)
 {
    const GLint width = texImage->Width;
    const GLint height = texImage->Height;
    const GLint depth = texImage->Depth;
-   const GLint rowstride = texImage->RowStride;
-   const GLushort *src = (const GLushort *) texImage->Data;
    GLint img, row;
 
    for (img = 0; img < depth; img++) {
+      GLubyte *srcMap;
+      GLint srcRowStride;
+
+      /* map src texture buffer */
+      ctx->Driver.MapTextureImage(ctx, texImage, img,
+                                  0, 0, width, height, GL_MAP_READ_BIT,
+                                  &srcMap, &srcRowStride);
+
       for (row = 0; row < height; row++) {
          void *dest = _mesa_image_address(dimensions, &ctx->Pack, pixels,
                                           width, height, format, type,
                                           img, row, 0);
-         memcpy(dest, src, width * sizeof(GLushort));
+         memcpy(dest, srcMap, width * sizeof(GLushort));
 
          /* check for byte swapping */
          if ((texImage->TexFormat == MESA_FORMAT_YCBCR
@@ -224,8 +230,10 @@ get_tex_ycbcr(struct gl_context *ctx, GLuint dimensions,
             _mesa_swap2((GLushort *) dest, width);
          }
 
-         src += rowstride;
+         srcMap += srcRowStride;
       }
+
+      ctx->Driver.UnmapTextureImage(ctx, texImage, img);
    }
 }
 
-- 
1.7.5.4



More information about the mesa-dev mailing list