diff options
author | Brian Paul <[email protected]> | 2011-07-31 21:00:21 -0700 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2011-09-27 12:12:07 -0700 |
commit | ce62473408f884c876ee535f5f48cfe70dacb1ef (patch) | |
tree | 69e26bd151f1d3af4d0c20e84a6ea3e34428ede2 /src/mesa/main/texgetimage.c | |
parent | 429b45e7c0001c0979e0d0fd20c3821c166da4a9 (diff) |
mesa: Finally, convert RGBA glGetTexImage() to using MapTextureImage().
v2: Changes by Brian to MapTexImage in the decompression path.
v3: Changes by anholt to fix srcRowStride for decompression of NPOT.
Tested-by: Brian Paul <[email protected]> (v2)
Diffstat (limited to 'src/mesa/main/texgetimage.c')
-rw-r--r-- | src/mesa/main/texgetimage.c | 44 |
1 files changed, 38 insertions, 6 deletions
diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c index 11494e53ad5..d2f25b9f802 100644 --- a/src/mesa/main/texgetimage.c +++ b/src/mesa/main/texgetimage.c @@ -241,8 +241,32 @@ get_tex_rgba(struct gl_context *ctx, GLuint dimensions, return; } - _mesa_decompress_image(texFormat, texImage->Width, texImage->Height, - texImage->Data, texImage->RowStride, tempImage); + /* Decompress the texture image - results in 'tempImage' */ + { + GLubyte *srcMap; + GLint srcRowStride; + GLuint bytes, bw, bh; + + bytes = _mesa_get_format_bytes(texImage->TexFormat); + _mesa_get_format_block_size(texImage->TexFormat, &bw, &bh); + + ctx->Driver.MapTextureImage(ctx, texImage, 0, + 0, 0, width, height, + GL_MAP_READ_BIT, + &srcMap, &srcRowStride); + + /* XXX This line is a bit of a hack to work around the + * mismatch of compressed row strides as returned by + * MapTextureImage() vs. what the texture decompression code + * uses. This will be fixed in the future. + */ + srcRowStride = srcRowStride * bh / bytes; + + _mesa_decompress_image(texFormat, width, height, + srcMap, srcRowStride, tempImage); + + ctx->Driver.UnmapTextureImage(ctx, texImage, 0); + } if (baseFormat == GL_LUMINANCE || baseFormat == GL_LUMINANCE_ALPHA) { @@ -270,7 +294,6 @@ get_tex_rgba(struct gl_context *ctx, GLuint dimensions, } else { /* No decompression needed */ - const GLint texelSize = _mesa_get_format_bytes(texFormat); GLuint img, row; GLfloat (*rgba)[4]; @@ -281,13 +304,19 @@ get_tex_rgba(struct gl_context *ctx, GLuint dimensions, } for (img = 0; img < depth; img++) { + GLubyte *srcMap; + GLint rowstride; + + /* map src texture buffer */ + ctx->Driver.MapTextureImage(ctx, texImage, img, + 0, 0, width, height, GL_MAP_READ_BIT, + &srcMap, &rowstride); + for (row = 0; row < height; row++) { + const GLubyte *src = srcMap + row * rowstride; void *dest = _mesa_image_address(dimensions, &ctx->Pack, pixels, width, height, format, type, img, row, 0); - const GLubyte *src = (const GLubyte *) texImage->Data + - (texImage->ImageOffsets[img] + - texImage->RowStride * row) * texelSize; _mesa_unpack_rgba_row(texFormat, width, src, rgba); @@ -327,6 +356,9 @@ get_tex_rgba(struct gl_context *ctx, GLuint dimensions, format, type, dest, &ctx->Pack, transferOps); } + + /* Unmap the src texture buffer */ + ctx->Driver.UnmapTextureImage(ctx, texImage, img); } free(rgba); |