diff options
author | Brian Paul <brian.paul@tungstengraphics.com> | 2000-11-09 22:31:28 +0000 |
---|---|---|
committer | Brian Paul <brian.paul@tungstengraphics.com> | 2000-11-09 22:31:28 +0000 |
commit | c6d4a00ca953886ad2733aae849551a18e71a4a8 (patch) | |
tree | 52310a265dfe71e3c81b989309cb3b8cbbc49172 | |
parent | 4cdc441b9aed7b30ac5f70c6ff2d5d4bd90ce806 (diff) |
fixed bug in _mesa_convert_texsubimage when format == MESA_FF_R8_G8_B8
-rw-r--r-- | src/mesa/main/texutil.c | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/src/mesa/main/texutil.c b/src/mesa/main/texutil.c index 7fe655034f..64830590b9 100644 --- a/src/mesa/main/texutil.c +++ b/src/mesa/main/texutil.c @@ -1,4 +1,4 @@ -/* $Id: texutil.c,v 1.5.4.3 2000/11/05 21:24:01 brianp Exp $ */ +/* $Id: texutil.c,v 1.5.4.4 2000/11/09 22:31:28 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -760,11 +760,11 @@ _mesa_convert_teximage(MesaIntTexFormat dstFormat, * Replace a subregion of a texture image with new data. * Input: * dstFormat - destination image format - * dstXoffset, dstYoffset - destination for new subregion - * dstWidth, dstHeight - total size of dest image + * dstXoffset, dstYoffset - destination for new subregion (in texels) + * dstWidth, dstHeight - total size of dest image (in texels) * dstImage - pointer to dest image - * dstRowStride - bytes to jump between image rows - * width, height - size of region to copy/replace + * dstRowStride - bytes to jump between image rows (in bytes) + * width, height - size of region to copy/replace (in texels) * srcWidth, srcHeight - size of the corresponding gl_texture_image * srcFormat, srcType - source image format and datatype * srcImage - source image @@ -1239,7 +1239,7 @@ _mesa_convert_texsubimage(MesaIntTexFormat dstFormat, case MESA_A8_R8_G8_B8: case MESA_FF_R8_G8_B8: /* 32-bit texels */ - if (srcFormat == GL_BGRA && srcType == GL_UNSIGNED_INT_8_8_8_8_REV){ + if (srcFormat == GL_BGRA && srcType == GL_UNSIGNED_INT_8_8_8_8_REV) { /* special, optimized case */ if (wScale == 1 && hScale == 1) { const GLubyte *src = (const GLubyte *) @@ -1273,9 +1273,23 @@ _mesa_convert_texsubimage(MesaIntTexFormat dstFormat, dst = (GLuint *) ((GLubyte *) dst + dstRowStride); } } + if (dstFormat == MESA_FF_R8_G8_B8) { + /* set alpha bytes to 0xff */ + GLint row, col; + GLubyte *dst = (GLubyte *) dstImage + + dstYoffset * dstRowStride + dstXoffset * 4; + assert(wScale == 1 && hScale == 1); /* XXX not done */ + for (row = 0; row < height; row++) { + for (col = 0; col < width; col++) { + dst[col * 4 + 3] = 0xff; + } + dst = dst + dstRowStride; + } + } } else if (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE) { /* general case */ + const GLubyte aMask = (dstFormat==MESA_FF_R8_G8_B8) ? 0xff : 0x00; if (wScale == 1 && hScale == 1) { const GLubyte *src = (const GLubyte *) _mesa_image_address(packing, srcImage, srcWidth, srcHeight, @@ -1291,7 +1305,7 @@ _mesa_convert_texsubimage(MesaIntTexFormat dstFormat, GLubyte r = src[col4 + 0]; GLubyte g = src[col4 + 1]; GLubyte b = src[col4 + 2]; - GLubyte a = src[col4 + 3]; + GLubyte a = src[col4 + 3] | aMask; dst[col] = (a << 24) | (r << 16) | (g << 8) | b; } src += srcStride; @@ -1314,7 +1328,7 @@ _mesa_convert_texsubimage(MesaIntTexFormat dstFormat, GLubyte r = src[col4 + 0]; GLubyte g = src[col4 + 1]; GLubyte b = src[col4 + 2]; - GLubyte a = src[col4 + 3]; + GLubyte a = src[col4 + 3] | aMask; dst[col] = (a << 24) | (r << 16) | (g << 8) | b; } dst = (GLuint *) ((GLubyte *) dst + dstRowStride); @@ -1325,18 +1339,6 @@ _mesa_convert_texsubimage(MesaIntTexFormat dstFormat, /* can't handle this source format/type combination */ return GL_FALSE; } - if (dstFormat == MESA_FF_R8_G8_B8) { - /* set alpha bytes to 0xff */ - GLint row, col; - GLubyte *dst = (GLubyte *) dstImage - + dstYoffset * dstRowStride + dstXoffset; - for (row = 0; row < height; row++) { - for (col = 0; col < width; col++) { - dst[col * 4 + 3] = 0xff; - } - dst = dst + dstRowStride; - } - } break; |