aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickshadereffect.cpp
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar.sletta@nokia.com>2011-12-20 00:50:15 +0100
committerQt by Nokia <qt-info@nokia.com>2012-01-03 17:58:59 +0100
commit42d6acd0a3ea5fa5cf7ab69f1f8f2206559107ea (patch)
tree84377465ecf6dbc45634656631c72f24e0e77f51 /src/quick/items/qquickshadereffect.cpp
parenta9b103d02831a03e8f3815af2b7d043c5cf4eae6 (diff)
Introduce layerering support (ShaderEffectSource) directly in Item
This is enabled by doing "Item.layer.enabled: true". The implementation is solely based on the existing shader effect (source) and simply swaps in a sibling next to the item when enabled. This change also adds the QSGTextureProvider to the public API, as it is now a natural part of the QQuickItem API since all items can be textures. Change-Id: I26705c11e92d5623a5121300acc123782b784077 Reviewed-by: Kim M. Kalland <kim.kalland@nokia.com>
Diffstat (limited to 'src/quick/items/qquickshadereffect.cpp')
-rw-r--r--src/quick/items/qquickshadereffect.cpp44
1 files changed, 27 insertions, 17 deletions
diff --git a/src/quick/items/qquickshadereffect.cpp b/src/quick/items/qquickshadereffect.cpp
index f90c538e1e..be01338c1b 100644
--- a/src/quick/items/qquickshadereffect.cpp
+++ b/src/quick/items/qquickshadereffect.cpp
@@ -46,7 +46,7 @@
#include "qquickitem_p.h"
#include <QtQuick/private/qsgcontext_p.h>
-#include <QtQuick/private/qsgtextureprovider_p.h>
+#include <QtQuick/qsgtextureprovider.h>
#include "qquickcanvas.h"
#include "qquickimage_p.h"
@@ -190,6 +190,7 @@ QQuickShaderEffect::QQuickShaderEffect(QQuickItem *parent)
, m_programDirty(true)
, m_dirtyMesh(true)
, m_dirtyGeometry(true)
+ , m_complete(false)
{
setFlag(QQuickItem::ItemHasContents);
}
@@ -199,12 +200,6 @@ QQuickShaderEffect::~QQuickShaderEffect()
reset();
}
-void QQuickShaderEffect::componentComplete()
-{
- updateProperties();
- QQuickItem::componentComplete();
-}
-
/*!
\qmlproperty string QtQuick2::ShaderEffect::fragmentShader
@@ -218,11 +213,8 @@ void QQuickShaderEffect::setFragmentShader(const QByteArray &code)
if (m_source.fragmentCode.constData() == code.constData())
return;
m_source.fragmentCode = code;
- if (isComponentComplete()) {
- reset();
- updateProperties();
- update();
- }
+ update();
+ m_complete = false;
emit fragmentShaderChanged();
}
@@ -240,11 +232,8 @@ void QQuickShaderEffect::setVertexShader(const QByteArray &code)
if (m_source.vertexCode.constData() == code.constData())
return;
m_source.vertexCode = code;
- if (isComponentComplete()) {
- reset();
- updateProperties();
- update();
- }
+ update();
+ m_complete = false;
emit vertexShaderChanged();
}
@@ -425,6 +414,10 @@ void QQuickShaderEffect::connectPropertySignals()
signalName.append(mp.notifySignal().signature());
connect(this, signalName, this, SLOT(updateData()));
} else {
+ // If the source is set via a dynamic property, like the layer is, then we need this check
+ // to disable the warning.
+ if (property(it->constData()).isValid())
+ continue;
qWarning("QQuickShaderEffect: '%s' does not have a matching property!", it->constData());
}
}
@@ -439,11 +432,26 @@ void QQuickShaderEffect::connectPropertySignals()
source.mapper->setMapping(this, i);
connect(source.mapper, SIGNAL(mapped(int)), this, SLOT(changeSource(int)));
} else {
+ // If the source is set via a dynamic property, like the layer is, then we need this check
+ // to disable the warning.
+ if (property(source.name.constData()).isValid())
+ continue;
qWarning("QQuickShaderEffect: '%s' does not have a matching source!", source.name.constData());
}
}
}
+
+void QQuickShaderEffect::ensureCompleted()
+{
+ if (!m_complete) {
+ reset();
+ updateProperties();
+ m_complete = true;
+ }
+}
+
+
void QQuickShaderEffect::reset()
{
disconnectPropertySignals();
@@ -666,6 +674,8 @@ QSGNode *QQuickShaderEffect::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeDa
{
QQuickShaderEffectNode *node = static_cast<QQuickShaderEffectNode *>(oldNode);
+ ensureCompleted();
+
// In the case of a bad vertex shader, don't try to create a node...
if (m_source.attributeNames.isEmpty()) {
if (node)