1 | // Copyright (C) 2020 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 QSGSOFTWAREPUBLICNODES_H |
5 | #define QSGSOFTWAREPUBLICNODES_H |
6 | |
7 | #include <QtQuick/qsgrectanglenode.h> |
8 | #include <QtQuick/qsgimagenode.h> |
9 | #include <QtQuick/qsgninepatchnode.h> |
10 | #include <QtGui/qpixmap.h> |
11 | #include <QtCore/private/qglobal_p.h> |
12 | |
13 | // |
14 | // W A R N I N G |
15 | // ------------- |
16 | // |
17 | // This file is not part of the Qt API. It exists purely as an |
18 | // implementation detail. This header file may change from version to |
19 | // version without notice, or even be removed. |
20 | // |
21 | // We mean it. |
22 | // |
23 | |
24 | QT_BEGIN_NAMESPACE |
25 | |
26 | class QSGSoftwareRectangleNode : public QSGRectangleNode |
27 | { |
28 | public: |
29 | QSGSoftwareRectangleNode(); |
30 | |
31 | void setRect(const QRectF &rect) override { m_rect = rect; markDirty(bits: DirtyMaterial); } |
32 | QRectF rect() const override { return m_rect; } |
33 | |
34 | void setColor(const QColor &color) override { m_color = color; markDirty(bits: DirtyMaterial); } |
35 | QColor color() const override { return m_color; } |
36 | |
37 | void paint(QPainter *painter); |
38 | |
39 | private: |
40 | QRectF m_rect; |
41 | QColor m_color; |
42 | }; |
43 | |
44 | class QSGSoftwareImageNode : public QSGImageNode |
45 | { |
46 | public: |
47 | QSGSoftwareImageNode(); |
48 | ~QSGSoftwareImageNode(); |
49 | |
50 | void setRect(const QRectF &rect) override { m_rect = rect; markDirty(bits: DirtyMaterial); } |
51 | QRectF rect() const override { return m_rect; } |
52 | |
53 | void setSourceRect(const QRectF &r) override { m_sourceRect = r; } |
54 | QRectF sourceRect() const override { return m_sourceRect; } |
55 | |
56 | void setTexture(QSGTexture *texture) override; |
57 | QSGTexture *texture() const override { return m_texture; } |
58 | |
59 | void setFiltering(QSGTexture::Filtering filtering) override { m_filtering = filtering; markDirty(bits: DirtyMaterial); } |
60 | QSGTexture::Filtering filtering() const override { return m_filtering; } |
61 | |
62 | void setMipmapFiltering(QSGTexture::Filtering) override { } |
63 | QSGTexture::Filtering mipmapFiltering() const override { return QSGTexture::None; } |
64 | |
65 | void setAnisotropyLevel(QSGTexture::AnisotropyLevel) override { } |
66 | QSGTexture::AnisotropyLevel anisotropyLevel() const override { return QSGTexture::AnisotropyNone; } |
67 | |
68 | void setTextureCoordinatesTransform(TextureCoordinatesTransformMode transformNode) override; |
69 | TextureCoordinatesTransformMode textureCoordinatesTransform() const override { return m_transformMode; } |
70 | |
71 | void setOwnsTexture(bool owns) override { m_owns = owns; } |
72 | bool ownsTexture() const override { return m_owns; } |
73 | |
74 | void paint(QPainter *painter); |
75 | |
76 | private: |
77 | void updateCachedMirroredPixmap(); |
78 | |
79 | QPixmap m_cachedPixmap; |
80 | QSGTexture *m_texture; |
81 | QRectF m_rect; |
82 | QRectF m_sourceRect; |
83 | bool m_owns; |
84 | QSGTexture::Filtering m_filtering; |
85 | TextureCoordinatesTransformMode m_transformMode; |
86 | bool m_cachedMirroredPixmapIsDirty; |
87 | }; |
88 | |
89 | class QSGSoftwareNinePatchNode : public QSGNinePatchNode |
90 | { |
91 | public: |
92 | QSGSoftwareNinePatchNode(); |
93 | |
94 | void setTexture(QSGTexture *texture) override; |
95 | void setBounds(const QRectF &bounds) override; |
96 | void setDevicePixelRatio(qreal ratio) override; |
97 | void setPadding(qreal left, qreal top, qreal right, qreal bottom) override; |
98 | void update() override; |
99 | |
100 | void paint(QPainter *painter); |
101 | |
102 | QRectF bounds() const; |
103 | |
104 | bool isOpaque() const { return !m_pixmap.hasAlphaChannel(); } |
105 | |
106 | private: |
107 | QPixmap m_pixmap; |
108 | QRectF m_bounds; |
109 | qreal m_pixelRatio = 1.0; |
110 | QMargins m_margins; |
111 | }; |
112 | |
113 | QT_END_NAMESPACE |
114 | |
115 | #endif // QSGSOFTWAREPUBLICNODES_H |
116 |