aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/main/texgetimage.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-12-03 09:09:06 +0100
committermarha <marha@users.sourceforge.net>2012-12-03 09:09:06 +0100
commitb8da71ffb17d3d16706db04115e9ba1dd8bc49b9 (patch)
tree52bf0a78e9db0a4eff7b3dbb7c3a036c01504f6a /mesalib/src/mesa/main/texgetimage.c
parentd2d73da59e64acdc4718e4e6790a69d967bee875 (diff)
downloadvcxsrv-b8da71ffb17d3d16706db04115e9ba1dd8bc49b9.tar.gz
vcxsrv-b8da71ffb17d3d16706db04115e9ba1dd8bc49b9.tar.bz2
vcxsrv-b8da71ffb17d3d16706db04115e9ba1dd8bc49b9.zip
fontconfig mesa xserver pixman xkeyboard-config git update 3 dec 2012
fontconfig: 2442d611579bccb84f0c29e3f9ceb0a7436df812 mesa: 54ff536823bf5a431efe1f2becdb21174c146948 xserver: b51a1bd2766e7dc975ca8f1cacc3f8bd0e1a68a3 pixman: 978bab253d1d061b00b5e80aa45ab6986aac466f xkeyboard-config: 05dcc6db64cd7425aea6d22efd6a3ecf34dbddd2
Diffstat (limited to 'mesalib/src/mesa/main/texgetimage.c')
-rw-r--r--mesalib/src/mesa/main/texgetimage.c38
1 files changed, 27 insertions, 11 deletions
diff --git a/mesalib/src/mesa/main/texgetimage.c b/mesalib/src/mesa/main/texgetimage.c
index 2ccdcebd9..69067df9f 100644
--- a/mesalib/src/mesa/main/texgetimage.c
+++ b/mesalib/src/mesa/main/texgetimage.c
@@ -229,6 +229,8 @@ get_tex_rgba_compressed(struct gl_context *ctx, GLuint dimensions,
const gl_format texFormat =
_mesa_get_srgb_format_linear(texImage->TexFormat);
const GLenum baseFormat = _mesa_get_format_base_format(texFormat);
+ const GLenum destBaseFormat = _mesa_base_tex_format(ctx, format);
+ GLenum rebaseFormat = GL_NONE;
const GLuint width = texImage->Width;
const GLuint height = texImage->Height;
const GLuint depth = texImage->Depth;
@@ -266,9 +268,31 @@ get_tex_rgba_compressed(struct gl_context *ctx, GLuint dimensions,
}
if (baseFormat == GL_LUMINANCE ||
+ baseFormat == GL_INTENSITY ||
baseFormat == GL_LUMINANCE_ALPHA) {
+ /* If a luminance (or intensity) texture is read back as RGB(A), the
+ * returned value should be (L,0,0,1), not (L,L,L,1). Set rebaseFormat
+ * here to get G=B=0.
+ */
+ rebaseFormat = texImage->_BaseFormat;
+ }
+ else if ((baseFormat == GL_RGBA ||
+ baseFormat == GL_RGB ||
+ baseFormat == GL_RG) &&
+ (destBaseFormat == GL_LUMINANCE ||
+ destBaseFormat == GL_LUMINANCE_ALPHA ||
+ destBaseFormat == GL_LUMINANCE_INTEGER_EXT ||
+ destBaseFormat == GL_LUMINANCE_ALPHA_INTEGER_EXT)) {
+ /* If we're reading back an RGB(A) texture as luminance then we need
+ * to return L=tex(R). Note, that's different from glReadPixels which
+ * returns L=R+G+B.
+ */
+ rebaseFormat = GL_LUMINANCE_ALPHA; /* this covers GL_LUMINANCE too */
+ }
+
+ if (rebaseFormat) {
_mesa_rebase_rgba_float(width * height, (GLfloat (*)[4]) tempImage,
- baseFormat);
+ rebaseFormat);
}
srcRow = tempImage;
@@ -332,7 +356,8 @@ get_tex_rgba_uncompressed(struct gl_context *ctx, GLuint dimensions,
rebaseFormat = texImage->_BaseFormat;
}
else if ((texImage->_BaseFormat == GL_RGBA ||
- texImage->_BaseFormat == GL_RGB) &&
+ texImage->_BaseFormat == GL_RGB ||
+ texImage->_BaseFormat == GL_RG) &&
(destBaseFormat == GL_LUMINANCE ||
destBaseFormat == GL_LUMINANCE_ALPHA ||
destBaseFormat == GL_LUMINANCE_INTEGER_EXT ||
@@ -419,15 +444,6 @@ get_tex_rgba(struct gl_context *ctx, GLuint dimensions,
transferOps |= IMAGE_CLAMP_BIT;
}
}
- /* This applies to RGB, RGBA textures. if the format is either LUMINANCE
- * or LUMINANCE ALPHA, luminance (L) is computed as L=R+G+B .we need to
- * clamp the sum to [0,1].
- */
- else if ((format == GL_LUMINANCE ||
- format == GL_LUMINANCE_ALPHA) &&
- dataType == GL_UNSIGNED_NORMALIZED) {
- transferOps |= IMAGE_CLAMP_BIT;
- }
if (_mesa_is_format_compressed(texImage->TexFormat)) {
get_tex_rgba_compressed(ctx, dimensions, format, type,