summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar.sletta@jollamobile.com>2015-01-22 18:53:53 +0100
committerGunnar Sletta <gunnar@sletta.org>2015-03-10 18:14:06 +0000
commit64fdf70c2249c20895101a7428a9828825a00542 (patch)
tree06b5e45c59d7fd85b5616aa34cdd15a20604e326
parent36d7b8240c9cb0096fc603981dd41abd9f1e7915 (diff)
downloadqtgraphicaleffects-64fdf70c2249c20895101a7428a9828825a00542.tar.gz
Let sourceproxy auto-configure layers.
In the old SourceProxy implementation, layer.enabled = true that the layer was used without a shader source in between. However, since effects like Blur and DropShadow requires updates to sourceRect and such, the effects would not work properly. Since the usecase for layers is primarily to combine it with layer.effect, we configure the layer. [ChangeLog] When applying an effect to Item::layer.effect, the effect will update the layer properties to make the effect work, such as 'smooth' to 'true' and changing 'sourceRect' to take 'transparentBorder' into account. Change-Id: Idd68b025ade46c0b84142b2afb244730bed863d2 Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
-rw-r--r--src/effects/private/qgfxsourceproxy.cpp23
-rw-r--r--tests/manual/SourceProxyTest.qml16
2 files changed, 25 insertions, 14 deletions
diff --git a/src/effects/private/qgfxsourceproxy.cpp b/src/effects/private/qgfxsourceproxy.cpp
index a319e18..cdc6fc1 100644
--- a/src/effects/private/qgfxsourceproxy.cpp
+++ b/src/effects/private/qgfxsourceproxy.cpp
@@ -96,7 +96,7 @@ void QGfxSourceProxy::useProxy()
m_proxy = new QQuickShaderEffectSource(this);
m_proxy->setSourceRect(m_sourceRect);
m_proxy->setSourceItem(m_input);
- m_proxy->setSmooth(true);
+ m_proxy->setSmooth(m_interpolation != NearestInterpolation);
setOutput(m_proxy);
}
@@ -111,23 +111,20 @@ void QGfxSourceProxy::updatePolish()
QQuickImage *image = qobject_cast<QQuickImage *>(m_input);
QQuickShaderEffectSource *shaderSource = qobject_cast<QQuickShaderEffectSource *>(m_input);
- bool layered = d->extra.isAllocated() && d->extra->layer && d->extra->layer->enabled();
+ bool layered = d->extra.isAllocated() && d->extra->transparentForPositioner;
if (shaderSource) {
- if ((shaderSource->sourceRect() != m_sourceRect)
- || (m_interpolation == LinearInterpolation && !shaderSource->smooth())
- || (m_interpolation == NearestInterpolation && shaderSource->smooth()))
- useProxy();
- else
+ if (layered) {
+ shaderSource->setSourceRect(m_sourceRect);
+ shaderSource->setSmooth(m_interpolation != NearestInterpolation);
setOutput(m_input);
-
- } else if (layered) {
- if ((d->extra->layer->sourceRect() != m_sourceRect)
- || (m_interpolation == LinearInterpolation && !d->extra->layer->smooth())
- || (m_interpolation == NearestInterpolation && d->extra->layer->smooth()))
+ } else if ((shaderSource->sourceRect() != m_sourceRect)
+ || (m_interpolation == LinearInterpolation && !shaderSource->smooth())
+ || (m_interpolation == NearestInterpolation && shaderSource->smooth())) {
useProxy();
- else
+ } else {
setOutput(m_input);
+ }
} else if (image && image->fillMode() == QQuickImage::Stretch && m_input->childItems().size() == 0) {
// item is an image with default tiling, use directly
diff --git a/tests/manual/SourceProxyTest.qml b/tests/manual/SourceProxyTest.qml
index e68bc35..94c948d 100644
--- a/tests/manual/SourceProxyTest.qml
+++ b/tests/manual/SourceProxyTest.qml
@@ -97,6 +97,20 @@ Rectangle {
}
Text {
+ id: autoConfLabel;
+ // This will be shown when the source is a layer which has different
+ // attributes set than what the source proxy expects. The source proxy
+ // will then configure the layer.
+ color: "#00ff00"
+ anchors.right: parent.right
+ anchors.verticalCenter: parent.verticalCenter;
+ text: "(configured)"
+ font.pixelSize: 12
+ font.bold: true
+ visible: root.expectProxy != proxy.active && !proxy.active && root.sourcing == "layered";
+ }
+
+ Text {
color: "red"
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter;
@@ -104,7 +118,7 @@ Rectangle {
text: "FAIL"
font.pixelSize: 12
font.bold: true
- visible: root.expectProxy != proxy.active
+ visible: root.expectProxy != proxy.active && !autoConfLabel.visible
}
}