diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2016-06-27 17:13:37 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2016-06-29 11:59:54 +0000 |
commit | 5ee02242d72ac9a536584b36ba549480a97303f7 (patch) | |
tree | c898b2eedad203ee0536d7b40cab6c1c08234056 /src/quick/items/qquickshadereffect.cpp | |
parent | 12bff27aa6f1caac9bfacf365c542cf5da6e3148 (diff) |
Unify ShaderEffect property setting
rendererInterface() should not require isSceneGraphInitialized() to be
true - the API and language queries like graphicsApi() have no need for the
scenegraph, they only need the plugin to be loaded, i.e. that the QQuickWindow
is constructed.
This is the key to be able to make GraphicsInfo report graphicsApi and
shaderType with the correct values as early as possible - meaning as soon
as the item is associated with a window. The initialization of the
scenegraph (the exact timing of which varies backend to backend) does not
matter here.
The fragment and vertex shader property setting is now unified in the two
ShaderEffect implementations:
- If the component is complete, the shader is attempted to be processed
right from the setter.
- Otherwise the item will trigger processing once the component is
complete.
- If there is no window when processing is trigerred, it is deferred via
polish.
To implement item polish handling we need a new virtual in
QQuickItemPrivate since we cannot intrdouce virtuals into the public
classes.
This way one can write a condition (and later potentially use file
selectors) like this:
fragmentShader: GraphicsInfo.shaderType == GraphicsInfo.GLSL ? "..." : ...
without having to worry about getting an unintended value processed due to
GraphicsInfo not yet reporting an up-to-date value.
parseLog() forces, for GL at least, shader processing to prevent autotests
from breaking.
Change-Id: If55c69d746c29cd07348ddad2d6b0f2b5dd7f3a2
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src/quick/items/qquickshadereffect.cpp')
-rw-r--r-- | src/quick/items/qquickshadereffect.cpp | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/src/quick/items/qquickshadereffect.cpp b/src/quick/items/qquickshadereffect.cpp index 4f1a9a28ec..f7c103a58f 100644 --- a/src/quick/items/qquickshadereffect.cpp +++ b/src/quick/items/qquickshadereffect.cpp @@ -39,6 +39,7 @@ #include <private/qquickshadereffect_p.h> #include <private/qsgcontextplugin_p.h> +#include <private/qquickitem_p.h> #ifndef QT_NO_OPENGL #include <private/qquickopenglshadereffect_p.h> #endif @@ -382,10 +383,18 @@ QT_BEGIN_NAMESPACE \sa {Item Layers} */ +class QQuickShaderEffectPrivate : public QQuickItemPrivate +{ + Q_DECLARE_PUBLIC(QQuickShaderEffect) + +public: + void updatePolish() override; +}; + QSGContextFactoryInterface::Flags qsg_backend_flags(); QQuickShaderEffect::QQuickShaderEffect(QQuickItem *parent) - : QQuickItem(parent), + : QQuickItem(*new QQuickShaderEffectPrivate, parent), #ifndef QT_NO_OPENGL m_glImpl(nullptr), #endif @@ -712,12 +721,12 @@ void QQuickShaderEffect::componentComplete() { #ifndef QT_NO_OPENGL if (m_glImpl) { - m_glImpl->handleComponentComplete(); + m_glImpl->maybeUpdateShaders(); QQuickItem::componentComplete(); return; } #endif - m_impl->handleComponentComplete(); + m_impl->maybeUpdateShaders(); QQuickItem::componentComplete(); } @@ -745,7 +754,19 @@ QString QQuickShaderEffect::parseLog() // for OpenGL-based autotests if (m_glImpl) return m_glImpl->parseLog(); #endif - return QString(); + return m_impl->parseLog(); +} + +void QQuickShaderEffectPrivate::updatePolish() +{ + Q_Q(QQuickShaderEffect); +#ifndef QT_NO_OPENGL + if (q->m_glImpl) { + q->m_glImpl->maybeUpdateShaders(); + return; + } +#endif + q->m_impl->maybeUpdateShaders(); } QT_END_NAMESPACE |