diff options
author | Allan Sandfeld Jensen <allan.jensen@digia.com> | 2014-07-23 14:55:09 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@digia.com> | 2014-07-30 20:03:09 +0200 |
commit | d702ba20e5edbdd4454fecd4b6e33705927f08a0 (patch) | |
tree | 197b4c6dba1f0bde0cf1ac344d68e773d0d50793 /src/gui/opengl/qopengltexturecache.cpp | |
parent | 0437e1cef6aa2ed27362fc5c7c8df6609f13c9ee (diff) |
Support RGB30 formats in OpenGL framebuffers and paint engine
This patch adds support for binding RGB30 images as textures, and as
internal format of framebuffer objects. Together with the
QOpenGLPaintDevice
this provides support for rendering to and from RGB30 in full precision.
[ChangeLog][QtGui][QOpenGLFramebufferObject] Support 10-bit per color
channels formats as the internal framebuffer format, making it possible
to render in that precision.
Change-Id: I06de2d12dfe1c1adc466d574fdffbc77f88f4f16
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
Diffstat (limited to 'src/gui/opengl/qopengltexturecache.cpp')
-rw-r--r-- | src/gui/opengl/qopengltexturecache.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/gui/opengl/qopengltexturecache.cpp b/src/gui/opengl/qopengltexturecache.cpp index 4a4a36d7e5..055974d5a4 100644 --- a/src/gui/opengl/qopengltexturecache.cpp +++ b/src/gui/opengl/qopengltexturecache.cpp @@ -49,6 +49,10 @@ QT_BEGIN_NAMESPACE +#ifndef GL_RGB10_A2 +#define GL_RGB10_A2 0x8059 +#endif + #ifndef GL_BGR #define GL_BGR 0x80E0 #endif @@ -61,6 +65,10 @@ QT_BEGIN_NAMESPACE #define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 #endif +#ifndef GL_UNSIGNED_INT_2_10_10_10_REV +#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 +#endif + class QOpenGLTextureCacheWrapper { public: @@ -228,6 +236,29 @@ GLuint QOpenGLTextureCache::bindTexture(QOpenGLContext *context, qint64 key, con } targetFormat = image.format(); break; + case QImage::Format_BGR30: + case QImage::Format_A2BGR30_Premultiplied: + if (isOpenGL12orBetter || (context->isOpenGLES() && context->format().majorVersion() >= 3)) { + pixelType = GL_UNSIGNED_INT_2_10_10_10_REV; + externalFormat = GL_RGBA; + internalFormat = GL_RGB10_A2; + targetFormat = image.format(); + } + break; + case QImage::Format_RGB30: + case QImage::Format_A2RGB30_Premultiplied: + if (isOpenGL12orBetter) { + pixelType = GL_UNSIGNED_INT_2_10_10_10_REV; + externalFormat = GL_BGRA; + internalFormat = GL_RGB10_A2; + targetFormat = image.format(); + } else if (context->isOpenGLES() && context->format().majorVersion() >= 3) { + pixelType = GL_UNSIGNED_INT_2_10_10_10_REV; + externalFormat = GL_RGBA; + internalFormat = GL_RGB10_A2; + targetFormat = QImage::Format_A2BGR30_Premultiplied; + } + break; case QImage::Format_RGB444: case QImage::Format_RGB555: case QImage::Format_RGB16: |