1// Copyright (C) 2022 The Qt Company Ltd.
2// Copyright (C) 2016 Jolla Ltd, author: <gunnar.sletta@jollamobile.com>
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#include <QtQuick/QQuickItem>
9#include <QtQml/qqmlregistration.h>
10
11#include <QtCore/private/qglobal_p.h>
12
13QT_BEGIN_NAMESPACE
14
15class QQuickShaderEffectSource;
16
17class QGfxSourceProxy : public QQuickItem
18{
19 Q_OBJECT
20
21 Q_PROPERTY(QQuickItem *input READ input WRITE setInput NOTIFY inputChanged RESET resetInput)
22 Q_PROPERTY(QQuickItem *output READ output NOTIFY outputChanged)
23 Q_PROPERTY(QRectF sourceRect READ sourceRect WRITE setSourceRect NOTIFY sourceRectChanged)
24
25 Q_PROPERTY(bool active READ isActive NOTIFY activeChanged)
26 Q_PROPERTY(Interpolation interpolation READ interpolation WRITE setInterpolation NOTIFY interpolationChanged)
27
28 Q_ENUMS(Interpolation)
29
30 QML_NAMED_ELEMENT(SourceProxy)
31 QML_ADDED_IN_VERSION(5, 0)
32
33public:
34 enum Interpolation {
35 AnyInterpolation,
36 NearestInterpolation,
37 LinearInterpolation
38 };
39
40 QGfxSourceProxy(QQuickItem *item = 0);
41 ~QGfxSourceProxy();
42
43 QQuickItem *input() const { return m_input; }
44 void setInput(QQuickItem *input);
45 void resetInput() { setInput(0); }
46
47 QQuickItem *output() const { return m_output; }
48
49 QRectF sourceRect() const { return m_sourceRect; }
50 void setSourceRect(const QRectF &sourceRect);
51
52 bool isActive() const { return m_output && m_output != m_input; }
53
54 void setInterpolation(Interpolation i);
55 Interpolation interpolation() const { return m_interpolation; }
56
57protected:
58 void updatePolish() override;
59
60signals:
61 void inputChanged();
62 void outputChanged();
63 void sourceRectChanged();
64 void activeChanged();
65 void interpolationChanged();
66
67private slots:
68 void repolish();
69
70private:
71 void setOutput(QQuickItem *output);
72 void useProxy();
73 static QObject *findLayer(QQuickItem *);
74
75 QRectF m_sourceRect;
76 QQuickItem *m_input;
77 QQuickItem *m_output;
78 QQuickShaderEffectSource *m_proxy;
79
80 Interpolation m_interpolation;
81};
82
83QT_END_NAMESPACE
84
85#endif // QGFXSOURCEPROXY_P_H
86

source code of qt5compat/src/imports/graphicaleffects5/private/qgfxsourceproxy_p.h