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 | |
22 | QT_BEGIN_NAMESPACE |
23 | |
24 | class QQuickShaderEffectSource; |
25 | |
26 | class QGfxSourceProxy : public QQuickItem |
27 | { |
28 | Q_OBJECT |
29 | Q_PROPERTY(QQuickItem *input READ input WRITE setInput NOTIFY inputChanged RESET resetInput FINAL) |
30 | Q_PROPERTY(QQuickItem *output READ output NOTIFY outputChanged FINAL) |
31 | Q_PROPERTY(QRectF sourceRect READ sourceRect WRITE setSourceRect NOTIFY sourceRectChanged FINAL) |
32 | Q_PROPERTY(bool active READ isActive NOTIFY activeChanged FINAL) |
33 | Q_PROPERTY(Interpolation interpolation READ interpolation WRITE setInterpolation NOTIFY interpolationChanged FINAL) |
34 | |
35 | public: |
36 | enum class Interpolation { |
37 | Any, |
38 | Nearest, |
39 | Linear |
40 | }; |
41 | Q_ENUM(Interpolation) |
42 | |
43 | QGfxSourceProxy(QQuickItem *parentItem = nullptr); |
44 | ~QGfxSourceProxy(); |
45 | |
46 | QQuickItem *input() const { return m_input; } |
47 | void setInput(QQuickItem *input); |
48 | void resetInput() { setInput(nullptr); } |
49 | |
50 | QQuickItem *output() const { return m_output; } |
51 | |
52 | QRectF sourceRect() const { return m_sourceRect; } |
53 | void setSourceRect(const QRectF &sourceRect); |
54 | |
55 | bool isActive() const { return m_output && m_output != m_input; } |
56 | |
57 | void setInterpolation(Interpolation i); |
58 | Interpolation interpolation() const { return m_interpolation; } |
59 | |
60 | protected: |
61 | void updatePolish() override; |
62 | |
63 | Q_SIGNALS: |
64 | void inputChanged(); |
65 | void outputChanged(); |
66 | void sourceRectChanged(); |
67 | void activeChanged(); |
68 | void interpolationChanged(); |
69 | |
70 | private Q_SLOTS: |
71 | void repolish(); |
72 | |
73 | private: |
74 | void setOutput(QQuickItem *output); |
75 | void useProxy(); |
76 | static QObject *findLayer(QQuickItem *); |
77 | |
78 | QRectF m_sourceRect; |
79 | QQuickItem *m_input = nullptr; |
80 | QQuickItem *m_output = nullptr; |
81 | QQuickShaderEffectSource *m_proxy = nullptr; |
82 | |
83 | Interpolation m_interpolation = Interpolation::Any; |
84 | }; |
85 | |
86 | QT_END_NAMESPACE |
87 | |
88 | #endif // QGFXSOURCEPROXY_P_H |
89 |