From 5d94aac2bae8bdbf8de7cebeb6a1a17a81685f0a Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 4 Jul 2019 15:17:29 +0200 Subject: Introduce QImage::Format_BGR888 Is pretty common on some architectures so we can avoid swizzling by supporting it. Fixes: QTBUG-45671 Change-Id: Ic7a21b5bfb374bf7496fd2b2b1252c2f1ed47705 Reviewed-by: Eirik Aavitsland --- src/gui/opengl/qopengltextureuploader.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/gui/opengl/qopengltextureuploader.cpp') diff --git a/src/gui/opengl/qopengltextureuploader.cpp b/src/gui/opengl/qopengltextureuploader.cpp index d9d5403cf34..9e393bc47a5 100644 --- a/src/gui/opengl/qopengltextureuploader.cpp +++ b/src/gui/opengl/qopengltextureuploader.cpp @@ -65,6 +65,10 @@ #define GL_RGBA16 0x805B #endif +#ifndef GL_BGR +#define GL_BGR 0x80E0 +#endif + #ifndef GL_BGRA #define GL_BGRA 0x80E1 #endif @@ -202,6 +206,20 @@ qsizetype QOpenGLTextureUploader::textureImage(GLenum target, const QImage &imag pixelType = GL_UNSIGNED_BYTE; targetFormat = QImage::Format_RGB888; break; + case QImage::Format_BGR888: + if (isOpenGL12orBetter) { + externalFormat = GL_BGR; + internalFormat = GL_RGB; + pixelType = GL_UNSIGNED_BYTE; + targetFormat = QImage::Format_BGR888; + } else if (funcs->hasOpenGLExtension(QOpenGLExtensions::TextureSwizzle)) { + funcs->glTexParameteri(target, GL_TEXTURE_SWIZZLE_B, GL_RED); + funcs->glTexParameteri(target, GL_TEXTURE_SWIZZLE_R, GL_BLUE); + externalFormat = internalFormat = GL_RGB; + pixelType = GL_UNSIGNED_BYTE; + targetFormat = QImage::Format_BGR888; + } + break; case QImage::Format_RGBX8888: case QImage::Format_RGBA8888: case QImage::Format_RGBA8888_Premultiplied: -- cgit v1.2.3