[Mesa-dev] [PATCH 23/37] mesa: Switch color-index GetTexImage to using MapTextureImage().
Eric Anholt
eric at anholt.net
Mon Aug 15 11:53:53 PDT 2011
From: Brian Paul <brianp at vmware.com>
---
src/mesa/main/texgetimage.c | 21 +++++++++++++++------
1 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c
index da07800..b98d708 100644
--- a/src/mesa/main/texgetimage.c
+++ b/src/mesa/main/texgetimage.c
@@ -70,18 +70,25 @@ type_with_negative_values(GLenum type)
static void
get_tex_color_index(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 GLuint indexBits =
_mesa_get_format_bits(texImage->TexFormat, GL_TEXTURE_INDEX_SIZE_EXT);
const GLbitfield transferOps = 0x0;
GLint img, row, col;
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++) {
GLuint indexRow[MAX_WIDTH] = { 0 };
void *dest = _mesa_image_address(dimensions, &ctx->Pack, pixels,
@@ -90,15 +97,15 @@ get_tex_color_index(struct gl_context *ctx, GLuint dimensions,
assert(dest);
if (indexBits == 8) {
- const GLubyte *src = (const GLubyte *) texImage->Data;
- src += rowstride * (img * height + row);
+ const GLubyte *src = srcMap;
+ src += srcRowStride * (img * height + row);
for (col = 0; col < width; col++) {
indexRow[col] = src[col];
}
}
else if (indexBits == 16) {
- const GLushort *src = (const GLushort *) texImage->Data;
- src += rowstride * (img * height + row);
+ const GLushort *src = (const GLushort *) srcMap;
+ src += srcRowStride * (img * height + row);
for (col = 0; col < width; col++) {
indexRow[col] = src[col];
}
@@ -109,6 +116,8 @@ get_tex_color_index(struct gl_context *ctx, GLuint dimensions,
_mesa_pack_index_span(ctx, width, type, dest,
indexRow, &ctx->Pack, transferOps);
}
+
+ ctx->Driver.UnmapTextureImage(ctx, texImage, img);
}
}
--
1.7.5.4
More information about the mesa-dev
mailing list