summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJocelyn Turcotte <jocelyn.turcotte@digia.com>2014-10-30 17:33:29 +0100
committerJocelyn Turcotte <jocelyn.turcotte@digia.com>2014-11-25 16:27:33 +0100
commitac70bf98b3b6c38bc800c5061cc1ee403c080a9c (patch)
tree6f829b14997e99fb09ce55a60335cd94ab068714
parentd604139c9fc68a27a1d95faf9122a91abb9dd8f0 (diff)
Disable the GPU process in cases where we can't setup context sharing
This explicitly disables WebGL and automatic Resource transfer through GL context sharing in cases that we know this won't work. This is currently the case for the QtQuick 2D Renderer as well as when using llvmpipe on Windows. It could be possible to get Chromium to use GL through opengl32sw.dll but the change would be more intrusive. Fall back to the Chromium software compositor code path in that case at the cost of losing WebGL support with llvmpipe. Change-Id: I9c1d27ed982dccbe005c8742162c343cc6284e74 Reviewed-by: Zeno Albisser <zeno.albisser@digia.com>
-rw-r--r--src/core/web_engine_context.cpp54
1 files changed, 45 insertions, 9 deletions
diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp
index d4659f0be..0725e523c 100644
--- a/src/core/web_engine_context.cpp
+++ b/src/core/web_engine_context.cpp
@@ -74,6 +74,7 @@
#include "type_conversion.h"
#include "surface_factory_qt.h"
#include "web_engine_library_info.h"
+#include <QFileInfo>
#include <QGuiApplication>
#include <QOpenGLContext>
#include <QStringList>
@@ -89,6 +90,37 @@ void destroyContext()
sContext = 0;
}
+bool usingSoftwareDynamicGL()
+{
+#if defined(Q_OS_WIN)
+ HMODULE handle = static_cast<HMODULE>(QOpenGLContext::openGLModuleHandle());
+ wchar_t path[MAX_PATH];
+ DWORD size = GetModuleFileName(handle, path, MAX_PATH);
+ QFileInfo openGLModule(QString::fromWCharArray(path, size));
+ return openGLModule.fileName() == QLatin1String("opengl32sw.dll");
+#else
+ return false;
+#endif
+}
+
+bool usingQtQuick2DRenderer()
+{
+ const QStringList args = QGuiApplication::arguments();
+ QString device;
+ for (int index = 0; index < args.count(); ++index) {
+ if (args.at(index).startsWith(QLatin1String("--device="))) {
+ device = args.at(index).mid(9);
+ break;
+ }
+ }
+
+ if (device.isEmpty())
+ device = QString::fromLocal8Bit(qgetenv("QMLSCENE_DEVICE"));
+
+ // This assumes that the plugin is installed and is going to be used by QtQuick.
+ return device == QLatin1String("softwarecontext");
+}
+
} // namespace
WebEngineContext::~WebEngineContext()
@@ -181,16 +213,20 @@ WebEngineContext::WebEngineContext()
GLContextHelper::initialize();
- const char *glType;
- switch (QOpenGLContext::currentContext()->openGLModuleType()) {
- case QOpenGLContext::LibGL:
- glType = gfx::kGLImplementationDesktopName;
- break;
- case QOpenGLContext::LibGLES:
- glType = gfx::kGLImplementationEGLName;
- break;
+ if (usingSoftwareDynamicGL() || usingQtQuick2DRenderer()) {
+ parsedCommandLine->AppendSwitch(switches::kDisableGpu);
+ } else {
+ const char *glType;
+ switch (QOpenGLContext::openGLModuleType()) {
+ case QOpenGLContext::LibGL:
+ glType = gfx::kGLImplementationDesktopName;
+ break;
+ case QOpenGLContext::LibGLES:
+ glType = gfx::kGLImplementationEGLName;
+ break;
+ }
+ parsedCommandLine->AppendSwitchASCII(switches::kUseGL, glType);
}
- parsedCommandLine->AppendSwitchASCII(switches::kUseGL, glType);
content::UtilityProcessHostImpl::RegisterUtilityMainThreadFactory(content::CreateInProcessUtilityThread);
content::RenderProcessHostImpl::RegisterRendererMainThreadFactory(content::CreateInProcessRendererThread);