libqt5-qtbase/0003-EGL-convenience-deal-with-DefaultRenderableType-when.patch

104 lines
3.9 KiB
Diff

From 7b6253efbf28b43c8b2a561c188670466ac3d916 Mon Sep 17 00:00:00 2001
From: Andrew Knight <andrew.knight@digia.com>
Date: Wed, 20 Nov 2013 16:56:07 +0200
Subject: [PATCH 1/1] EGL convenience: deal with DefaultRenderableType when
appropriate
When encountering QSurfaceFormat::DefaultRenderableType, the surface
format choosers should not default to OpenGL ES, but rather desktop
OpenGL when Qt has been configured without ES2 support.
Change-Id: I57aa7cfe63ebe0ffb32f4ba32808e62b0a4589f8
Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
---
.../eglconvenience/qeglconvenience.cpp | 29 ++++++++++++++++------
.../eglconvenience/qeglplatformcontext.cpp | 15 ++++++++---
2 files changed, 34 insertions(+), 10 deletions(-)
diff --git a/src/platformsupport/eglconvenience/qeglconvenience.cpp b/src/platformsupport/eglconvenience/qeglconvenience.cpp
index b711a2a..32f553a 100644
--- a/src/platformsupport/eglconvenience/qeglconvenience.cpp
+++ b/src/platformsupport/eglconvenience/qeglconvenience.cpp
@@ -232,17 +232,28 @@ EGLConfig QEglConfigChooser::chooseConfig()
configureAttributes.append(surfaceType());
configureAttributes.append(EGL_RENDERABLE_TYPE);
- if (m_format.renderableType() == QSurfaceFormat::OpenVG)
+ switch (m_format.renderableType()) {
+ case QSurfaceFormat::OpenVG:
configureAttributes.append(EGL_OPENVG_BIT);
+ break;
#ifdef EGL_VERSION_1_4
- else if (m_format.renderableType() == QSurfaceFormat::OpenGL)
+# if !defined(QT_OPENGL_ES_2)
+ case QSurfaceFormat::DefaultRenderableType:
+# endif
+ case QSurfaceFormat::OpenGL:
configureAttributes.append(EGL_OPENGL_BIT);
+ break;
#endif
- else if (m_format.majorVersion() == 1)
- configureAttributes.append(EGL_OPENGL_ES_BIT);
- else
+ case QSurfaceFormat::OpenGLES:
+ if (m_format.majorVersion() == 1) {
+ configureAttributes.append(EGL_OPENGL_ES_BIT);
+ break;
+ }
+ // fall through
+ default:
configureAttributes.append(EGL_OPENGL_ES2_BIT);
-
+ break;
+ }
configureAttributes.append(EGL_NONE);
EGLConfig cfg = 0;
@@ -336,7 +347,11 @@ QSurfaceFormat q_glFormatFromConfig(EGLDisplay display, const EGLConfig config,
if (referenceFormat.renderableType() == QSurfaceFormat::OpenVG && (renderableType & EGL_OPENVG_BIT))
format.setRenderableType(QSurfaceFormat::OpenVG);
#ifdef EGL_VERSION_1_4
- else if (referenceFormat.renderableType() == QSurfaceFormat::OpenGL && (renderableType & EGL_OPENGL_BIT))
+ else if ((referenceFormat.renderableType() == QSurfaceFormat::OpenGL
+# if !defined(QT_OPENGL_ES_2)
+ || referenceFormat.renderableType() == QSurfaceFormat::DefaultRenderableType
+# endif
+ ) && (renderableType & EGL_OPENGL_BIT))
format.setRenderableType(QSurfaceFormat::OpenGL);
#endif
else
diff --git a/src/platformsupport/eglconvenience/qeglplatformcontext.cpp b/src/platformsupport/eglconvenience/qeglplatformcontext.cpp
index 34ba21a..714ad8a 100644
--- a/src/platformsupport/eglconvenience/qeglplatformcontext.cpp
+++ b/src/platformsupport/eglconvenience/qeglplatformcontext.cpp
@@ -49,14 +49,23 @@
static inline void bindApi(const QSurfaceFormat &format)
{
- if (format.renderableType() == QSurfaceFormat::OpenVG)
+ switch (format.renderableType()) {
+ case QSurfaceFormat::OpenVG:
eglBindAPI(EGL_OPENVG_API);
+ break;
#ifdef EGL_VERSION_1_4
- else if (format.renderableType() == QSurfaceFormat::OpenGL)
+# if !defined(QT_OPENGL_ES_2)
+ case QSurfaceFormat::DefaultRenderableType:
+# endif
+ case QSurfaceFormat::OpenGL:
eglBindAPI(EGL_OPENGL_API);
+ break;
#endif
- else
+ case QSurfaceFormat::OpenGLES:
+ default:
eglBindAPI(EGL_OPENGL_ES_API);
+ break;
+ }
}
QEGLPlatformContext::QEGLPlatformContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display,
--
1.8.4.4