aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/main/texgetimage.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-01-25 08:32:49 +0100
committermarha <marha@users.sourceforge.net>2012-01-25 08:32:49 +0100
commit0c1cee47049afdcf74d87a23f4f4fd57867f6798 (patch)
tree14c117114d1b996e5b04e6546b1580ea53bc26f2 /mesalib/src/mesa/main/texgetimage.c
parent5be921907008288d6465962063bc10fd7a5b1906 (diff)
parente6432710d8a586386b3c7025e845cf4f80830da3 (diff)
downloadvcxsrv-0c1cee47049afdcf74d87a23f4f4fd57867f6798.tar.gz
vcxsrv-0c1cee47049afdcf74d87a23f4f4fd57867f6798.tar.bz2
vcxsrv-0c1cee47049afdcf74d87a23f4f4fd57867f6798.zip
Merge remote-tracking branch 'origin/released'
Diffstat (limited to 'mesalib/src/mesa/main/texgetimage.c')
-rw-r--r--mesalib/src/mesa/main/texgetimage.c127
1 files changed, 87 insertions, 40 deletions
diff --git a/mesalib/src/mesa/main/texgetimage.c b/mesalib/src/mesa/main/texgetimage.c
index 8c85c1e54..818deb8e4 100644
--- a/mesalib/src/mesa/main/texgetimage.c
+++ b/mesalib/src/mesa/main/texgetimage.c
@@ -312,18 +312,26 @@ get_tex_rgba_uncompressed(struct gl_context *ctx, GLuint dimensions,
const gl_format texFormat =
_mesa_get_srgb_format_linear(texImage->TexFormat);
const GLuint width = texImage->Width;
- const GLuint height = texImage->Height;
- const GLuint depth = texImage->Depth;
+ GLuint height = texImage->Height;
+ GLuint depth = texImage->Depth;
GLuint img, row;
GLfloat (*rgba)[4];
+ GLuint (*rgba_uint)[4];
+ GLboolean is_integer = _mesa_is_format_integer_color(texImage->TexFormat);
/* Allocate buffer for one row of texels */
rgba = (GLfloat (*)[4]) malloc(4 * width * sizeof(GLfloat));
+ rgba_uint = (GLuint (*)[4]) rgba;
if (!rgba) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glGetTexImage()");
return;
}
+ if (texImage->TexObject->Target == GL_TEXTURE_1D_ARRAY) {
+ depth = height;
+ height = 1;
+ }
+
for (img = 0; img < depth; img++) {
GLubyte *srcMap;
GLint rowstride;
@@ -339,44 +347,83 @@ get_tex_rgba_uncompressed(struct gl_context *ctx, GLuint dimensions,
width, height, format, type,
img, row, 0);
- _mesa_unpack_rgba_row(texFormat, width, src, rgba);
-
- if (texImage->_BaseFormat == GL_ALPHA) {
- GLint col;
- for (col = 0; col < width; col++) {
- rgba[col][RCOMP] = 0.0F;
- rgba[col][GCOMP] = 0.0F;
- rgba[col][BCOMP] = 0.0F;
- }
- }
- else if (texImage->_BaseFormat == GL_LUMINANCE) {
- GLint col;
- for (col = 0; col < width; col++) {
- rgba[col][GCOMP] = 0.0F;
- rgba[col][BCOMP] = 0.0F;
- rgba[col][ACOMP] = 1.0F;
- }
- }
- else if (texImage->_BaseFormat == GL_LUMINANCE_ALPHA) {
- GLint col;
- for (col = 0; col < width; col++) {
- rgba[col][GCOMP] = 0.0F;
- rgba[col][BCOMP] = 0.0F;
- }
- }
- else if (texImage->_BaseFormat == GL_INTENSITY) {
- GLint col;
- for (col = 0; col < width; col++) {
- rgba[col][GCOMP] = 0.0F;
- rgba[col][BCOMP] = 0.0F;
- rgba[col][ACOMP] = 1.0F;
- }
- }
-
- _mesa_pack_rgba_span_float(ctx, width, (GLfloat (*)[4]) rgba,
- format, type, dest,
- &ctx->Pack, transferOps);
- }
+ if (is_integer) {
+ _mesa_unpack_uint_rgba_row(texFormat, width, src, rgba_uint);
+
+ if (texImage->_BaseFormat == GL_ALPHA) {
+ GLuint col;
+ for (col = 0; col < width; col++) {
+ rgba_uint[col][RCOMP] = 0;
+ rgba_uint[col][GCOMP] = 0;
+ rgba_uint[col][BCOMP] = 0;
+ }
+ }
+ else if (texImage->_BaseFormat == GL_LUMINANCE) {
+ GLuint col;
+ for (col = 0; col < width; col++) {
+ rgba_uint[col][GCOMP] = 0;
+ rgba_uint[col][BCOMP] = 0;
+ rgba_uint[col][ACOMP] = 1;
+ }
+ }
+ else if (texImage->_BaseFormat == GL_LUMINANCE_ALPHA) {
+ GLuint col;
+ for (col = 0; col < width; col++) {
+ rgba_uint[col][GCOMP] = 0;
+ rgba_uint[col][BCOMP] = 0;
+ }
+ }
+ else if (texImage->_BaseFormat == GL_INTENSITY) {
+ GLuint col;
+ for (col = 0; col < width; col++) {
+ rgba_uint[col][GCOMP] = 0;
+ rgba_uint[col][BCOMP] = 0;
+ rgba_uint[col][ACOMP] = 1;
+ }
+ }
+
+ _mesa_pack_rgba_span_int(ctx, width, rgba_uint,
+ format, type, dest);
+ } else {
+ _mesa_unpack_rgba_row(texFormat, width, src, rgba);
+
+ if (texImage->_BaseFormat == GL_ALPHA) {
+ GLuint col;
+ for (col = 0; col < width; col++) {
+ rgba[col][RCOMP] = 0.0F;
+ rgba[col][GCOMP] = 0.0F;
+ rgba[col][BCOMP] = 0.0F;
+ }
+ }
+ else if (texImage->_BaseFormat == GL_LUMINANCE) {
+ GLuint col;
+ for (col = 0; col < width; col++) {
+ rgba[col][GCOMP] = 0.0F;
+ rgba[col][BCOMP] = 0.0F;
+ rgba[col][ACOMP] = 1.0F;
+ }
+ }
+ else if (texImage->_BaseFormat == GL_LUMINANCE_ALPHA) {
+ GLuint col;
+ for (col = 0; col < width; col++) {
+ rgba[col][GCOMP] = 0.0F;
+ rgba[col][BCOMP] = 0.0F;
+ }
+ }
+ else if (texImage->_BaseFormat == GL_INTENSITY) {
+ GLuint col;
+ for (col = 0; col < width; col++) {
+ rgba[col][GCOMP] = 0.0F;
+ rgba[col][BCOMP] = 0.0F;
+ rgba[col][ACOMP] = 1.0F;
+ }
+ }
+
+ _mesa_pack_rgba_span_float(ctx, width, (GLfloat (*)[4]) rgba,
+ format, type, dest,
+ &ctx->Pack, transferOps);
+ }
+ }
/* Unmap the src texture buffer */
ctx->Driver.UnmapTextureImage(ctx, texImage, img);