From 7aa99d8d5b0dbf024019e70bf39b7d15796e1080 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCri=20Valdmann?= Date: Fri, 26 Jun 2020 13:24:01 +0200 Subject: Fix ScopedGLContextChecker with QTWEBENGINE_DISABLE_GPU_THREAD=1 The ScopedGLContextChecker, which deactivates the current QOpenGLContext when executing Chromium tasks, is currently enabled only if QOpenGLContext::supportsThreadedOpenGL() is false. But the gpu thread can nowadays be disabled also with an environment variable and ScopedGLContextChecker needs to take this into account. Change-Id: I012524538b49b033ed053dbc41ed4350db916542 Reviewed-by: Michal Klocek (cherry picked from commit 5988cec1a1b59aa163042a419c4c2e978bb814bb) --- src/core/web_engine_context.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'src/core/web_engine_context.cpp') diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp index 7cc84eae7..11692c2d1 100644 --- a/src/core/web_engine_context.cpp +++ b/src/core/web_engine_context.cpp @@ -496,6 +496,17 @@ const static char kChromiumFlagsEnv[] = "QTWEBENGINE_CHROMIUM_FLAGS"; const static char kDisableSandboxEnv[] = "QTWEBENGINE_DISABLE_SANDBOX"; const static char kDisableInProcGpuThread[] = "QTWEBENGINE_DISABLE_GPU_THREAD"; +// static +bool WebEngineContext::isGpuServiceOnUIThread() +{ + static bool threadedGpu = +#if QT_CONFIG(opengl) && !defined(Q_OS_MACOS) + QOpenGLContext::supportsThreadedOpenGL() && +#endif + !qEnvironmentVariableIsSet(kDisableInProcGpuThread); + return !threadedGpu; +} + static void appendToFeatureList(std::string &featureList, const char *feature) { if (featureList.empty()) @@ -606,16 +617,6 @@ WebEngineContext::WebEngineContext() if (isDesktopGLOrSoftware || isGLES2Context) parsedCommandLine->AppendSwitch(switches::kDisableES3GLContext); #endif - bool threadedGpu = false; -#if QT_CONFIG(opengl) - threadedGpu = QOpenGLContext::supportsThreadedOpenGL(); -#if defined(Q_OS_MACOS) - // QtBase disabled it when building on 10.14+, unfortunately we still need it - // until we have fixed single-threaded viz-display-compositor. - threadedGpu = true; -#endif -#endif - threadedGpu = threadedGpu && !qEnvironmentVariableIsSet(kDisableInProcGpuThread); bool enableViz = !parsedCommandLine->HasSwitch("disable-viz-display-compositor"); parsedCommandLine->RemoveSwitch("disable-viz-display-compositor"); @@ -774,7 +775,7 @@ WebEngineContext::WebEngineContext() parsedCommandLine->AppendSwitch(switches::kDisableGpu); } - registerMainThreadFactories(threadedGpu); + registerMainThreadFactories(); SetContentClient(new ContentClientQt); -- cgit v1.2.3