Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qquickcontext2dcommandbuffer_p.h
Go to the documentation of this file.
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 QQUICKCONTEXT2DCOMMANDBUFFER_P_H
5#define QQUICKCONTEXT2DCOMMANDBUFFER_P_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/qtquickglobal_p.h>
19
20QT_REQUIRE_CONFIG(quick_canvas);
21
22#include <QtCore/qmutex.h>
23#include "qquickcontext2d_p.h"
24
26
28class QMutex;
29
31{
32public:
35 void reset();
36 void clear();
37
38 inline int size() const { return commands.size(); }
39 inline bool isEmpty() const {return commands.isEmpty(); }
40 inline bool hasNext() const {return cmdIdx < commands.size(); }
41 inline QQuickContext2D::PaintCommand takeNextCommand() { return commands.at(cmdIdx++); }
42
43 inline qreal takeGlobalAlpha() { return takeReal(); }
45 inline QBrush takeStrokeStyle() { return takeBrush(); }
46 inline QBrush takeFillStyle() { return takeBrush(); }
47
48 inline qreal takeLineWidth() { return takeReal(); }
49 inline Qt::PenCapStyle takeLineCap() { return static_cast<Qt::PenCapStyle>(takeInt());}
50 inline Qt::PenJoinStyle takeLineJoin(){ return static_cast<Qt::PenJoinStyle>(takeInt());}
51 inline qreal takeMiterLimit() { return takeReal(); }
52
54 {
56 reals << alpha;
57 }
58
64
65 inline void setStrokeStyle(const QBrush &style, bool repeatX = false, bool repeatY = false)
66 {
68 brushes << style;
69 bools << repeatX << repeatY;
70 }
71
72 inline void drawImage(const QImage& image, const QRectF& sr, const QRectF& dr)
73 {
75 images << image;
76 rects << sr << dr;
77 }
78
79 inline void drawPixmap(QQmlRefPointer<QQuickCanvasPixmap> pixmap, const QRectF& sr, const QRectF& dr)
80 {
82 pixmaps << pixmap;
83 rects << sr << dr;
84 }
85
86 inline qreal takeShadowOffsetX() { return takeReal(); }
87 inline qreal takeShadowOffsetY() { return takeReal(); }
88 inline qreal takeShadowBlur() { return takeReal(); }
89 inline QColor takeShadowColor() { return takeColor(); }
90
91
92 inline void updateMatrix(const QTransform& matrix)
93 {
95 matrixes << matrix;
96 }
97
98 inline void clearRect(const QRectF& r)
99 {
101 rects << r;
102 }
103
104 inline void fillRect(const QRectF& r)
105 {
107 rects << r;
108 }
109
110 inline void strokeRect(const QRectF& r)
111 {
113 p.addRect(r);
114
116 pathes << p;
117 }
118
119
120 inline void fill(const QPainterPath& path)
121 {
123 pathes << path;
124
125 }
126
127 inline void stroke(const QPainterPath& path)
128 {
130 pathes << path;
131 }
132
133 inline void clip(bool enabled, const QPainterPath& path)
134 {
136 bools << enabled;
137 pathes << path;
138 }
139
140
141
142 inline void setFillStyle(const QBrush &style, bool repeatX = false, bool repeatY = false)
143 {
145 brushes << style;
146 bools << repeatX << repeatY;
147 }
148
149
150 inline void setLineWidth( qreal w)
151 {
153 reals << w;
154 }
155
157 {
159 ints << cap;
160 }
161
163 {
165 ints << join;
166 }
167
168 inline void setLineDash(const QVector<qreal> &pattern)
169 {
171 reals << pattern.size();
172 for (qreal r : pattern)
173 reals << r;
174 }
175
177 {
179 reals << offset;
180 }
181
183 {
185 reals << limit;
186 }
187
189 {
191 reals << x;
192 }
193
195 {
197 reals << y;
198 }
199
200 inline void setShadowBlur( qreal b)
201 {
203 reals << b;
204 }
205
206 inline void setShadowColor(const QColor &color)
207 {
209 colors << color;
210 }
211
212 inline QTransform takeMatrix() { return matrixes.at(matrixIdx++); }
213
214 inline QRectF takeRect() { return rects.at(rectIdx++); }
215
216 inline QPainterPath takePath() { return pathes.at(pathIdx++); }
217
218 inline const QImage& takeImage() { return images.at(imageIdx++); }
219 inline QQmlRefPointer<QQuickCanvasPixmap> takePixmap() { return pixmaps.at(pixmapIdx++); }
220
221 inline int takeInt() { return ints.at(intIdx++); }
222 inline bool takeBool() {return bools.at(boolIdx++); }
223 inline qreal takeReal() { return reals.at(realIdx++); }
224 inline QColor takeColor() { return colors.at(colorIdx++); }
225 inline QBrush takeBrush() { return brushes.at(brushIdx++); }
226
227 void replay(QPainter* painter, QQuickContext2D::State& state, const QVector2D &scaleFactor);
228
229private:
230 static QPen makePen(const QQuickContext2D::State& state);
231 void setPainterState(QPainter* painter, const QQuickContext2D::State& state, const QPen& pen);
232 int cmdIdx;
233 int intIdx;
234 int boolIdx;
235 int realIdx;
236 int rectIdx;
237 int colorIdx;
238 int matrixIdx;
239 int brushIdx;
240 int pathIdx;
241 int imageIdx;
242 int pixmapIdx;
243 QVector<QQuickContext2D::PaintCommand> commands;
244
245 QVector<int> ints;
246 QVector<bool> bools;
247 QVector<qreal> reals;
248 QVector<QRectF> rects;
249 QVector<QColor> colors;
250 QVector<QTransform> matrixes;
251 QVector<QBrush> brushes;
252 QVector<QPainterPath> pathes;
253 QVector<QImage> images;
254 QVector<QQmlRefPointer<QQuickCanvasPixmap> > pixmaps;
255 QMutex queueLock;
256};
257
259
260#endif // QQUICKCONTEXT2DCOMMANDBUFFER_P_H
\inmodule QtGui
Definition qbrush.h:30
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
\inmodule QtGui
Definition qimage.h:37
\inmodule QtCore
Definition qmutex.h:281
\inmodule QtGui
void addRect(const QRectF &rect)
Adds the given rectangle to this path as a closed subpath.
The QPainter class performs low-level painting on widgets and other paint devices.
Definition qpainter.h:46
CompositionMode
Defines the modes supported for digital image compositing.
Definition qpainter.h:97
\inmodule QtGui
Definition qpen.h:28
void updateMatrix(const QTransform &matrix)
QQuickContext2D::PaintCommand takeNextCommand()
void setGlobalCompositeOperation(QPainter::CompositionMode cm)
void drawPixmap(QQmlRefPointer< QQuickCanvasPixmap > pixmap, const QRectF &sr, const QRectF &dr)
void setStrokeStyle(const QBrush &style, bool repeatX=false, bool repeatY=false)
void stroke(const QPainterPath &path)
void setFillStyle(const QBrush &style, bool repeatX=false, bool repeatY=false)
void replay(QPainter *painter, QQuickContext2D::State &state, const QVector2D &scaleFactor)
void setLineDash(const QVector< qreal > &pattern)
QQmlRefPointer< QQuickCanvasPixmap > takePixmap()
void clip(bool enabled, const QPainterPath &path)
void drawImage(const QImage &image, const QRectF &sr, const QRectF &dr)
QPainter::CompositionMode takeGlobalCompositeOperation()
\inmodule QtCore\reentrant
Definition qrect.h:484
The QTransform class specifies 2D transformations of a coordinate system.
Definition qtransform.h:20
The QVector2D class represents a vector or vertex in 2D space.
Definition qvectornd.h:31
EGLint EGLint EGLint EGLint int int * ints
else opt state
[0]
Combined button and popup list for selecting options.
PenJoinStyle
PenCapStyle
Definition image.cpp:4
GLboolean GLboolean GLboolean b
GLint GLint GLint GLint GLint x
[0]
GLfloat GLfloat GLfloat w
[0]
GLboolean r
[2]
GLsizei const GLubyte * commands
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLuint color
[2]
GLenum GLuint GLintptr offset
GLint y
GLint limit
GLuint GLenum matrix
GLsizei const GLchar *const * path
GLfloat GLfloat p
[1]
GLfloat GLfloat GLfloat alpha
Definition qopenglext.h:418
GLubyte * pattern
GLenum cap
#define QT_REQUIRE_CONFIG(feature)
double qreal
Definition qtypes.h:187
#define enabled
widget render & pixmap
QPainter painter(this)
[7]