From 0a4be7036864efa6b30d78e0aac449d34b812c13 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 4 Aug 2006 03:44:53 +0000 Subject: more work for GL_EXT_texture_sRGB. --- src/mesa/main/texstore.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'src/mesa/main/texstore.c') diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c index 9eb9856b0c..654047cda8 100644 --- a/src/mesa/main/texstore.c +++ b/src/mesa/main/texstore.c @@ -4124,6 +4124,27 @@ _mesa_upscale_teximage2d (GLsizei inWidth, GLsizei inHeight, } +#if FEATURE_EXT_texture_sRGB + +/** + * Test if given texture image is an sRGB format. + */ +static GLboolean +is_srgb_teximage(const struct gl_texture_image *texImage) +{ + switch (texImage->TexFormat->MesaFormat) { + case MESA_FORMAT_SRGB8: + case MESA_FORMAT_SRGBA8: + case MESA_FORMAT_SL8: + case MESA_FORMAT_SLA8: + return GL_TRUE; + default: + return GL_FALSE; + } +} + +#endif /* FEATURE_EXT_texture_sRGB */ + /** * This is the software fallback for Driver.GetTexImage(). @@ -4238,6 +4259,16 @@ _mesa_get_teximage(GLcontext *ctx, GLenum target, GLint level, _mesa_swap2((GLushort *) dest, width); } } +#if FEATURE_EXT_texture_sRGB + else if (is_srgb_teximage(texImage)) { + /* no pixel transfer and no non-linear to linear conversion */ + const GLint comps = texImage->TexFormat->TexelBytes; + const GLint rowstride = comps * texImage->RowStride; + MEMCPY(dest, + (const GLubyte *) texImage->Data + row * rowstride, + comps * width * sizeof(GLubyte)); + } +#endif /* FEATURE_EXT_texture_sRGB */ else { /* general case: convert row to RGBA format */ GLfloat rgba[MAX_WIDTH][4]; -- cgit v1.2.3