| 1 | // Copyright (C) 2016 Jolla Ltd, author: <gunnar.sletta@jollamobile.com> |
|---|---|
| 2 | // Copyright (C) 2022 The Qt Company Ltd. |
| 3 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 4 | |
| 5 | #ifndef QGFXSOURCEPROXY_P_H |
| 6 | #define QGFXSOURCEPROXY_P_H |
| 7 | |
| 8 | // |
| 9 | // W A R N I N G |
| 10 | // ------------- |
| 11 | // |
| 12 | // This file is not part of the Qt API. It exists purely as an |
| 13 | // implementation detail. This header file may change from version to |
| 14 | // version without notice, or even be removed. |
| 15 | // |
| 16 | // We mean it. |
| 17 | // |
| 18 | |
| 19 | #include <QtQuick/QQuickItem> |
| 20 | #include <QtCore/private/qglobal_p.h> |
| 21 | #include <QtCore/qrect.h> |
| 22 | |
| 23 | QT_BEGIN_NAMESPACE |
| 24 | |
| 25 | class QQuickShaderEffectSource; |
| 26 | |
| 27 | class QGfxSourceProxyME : public QQuickItem |
| 28 | { |
| 29 | Q_OBJECT |
| 30 | Q_PROPERTY(QQuickItem *input READ input WRITE setInput NOTIFY inputChanged RESET resetInput FINAL) |
| 31 | Q_PROPERTY(QQuickItem *output READ output NOTIFY outputChanged FINAL) |
| 32 | Q_PROPERTY(QRectF sourceRect READ sourceRect WRITE setSourceRect NOTIFY sourceRectChanged FINAL) |
| 33 | Q_PROPERTY(bool active READ isActive NOTIFY activeChanged FINAL) |
| 34 | Q_PROPERTY(Interpolation interpolation READ interpolation WRITE setInterpolation NOTIFY interpolationChanged FINAL) |
| 35 | |
| 36 | public: |
| 37 | enum class Interpolation { |
| 38 | Any, |
| 39 | Nearest, |
| 40 | Linear |
| 41 | }; |
| 42 | Q_ENUM(Interpolation) |
| 43 | |
| 44 | QGfxSourceProxyME(QQuickItem *parentItem = nullptr); |
| 45 | ~QGfxSourceProxyME(); |
| 46 | |
| 47 | QQuickItem *input() const { return m_input; } |
| 48 | void setInput(QQuickItem *input); |
| 49 | void resetInput() { setInput(nullptr); } |
| 50 | |
| 51 | QQuickItem *output() const { return m_output; } |
| 52 | |
| 53 | QRectF sourceRect() const { return m_sourceRect; } |
| 54 | void setSourceRect(const QRectF &sourceRect); |
| 55 | |
| 56 | bool isActive() const { return m_output && m_output != m_input; } |
| 57 | |
| 58 | void setInterpolation(Interpolation i); |
| 59 | Interpolation interpolation() const { return m_interpolation; } |
| 60 | |
| 61 | protected: |
| 62 | void updatePolish() override; |
| 63 | |
| 64 | Q_SIGNALS: |
| 65 | void inputChanged(); |
| 66 | void outputChanged(); |
| 67 | void sourceRectChanged(); |
| 68 | void activeChanged(); |
| 69 | void interpolationChanged(); |
| 70 | |
| 71 | private Q_SLOTS: |
| 72 | void repolish(); |
| 73 | |
| 74 | private: |
| 75 | void setOutput(QQuickItem *output); |
| 76 | void useProxy(); |
| 77 | static QObject *findLayer(QQuickItem *); |
| 78 | |
| 79 | QRectF m_sourceRect; |
| 80 | QQuickItem *m_input = nullptr; |
| 81 | QQuickItem *m_output = nullptr; |
| 82 | QQuickShaderEffectSource *m_proxy = nullptr; |
| 83 | |
| 84 | Interpolation m_interpolation = Interpolation::Any; |
| 85 | }; |
| 86 | |
| 87 | QT_END_NAMESPACE |
| 88 | |
| 89 | #endif // QGFXSOURCEPROXY_P_H |
| 90 |
