diff options
author | Laszlo Agocs <laszlo.agocs@theqtcompany.com> | 2016-04-11 16:06:39 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@theqtcompany.com> | 2016-04-13 09:22:18 +0000 |
commit | 96a7afec18542396f8e9a0b0f75d219a08725b3f (patch) | |
tree | ba2ed094f071214a93afea29dd100e6669641fbb /src/quick/scenegraph/qsgcontextplugin.cpp | |
parent | e188a3d864a5310bf18c3ad759a12560013deb64 (diff) |
Route ShaderEffect through the old GL impl
Register the common QQuickShaderEffect class as ShaderEffect to QML.
In case of GL this will route to QQuickOpenGLShaderEffect. For others
the default no-op implementation is used (at least for now). Later this
new implementation will route to a backend-specific scenegraph node via
the adaptation layer.
This also means that QQuickOpenGLShaderEffect is no longer a QQuickItem
and QQuickShaderEffect must handle everything item-related and forward.
Change-Id: I1ff4b674253543a04978a69f4a3b67f3a44dd983
Reviewed-by: Andy Nichols <andy.nichols@theqtcompany.com>
Diffstat (limited to 'src/quick/scenegraph/qsgcontextplugin.cpp')
-rw-r--r-- | src/quick/scenegraph/qsgcontextplugin.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/quick/scenegraph/qsgcontextplugin.cpp b/src/quick/scenegraph/qsgcontextplugin.cpp index 1605212c76..646798efe2 100644 --- a/src/quick/scenegraph/qsgcontextplugin.cpp +++ b/src/quick/scenegraph/qsgcontextplugin.cpp @@ -77,13 +77,15 @@ struct QSGAdaptionBackendData bool tried; QSGContextFactoryInterface *factory; QString name; + QSGContextFactoryInterface::Flags flags; QVector<QSGContextFactoryInterface *> builtIns; }; QSGAdaptionBackendData::QSGAdaptionBackendData() : tried(false) - , factory(0) + , factory(nullptr) + , flags(0) { // Fill in the table with the built-in adaptations. builtIns.append(new QSGSoftwareAdaptation); @@ -94,6 +96,16 @@ QSGAdaptionBackendData::QSGAdaptionBackendData() Q_GLOBAL_STATIC(QSGAdaptionBackendData, qsg_adaptation_data) +// This only works when the backend is loaded (contextFactory() was called), +// otherwise the return value is 0. +// +// Note that the default (OpenGL) implementation always results in 0, custom flags +// can only be returned from the other (either compiled-in or plugin-based) backends. +QSGContextFactoryInterface::Flags qsg_backend_flags() +{ + return qsg_adaptation_data()->flags; +} + QSGAdaptionBackendData *contextFactory() { QSGAdaptionBackendData *backendData = qsg_adaptation_data(); @@ -136,6 +148,8 @@ QSGAdaptionBackendData *contextFactory() for (QSGContextFactoryInterface *builtInBackend : qAsConst(backendData->builtIns)) { if (builtInBackend->keys().contains(requestedBackend)) { backendData->factory = builtInBackend; + backendData->name = requestedBackend; + backendData->flags = backendData->factory->flags(requestedBackend); break; } } @@ -146,7 +160,10 @@ QSGAdaptionBackendData *contextFactory() const int index = loader()->indexOf(requestedBackend); if (index != -1) backendData->factory = qobject_cast<QSGContextFactoryInterface*>(loader()->instance(index)); - backendData->name = requestedBackend; + if (backendData->factory) { + backendData->name = requestedBackend; + backendData->flags = backendData->factory->flags(requestedBackend); + } #ifndef QT_NO_DEBUG if (!backendData->factory) { qWarning("Could not create scene graph context for backend '%s'" |