summaryrefslogtreecommitdiffstats
path: root/src/core/web_engine_context.cpp
diff options
context:
space:
mode:
authorAkihiko Odaki <akihiko.odaki.4i@stu.hosei.ac.jp>2016-06-02 10:14:41 +0900
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2016-07-13 17:07:50 +0000
commitf2c7c89d9f31b79a1db403602195362bca40c4bb (patch)
treea160dab34769a2662003581b78e6de1443bfda76 /src/core/web_engine_context.cpp
parent1e83a2d1b61b13323163dfe8cac64dad397cb202 (diff)
Improve OpenGL implementation check
Qt WebEngine uses `isOpenGLES` to know whether the OpenGL implementation is EGL with OpenGL ES 2.0. However, some non-ES OpenGL implementation such as eglfs_x11 uses EGL and are compatible with OpenGL ES 2.0. This change allows to use them. Also the change will allow to detect incompatible combinations. (i.e. EGL + ES-incompatible OpenGL, API other than EGL + OpenGL ES) Change-Id: I0abea253696d06ec365bde2176663700e8567f45 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/core/web_engine_context.cpp')
-rw-r--r--src/core/web_engine_context.cpp46
1 files changed, 38 insertions, 8 deletions
diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp
index 4bd29dddf..3289a3c23 100644
--- a/src/core/web_engine_context.cpp
+++ b/src/core/web_engine_context.cpp
@@ -78,8 +78,10 @@
#include "web_engine_library_info.h"
#include <QFileInfo>
#include <QGuiApplication>
+#include <QOffscreenSurface>
#include <QOpenGLContext>
#include <QStringList>
+#include <QSurfaceFormat>
#include <QVector>
#include <qpa/qplatformnativeinterface.h>
@@ -261,15 +263,40 @@ WebEngineContext::WebEngineContext()
GLContextHelper::initialize();
- if (usingANGLE() || usingSoftwareDynamicGL() || usingQtQuick2DRenderer()) {
- parsedCommandLine->AppendSwitch(switches::kDisableGpu);
- } else {
- const char *glType = 0;
+ const char *glType = 0;
+ if (!usingANGLE() && !usingSoftwareDynamicGL() && !usingQtQuick2DRenderer()) {
if (qt_gl_global_share_context()) {
- if (qt_gl_global_share_context()->isOpenGLES()) {
- glType = gfx::kGLImplementationEGLName;
+ if (!strcmp(qt_gl_global_share_context()->nativeHandle().typeName(), "QEGLNativeContext")) {
+ if (qt_gl_global_share_context()->isOpenGLES()) {
+ glType = gfx::kGLImplementationEGLName;
+ } else {
+ QOpenGLContext context;
+ QSurfaceFormat format;
+
+ format.setRenderableType(QSurfaceFormat::OpenGLES);
+ format.setVersion(2, 0);
+
+ context.setFormat(format);
+ context.setShareContext(qt_gl_global_share_context());
+ if (context.create()) {
+ QOffscreenSurface surface;
+
+ surface.setFormat(format);
+ surface.create();
+
+ if (context.makeCurrent(&surface)) {
+ if (context.hasExtension("GL_ARB_ES2_compatibility"))
+ glType = gfx::kGLImplementationEGLName;
+
+ context.doneCurrent();
+ }
+
+ surface.destroy();
+ }
+ }
} else {
- glType = gfx::kGLImplementationDesktopName;
+ if (!qt_gl_global_share_context()->isOpenGLES())
+ glType = gfx::kGLImplementationDesktopName;
}
} else {
qWarning("WebEngineContext used before QtWebEngine::initialize()");
@@ -283,9 +310,12 @@ WebEngineContext::WebEngineContext()
break;
}
}
+ }
+ if (glType)
parsedCommandLine->AppendSwitchASCII(switches::kUseGL, glType);
- }
+ else
+ parsedCommandLine->AppendSwitch(switches::kDisableGpu);
content::UtilityProcessHostImpl::RegisterUtilityMainThreadFactory(content::CreateInProcessUtilityThread);
content::RenderProcessHostImpl::RegisterRendererMainThreadFactory(content::CreateInProcessRendererThread);