1 | // Copyright (C) 2016 The Qt Company Ltd. |
---|---|
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #ifndef MASKEXTRUDER_H |
5 | #define MASKEXTRUDER_H |
6 | |
7 | // |
8 | // W A R N I N G |
9 | // ------------- |
10 | // |
11 | // This file is not part of the Qt API. It exists purely as an |
12 | // implementation detail. This header file may change from version to |
13 | // version without notice, or even be removed. |
14 | // |
15 | // We mean it. |
16 | // |
17 | #include "qquickparticleextruder_p.h" |
18 | #include <private/qquickpixmapcache_p.h> |
19 | #include <QUrl> |
20 | #include <QImage> |
21 | |
22 | QT_BEGIN_NAMESPACE |
23 | |
24 | class Q_QUICKPARTICLES_PRIVATE_EXPORT QQuickMaskExtruder : public QQuickParticleExtruder |
25 | { |
26 | Q_OBJECT |
27 | Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged FINAL) |
28 | QML_NAMED_ELEMENT(MaskShape) |
29 | QML_ADDED_IN_VERSION(2, 0) |
30 | public: |
31 | explicit QQuickMaskExtruder(QObject *parent = nullptr); |
32 | QPointF extrude(const QRectF &) override; |
33 | bool contains(const QRectF &bounds, const QPointF &point) override; |
34 | |
35 | QUrl source() const |
36 | { |
37 | return m_source; |
38 | } |
39 | |
40 | Q_SIGNALS: |
41 | |
42 | void sourceChanged(const QUrl &arg); |
43 | |
44 | public Q_SLOTS: |
45 | void setSource(const QUrl &arg); |
46 | |
47 | private Q_SLOTS: |
48 | void startMaskLoading(); |
49 | void finishMaskLoading(); |
50 | |
51 | private: |
52 | QUrl m_source; |
53 | |
54 | void ensureInitialized(const QRectF &r); |
55 | int m_lastWidth; |
56 | int m_lastHeight; |
57 | QQuickPixmap m_pix; |
58 | QImage m_img; |
59 | QList<QPointF> m_mask;//TODO: More memory efficient datastructures |
60 | //Perhaps just the mask for the largest bounds is stored, and interpolate up |
61 | }; |
62 | |
63 | QT_END_NAMESPACE |
64 | |
65 | #endif // MASKEXTRUDER_H |
66 |