From 5adbb9cc576546c42249099e549f1947cca54610 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 4 Aug 2014 11:47:11 +0200 Subject: Support Alpha8 and Grayscale8 natively in the OpenGL paint engine Adds special shaders for the Alpha8 and Grayscale8 formats so that they do not need to rely on the support of GL_ALPHA and GL_LUMINANCE that has been removed from core in recent OpenGL versions. Change-Id: Ie370379b458abf2a50e252bc5099aefc1b11fb1d Reviewed-by: Laszlo Agocs --- src/gui/opengl/qopengltexturecache.cpp | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'src/gui/opengl/qopengltexturecache.cpp') diff --git a/src/gui/opengl/qopengltexturecache.cpp b/src/gui/opengl/qopengltexturecache.cpp index 5ac5eb94b68..f85a26cd6e0 100644 --- a/src/gui/opengl/qopengltexturecache.cpp +++ b/src/gui/opengl/qopengltexturecache.cpp @@ -41,6 +41,10 @@ QT_BEGIN_NAMESPACE +#ifndef GL_RED +#define GL_RED 0x1903 +#endif + #ifndef GL_RGB10_A2 #define GL_RGB10_A2 0x8059 #endif @@ -273,21 +277,34 @@ GLuint QOpenGLTextureCache::bindTexture(QOpenGLContext *context, qint64 key, con pixelType = GL_UNSIGNED_BYTE; targetFormat = image.format(); break; + case QImage::Format_Indexed8: + if (options & UseRedFor8BitBindOption) { + externalFormat = internalFormat = GL_RED; + pixelType = GL_UNSIGNED_BYTE; + targetFormat = image.format(); + } + break; case QImage::Format_Alpha8: - if (context->isOpenGLES() || context->format().profile() != QSurfaceFormat::CoreProfile) { + if (options & UseRedFor8BitBindOption) { + externalFormat = internalFormat = GL_RED; + pixelType = GL_UNSIGNED_BYTE; + targetFormat = image.format(); + } else if (context->isOpenGLES() || context->format().profile() != QSurfaceFormat::CoreProfile) { externalFormat = internalFormat = GL_ALPHA; pixelType = GL_UNSIGNED_BYTE; targetFormat = image.format(); } - // ### add support for core profiles. break; case QImage::Format_Grayscale8: - if (context->isOpenGLES() || context->format().profile() != QSurfaceFormat::CoreProfile) { + if (options & UseRedFor8BitBindOption) { + externalFormat = internalFormat = GL_RED; + pixelType = GL_UNSIGNED_BYTE; + targetFormat = image.format(); + } else if (context->isOpenGLES() || context->format().profile() != QSurfaceFormat::CoreProfile) { externalFormat = internalFormat = GL_LUMINANCE; pixelType = GL_UNSIGNED_BYTE; targetFormat = image.format(); } - // ### add support for core profiles. break; default: break; -- cgit v1.2.3