aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/scenegraph/qsgcontextplugin.cpp
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@theqtcompany.com>2016-05-23 20:48:08 +0200
committerLaszlo Agocs <laszlo.agocs@theqtcompany.com>2016-05-30 09:35:43 +0000
commit5956771cb9fc6468eaf002ebe8a7a3396807c2c1 (patch)
tree293250efb3f39351046248167acd616a020c0c34 /src/quick/scenegraph/qsgcontextplugin.cpp
parent0837453ef90f5d5f569702aa1c7620648dae2c00 (diff)
Add an API to set the scenegraph backend
As an alternative to QT_QUICK_BACKEND and QMLSCENE_DEVICE. The need for this is twofold: it is requested by Creator since environment variables have potential issues with child processes inheriting them. Also, platforms like WinRT may have issues with environment variables - as such a concept may not necessarily exist. Change-Id: Ia66b78dc83fce5af0f36d4b34dc094582eb6e61d Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
Diffstat (limited to 'src/quick/scenegraph/qsgcontextplugin.cpp')
-rw-r--r--src/quick/scenegraph/qsgcontextplugin.cpp31
1 files changed, 21 insertions, 10 deletions
diff --git a/src/quick/scenegraph/qsgcontextplugin.cpp b/src/quick/scenegraph/qsgcontextplugin.cpp
index 5a5a16e005..7569cd2495 100644
--- a/src/quick/scenegraph/qsgcontextplugin.cpp
+++ b/src/quick/scenegraph/qsgcontextplugin.cpp
@@ -67,9 +67,9 @@ Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
(QSGContextFactoryInterface_iid, QLatin1String("/scenegraph")))
#endif
-struct QSGAdaptionBackendData
+struct QSGAdaptationBackendData
{
- QSGAdaptionBackendData();
+ QSGAdaptationBackendData();
bool tried;
QSGContextFactoryInterface *factory;
@@ -77,9 +77,11 @@ struct QSGAdaptionBackendData
QSGContextFactoryInterface::Flags flags;
QVector<QSGContextFactoryInterface *> builtIns;
+
+ QString quickWindowBackendRequest;
};
-QSGAdaptionBackendData::QSGAdaptionBackendData()
+QSGAdaptationBackendData::QSGAdaptationBackendData()
: tried(false)
, factory(nullptr)
, flags(0)
@@ -88,7 +90,7 @@ QSGAdaptionBackendData::QSGAdaptionBackendData()
builtIns.append(new QSGSoftwareAdaptation);
}
-Q_GLOBAL_STATIC(QSGAdaptionBackendData, qsg_adaptation_data)
+Q_GLOBAL_STATIC(QSGAdaptationBackendData, qsg_adaptation_data)
// This only works when the backend is loaded (contextFactory() was called),
// otherwise the return value is 0.
@@ -100,15 +102,15 @@ QSGContextFactoryInterface::Flags qsg_backend_flags()
return qsg_adaptation_data()->flags;
}
-QSGAdaptionBackendData *contextFactory()
+QSGAdaptationBackendData *contextFactory()
{
- QSGAdaptionBackendData *backendData = qsg_adaptation_data();
+ QSGAdaptationBackendData *backendData = qsg_adaptation_data();
if (!backendData->tried) {
backendData->tried = true;
const QStringList args = QGuiApplication::arguments();
- QString requestedBackend;
+ QString requestedBackend = backendData->quickWindowBackendRequest; // empty or set via QQuickWindow::setBackend()
for (int index = 0; index < args.count(); ++index) {
if (args.at(index).startsWith(QLatin1String("--device="))) {
@@ -184,7 +186,7 @@ QSGAdaptionBackendData *contextFactory()
*/
QSGContext *QSGContext::createDefaultContext()
{
- QSGAdaptionBackendData *backendData = contextFactory();
+ QSGAdaptationBackendData *backendData = contextFactory();
if (backendData->factory)
return backendData->factory->create(backendData->name);
#ifndef QT_NO_OPENGL
@@ -205,7 +207,7 @@ QSGContext *QSGContext::createDefaultContext()
QQuickTextureFactory *QSGContext::createTextureFactoryFromImage(const QImage &image)
{
- QSGAdaptionBackendData *backendData = contextFactory();
+ QSGAdaptationBackendData *backendData = contextFactory();
if (backendData->factory)
return backendData->factory->createTextureFactoryFromImage(image);
return 0;
@@ -219,10 +221,19 @@ QQuickTextureFactory *QSGContext::createTextureFactoryFromImage(const QImage &im
QSGRenderLoop *QSGContext::createWindowManager()
{
- QSGAdaptionBackendData *backendData = contextFactory();
+ QSGAdaptationBackendData *backendData = contextFactory();
if (backendData->factory)
return backendData->factory->createWindowManager();
return 0;
}
+void QSGContext::setBackend(const QString &backend)
+{
+ QSGAdaptationBackendData *backendData = qsg_adaptation_data();
+ if (backendData->tried)
+ qWarning("Scenegraph already initialized, setBackend() request ignored");
+
+ backendData->quickWindowBackendRequest = backend;
+}
+
QT_END_NAMESPACE