Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/items/context2d/qquickcontext2dcommandbuffer_p.h |
Source code | Switch to Preprocessed file |
Line | Source | Count |
---|---|---|
1 | /**************************************************************************** | - |
2 | ** | - |
3 | ** Copyright (C) 2016 The Qt Company Ltd. | - |
4 | ** Contact: https://www.qt.io/licensing/ | - |
5 | ** | - |
6 | ** This file is part of the QtQuick module of the Qt Toolkit. | - |
7 | ** | - |
8 | ** $QT_BEGIN_LICENSE:LGPL$ | - |
9 | ** Commercial License Usage | - |
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - |
11 | ** accordance with the commercial license agreement provided with the | - |
12 | ** Software or, alternatively, in accordance with the terms contained in | - |
13 | ** a written agreement between you and The Qt Company. For licensing terms | - |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further | - |
15 | ** information use the contact form at https://www.qt.io/contact-us. | - |
16 | ** | - |
17 | ** GNU Lesser General Public License Usage | - |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - |
19 | ** General Public License version 3 as published by the Free Software | - |
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - |
21 | ** packaging of this file. Please review the following information to | - |
22 | ** ensure the GNU Lesser General Public License version 3 requirements | - |
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - |
24 | ** | - |
25 | ** GNU General Public License Usage | - |
26 | ** Alternatively, this file may be used under the terms of the GNU | - |
27 | ** General Public License version 2.0 or (at your option) the GNU General | - |
28 | ** Public license version 3 or any later version approved by the KDE Free | - |
29 | ** Qt Foundation. The licenses are as published by the Free Software | - |
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - |
31 | ** included in the packaging of this file. Please review the following | - |
32 | ** information to ensure the GNU General Public License requirements will | - |
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - |
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - |
35 | ** | - |
36 | ** $QT_END_LICENSE$ | - |
37 | ** | - |
38 | ****************************************************************************/ | - |
39 | - | |
40 | #ifndef QQUICKCONTEXT2DCOMMANDBUFFER_P_H | - |
41 | #define QQUICKCONTEXT2DCOMMANDBUFFER_P_H | - |
42 | - | |
43 | // | - |
44 | // W A R N I N G | - |
45 | // ------------- | - |
46 | // | - |
47 | // This file is not part of the Qt API. It exists purely as an | - |
48 | // implementation detail. This header file may change from version to | - |
49 | // version without notice, or even be removed. | - |
50 | // | - |
51 | // We mean it. | - |
52 | // | - |
53 | - | |
54 | #include <private/qtquickglobal_p.h> | - |
55 | - | |
56 | QT_REQUIRE_CONFIG(quick_canvas); | - |
57 | - | |
58 | #include <QtCore/qmutex.h> | - |
59 | #include "qquickcontext2d_p.h" | - |
60 | - | |
61 | QT_BEGIN_NAMESPACE | - |
62 | - | |
63 | class QQuickCanvasItem; | - |
64 | class QMutex; | - |
65 | - | |
66 | class QQuickContext2DCommandBuffer | - |
67 | { | - |
68 | public: | - |
69 | QQuickContext2DCommandBuffer(); | - |
70 | ~QQuickContext2DCommandBuffer(); | - |
71 | void reset(); | - |
72 | void clear(); | - |
73 | - | |
74 | inline int size() const { return commands.size(); } never executed: return commands.size(); | 0 |
75 | inline bool isEmpty() const {return commands.isEmpty(); } never executed: return commands.isEmpty(); | 0 |
76 | inline bool hasNext() const {return cmdIdx < commands.size(); } never executed: return cmdIdx < commands.size(); | 0 |
77 | inline QQuickContext2D::PaintCommand takeNextCommand() { return commands.at(cmdIdx++); } never executed: return commands.at(cmdIdx++); | 0 |
78 | - | |
79 | inline qreal takeGlobalAlpha() { return takeReal(); } never executed: return takeReal(); | 0 |
80 | inline QPainter::CompositionMode takeGlobalCompositeOperation(){ return static_cast<QPainter::CompositionMode>(takeInt()); } never executed: return static_cast<QPainter::CompositionMode>(takeInt()); | 0 |
81 | inline QBrush takeStrokeStyle() { return takeBrush(); } never executed: return takeBrush(); | 0 |
82 | inline QBrush takeFillStyle() { return takeBrush(); } never executed: return takeBrush(); | 0 |
83 | - | |
84 | inline qreal takeLineWidth() { return takeReal(); } never executed: return takeReal(); | 0 |
85 | inline Qt::PenCapStyle takeLineCap() { return static_cast<Qt::PenCapStyle>(takeInt());} never executed: return static_cast<Qt::PenCapStyle>(takeInt()); | 0 |
86 | inline Qt::PenJoinStyle takeLineJoin(){ return static_cast<Qt::PenJoinStyle>(takeInt());} never executed: return static_cast<Qt::PenJoinStyle>(takeInt()); | 0 |
87 | inline qreal takeMiterLimit() { return takeReal(); } never executed: return takeReal(); | 0 |
88 | - | |
89 | inline void setGlobalAlpha( qreal alpha) | - |
90 | { | - |
91 | commands << QQuickContext2D::GlobalAlpha; | - |
92 | reals << alpha; | - |
93 | } never executed: end of block | 0 |
94 | - | |
95 | inline void setGlobalCompositeOperation(QPainter::CompositionMode cm) | - |
96 | { | - |
97 | commands << QQuickContext2D::GlobalCompositeOperation; | - |
98 | ints << cm; | - |
99 | } never executed: end of block | 0 |
100 | - | |
101 | inline void setStrokeStyle(const QBrush &style, bool repeatX = false, bool repeatY = false) | - |
102 | { | - |
103 | commands << QQuickContext2D::StrokeStyle; | - |
104 | brushes << style; | - |
105 | bools << repeatX << repeatY; | - |
106 | } never executed: end of block | 0 |
107 | - | |
108 | inline void drawImage(const QImage& image, const QRectF& sr, const QRectF& dr) | - |
109 | { | - |
110 | commands << QQuickContext2D::DrawImage; | - |
111 | images << image; | - |
112 | rects << sr << dr; | - |
113 | } never executed: end of block | 0 |
114 | - | |
115 | inline void drawPixmap(QQmlRefPointer<QQuickCanvasPixmap> pixmap, const QRectF& sr, const QRectF& dr) | - |
116 | { | - |
117 | commands << QQuickContext2D::DrawPixmap; | - |
118 | pixmaps << pixmap; | - |
119 | rects << sr << dr; | - |
120 | } never executed: end of block | 0 |
121 | - | |
122 | inline qreal takeShadowOffsetX() { return takeReal(); } never executed: return takeReal(); | 0 |
123 | inline qreal takeShadowOffsetY() { return takeReal(); } never executed: return takeReal(); | 0 |
124 | inline qreal takeShadowBlur() { return takeReal(); } never executed: return takeReal(); | 0 |
125 | inline QColor takeShadowColor() { return takeColor(); } never executed: return takeColor(); | 0 |
126 | - | |
127 | - | |
128 | inline void updateMatrix(const QTransform& matrix) | - |
129 | { | - |
130 | commands << QQuickContext2D::UpdateMatrix; | - |
131 | matrixes << matrix; | - |
132 | } never executed: end of block | 0 |
133 | - | |
134 | inline void clearRect(const QRectF& r) | - |
135 | { | - |
136 | commands << QQuickContext2D::ClearRect; | - |
137 | rects << r; | - |
138 | } never executed: end of block | 0 |
139 | - | |
140 | inline void fillRect(const QRectF& r) | - |
141 | { | - |
142 | commands << QQuickContext2D::FillRect; | - |
143 | rects << r; | - |
144 | } never executed: end of block | 0 |
145 | - | |
146 | inline void strokeRect(const QRectF& r) | - |
147 | { | - |
148 | QPainterPath p; | - |
149 | p.addRect(r); | - |
150 | - | |
151 | commands << QQuickContext2D::Stroke; | - |
152 | pathes << p; | - |
153 | } never executed: end of block | 0 |
154 | - | |
155 | - | |
156 | inline void fill(const QPainterPath& path) | - |
157 | { | - |
158 | commands << QQuickContext2D::Fill; | - |
159 | pathes << path; | - |
160 | - | |
161 | } never executed: end of block | 0 |
162 | - | |
163 | inline void stroke(const QPainterPath& path) | - |
164 | { | - |
165 | commands << QQuickContext2D::Stroke; | - |
166 | pathes << path; | - |
167 | } never executed: end of block | 0 |
168 | - | |
169 | inline void clip(bool enabled, const QPainterPath& path) | - |
170 | { | - |
171 | commands << QQuickContext2D::Clip; | - |
172 | bools << enabled; | - |
173 | pathes << path; | - |
174 | } never executed: end of block | 0 |
175 | - | |
176 | - | |
177 | - | |
178 | inline void setFillStyle(const QBrush &style, bool repeatX = false, bool repeatY = false) | - |
179 | { | - |
180 | commands << QQuickContext2D::FillStyle; | - |
181 | brushes << style; | - |
182 | bools << repeatX << repeatY; | - |
183 | } never executed: end of block | 0 |
184 | - | |
185 | - | |
186 | inline void setLineWidth( qreal w) | - |
187 | { | - |
188 | commands << QQuickContext2D::LineWidth; | - |
189 | reals << w; | - |
190 | } never executed: end of block | 0 |
191 | - | |
192 | inline void setLineCap(Qt::PenCapStyle cap) | - |
193 | { | - |
194 | commands << QQuickContext2D::LineCap; | - |
195 | ints << cap; | - |
196 | } never executed: end of block | 0 |
197 | - | |
198 | inline void setLineJoin(Qt::PenJoinStyle join) | - |
199 | { | - |
200 | commands << QQuickContext2D::LineJoin; | - |
201 | ints << join; | - |
202 | } never executed: end of block | 0 |
203 | - | |
204 | inline void setMiterLimit( qreal limit) | - |
205 | { | - |
206 | commands << QQuickContext2D::MiterLimit; | - |
207 | reals << limit; | - |
208 | } never executed: end of block | 0 |
209 | - | |
210 | inline void setShadowOffsetX( qreal x) | - |
211 | { | - |
212 | commands << QQuickContext2D::ShadowOffsetX; | - |
213 | reals << x; | - |
214 | } never executed: end of block | 0 |
215 | - | |
216 | inline void setShadowOffsetY( qreal y) | - |
217 | { | - |
218 | commands << QQuickContext2D::ShadowOffsetY; | - |
219 | reals << y; | - |
220 | } never executed: end of block | 0 |
221 | - | |
222 | inline void setShadowBlur( qreal b) | - |
223 | { | - |
224 | commands << QQuickContext2D::ShadowBlur; | - |
225 | reals << b; | - |
226 | } never executed: end of block | 0 |
227 | - | |
228 | inline void setShadowColor(const QColor &color) | - |
229 | { | - |
230 | commands << QQuickContext2D::ShadowColor; | - |
231 | colors << color; | - |
232 | } never executed: end of block | 0 |
233 | - | |
234 | inline QTransform takeMatrix() { return matrixes.at(matrixIdx++); } never executed: return matrixes.at(matrixIdx++); | 0 |
235 | - | |
236 | inline QRectF takeRect() { return rects.at(rectIdx++); } never executed: return rects.at(rectIdx++); | 0 |
237 | - | |
238 | inline QPainterPath takePath() { return pathes.at(pathIdx++); } never executed: return pathes.at(pathIdx++); | 0 |
239 | - | |
240 | inline const QImage& takeImage() { return images.at(imageIdx++); } never executed: return images.at(imageIdx++); | 0 |
241 | inline QQmlRefPointer<QQuickCanvasPixmap> takePixmap() { return pixmaps.at(pixmapIdx++); } never executed: return pixmaps.at(pixmapIdx++); | 0 |
242 | - | |
243 | inline int takeInt() { return ints.at(intIdx++); } never executed: return ints.at(intIdx++); | 0 |
244 | inline bool takeBool() {return bools.at(boolIdx++); } never executed: return bools.at(boolIdx++); | 0 |
245 | inline qreal takeReal() { return reals.at(realIdx++); } never executed: return reals.at(realIdx++); | 0 |
246 | inline QColor takeColor() { return colors.at(colorIdx++); } never executed: return colors.at(colorIdx++); | 0 |
247 | inline QBrush takeBrush() { return brushes.at(brushIdx++); } never executed: return brushes.at(brushIdx++); | 0 |
248 | - | |
249 | void replay(QPainter* painter, QQuickContext2D::State& state, const QVector2D &scaleFactor); | - |
250 | - | |
251 | private: | - |
252 | static QPen makePen(const QQuickContext2D::State& state); | - |
253 | void setPainterState(QPainter* painter, const QQuickContext2D::State& state, const QPen& pen); | - |
254 | int cmdIdx; | - |
255 | int intIdx; | - |
256 | int boolIdx; | - |
257 | int realIdx; | - |
258 | int rectIdx; | - |
259 | int colorIdx; | - |
260 | int matrixIdx; | - |
261 | int brushIdx; | - |
262 | int pathIdx; | - |
263 | int imageIdx; | - |
264 | int pixmapIdx; | - |
265 | QVector<QQuickContext2D::PaintCommand> commands; | - |
266 | - | |
267 | QVector<int> ints; | - |
268 | QVector<bool> bools; | - |
269 | QVector<qreal> reals; | - |
270 | QVector<QRectF> rects; | - |
271 | QVector<QColor> colors; | - |
272 | QVector<QTransform> matrixes; | - |
273 | QVector<QBrush> brushes; | - |
274 | QVector<QPainterPath> pathes; | - |
275 | QVector<QImage> images; | - |
276 | QVector<QQmlRefPointer<QQuickCanvasPixmap> > pixmaps; | - |
277 | QMutex queueLock; | - |
278 | }; | - |
279 | - | |
280 | QT_END_NAMESPACE | - |
281 | - | |
282 | #endif // QQUICKCONTEXT2DCOMMANDBUFFER_P_H | - |
Source code | Switch to Preprocessed file |