diff options
author | Alexandru Croitor <[email protected]> | 2021-08-12 11:24:12 +0200 |
---|---|---|
committer | Alexandru Croitor <[email protected]> | 2021-08-12 17:51:01 +0200 |
commit | 425911d07fc8c3bb899226a1355c38a166b5e1de (patch) | |
tree | 1d5e0e5ae3ec66b10920bb9104e7d12c69b4a52f /src/effects/private | |
parent | 59ab3e11433a5157aac0f3af7c0d7fe70a373373 (diff) |
Add a README.md mentioning the documentation on where the ported
effects can be found, as well as how to check out the Qt5 branch.
Pick-to: 6.2
Fixes: QTBUG-95757
Change-Id: Ib47c7e73f8622c8e287df0f74c6f16a5113b357e
Reviewed-by: Tor Arne Vestbø <[email protected]>
Reviewed-by: Volker Hilsheimer <[email protected]>
Diffstat (limited to 'src/effects/private')
-rw-r--r-- | src/effects/private/.prev_CMakeLists.txt | 73 | ||||
-rw-r--r-- | src/effects/private/CMakeLists.txt | 44 | ||||
-rw-r--r-- | src/effects/private/FastGlow.qml | 342 | ||||
-rw-r--r-- | src/effects/private/plugin.cpp | 79 | ||||
-rw-r--r-- | src/effects/private/private.pro | 21 | ||||
-rw-r--r-- | src/effects/private/qgfxsourceproxy.cpp | 216 | ||||
-rw-r--r-- | src/effects/private/qgfxsourceproxy_p.h | 125 | ||||
-rw-r--r-- | src/effects/private/qmldir | 4 |
8 files changed, 0 insertions, 904 deletions
diff --git a/src/effects/private/.prev_CMakeLists.txt b/src/effects/private/.prev_CMakeLists.txt deleted file mode 100644 index aba6f59..0000000 --- a/src/effects/private/.prev_CMakeLists.txt +++ /dev/null @@ -1,73 +0,0 @@ -# Generated from private.pro. - -##################################################################### -## qtgraphicaleffectsprivate Plugin: -##################################################################### - -qt_add_qml_module(qtgraphicaleffectsprivate - URI "QtGraphicalEffects.private" - VERSION "${CMAKE_PROJECT_VERSION}" - CLASSNAME QtGraphicalEffectsPrivatePlugin - SOURCES - plugin.cpp - qgfxshaderbuilder.cpp qgfxshaderbuilder_p.h - qgfxsourceproxy.cpp qgfxsourceproxy_p.h - PUBLIC_LIBRARIES - Qt::Core - Qt::CorePrivate - Qt::Gui - Qt::GuiPrivate - Qt::Qml - Qt::QmlPrivate - Qt::Quick - Qt::QuickPrivate -) - -#### Keys ignored in scope 1:.:.:private.pro:<TRUE>: -# CXX_MODULE = "qml" -# QML_FILES = "DropShadowBase.qml" "FastGlow.qml" "FastInnerShadow.qml" "FastMaskedBlur.qml" "GaussianDirectionalBlur.qml" "GaussianGlow.qml" "GaussianInnerShadow.qml" "GaussianMaskedBlur.qml" -# QML_IMPORT_VERSION = "$$QT_VERSION" -# TARGETPATH = "QtGraphicalEffects/private" - -## Scopes: -##################################################################### - -set(qml_files - "DropShadowBase.qml" - "FastGlow.qml" - "FastInnerShadow.qml" - "FastMaskedBlur.qml" - "GaussianDirectionalBlur.qml" - "GaussianGlow.qml" - "GaussianInnerShadow.qml" - "GaussianMaskedBlur.qml" -) -set_source_files_properties(DropShadowBase.qml PROPERTIES - QT_QML_SOURCE_VERSION "1.0" -) -set_source_files_properties(FastGlow.qml PROPERTIES - QT_QML_SOURCE_VERSION "1.0" -) -set_source_files_properties(FastInnerShadow.qml PROPERTIES - QT_QML_SOURCE_VERSION "1.0" -) -set_source_files_properties(FastMaskedBlur.qml PROPERTIES - QT_QML_SOURCE_VERSION "1.0" -) -set_source_files_properties(GaussianDirectionalBlur.qml PROPERTIES - QT_QML_SOURCE_VERSION "1.0" -) -set_source_files_properties(GaussianGlow.qml PROPERTIES - QT_QML_SOURCE_VERSION "1.0" -) -set_source_files_properties(GaussianInnerShadow.qml PROPERTIES - QT_QML_SOURCE_VERSION "1.0" -) -set_source_files_properties(GaussianMaskedBlur.qml PROPERTIES - QT_QML_SOURCE_VERSION "1.0" -) - -qt6_target_qml_files(qtgraphicaleffectsprivate - FILES - ${qml_files} -) diff --git a/src/effects/private/CMakeLists.txt b/src/effects/private/CMakeLists.txt deleted file mode 100644 index b8e0e5b..0000000 --- a/src/effects/private/CMakeLists.txt +++ /dev/null @@ -1,44 +0,0 @@ -# Generated from private.pro. - -##################################################################### -## qtgraphicaleffectsprivate Plugin: -##################################################################### - -qt_internal_add_qml_module(qtgraphicaleffectsprivate - URI "QtGraphicalEffects.private" - VERSION "${CMAKE_PROJECT_VERSION}" - CLASSNAME QtGraphicalEffectsPrivatePlugin - SOURCES - plugin.cpp - qgfxsourceproxy.cpp qgfxsourceproxy_p.h - PUBLIC_LIBRARIES - Qt::Core - Qt::CorePrivate - Qt::Gui - Qt::GuiPrivate - Qt::Qml - Qt::QmlPrivate - Qt::Quick - Qt::QuickPrivate -) - -#### Keys ignored in scope 1:.:.:private.pro:<TRUE>: -# CXX_MODULE = "qml" -# QML_FILES = "FastGlow.qml" -# QML_IMPORT_VERSION = "$$QT_VERSION" -# TARGETPATH = "QtGraphicalEffects/private" - -## Scopes: -##################################################################### - -set(qml_files - "FastGlow.qml" -) -set_source_files_properties(FastGlow.qml PROPERTIES - QT_QML_SOURCE_VERSION "1.0" -) - -qt6_target_qml_files(qtgraphicaleffectsprivate - FILES - ${qml_files} -) diff --git a/src/effects/private/FastGlow.qml b/src/effects/private/FastGlow.qml deleted file mode 100644 index 896dcae..0000000 --- a/src/effects/private/FastGlow.qml +++ /dev/null @@ -1,342 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2020 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Graphical Effects module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.12 -import QtGraphicalEffects.private 1.12 - -Item { - id: rootItem - property variant source - property real spread: 0.0 - property real blur: 0.0 - property color color: "white" - property bool transparentBorder: false - property bool cached: false - - SourceProxy { - id: sourceProxy - input: rootItem.source - } - - ShaderEffectSource { - id: cacheItem - anchors.fill: shaderItem - visible: rootItem.cached - smooth: true - sourceItem: shaderItem - live: true - hideSource: visible - } - - property string __internalBlurVertexShader: "qrc:/qt-project.org/imports/QtGraphicalEffects/shaders_ng/fastblur_internal.vert.qsb" - - property string __internalBlurFragmentShader: "qrc:/qt-project.org/imports/QtGraphicalEffects/shaders_ng/fastblur_internal.frag.qsb" - - ShaderEffect { - id: level0 - property variant source: sourceProxy.output - anchors.fill: parent - visible: false - smooth: true - } - - ShaderEffectSource { - id: level1 - width: Math.ceil(shaderItem.width / 32) * 32 - height: Math.ceil(shaderItem.height / 32) * 32 - sourceItem: level0 - hideSource: rootItem.visible - sourceRect: transparentBorder ? Qt.rect(-64, -64, shaderItem.width, shaderItem.height) : Qt.rect(0,0,0,0) - smooth: true - visible: false - } - - ShaderEffect { - id: effect1 - property variant source: level1 - property real yStep: 1/height - property real xStep: 1/width - anchors.fill: level2 - visible: false - smooth: true - vertexShader: __internalBlurVertexShader - fragmentShader: __internalBlurFragmentShader - } - - ShaderEffectSource { - id: level2 - width: level1.width / 2 - height: level1.height / 2 - sourceItem: effect1 - hideSource: rootItem.visible - visible: false - smooth: true - } - - ShaderEffect { - id: effect2 - property variant source: level2 - property real yStep: 1/height - property real xStep: 1/width - anchors.fill: level3 - visible: false - smooth: true - vertexShader: __internalBlurVertexShader - fragmentShader: __internalBlurFragmentShader - } - - ShaderEffectSource { - id: level3 - width: level2.width / 2 - height: level2.height / 2 - sourceItem: effect2 - hideSource: rootItem.visible - visible: false - smooth: true - } - - ShaderEffect { - id: effect3 - property variant source: level3 - property real yStep: 1/height - property real xStep: 1/width - anchors.fill: level4 - visible: false - smooth: true - vertexShader: __internalBlurVertexShader - fragmentShader: __internalBlurFragmentShader - } - - ShaderEffectSource { - id: level4 - width: level3.width / 2 - height: level3.height / 2 - sourceItem: effect3 - hideSource: rootItem.visible - visible: false - smooth: true - } - - ShaderEffect { - id: effect4 - property variant source: level4 - property real yStep: 1/height - property real xStep: 1/width - anchors.fill: level5 - visible: false - smooth: true - vertexShader: __internalBlurVertexShader - fragmentShader: __internalBlurFragmentShader - } - - ShaderEffectSource { - id: level5 - width: level4.width / 2 - height: level4.height / 2 - sourceItem: effect4 - hideSource: rootItem.visible - visible: false - smooth: true - } - - ShaderEffect { - id: effect5 - property variant source: level5 - property real yStep: 1/height - property real xStep: 1/width - anchors.fill: level6 - visible: false - smooth: true - vertexShader: __internalBlurVertexShader - fragmentShader: __internalBlurFragmentShader - } - - ShaderEffectSource { - id: level6 - width: level5.width / 2 - height: level5.height / 2 - sourceItem: effect5 - hideSource: rootItem.visible - visible: false - smooth: true - } - - Item { - id: dummysource - width: 1 - height: 1 - visible: false - } - - ShaderEffectSource { - id: dummy - width: 1 - height: 1 - sourceItem: dummysource - visible: false - smooth: false - live: false - } - - ShaderEffect { - id: shaderItem - x: transparentBorder ? -64 : 0 - y: transparentBorder ? -64 : 0 - width: transparentBorder ? parent.width + 128 : parent.width - height: transparentBorder ? parent.height + 128 : parent.height - - property variant source1: level1 - property variant source2: level2 - property variant source3: level3 - property variant source4: level4 - property variant source5: level5 - property variant source6: level6 - property real lod: rootItem.blur - - property real weight1; - property real weight2; - property real weight3; - property real weight4; - property real weight5; - property real weight6; - - property real spread: 1.0 - (rootItem.spread * 0.98) - property alias color: rootItem.color - - function weight(v) { - if (v <= 0.0) - return 1 - if (v >= 0.5) - return 0 - - return 1.0 - v / 0.5 - } - - function calculateWeights() { - - var w1 = weight(Math.abs(lod - 0.100)) - var w2 = weight(Math.abs(lod - 0.300)) - var w3 = weight(Math.abs(lod - 0.500)) - var w4 = weight(Math.abs(lod - 0.700)) - var w5 = weight(Math.abs(lod - 0.900)) - var w6 = weight(Math.abs(lod - 1.100)) - - var sum = w1 + w2 + w3 + w4 + w5 + w6; - weight1 = w1 / sum; - weight2 = w2 / sum; - weight3 = w3 / sum; - weight4 = w4 / sum; - weight5 = w5 / sum; - weight6 = w6 / sum; - - upateSources() - } - - function upateSources() { - var sources = new Array(); - var weights = new Array(); - - if (weight1 > 0) { - sources.push(level1) - weights.push(weight1) - } - - if (weight2 > 0) { - sources.push(level2) - weights.push(weight2) - } - - if (weight3 > 0) { - sources.push(level3) - weights.push(weight3) - } - - if (weight4 > 0) { - sources.push(level4) - weights.push(weight4) - } - - if (weight5 > 0) { - sources.push(level5) - weights.push(weight5) - } - - if (weight6 > 0) { - sources.push(level6) - weights.push(weight6) - } - - for (var j = sources.length; j < 6; j++) { - sources.push(dummy) - weights.push(0.0) - } - - source1 = sources[0] - source2 = sources[1] - source3 = sources[2] - source4 = sources[3] - source5 = sources[4] - source6 = sources[5] - - weight1 = weights[0] - weight2 = weights[1] - weight3 = weights[2] - weight4 = weights[3] - weight5 = weights[4] - weight6 = weights[5] - } - - Component.onCompleted: calculateWeights() - - onLodChanged: calculateWeights() - - fragmentShader: "qrc:/qt-project.org/imports/QtGraphicalEffects/shaders_ng/fastglow.frag.qsb" - } -} diff --git a/src/effects/private/plugin.cpp b/src/effects/private/plugin.cpp deleted file mode 100644 index c03926c..0000000 --- a/src/effects/private/plugin.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Jolla Ltd, author: <[email protected]> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Graphical Effects module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtQml/qqmlextensionplugin.h> -#include <QtQml/qqml.h> -#include <QtQml/qqmlengine.h> - -#include "qgfxsourceproxy_p.h" - -QT_BEGIN_NAMESPACE - -class QtGraphicalEffectsPrivatePlugin : public QQmlExtensionPlugin -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) - -public: - QtGraphicalEffectsPrivatePlugin(QObject *parent = 0) : QQmlExtensionPlugin(parent) { } - void registerTypes(const char *uri) override - { - Q_ASSERT(QByteArray(uri) == QByteArrayLiteral("QtGraphicalEffects.private")); - qmlRegisterType<QGfxSourceProxy>(uri, 1, 0, "SourceProxy"); - - // The minor version used to be the current Qt 5 minor. For compatibility it is the last - // Qt 5 release. - qmlRegisterModule(uri, 1, 15); - } -}; - -QT_END_NAMESPACE - -#include "plugin.moc" diff --git a/src/effects/private/private.pro b/src/effects/private/private.pro deleted file mode 100644 index b8d162a..0000000 --- a/src/effects/private/private.pro +++ /dev/null @@ -1,21 +0,0 @@ -CXX_MODULE=qml -TARGETPATH=QtGraphicalEffects/private -TARGET = qtgraphicaleffectsprivate -QML_IMPORT_VERSION = $$QT_VERSION - -QT += quick qml -# Needed to get a hold of QQuickShaderEffectSource, QQuickImage and QQuickItemPrivate -QT += quick-private gui-private core-private qml-private - -SOURCES += plugin.cpp \ - qgfxsourceproxy.cpp - -HEADERS += \ - qgfxsourceproxy_p.h - -QML_FILES = \ - FastGlow.qml - -!static: CONFIG += qmlcache - -load(qml_plugin) diff --git a/src/effects/private/qgfxsourceproxy.cpp b/src/effects/private/qgfxsourceproxy.cpp deleted file mode 100644 index cf64807..0000000 --- a/src/effects/private/qgfxsourceproxy.cpp +++ /dev/null @@ -1,216 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Jolla Ltd, author: <[email protected]> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Graphical Effects module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qgfxsourceproxy_p.h" - -#include <private/qquickshadereffectsource_p.h> -#include <private/qquickitem_p.h> -#include <private/qquickimage_p.h> - -QT_BEGIN_NAMESPACE - -QGfxSourceProxy::QGfxSourceProxy(QQuickItem *parentItem) - : QQuickItem(parentItem) - , m_input(0) - , m_output(0) - , m_proxy(0) - , m_interpolation(AnyInterpolation) -{ -} - -QGfxSourceProxy::~QGfxSourceProxy() -{ - delete m_proxy; -} - -void QGfxSourceProxy::setInput(QQuickItem *input) -{ - if (m_input == input) - return; - - if (m_input != nullptr) - disconnect(m_input, nullptr, this, nullptr); - m_input = input; - polish(); - if (m_input != nullptr) { - if (QQuickImage *image = qobject_cast<QQuickImage *>(m_input)) { - connect(image, &QQuickImage::sourceSizeChanged, this, &QGfxSourceProxy::repolish); - connect(image, &QQuickImage::fillModeChanged, this, &QGfxSourceProxy::repolish); - } - connect(m_input, &QQuickItem::childrenChanged, this, &QGfxSourceProxy::repolish); - } - emit inputChanged(); -} - -void QGfxSourceProxy::setOutput(QQuickItem *output) -{ - if (m_output == output) - return; - m_output = output; - emit activeChanged(); - emit outputChanged(); -} - -void QGfxSourceProxy::setSourceRect(const QRectF &sourceRect) -{ - if (m_sourceRect == sourceRect) - return; - m_sourceRect = sourceRect; - polish(); - emit sourceRectChanged(); -} - -void QGfxSourceProxy::setInterpolation(Interpolation i) -{ - if (m_interpolation == i) - return; - m_interpolation = i; - polish(); - emit interpolationChanged(); -} - - -void QGfxSourceProxy::useProxy() -{ - if (!m_proxy) - m_proxy = new QQuickShaderEffectSource(this); - m_proxy->setSourceRect(m_sourceRect); - m_proxy->setSourceItem(m_input); - m_proxy->setSmooth(m_interpolation != NearestInterpolation); - setOutput(m_proxy); -} - -void QGfxSourceProxy::repolish() -{ - polish(); -} - -QObject *QGfxSourceProxy::findLayer(QQuickItem *item) -{ - if (!item) - return 0; - QQuickItemPrivate *d = QQuickItemPrivate::get(item); - if (d->extra.isAllocated() && d->extra->layer) { - QObject *layer = qvariant_cast<QObject *>(item->property("layer")); - if (layer && layer->property("enabled").toBool()) - return layer; - } - return 0; -} - -void QGfxSourceProxy::updatePolish() -{ - if (m_input == 0) { - setOutput(0); - return; - } - - QQuickImage *image = qobject_cast<QQuickImage *>(m_input); - QQuickShaderEffectSource *shaderSource = qobject_cast<QQuickShaderEffectSource *>(m_input); - 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); - - // Layers can be used in two different ways. Option 1 is when the item is - // used as input to a separate ShaderEffect component. In this case, - // m_input will be the item itself. - QObject *layer = findLayer(m_input); - if (!layer && shaderSource) { - // Alternatively, the effect is applied via layer.effect, and the - // input to the effect will be the layer's internal ShaderEffectSource - // item. In this case, we need to backtrack and find the item that has - // the layer and configure it accordingly. - layer = findLayer(shaderSource->sourceItem()); - } - - // 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; - - bool direct = false; - - if (layer) { - // Auto-configure the layer so interpolation and padding works as - // expected without allocating additional FBOs. In edgecases, where - // this feature is undesiered, the user can simply use - // ShaderEffectSource rather than layer. - layer->setProperty("sourceRect", m_sourceRect); - layer->setProperty("smooth", m_interpolation != NearestInterpolation); - direct = true; - - } else if (childless && interpOk) { - - if (shaderSource) { - if (shaderSource->sourceRect() == m_sourceRect || m_sourceRect.isEmpty()) - direct = true; - - } else if (!padded && ((image && image->fillMode() == QQuickImage::Stretch && !image->sourceSize().isNull()) - || (!image && m_input->isTextureProvider()) - ) - ) { - direct = true; - } - } - - if (direct) { - setOutput(m_input); - } else { - useProxy(); - } - - // Remove the proxy if it is not in use.. - if (m_proxy && m_output == m_input) { - delete m_proxy; - m_proxy = 0; - } -} - -QT_END_NAMESPACE diff --git a/src/effects/private/qgfxsourceproxy_p.h b/src/effects/private/qgfxsourceproxy_p.h deleted file mode 100644 index 8fe592c..0000000 --- a/src/effects/private/qgfxsourceproxy_p.h +++ /dev/null @@ -1,125 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Jolla Ltd, author: <[email protected]> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Graphical Effects module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGFXSOURCEPROXY_P_H -#define QGFXSOURCEPROXY_P_H - -#include <QtQuick/QQuickItem> - -QT_BEGIN_NAMESPACE - -class QQuickShaderEffectSource; - -class QGfxSourceProxy : public QQuickItem -{ - Q_OBJECT - - Q_PROPERTY(QQuickItem *input READ input WRITE setInput NOTIFY inputChanged RESET resetInput) - Q_PROPERTY(QQuickItem *output READ output NOTIFY outputChanged) - Q_PROPERTY(QRectF sourceRect READ sourceRect WRITE setSourceRect NOTIFY sourceRectChanged) - - Q_PROPERTY(bool active READ isActive NOTIFY activeChanged) - Q_PROPERTY(Interpolation interpolation READ interpolation WRITE setInterpolation NOTIFY interpolationChanged) - - Q_ENUMS(Interpolation) - -public: - enum Interpolation { - AnyInterpolation, - NearestInterpolation, - LinearInterpolation - }; - - QGfxSourceProxy(QQuickItem *item = 0); - ~QGfxSourceProxy(); - - QQuickItem *input() const { return m_input; } - void setInput(QQuickItem *input); - void resetInput() { setInput(0); } - - QQuickItem *output() const { return m_output; } - - QRectF sourceRect() const { return m_sourceRect; } - void setSourceRect(const QRectF &sourceRect); - - bool isActive() const { return m_output && m_output != m_input; } - - void setInterpolation(Interpolation i); - Interpolation interpolation() const { return m_interpolation; } - -protected: - void updatePolish() override; - -signals: - void inputChanged(); - void outputChanged(); - void sourceRectChanged(); - void activeChanged(); - void interpolationChanged(); - -private slots: - void repolish(); - -private: - void setOutput(QQuickItem *output); - void useProxy(); - static QObject *findLayer(QQuickItem *); - - QRectF m_sourceRect; - QQuickItem *m_input; - QQuickItem *m_output; - QQuickShaderEffectSource *m_proxy; - - Interpolation m_interpolation; -}; - -QT_END_NAMESPACE - -#endif // QGFXSOURCEPROXY_P_H diff --git a/src/effects/private/qmldir b/src/effects/private/qmldir deleted file mode 100644 index da46a25..0000000 --- a/src/effects/private/qmldir +++ /dev/null @@ -1,4 +0,0 @@ -module QtGraphicalEffects.private -plugin qtgraphicaleffectsprivate -classname QtGraphicalEffectsPrivatePlugin -FastGlow 1.0 FastGlow.qml |