diff options
author | Gunnar Sletta <gunnar@sletta.org> | 2015-10-19 20:02:57 +0200 |
---|---|---|
committer | Gunnar Sletta <gunnar@sletta.org> | 2015-12-08 06:05:23 +0000 |
commit | 3f240169388d2f3090cd5730e03df8d8ab670510 (patch) | |
tree | e5296f87fa55bbc7bad600ff651354173a0d8759 | |
parent | 59699c9322b3861e3d0251dfd40a65d0f03c76d4 (diff) |
Fix SourceProxy's method for determining when to activate.v5.6.0-beta1
The logic had several flaws, including not respecting sourceRect
and wanted interpolation, so do it over.
Change-Id: I40b147a0e18ef5f9f3a0086904f9e9f93463c7fc
Task-number: QTBUG-47749
Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
-rw-r--r-- | src/effects/private/qgfxsourceproxy.cpp | 53 | ||||
-rw-r--r-- | tests/manual/SourceProxyTest.qml | 2 | ||||
-rw-r--r-- | tests/manual/testSourceProxy.qml | 6 |
3 files changed, 44 insertions, 17 deletions
diff --git a/src/effects/private/qgfxsourceproxy.cpp b/src/effects/private/qgfxsourceproxy.cpp index 8f841f2..e9b4254 100644 --- a/src/effects/private/qgfxsourceproxy.cpp +++ b/src/effects/private/qgfxsourceproxy.cpp @@ -110,23 +110,50 @@ void QGfxSourceProxy::updatePolish() QQuickItemPrivate *d = QQuickItemPrivate::get(m_input); QQuickImage *image = qobject_cast<QQuickImage *>(m_input); QQuickShaderEffectSource *shaderSource = qobject_cast<QQuickShaderEffectSource *>(m_input); - bool layered = d->extra.isAllocated() && d->extra->transparentForPositioner; + bool childless = m_input->childItems().size() == 0; + bool interpOk = m_interpolation == AnyInterpolation + || (m_interpolation == LinearInterpolation && m_input->smooth() == true) + || (m_interpolation == NearestInterpolation && m_input->smooth() == false); + + + // Layer logic is handled via QObject properties since the class is not + // private exported.. + bool maybeLayered = d->extra.isAllocated() && d->extra->layer; + QObject *layer = 0; + if (maybeLayered) { + layer = qvariant_cast<QObject *>(m_input->property("layer")); + if (!layer || !layer->property("enabled").toBool()) + layer = 0; + } - if (shaderSource) { - if (layered) { - shaderSource->setSourceRect(m_sourceRect); - shaderSource->setSmooth(m_interpolation != NearestInterpolation); - } - setOutput(m_input); + // A bit crude test, but we're only using source rect for + // blurring+transparent edge, so this is good enough. + bool padded = m_sourceRect.x() < 0 || m_sourceRect.y() < 0; - } else if (image && image->fillMode() == QQuickImage::Stretch && m_input->childItems().size() == 0) { - // item is an image with default tiling, use directly - setOutput(m_input); + bool direct = false; - } else if (!image && m_input->isTextureProvider() && m_input->childItems().size() == 0) { - // item is a texture provider without children, use directly... - setOutput(m_input); + if (layer) { + // Item layer which we can configure to our needs + layer->setProperty("sourceRect", m_sourceRect); + layer->setProperty("smooth", m_interpolation != NearestInterpolation); + direct = true; + + } else if (childless && interpOk) { + if (shaderSource) { + if (shaderSource->sourceRect() == m_sourceRect) + direct = true; + + } else if (!padded && ((image && image->fillMode() == QQuickImage::Stretch) + || (!image && m_input->isTextureProvider()) + ) + ) { + direct = true; + } + } + + if (direct) { + setOutput(m_input); } else { useProxy(); } diff --git a/tests/manual/SourceProxyTest.qml b/tests/manual/SourceProxyTest.qml index 94c948d..5ba74e7 100644 --- a/tests/manual/SourceProxyTest.qml +++ b/tests/manual/SourceProxyTest.qml @@ -91,7 +91,7 @@ Rectangle { SourceProxy { id: proxy - input: sourcing == "shadersource" ? shaderSource : text; + input: sourcing == "shadersource" ? shaderSource : (root.sourcing == "layered" ? text : null); visible: false sourceRect: proxyPadding ? Qt.rect(-1, -1, text.width, text.height) : Qt.rect(0, 0, 0, 0); } diff --git a/tests/manual/testSourceProxy.qml b/tests/manual/testSourceProxy.qml index 1ca3f95..a623ff7 100644 --- a/tests/manual/testSourceProxy.qml +++ b/tests/manual/testSourceProxy.qml @@ -223,19 +223,19 @@ Item { label: "source: none\nproxy: any-interpolation" sourcing: "none" proxyInterpolation: SourceProxy.AnyInterpolation - expectProxy: true + expectProxy: false } SourceProxyTest { label: "source: none\nproxy: nearest-interpolation" sourcing: "none" proxyInterpolation: SourceProxy.NearestInterpolation - expectProxy: true + expectProxy: false } SourceProxyTest { label: "source: none\nproxy: linear-interpolation" sourcing: "none" proxyInterpolation: SourceProxy.LinearInterpolation - expectProxy: true + expectProxy: false } |