summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/ozone/gl_context_qt.cpp6
-rw-r--r--src/core/web_engine_context.cpp33
-rw-r--r--src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp38
3 files changed, 52 insertions, 25 deletions
diff --git a/src/core/ozone/gl_context_qt.cpp b/src/core/ozone/gl_context_qt.cpp
index 1850380a2..18181d310 100644
--- a/src/core/ozone/gl_context_qt.cpp
+++ b/src/core/ozone/gl_context_qt.cpp
@@ -119,7 +119,13 @@ void* GLContextHelper::getGlXConfig()
void* GLContextHelper::getEGLDisplay()
{
+#ifdef Q_OS_WIN
+ // Windows QPA plugin does not implement resourceForIntegration for "egldisplay".
+ // Use resourceForContext instead.
+ return resourceForContext(QByteArrayLiteral("egldisplay"));
+#else
return resourceForIntegration(QByteArrayLiteral("egldisplay"));
+#endif
}
void* GLContextHelper::getXDisplay()
diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp
index db74978d3..096568570 100644
--- a/src/core/web_engine_context.cpp
+++ b/src/core/web_engine_context.cpp
@@ -422,10 +422,23 @@ WebEngineContext::WebEngineContext()
// an OpenGL Core Profile context. If the switch is not set, it would always try to create a
// Core Profile context, even if Qt uses a legacy profile, which causes
// "Could not share GL contexts" warnings, because it's not possible to share between Core and
- // legacy profiles.
- // Given that Core profile is not currently supported on Windows anyway, pass this switch to
- // get rid of the warnings.
- parsedCommandLine->AppendSwitch(switches::kDisableES3GLContext);
+ // legacy profiles. See GLContextWGL::Initialize().
+ // Given that Desktop GL Core profile is not currently supported on Windows anyway, pass this
+ // switch to get rid of the warnings.
+ //
+ // The switch is also used to determine which version of OpenGL ES to use (2 or 3) when using
+ // ANGLE.
+ // If the switch is not set, Chromium will always try to create an ES3 context, even if Qt uses
+ // an ES2 context, which causes resource sharing issues (black screen),
+ // see gpu::gles2::GenerateGLContextAttribs().
+ // Make sure to disable ES3 context creation when using ES2.
+ const bool isGLES2Context = qt_gl_global_share_context()
+ && qt_gl_global_share_context()->isOpenGLES()
+ && qt_gl_global_share_context()->format().majorVersion() == 2;
+ const bool isDesktopGLOrSoftware = !usingANGLE();
+
+ if (isDesktopGLOrSoftware || isGLES2Context)
+ parsedCommandLine->AppendSwitch(switches::kDisableES3GLContext);
#endif
// Needed to allow navigations within pages that were set using setHtml(). One example is
// tst_QWebEnginePage::acceptNavigationRequest.
@@ -456,8 +469,7 @@ WebEngineContext::WebEngineContext()
#ifndef QT_NO_OPENGL
bool tryGL =
- !usingANGLE()
- && (!usingSoftwareDynamicGL()
+ (!usingSoftwareDynamicGL()
// If user requested WebGL support instead of using Skia rendering to
// bitmaps, use software rendering via software OpenGL. This might be less
// performant, but at least provides WebGL support.
@@ -467,10 +479,13 @@ WebEngineContext::WebEngineContext()
if (tryGL) {
if (qt_gl_global_share_context() && qt_gl_global_share_context()->isValid()) {
- // If the native handle is QEGLNativeContext try to use GL ES/2, if there is no native handle
- // assume we are using wayland and try GL ES/2, and finally Ozone demands GL ES/2 too.
+ // If the native handle is QEGLNativeContext try to use GL ES/2.
+ // If there is no native handle, assume we are using wayland and try GL ES/2.
+ // If we are using ANGLE on Windows, use OpenGL ES (2 or 3).
if (qt_gl_global_share_context()->nativeHandle().isNull()
- || !strcmp(qt_gl_global_share_context()->nativeHandle().typeName(), "QEGLNativeContext"))
+ || !strcmp(qt_gl_global_share_context()->nativeHandle().typeName(),
+ "QEGLNativeContext")
+ || usingANGLE())
{
if (qt_gl_global_share_context()->isOpenGLES()) {
glType = gl::kGLImplementationEGLName;
diff --git a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
index 7bbd85091..2753f5d3d 100644
--- a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
+++ b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
@@ -133,25 +133,31 @@ RenderWidgetHostViewQtDelegateWidget::RenderWidgetHostViewQtDelegateWidget(Rende
"QSurfaceFormat before the QtGui application instance is created.");
}
#endif
-
- // Make sure the OpenGL profile of the QQuickWidget matches the shared context profile.
- if (sharedFormat.profile() == QSurfaceFormat::CoreProfile) {
- int major;
- int minor;
- QSurfaceFormat::OpenGLContextProfile profile;
-
+ int major;
+ int minor;
+ QSurfaceFormat::OpenGLContextProfile profile;
#ifdef Q_OS_MACOS
- // Due to QTBUG-63180, requesting the sharedFormat.majorVersion() on macOS will lead to
- // a failed creation of QQuickWidget shared context. Thus make sure to request the
- // major version specified in the defaultFormat instead.
- major = defaultFormat.majorVersion();
- minor = defaultFormat.minorVersion();
- profile = defaultFormat.profile();
+ // Due to QTBUG-63180, requesting the sharedFormat.majorVersion() on macOS will lead to
+ // a failed creation of QQuickWidget shared context. Thus make sure to request the
+ // major version specified in the defaultFormat instead.
+ major = defaultFormat.majorVersion();
+ minor = defaultFormat.minorVersion();
+ profile = defaultFormat.profile();
#else
- major = sharedFormat.majorVersion();
- minor = sharedFormat.minorVersion();
- profile = sharedFormat.profile();
+ major = sharedFormat.majorVersion();
+ minor = sharedFormat.minorVersion();
+ profile = sharedFormat.profile();
+#endif
+
+ // Make sure the OpenGL profile of the QQuickWidget matches the shared context profile.
+ // It covers the following cases:
+ // 1) Desktop OpenGL Core Profile.
+ // 2) Windows ANGLE OpenGL ES profile.
+ if (sharedFormat.profile() == QSurfaceFormat::CoreProfile
+#ifdef Q_OS_WIN
+ || globalSharedContext->isOpenGLES()
#endif
+ ) {
format.setMajorVersion(major);
format.setMinorVersion(minor);
format.setProfile(profile);