Fix major performance regression in QGLWidget on texture bind

Since Qt 5.1 we have not recognized the GL_EXT_bgra extension on desktop
OpenGL, or the GL_EXT_texture_format_BGRA8888 extension on OpenGL ES.

This patch matches the GL_EXT_bgra extension on both OpenGL and OpenGL ES
and adds discovery of GL_EXT_texture_format_BGRA8888 under OpenGL ES.

The old name for GL_EXT_texture_format_BGRA8888, GL_IMG_texture_format_BGRA8888
is also recognized.

Change-Id: I2035bfe045aee14e86a1f407f5b8556454f8bb90
Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
This commit is contained in:
Allan Sandfeld Jensen 2013-11-01 14:29:51 +01:00 committed by The Qt Project
parent c87b27f308
commit 1d07c72431

View File

@ -347,6 +347,9 @@ static int qt_gl_resolve_extensions()
{ {
int extensions = 0; int extensions = 0;
QOpenGLExtensionMatcher extensionMatcher; QOpenGLExtensionMatcher extensionMatcher;
if (extensionMatcher.match("GL_EXT_bgra"))
extensions |= QOpenGLExtensions::BGRATextureFormat;
#if defined(QT_OPENGL_ES) #if defined(QT_OPENGL_ES)
if (extensionMatcher.match("GL_OES_mapbuffer")) if (extensionMatcher.match("GL_OES_mapbuffer"))
extensions |= QOpenGLExtensions::MapBuffer; extensions |= QOpenGLExtensions::MapBuffer;
@ -356,10 +359,9 @@ static int qt_gl_resolve_extensions()
extensions |= QOpenGLExtensions::ElementIndexUint; extensions |= QOpenGLExtensions::ElementIndexUint;
if (extensionMatcher.match("GL_OES_depth24")) if (extensionMatcher.match("GL_OES_depth24"))
extensions |= QOpenGLExtensions::Depth24; extensions |= QOpenGLExtensions::Depth24;
// TODO: Consider matching GL_APPLE_texture_format_BGRA8888 as well, but it needs testing.
if (extensionMatcher.match("GL_EXT_bgra")) if (extensionMatcher.match("GL_IMG_texture_format_BGRA8888") || extensionMatcher.match("GL_EXT_texture_format_BGRA8888"))
extensions |= QOpenGLExtensions::BGRATextureFormat; extensions |= QOpenGLExtensions::BGRATextureFormat;
#else #else
QSurfaceFormat format = QOpenGLContext::currentContext()->format(); QSurfaceFormat format = QOpenGLContext::currentContext()->format();
extensions |= QOpenGLExtensions::ElementIndexUint | QOpenGLExtensions::MapBuffer; extensions |= QOpenGLExtensions::ElementIndexUint | QOpenGLExtensions::MapBuffer;