aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickgraphicsinfo.cpp
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2016-06-27 17:13:37 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2016-06-29 11:59:54 +0000
commit5ee02242d72ac9a536584b36ba549480a97303f7 (patch)
treec898b2eedad203ee0536d7b40cab6c1c08234056 /src/quick/items/qquickgraphicsinfo.cpp
parent12bff27aa6f1caac9bfacf365c542cf5da6e3148 (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/qquickgraphicsinfo.cpp')
-rw-r--r--src/quick/items/qquickgraphicsinfo.cpp35
1 files changed, 16 insertions, 19 deletions
diff --git a/src/quick/items/qquickgraphicsinfo.cpp b/src/quick/items/qquickgraphicsinfo.cpp
index 79b0edf031..761d0c3cad 100644
--- a/src/quick/items/qquickgraphicsinfo.cpp
+++ b/src/quick/items/qquickgraphicsinfo.cpp
@@ -112,11 +112,11 @@ QQuickGraphicsInfo *QQuickGraphicsInfo::qmlAttachedProperties(QObject *object)
\endlist
\note The value is only up-to-date once the item is associated with a
- window and the window's scenegraph has initialized. Bindings relying on the
- value have to keep this in mind since the value may change from
- GraphicsInfo.UnknownShadingLanguage to the actual value after component
- initialization is complete. This is particularly relevant for ShaderEffect
- items inside ShaderEffectSource items set as property values.
+ window. Bindings relying on the value have to keep this in mind since the
+ value may change from GraphicsInfo.UnknownShadingLanguage to the actual
+ value after component initialization is complete. This is particularly
+ relevant for ShaderEffect items inside ShaderEffectSource items set as
+ property values.
\since 5.8
\since QtQuick 2.8
@@ -140,11 +140,10 @@ QQuickGraphicsInfo *QQuickGraphicsInfo::qmlAttachedProperties(QObject *object)
expected to focus more on GraphicsInfo.OfflineCompilation, however.
\note The value is only up-to-date once the item is associated with a
- window and the window's scenegraph has initialized. Bindings relying on the
- value have to keep this in mind since the value may change from \c 0 to the
- actual bitmask after component initialization is complete. This is
- particularly relevant for ShaderEffect items inside ShaderEffectSource
- items set as property values.
+ window. Bindings relying on the value have to keep this in mind since the
+ value may change from \c 0 to the actual bitmask after component
+ initialization is complete. This is particularly relevant for ShaderEffect
+ items inside ShaderEffectSource items set as property values.
\since 5.8
\since QtQuick 2.8
@@ -172,11 +171,10 @@ QQuickGraphicsInfo *QQuickGraphicsInfo::qmlAttachedProperties(QObject *object)
bytecode.
\note The value is only up-to-date once the item is associated with a
- window and the window's scenegraph has initialized. Bindings relying on the
- value have to keep this in mind since the value may change from \c 0 to the
- actual bitmask after component initialization is complete. This is
- particularly relevant for ShaderEffect items inside ShaderEffectSource
- items set as property values.
+ window. Bindings relying on the value have to keep this in mind since the
+ value may change from \c 0 to the actual bitmask after component
+ initialization is complete. This is particularly relevant for ShaderEffect
+ items inside ShaderEffectSource items set as property values.
\since 5.8
\since QtQuick 2.8
@@ -240,9 +238,8 @@ QQuickGraphicsInfo *QQuickGraphicsInfo::qmlAttachedProperties(QObject *object)
void QQuickGraphicsInfo::updateInfo()
{
- const bool sgReady = m_window && m_window->isSceneGraphInitialized();
-
- if (sgReady) {
+ // The queries via the RIF do not depend on isSceneGraphInitialized(), they only need a window.
+ if (m_window) {
QSGRendererInterface *rif = m_window->rendererInterface();
if (rif) {
GraphicsApi newAPI = GraphicsApi(rif->graphicsApi());
@@ -261,7 +258,7 @@ void QQuickGraphicsInfo::updateInfo()
QSurfaceFormat format = QSurfaceFormat::defaultFormat();
#ifndef QT_NO_OPENGL
- if (sgReady) {
+ if (m_window && m_window->isSceneGraphInitialized()) {
QOpenGLContext *context = m_window->openglContext();
if (context)
format = context->format();