Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/items/context2d/qquickcontext2d_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 QQUICKCONTEXT2D_P_H | - |
41 | #define QQUICKCONTEXT2D_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 <QtQml/qqml.h> | - |
59 | #include <QtQml/qqmlcomponent.h> | - |
60 | #include <private/qquickcanvascontext_p.h> | - |
61 | #include <private/qquickcanvasitem_p.h> | - |
62 | #include <QtGui/qpainter.h> | - |
63 | #include <QtGui/qpainterpath.h> | - |
64 | #include <QtGui/qoffscreensurface.h> | - |
65 | #include <QtCore/qstring.h> | - |
66 | #include <QtCore/qstack.h> | - |
67 | #include <QtCore/qqueue.h> | - |
68 | #include <private/qv8engine_p.h> | - |
69 | #include <QtCore/QWaitCondition> | - |
70 | - | |
71 | #include <private/qv4value_p.h> | - |
72 | #include <private/qv4persistent_p.h> | - |
73 | - | |
74 | //#define QQUICKCONTEXT2D_DEBUG //enable this for just DEBUG purpose! | - |
75 | - | |
76 | #ifdef QQUICKCONTEXT2D_DEBUG | - |
77 | #include <QElapsedTimer> | - |
78 | #endif | - |
79 | - | |
80 | QT_BEGIN_NAMESPACE | - |
81 | - | |
82 | class QQuickContext2DCommandBuffer; | - |
83 | class QQuickContext2DTexture; | - |
84 | class QQuickPixmap; | - |
85 | class QSGTexture; | - |
86 | class QSurface; | - |
87 | class QOpenGLContext; | - |
88 | - | |
89 | class QQuickContext2D : public QQuickCanvasContext | - |
90 | { | - |
91 | Q_OBJECT | - |
92 | - | |
93 | public: | - |
94 | Q_DISABLE_COPY(QQuickContext2D) | - |
95 | - | |
96 | enum TextBaseLineType { Alphabetic=0, Top, Middle, Bottom, Hanging}; | - |
97 | enum TextAlignType { Start=0, End, Left, Right, Center}; | - |
98 | enum PaintCommand { | - |
99 | Invalid = 0, | - |
100 | UpdateMatrix, | - |
101 | ClearRect, | - |
102 | FillRect, | - |
103 | StrokeRect, | - |
104 | Fill, | - |
105 | Stroke, | - |
106 | Clip, | - |
107 | UpdateBrush, | - |
108 | GlobalAlpha, | - |
109 | GlobalCompositeOperation, | - |
110 | StrokeStyle, | - |
111 | FillStyle, | - |
112 | LineWidth, | - |
113 | LineCap, | - |
114 | LineJoin, | - |
115 | MiterLimit, | - |
116 | ShadowOffsetX, | - |
117 | ShadowOffsetY, | - |
118 | ShadowBlur, | - |
119 | ShadowColor, | - |
120 | Font, | - |
121 | TextBaseline, | - |
122 | TextAlign, | - |
123 | FillText, | - |
124 | StrokeText, | - |
125 | DrawImage, | - |
126 | DrawPixmap, | - |
127 | GetImageData | - |
128 | }; | - |
129 | - | |
130 | struct State { | - |
131 | State() | - |
132 | : strokeStyle(QColor(Qt::black)) | - |
133 | , fillStyle(QColor(Qt::black)) | - |
134 | , fillPatternRepeatX(false) | - |
135 | , fillPatternRepeatY(false) | - |
136 | , strokePatternRepeatX(false) | - |
137 | , strokePatternRepeatY(false) | - |
138 | , invertibleCTM(true) | - |
139 | , clip(false) | - |
140 | , fillRule(Qt::WindingFill) | - |
141 | , globalAlpha(1.0) | - |
142 | , lineWidth(1) | - |
143 | , lineCap(Qt::FlatCap) | - |
144 | , lineJoin(Qt::MiterJoin) | - |
145 | , miterLimit(10) | - |
146 | , shadowOffsetX(0) | - |
147 | , shadowOffsetY(0) | - |
148 | , shadowBlur(0) | - |
149 | , shadowColor(qRgba(0, 0, 0, 0)) | - |
150 | , globalCompositeOperation(QPainter::CompositionMode_SourceOver) | - |
151 | , font(QFont(QLatin1String("sans-serif"))) | - |
152 | , textAlign(QQuickContext2D::Start) | - |
153 | , textBaseline(QQuickContext2D::Alphabetic) | - |
154 | { | - |
155 | font.setPixelSize(10); | - |
156 | } never executed: end of block | 0 |
157 | - | |
158 | QTransform matrix; | - |
159 | QPainterPath clipPath; | - |
160 | QBrush strokeStyle; | - |
161 | QBrush fillStyle; | - |
162 | bool fillPatternRepeatX:1; | - |
163 | bool fillPatternRepeatY:1; | - |
164 | bool strokePatternRepeatX:1; | - |
165 | bool strokePatternRepeatY:1; | - |
166 | bool invertibleCTM:1; | - |
167 | bool clip:1; | - |
168 | Qt::FillRule fillRule; | - |
169 | qreal globalAlpha; | - |
170 | qreal lineWidth; | - |
171 | Qt::PenCapStyle lineCap; | - |
172 | Qt::PenJoinStyle lineJoin; | - |
173 | qreal miterLimit; | - |
174 | qreal shadowOffsetX; | - |
175 | qreal shadowOffsetY; | - |
176 | qreal shadowBlur; | - |
177 | QColor shadowColor; | - |
178 | QPainter::CompositionMode globalCompositeOperation; | - |
179 | QFont font; | - |
180 | QQuickContext2D::TextAlignType textAlign; | - |
181 | QQuickContext2D::TextBaseLineType textBaseline; | - |
182 | }; | - |
183 | - | |
184 | QQuickContext2D(QObject *parent = nullptr); | - |
185 | ~QQuickContext2D(); | - |
186 | - | |
187 | QStringList contextNames() const override; | - |
188 | void init(QQuickCanvasItem *canvasItem, const QVariantMap &args) override; | - |
189 | void prepare(const QSize& canvasSize, const QSize& tileSize, const QRect& canvasWindow, const QRect& dirtyRect, bool smooth, bool antialiasing) override; | - |
190 | void flush() override; | - |
191 | void sync(); | - |
192 | QThread *thread() const { return m_thread; } never executed: return m_thread; | 0 |
193 | QQuickContext2DTexture *texture() const; | - |
194 | QImage toImage(const QRectF& bounds) override; | - |
195 | - | |
196 | QV4::ReturnedValue v4value() const override; | - |
197 | void setV4Engine(QV4::ExecutionEngine *eng) override; | - |
198 | - | |
199 | QQuickCanvasItem* canvas() const { return m_canvas; } never executed: return m_canvas; | 0 |
200 | QQuickContext2DCommandBuffer* buffer() const { return m_buffer; } never executed: return m_buffer; | 0 |
201 | - | |
202 | bool bufferValid() const { return m_buffer != nullptr; } never executed: return m_buffer != nullptr; | 0 |
203 | void popState(); | - |
204 | void pushState(); | - |
205 | void reset(); | - |
206 | - | |
207 | void fill(); | - |
208 | void clip(); | - |
209 | void stroke(); | - |
210 | void fillRect(qreal x, qreal y, qreal w, qreal h); | - |
211 | void strokeRect(qreal x, qreal y, qreal w, qreal h); | - |
212 | void clearRect(qreal x, qreal y, qreal w, qreal h); | - |
213 | void drawText(const QString& text, qreal x, qreal y, bool fill); | - |
214 | - | |
215 | //Transform APIs | - |
216 | void scale(qreal x, qreal y); | - |
217 | void rotate(qreal angle); | - |
218 | void shear(qreal h, qreal v); | - |
219 | void translate(qreal x, qreal y); | - |
220 | void transform(qreal a, qreal b, qreal c, qreal d, qreal e, qreal f); | - |
221 | void setTransform(qreal a, qreal b, qreal c, qreal d, qreal e, qreal f); | - |
222 | - | |
223 | // Path APIs | - |
224 | void beginPath(); | - |
225 | void closePath(); | - |
226 | void moveTo(qreal x, qreal y); | - |
227 | void lineTo(qreal x, qreal y); | - |
228 | void quadraticCurveTo(qreal cpx, qreal cpy, qreal x, qreal y); | - |
229 | void bezierCurveTo(qreal cp1x, qreal cp1y, | - |
230 | qreal cp2x, qreal cp2y, qreal x, qreal y); | - |
231 | void arcTo(qreal x1, qreal y1, qreal x2, qreal y2, qreal radius); | - |
232 | void rect(qreal x, qreal y, qreal w, qreal h); | - |
233 | void roundedRect(qreal x, qreal y,qreal w, qreal h, qreal xr, qreal yr); | - |
234 | void ellipse(qreal x, qreal y,qreal w, qreal h); | - |
235 | void text(const QString& str, qreal x, qreal y); | - |
236 | void arc(qreal x, qreal y, qreal radius, | - |
237 | qreal startAngle, qreal endAngle, | - |
238 | bool anticlockwise); | - |
239 | void addArcTo(const QPointF& p1, const QPointF& p2, float radius); | - |
240 | - | |
241 | bool isPointInPath(qreal x, qreal y) const; | - |
242 | - | |
243 | QPainterPath createTextGlyphs(qreal x, qreal y, const QString& text); | - |
244 | QQmlRefPointer<QQuickCanvasPixmap> createPixmap(const QUrl& url); | - |
245 | - | |
246 | QOpenGLContext *glContext() const { return m_glContext; } never executed: return m_glContext; | 0 |
247 | QSurface *surface() const { return m_surface.data(); } never executed: return m_surface.data(); | 0 |
248 | void setGrabbedImage(const QImage& grab); | - |
249 | - | |
250 | State state; | - |
251 | QStack<QQuickContext2D::State> m_stateStack; | - |
252 | QQuickCanvasItem* m_canvas; | - |
253 | QQuickContext2DCommandBuffer* m_buffer; | - |
254 | QPainterPath m_path; | - |
255 | QV4::PersistentValue m_fillStyle; | - |
256 | QV4::PersistentValue m_strokeStyle; | - |
257 | QV4::PersistentValue m_v4path; | - |
258 | QV4::ExecutionEngine *m_v4engine; | - |
259 | QScopedPointer<QOffscreenSurface> m_surface; | - |
260 | QOpenGLContext *m_glContext; | - |
261 | QV4::PersistentValue m_v4value; | - |
262 | QQuickContext2DTexture *m_texture; | - |
263 | QQuickCanvasItem::RenderTarget m_renderTarget; | - |
264 | QQuickCanvasItem::RenderStrategy m_renderStrategy; | - |
265 | QQueue<QQuickContext2DCommandBuffer*> m_bufferQueue; | - |
266 | QThread *m_thread; | - |
267 | QImage m_grabbedImage; | - |
268 | bool m_grabbed:1; | - |
269 | - | |
270 | static QMutex mutex; | - |
271 | }; | - |
272 | - | |
273 | - | |
274 | QT_END_NAMESPACE | - |
275 | QML_DECLARE_TYPE(QQuickContext2D) | - |
276 | - | |
277 | #endif // QQUICKCONTEXT2D_P_H | - |
Source code | Switch to Preprocessed file |