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 QSGSOFTWAREINTERNALIMAGENODE_H
5#define QSGSOFTWAREINTERNALIMAGENODE_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
18#include <private/qsgadaptationlayer_p.h>
19#include <private/qsgtexturematerial_p.h>
20
21#include <QtCore/QPointer>
22
23QT_BEGIN_NAMESPACE
24
25namespace QSGSoftwareHelpers {
26
27typedef QVarLengthArray<QPainter::PixmapFragment, 16> QPixmapFragmentsArray;
28
29struct QTileRules
30{
31 inline QTileRules(Qt::TileRule horizontalRule, Qt::TileRule verticalRule)
32 : horizontal(horizontalRule), vertical(verticalRule) {}
33 inline QTileRules(Qt::TileRule rule = Qt::StretchTile)
34 : horizontal(rule), vertical(rule) {}
35 Qt::TileRule horizontal;
36 Qt::TileRule vertical;
37};
38
39#ifndef Q_QDOC
40// For internal use only.
41namespace QDrawBorderPixmap
42{
43 enum DrawingHint
44 {
45 OpaqueTopLeft = 0x0001,
46 OpaqueTop = 0x0002,
47 OpaqueTopRight = 0x0004,
48 OpaqueLeft = 0x0008,
49 OpaqueCenter = 0x0010,
50 OpaqueRight = 0x0020,
51 OpaqueBottomLeft = 0x0040,
52 OpaqueBottom = 0x0080,
53 OpaqueBottomRight = 0x0100,
54 OpaqueCorners = OpaqueTopLeft | OpaqueTopRight | OpaqueBottomLeft | OpaqueBottomRight,
55 OpaqueEdges = OpaqueTop | OpaqueLeft | OpaqueRight | OpaqueBottom,
56 OpaqueFrame = OpaqueCorners | OpaqueEdges,
57 OpaqueAll = OpaqueCenter | OpaqueFrame
58 };
59
60 Q_DECLARE_FLAGS(DrawingHints, DrawingHint)
61}
62#endif
63
64void qDrawBorderPixmap(QPainter *painter, const QRect &targetRect, const QMargins &targetMargins,
65 const QPixmap &pixmap, const QRect &sourceRect,const QMargins &sourceMargins,
66 const QTileRules &rules, QDrawBorderPixmap::DrawingHints hints);
67
68} // QSGSoftwareHelpers namespace
69
70class QSGSoftwareInternalImageNode : public QSGInternalImageNode
71{
72public:
73 QSGSoftwareInternalImageNode();
74
75 void setTargetRect(const QRectF &rect) override;
76 void setInnerTargetRect(const QRectF &rect) override;
77 void setInnerSourceRect(const QRectF &rect) override;
78 void setSubSourceRect(const QRectF &rect) override;
79 void setTexture(QSGTexture *texture) override;
80 void setMirror(bool mirrorHorizontally, bool mirrorVertically) override;
81 void setMipmapFiltering(QSGTexture::Filtering filtering) override;
82 void setFiltering(QSGTexture::Filtering filtering) override;
83 void setHorizontalWrapMode(QSGTexture::WrapMode wrapMode) override;
84 void setVerticalWrapMode(QSGTexture::WrapMode wrapMode) override;
85 void update() override;
86
87 void preprocess() override;
88
89 void paint(QPainter *painter);
90
91 QRectF rect() const;
92
93 const QPixmap &pixmap() const;
94private:
95
96 QRectF m_targetRect;
97 QRectF m_innerTargetRect;
98 QRectF m_innerSourceRect;
99 QRectF m_subSourceRect;
100
101 QPointer<QSGTexture> m_texture;
102 QPixmap m_cachedMirroredPixmap;
103
104 bool m_mirrorHorizontally;
105 bool m_mirrorVertically;
106 bool m_textureIsLayer;
107 bool m_smooth;
108 bool m_tileHorizontal;
109 bool m_tileVertical;
110 bool m_cachedMirroredPixmapIsDirty;
111};
112
113QT_END_NAMESPACE
114
115#endif // QSGSOFTWAREINTERNALIMAGENODE_H
116

source code of qtdeclarative/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode_p.h