OpenCoverage

qquickshape.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quickshapes/qquickshape.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
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#include "qquickshape_p.h"-
41#include "qquickshape_p_p.h"-
42#include "qquickshapegenericrenderer_p.h"-
43#include "qquickshapenvprrenderer_p.h"-
44#include "qquickshapesoftwarerenderer_p.h"-
45#include <private/qsgtexture_p.h>-
46#include <private/qquicksvgparser_p.h>-
47#include <QtGui/private/qdrawhelper_p.h>-
48#include <QOpenGLFunctions>-
49#include <QLoggingCategory>-
50-
51QT_BEGIN_NAMESPACE-
52-
53Q_LOGGING_CATEGORY(QQSHAPE_LOG_TIME_DIRTY_SYNC, "qt.shape.time.sync")
executed 91 times by 2 tests: return category;
Executed by:
  • tst_examples
  • tst_qquickshape
91
54-
55/*!-
56 \qmlmodule QtQuick.Shapes 1.11-
57 \title Qt Quick Shapes QML Types-
58 \ingroup qmlmodules-
59 \brief Provides QML types for drawing stroked and filled shapes.-
60-
61 To use the types in this module, import the module with the following line:-
62-
63 \badcode-
64 import QtQuick.Shapes 1.11-
65 \endcode-
66*/-
67-
68QQuickShapeStrokeFillParams::QQuickShapeStrokeFillParams()-
69 : strokeColor(Qt::white),-
70 strokeWidth(1),-
71 fillColor(Qt::white),-
72 fillRule(QQuickShapePath::OddEvenFill),-
73 joinStyle(QQuickShapePath::BevelJoin),-
74 miterLimit(2),-
75 capStyle(QQuickShapePath::SquareCap),-
76 strokeStyle(QQuickShapePath::SolidLine),-
77 dashOffset(0),-
78 fillGradient(nullptr)-
79{-
80 dashPattern << 4 << 2; // 4 * strokeWidth dash followed by 2 * strokeWidth space-
81}
executed 1072 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
1072
82-
83/*!-
84 \qmltype ShapePath-
85 \instantiates QQuickShapePath-
86 \inqmlmodule QtQuick.Shapes-
87 \ingroup qtquick-paths-
88 \ingroup qtquick-views-
89 \inherits Path-
90 \brief Describes a Path and associated properties for stroking and filling.-
91 \since 5.10-
92-
93 A \l Shape contains one or more ShapePath elements. At least one ShapePath is-
94 necessary in order to have a Shape output anything visible. A ShapePath-
95 itself is a \l Path with additional properties describing the stroking and-
96 filling parameters, such as the stroke width and color, the fill color or-
97 gradient, join and cap styles, and so on. As with ordinary \l Path objects,-
98 ShapePath also contains a list of path elements like \l PathMove, \l PathLine,-
99 \l PathCubic, \l PathQuad, \l PathArc, together with a starting position.-
100-
101 Any property changes in these data sets will be bubble up and change the-
102 output of the Shape. This means that it is simple and easy to change, or-
103 even animate, the starting and ending position, control points, or any-
104 stroke or fill parameters using the usual QML bindings and animation types-
105 like NumberAnimation.-
106-
107 In the following example the line join style changes automatically based on-
108 the value of joinStyleIndex:-
109-
110 \qml-
111 ShapePath {-
112 strokeColor: "black"-
113 strokeWidth: 16-
114 fillColor: "transparent"-
115 capStyle: ShapePath.RoundCap-
116-
117 property int joinStyleIndex: 0-
118-
119 property variant styles: [-
120 ShapePath.BevelJoin,-
121 ShapePath.MiterJoin,-
122 ShapePath.RoundJoin-
123 ]-
124-
125 joinStyle: styles[joinStyleIndex]-
126-
127 startX: 30-
128 startY: 30-
129 PathLine { x: 100; y: 100 }-
130 PathLine { x: 30; y: 100 }-
131 }-
132 \endqml-
133-
134 Once associated with a Shape, here is the output with a joinStyleIndex-
135 of 2 (ShapePath.RoundJoin):-
136-
137 \image visualpath-code-example.png-
138-
139 \sa {Qt Quick Examples - Shapes}, Shape-
140 */-
141-
142QQuickShapePathPrivate::QQuickShapePathPrivate()-
143 : dirty(DirtyAll)-
144{-
145 // Set this QQuickPath to be a ShapePath-
146 isShapePath = true;-
147}
executed 1072 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
1072
148-
149QQuickShapePath::QQuickShapePath(QObject *parent)-
150 : QQuickPath(*(new QQuickShapePathPrivate), parent)-
151{-
152 // The inherited changed() and the shapePathChanged() signals remain-
153 // distinct, and this is intentional. Combining the two is not possible due-
154 // to the difference in semantics and the need to act (see dirty flag-
155 // below) differently on QQuickPath-related changes.-
156-
157 connect(this, &QQuickPath::changed, [this]() {-
158 Q_D(QQuickShapePath);-
159 d->dirty |= QQuickShapePathPrivate::DirtyPath;-
160 emit shapePathChanged();-
161 });
executed 1158 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
1158
162}
executed 1072 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
1072
163-
164QQuickShapePath::~QQuickShapePath()-
165{-
166}-
167-
168/*!-
169 \qmlproperty color QtQuick.Shapes::ShapePath::strokeColor-
170-
171 This property holds the stroking color.-
172-
173 When set to \c transparent, no stroking occurs.-
174-
175 The default value is \c white.-
176 */-
177-
178QColor QQuickShapePath::strokeColor() const-
179{-
180 Q_D(const QQuickShapePath);-
181 return d->sfp.strokeColor;
executed 1053 times by 2 tests: return d->sfp.strokeColor;
Executed by:
  • tst_examples
  • tst_qquickshape
1053
182}-
183-
184void QQuickShapePath::setStrokeColor(const QColor &color)-
185{-
186 Q_D(QQuickShapePath);-
187 if (d->sfp.strokeColor != color) {
d->sfp.strokeColor != colorDescription
TRUEevaluated 410 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
FALSEnever evaluated
0-410
188 d->sfp.strokeColor = color;-
189 d->dirty |= QQuickShapePathPrivate::DirtyStrokeColor;-
190 emit strokeColorChanged();-
191 emit shapePathChanged();-
192 }
executed 410 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
410
193}
executed 410 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
410
194-
195/*!-
196 \qmlproperty color QtQuick.Shapes::ShapePath::strokeWidth-
197-
198 This property holds the stroke width.-
199-
200 When set to a negative value, no stroking occurs.-
201-
202 The default value is 1.-
203 */-
204-
205qreal QQuickShapePath::strokeWidth() const-
206{-
207 Q_D(const QQuickShapePath);-
208 return d->sfp.strokeWidth;
executed 1057 times by 2 tests: return d->sfp.strokeWidth;
Executed by:
  • tst_examples
  • tst_qquickshape
1057
209}-
210-
211void QQuickShapePath::setStrokeWidth(qreal w)-
212{-
213 Q_D(QQuickShapePath);-
214 if (d->sfp.strokeWidth != w) {
d->sfp.strokeWidth != wDescription
TRUEevaluated 1016 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
FALSEevaluated 38 times by 1 test
Evaluated by:
  • tst_examples
38-1016
215 d->sfp.strokeWidth = w;-
216 d->dirty |= QQuickShapePathPrivate::DirtyStrokeWidth;-
217 emit strokeWidthChanged();-
218 emit shapePathChanged();-
219 }
executed 1016 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
1016
220}
executed 1054 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
1054
221-
222/*!-
223 \qmlproperty color QtQuick.Shapes::ShapePath::fillColor-
224-
225 This property holds the fill color.-
226-
227 When set to \c transparent, no filling occurs.-
228-
229 The default value is \c white.-
230 */-
231-
232QColor QQuickShapePath::fillColor() const-
233{-
234 Q_D(const QQuickShapePath);-
235 return d->sfp.fillColor;
executed 1053 times by 2 tests: return d->sfp.fillColor;
Executed by:
  • tst_examples
  • tst_qquickshape
1053
236}-
237-
238void QQuickShapePath::setFillColor(const QColor &color)-
239{-
240 Q_D(QQuickShapePath);-
241 if (d->sfp.fillColor != color) {
d->sfp.fillColor != colorDescription
TRUEevaluated 824 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
FALSEevaluated 224 times by 1 test
Evaluated by:
  • tst_examples
224-824
242 d->sfp.fillColor = color;-
243 d->dirty |= QQuickShapePathPrivate::DirtyFillColor;-
244 emit fillColorChanged();-
245 emit shapePathChanged();-
246 }
executed 824 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
824
247}
executed 1048 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
1048
248-
249/*!-
250 \qmlproperty enumeration QtQuick.Shapes::ShapePath::fillRule-
251-
252 This property holds the fill rule. The default value is-
253 \c ShapePath.OddEvenFill. For an explanation on fill rules, see-
254 QPainterPath::setFillRule().-
255-
256 \value ShapePath.OddEvenFill-
257 Odd-even fill rule.-
258-
259 \value ShapePath.WindingFill-
260 Non-zero winding fill rule.-
261 */-
262-
263QQuickShapePath::FillRule QQuickShapePath::fillRule() const-
264{-
265 Q_D(const QQuickShapePath);-
266 return d->sfp.fillRule;
executed 1057 times by 2 tests: return d->sfp.fillRule;
Executed by:
  • tst_examples
  • tst_qquickshape
1057
267}-
268-
269void QQuickShapePath::setFillRule(FillRule fillRule)-
270{-
271 Q_D(QQuickShapePath);-
272 if (d->sfp.fillRule != fillRule) {
d->sfp.fillRule != fillRuleDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickshape
FALSEnever evaluated
0-2
273 d->sfp.fillRule = fillRule;-
274 d->dirty |= QQuickShapePathPrivate::DirtyFillRule;-
275 emit fillRuleChanged();-
276 emit shapePathChanged();-
277 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickshape
2
278}
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickshape
2
279-
280/*!-
281 \qmlproperty enumeration QtQuick.Shapes::ShapePath::joinStyle-
282-
283 This property defines how joins between two connected lines are drawn. The-
284 default value is \c ShapePath.BevelJoin.-
285-
286 \value ShapePath.MiterJoin-
287 The outer edges of the lines are extended to meet at an angle, and-
288 this area is filled.-
289-
290 \value ShapePath.BevelJoin-
291 The triangular notch between the two lines is filled.-
292-
293 \value ShapePath.RoundJoin-
294 A circular arc between the two lines is filled.-
295 */-
296-
297QQuickShapePath::JoinStyle QQuickShapePath::joinStyle() const-
298{-
299 Q_D(const QQuickShapePath);-
300 return d->sfp.joinStyle;
executed 1053 times by 2 tests: return d->sfp.joinStyle;
Executed by:
  • tst_examples
  • tst_qquickshape
1053
301}-
302-
303void QQuickShapePath::setJoinStyle(JoinStyle style)-
304{-
305 Q_D(QQuickShapePath);-
306 if (d->sfp.joinStyle != style) {
d->sfp.joinStyle != styleDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickshape
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_examples
2-4
307 d->sfp.joinStyle = style;-
308 d->dirty |= QQuickShapePathPrivate::DirtyStyle;-
309 emit joinStyleChanged();-
310 emit shapePathChanged();-
311 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickshape
2
312}
executed 6 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
6
313-
314/*!-
315 \qmlproperty int QtQuick.Shapes::ShapePath::miterLimit-
316-
317 When joinStyle is set to \c ShapePath.MiterJoin, this property-
318 specifies how far the miter join can extend from the join point.-
319-
320 The default value is 2.-
321 */-
322-
323int QQuickShapePath::miterLimit() const-
324{-
325 Q_D(const QQuickShapePath);-
326 return d->sfp.miterLimit;
executed 1053 times by 2 tests: return d->sfp.miterLimit;
Executed by:
  • tst_examples
  • tst_qquickshape
1053
327}-
328-
329void QQuickShapePath::setMiterLimit(int limit)-
330{-
331 Q_D(QQuickShapePath);-
332 if (d->sfp.miterLimit != limit) {
d->sfp.miterLimit != limitDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickshape
FALSEnever evaluated
0-2
333 d->sfp.miterLimit = limit;-
334 d->dirty |= QQuickShapePathPrivate::DirtyStyle;-
335 emit miterLimitChanged();-
336 emit shapePathChanged();-
337 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickshape
2
338}
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickshape
2
339-
340/*!-
341 \qmlproperty enumeration QtQuick.Shapes::ShapePath::capStyle-
342-
343 This property defines how the end points of lines are drawn. The-
344 default value is \c ShapePath.SquareCap.-
345-
346 \value ShapePath.FlatCap-
347 A square line end that does not cover the end point of the line.-
348-
349 \value ShapePath.SquareCap-
350 A square line end that covers the end point and extends beyond it-
351 by half the line width.-
352-
353 \value ShapePath.RoundCap-
354 A rounded line end.-
355 */-
356-
357QQuickShapePath::CapStyle QQuickShapePath::capStyle() const-
358{-
359 Q_D(const QQuickShapePath);-
360 return d->sfp.capStyle;
executed 1053 times by 2 tests: return d->sfp.capStyle;
Executed by:
  • tst_examples
  • tst_qquickshape
1053
361}-
362-
363void QQuickShapePath::setCapStyle(CapStyle style)-
364{-
365 Q_D(QQuickShapePath);-
366 if (d->sfp.capStyle != style) {
d->sfp.capStyle != styleDescription
TRUEevaluated 20 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
FALSEnever evaluated
0-20
367 d->sfp.capStyle = style;-
368 d->dirty |= QQuickShapePathPrivate::DirtyStyle;-
369 emit capStyleChanged();-
370 emit shapePathChanged();-
371 }
executed 20 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
20
372}
executed 20 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
20
373-
374/*!-
375 \qmlproperty enumeration QtQuick.Shapes::ShapePath::strokeStyle-
376-
377 This property defines the style of stroking. The default value is-
378 ShapePath.SolidLine.-
379-
380 \list-
381 \li ShapePath.SolidLine - A plain line.-
382 \li ShapePath.DashLine - Dashes separated by a few pixels.-
383 \endlist-
384 */-
385-
386QQuickShapePath::StrokeStyle QQuickShapePath::strokeStyle() const-
387{-
388 Q_D(const QQuickShapePath);-
389 return d->sfp.strokeStyle;
executed 1055 times by 2 tests: return d->sfp.strokeStyle;
Executed by:
  • tst_examples
  • tst_qquickshape
1055
390}-
391-
392void QQuickShapePath::setStrokeStyle(StrokeStyle style)-
393{-
394 Q_D(QQuickShapePath);-
395 if (d->sfp.strokeStyle != style) {
d->sfp.strokeStyle != styleDescription
TRUEevaluated 38 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
FALSEnever evaluated
0-38
396 d->sfp.strokeStyle = style;-
397 d->dirty |= QQuickShapePathPrivate::DirtyDash;-
398 emit strokeStyleChanged();-
399 emit shapePathChanged();-
400 }
executed 38 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
38
401}
executed 38 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
38
402-
403/*!-
404 \qmlproperty real QtQuick.Shapes::ShapePath::dashOffset-
405-
406 This property defines the starting point on the dash pattern, measured in-
407 units used to specify the dash pattern.-
408-
409 The default value is 0.-
410-
411 \sa QPen::setDashOffset()-
412 */-
413-
414qreal QQuickShapePath::dashOffset() const-
415{-
416 Q_D(const QQuickShapePath);-
417 return d->sfp.dashOffset;
executed 1053 times by 2 tests: return d->sfp.dashOffset;
Executed by:
  • tst_examples
  • tst_qquickshape
1053
418}-
419-
420void QQuickShapePath::setDashOffset(qreal offset)-
421{-
422 Q_D(QQuickShapePath);-
423 if (d->sfp.dashOffset != offset) {
d->sfp.dashOffset != offsetDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickshape
FALSEnever evaluated
0-2
424 d->sfp.dashOffset = offset;-
425 d->dirty |= QQuickShapePathPrivate::DirtyDash;-
426 emit dashOffsetChanged();-
427 emit shapePathChanged();-
428 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickshape
2
429}
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickshape
2
430-
431/*!-
432 \qmlproperty list<real> QtQuick.Shapes::ShapePath::dashPattern-
433-
434 This property defines the dash pattern when ShapePath.strokeStyle is set-
435 to ShapePath.DashLine. The pattern must be specified as an even number of-
436 positive entries where the entries 1, 3, 5... are the dashes and 2, 4,-
437 6... are the spaces. The pattern is specified in units of the pen's width.-
438-
439 The default value is (4, 2), meaning a dash of 4 * ShapePath.strokeWidth-
440 pixels followed by a space of 2 * ShapePath.strokeWidth pixels.-
441-
442 \sa QPen::setDashPattern()-
443 */-
444-
445QVector<qreal> QQuickShapePath::dashPattern() const-
446{-
447 Q_D(const QQuickShapePath);-
448 return d->sfp.dashPattern;
executed 1053 times by 2 tests: return d->sfp.dashPattern;
Executed by:
  • tst_examples
  • tst_qquickshape
1053
449}-
450-
451void QQuickShapePath::setDashPattern(const QVector<qreal> &array)-
452{-
453 Q_D(QQuickShapePath);-
454 if (d->sfp.dashPattern != array) {
d->sfp.dashPattern != arrayDescription
TRUEevaluated 24 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
FALSEnever evaluated
0-24
455 d->sfp.dashPattern = array;-
456 d->dirty |= QQuickShapePathPrivate::DirtyDash;-
457 emit dashPatternChanged();-
458 emit shapePathChanged();-
459 }
executed 24 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
24
460}
executed 24 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
24
461-
462/*!-
463 \qmlproperty ShapeGradient QtQuick.Shapes::ShapePath::fillGradient-
464-
465 This property defines the fill gradient. By default no gradient is enabled-
466 and the value is \c null. In this case the fill uses a solid color based-
467 on the value of ShapePath.fillColor.-
468-
469 When set, ShapePath.fillColor is ignored and filling is done using one of-
470 the ShapeGradient subtypes.-
471-
472 \note The Gradient type cannot be used here. Rather, prefer using one of-
473 the advanced subtypes, like LinearGradient.-
474 */-
475-
476QQuickShapeGradient *QQuickShapePath::fillGradient() const-
477{-
478 Q_D(const QQuickShapePath);-
479 return d->sfp.fillGradient;
executed 1059 times by 2 tests: return d->sfp.fillGradient;
Executed by:
  • tst_examples
  • tst_qquickshape
1059
480}-
481-
482void QQuickShapePath::setFillGradient(QQuickShapeGradient *gradient)-
483{-
484 Q_D(QQuickShapePath);-
485 if (d->sfp.fillGradient != gradient) {
d->sfp.fillGra...nt != gradientDescription
TRUEevaluated 36 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
FALSEnever evaluated
0-36
486 if (d->sfp.fillGradient)
d->sfp.fillGradientDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickshape
FALSEevaluated 34 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
2-34
487 qmlobject_disconnect(d->sfp.fillGradient, QQuickShapeGradient, SIGNAL(updated()),
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickshape
executed 2 times by 1 test: methodIdx = QQuickShapePath::staticMetaObject.indexOfSlot(method+1);
Executed by:
  • tst_qquickshape
never executed: methodIdx = QQuickShapePath::staticMetaObject.indexOfSignal(method+1);
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickshape
signalIdx < 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickshape
FALSEnever evaluated
methodIdx < 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickshape
FALSEnever evaluated
code == 1Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickshape
FALSEnever evaluated
0-2
488 this, QQuickShapePath, SLOT(_q_fillGradientChanged()));-
489 d->sfp.fillGradient = gradient;-
490 if (d->sfp.fillGradient)
d->sfp.fillGradientDescription
TRUEevaluated 34 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickshape
2-34
491 qmlobject_connect(d->sfp.fillGradient, QQuickShapeGradient, SIGNAL(updated()),
executed 4 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
executed 4 times by 2 tests: methodIdx = QQuickShapePath::staticMetaObject.indexOfSlot(method+1);
Executed by:
  • tst_examples
  • tst_qquickshape
never executed: methodIdx = QQuickShapePath::staticMetaObject.indexOfSignal(method+1);
executed 34 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
signalIdx < 0Description
TRUEevaluated 4 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
FALSEevaluated 30 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
methodIdx < 0Description
TRUEevaluated 4 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
FALSEevaluated 30 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
code == 1Description
TRUEevaluated 4 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
FALSEnever evaluated
0-34
492 this, QQuickShapePath, SLOT(_q_fillGradientChanged()));-
493 d->dirty |= QQuickShapePathPrivate::DirtyFillGradient;-
494 emit shapePathChanged();-
495 }
executed 36 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
36
496}
executed 36 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
36
497-
498void QQuickShapePathPrivate::_q_fillGradientChanged()-
499{-
500 Q_Q(QQuickShapePath);-
501 dirty |= DirtyFillGradient;-
502 emit q->shapePathChanged();-
503}
executed 22 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
22
504-
505void QQuickShapePath::resetFillGradient()-
506{-
507 setFillGradient(nullptr);-
508}
never executed: end of block
0
509-
510/*!-
511 \qmltype Shape-
512 \instantiates QQuickShape-
513 \inqmlmodule QtQuick.Shapes-
514 \ingroup qtquick-paths-
515 \ingroup qtquick-views-
516 \inherits Item-
517 \brief Renders a path.-
518 \since 5.10-
519-
520 Renders a path either by generating geometry via QPainterPath and manual-
521 triangulation or by using a GPU vendor extension like-
522 \c{GL_NV_path_rendering}.-
523-
524 This approach is different from rendering shapes via QQuickPaintedItem or-
525 the 2D Canvas because the path never gets rasterized in software.-
526 Therefore Shape is suitable for creating shapes spreading over larger-
527 areas of the screen, avoiding the performance penalty for texture uploads-
528 or framebuffer blits. In addition, the declarative API allows manipulating,-
529 binding to, and even animating the path element properties like starting-
530 and ending position, the control points, and so on.-
531-
532 The types for specifying path elements are shared between \l PathView and-
533 Shape. However, not all Shape implementations support all path-
534 element types, while some may not make sense for PathView. Shape's-
535 currently supported subset is: PathMove, PathLine, PathQuad, PathCubic,-
536 PathArc, and PathSvg.-
537-
538 See \l Path for a detailed overview of the supported path elements.-
539-
540 \qml-
541 Shape {-
542 width: 200-
543 height: 150-
544 anchors.centerIn: parent-
545 ShapePath {-
546 strokeWidth: 4-
547 strokeColor: "red"-
548 fillGradient: LinearGradient {-
549 x1: 20; y1: 20-
550 x2: 180; y2: 130-
551 GradientStop { position: 0; color: "blue" }-
552 GradientStop { position: 0.2; color: "green" }-
553 GradientStop { position: 0.4; color: "red" }-
554 GradientStop { position: 0.6; color: "yellow" }-
555 GradientStop { position: 1; color: "cyan" }-
556 }-
557 strokeStyle: ShapePath.DashLine-
558 dashPattern: [ 1, 4 ]-
559 startX: 20; startY: 20-
560 PathLine { x: 180; y: 130 }-
561 PathLine { x: 20; y: 130 }-
562 PathLine { x: 20; y: 20 }-
563 }-
564 }-
565 \endqml-
566-
567 \image pathitem-code-example.png-
568-
569 Like \l Item, Shape also allows any visual or non-visual objects to be-
570 declared as children. ShapePath objects are handled specially. This is-
571 useful since it allows adding visual items, like \l Rectangle or \l Image,-
572 and non-visual objects, like \l Timer directly as children of Shape.-
573-
574 The following list summarizes the available Shape rendering approaches:-
575-
576 \list-
577-
578 \li When running with the default, OpenGL backend of Qt Quick, both the-
579 generic, triangulation-based and the NVIDIA-specific-
580 \c{GL_NV_path_rendering} methods are available. The choice is made at-
581 runtime, depending on the graphics driver's capabilities. When this is not-
582 desired, applications can force using the generic method by setting the-
583 Shape.vendorExtensionsEnabled property to \c false.-
584-
585 \li The \c software backend is fully supported. The path is rendered via-
586 QPainter::strokePath() and QPainter::fillPath() in this case.-
587-
588 \li The Direct 3D 12 backend is not currently supported.-
589-
590 \li The OpenVG backend is not currently supported.-
591-
592 \endlist-
593-
594 When using Shape, it is important to be aware of potential performance-
595 implications:-
596-
597 \list-
598-
599 \li When the application is running with the generic, triangulation-based-
600 Shape implementation, the geometry generation happens entirely on the-
601 CPU. This is potentially expensive. Changing the set of path elements,-
602 changing the properties of these elements, or changing certain properties-
603 of the Shape itself all lead to retriangulation of the affected paths on-
604 every change. Therefore, applying animation to such properties can affect-
605 performance on less powerful systems.-
606-
607 \li However, the data-driven, declarative nature of the Shape API often-
608 means better cacheability for the underlying CPU and GPU resources. A-
609 property change in one ShapePath will only lead to reprocessing the-
610 affected ShapePath, leaving other parts of the Shape unchanged. Therefore,-
611 a frequently changing property can still result in a lower overall system-
612 load than with imperative painting approaches (for example, QPainter).-
613-
614 \li If animating properties other than stroke and fill colors is a must,-
615 it is recommended to target systems providing \c{GL_NV_path_rendering}-
616 where the cost of property changes is smaller.-
617-
618 \li At the same time, attention must be paid to the number of Shape-
619 elements in the scene, in particular when using this special accelerated-
620 approach for \c{GL_NV_path_rendering}. The way such a Shape item is-
621 represented in the scene graph is different from an ordinary-
622 geometry-based item, and incurs a certain cost when it comes to OpenGL-
623 state changes.-
624-
625 \li As a general rule, scenes should avoid using separate Shape items when-
626 it is not absolutely necessary. Prefer using one Shape item with multiple-
627 ShapePath elements over multiple Shape items. Scenes that cannot avoid-
628 using a large number of individual Shape items should consider setting-
629 Shape.vendorExtensionsEnabled to \c false.-
630 \endlist-
631-
632 \sa {Qt Quick Examples - Shapes}, Path, PathMove, PathLine, PathQuad, PathCubic, PathArc, PathSvg-
633*/-
634-
635QQuickShapePrivate::QQuickShapePrivate()-
636 : effectRefCount(0)-
637{-
638}
executed 112 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
112
639-
640QQuickShapePrivate::~QQuickShapePrivate()-
641{-
642 delete renderer;-
643}
executed 112 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
112
644-
645void QQuickShapePrivate::_q_shapePathChanged()-
646{-
647 Q_Q(QQuickShape);-
648 spChanged = true;-
649 q->polish();-
650}
executed 258 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
258
651-
652void QQuickShapePrivate::setStatus(QQuickShape::Status newStatus)-
653{-
654 Q_Q(QQuickShape);-
655 if (status != newStatus) {
status != newStatusDescription
TRUEevaluated 91 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
FALSEnever evaluated
0-91
656 status = newStatus;-
657 emit q->statusChanged();-
658 }
executed 91 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
91
659}
executed 91 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
91
660-
661struct QQuickShapeResourceInitializer-
662{-
663 QQuickShapeResourceInitializer()-
664 {-
665#if defined(QT_STATIC)-
666 Q_INIT_RESOURCE(qtquickshapes);-
667#endif-
668 }-
669};-
670-
671Q_GLOBAL_STATIC(QQuickShapeResourceInitializer, initQQuickShapeResources)
executed 4 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
executed 4 times by 2 tests: guard.store(QtGlobalStatic::Destroyed);
Executed by:
  • tst_examples
  • tst_qquickshape
executed 112 times by 2 tests: return &holder.value;
Executed by:
  • tst_examples
  • tst_qquickshape
guard.load() =...c::InitializedDescription
TRUEevaluated 4 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
FALSEnever evaluated
0-112
672-
673QQuickShape::QQuickShape(QQuickItem *parent)-
674 : QQuickItem(*(new QQuickShapePrivate), parent)-
675{-
676 initQQuickShapeResources();-
677 setFlag(ItemHasContents);-
678}
executed 112 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
112
679-
680QQuickShape::~QQuickShape()-
681{-
682}-
683-
684/*!-
685 \qmlproperty enumeration QtQuick.Shapes::Shape::rendererType-
686-
687 This property determines which path rendering backend is active.-
688-
689 \value Shape.UnknownRenderer-
690 The renderer is unknown.-
691-
692 \value Shape.GeometryRenderer-
693 The generic, driver independent solution for OpenGL. Uses the same-
694 CPU-based triangulation approach as QPainter's OpenGL 2 paint-
695 engine. This is the default on non-NVIDIA hardware when the default,-
696 OpenGL Qt Quick scenegraph backend is in use.-
697-
698 \value Shape.NvprRenderer-
699 Path items are rendered by performing OpenGL calls using the-
700 \c{GL_NV_path_rendering} extension. This is the default on NVIDIA-
701 hardware when the default, OpenGL Qt Quick scenegraph backend is in-
702 use.-
703-
704 \value Shape.SoftwareRenderer-
705 Pure QPainter drawing using the raster paint engine. This is the-
706 default, and only, option when the Qt Quick scenegraph is running-
707 with the \c software backend.-
708*/-
709-
710QQuickShape::RendererType QQuickShape::rendererType() const-
711{-
712 Q_D(const QQuickShape);-
713 return d->rendererType;
executed 8 times by 2 tests: return d->rendererType;
Executed by:
  • tst_examples
  • tst_qquickshape
8
714}-
715-
716/*!-
717 \qmlproperty bool QtQuick.Shapes::Shape::asynchronous-
718-
719 When rendererType is \c Shape.GeometryRenderer, the input path is-
720 triangulated on the CPU during the polishing phase of the Shape. This is-
721 potentially expensive. To offload this work to separate worker threads,-
722 set this property to \c true.-
723-
724 When enabled, making a Shape visible will not wait for the content to-
725 become available. Instead, the gui/main thread is not blocked and the-
726 results of the path rendering are shown only when all the asynchronous-
727 work has been finished.-
728-
729 The default value is \c false.-
730 */-
731-
732bool QQuickShape::asynchronous() const-
733{-
734 Q_D(const QQuickShape);-
735 return d->async;
executed 4 times by 1 test: return d->async;
Executed by:
  • tst_qquickshape
4
736}-
737-
738void QQuickShape::setAsynchronous(bool async)-
739{-
740 Q_D(QQuickShape);-
741 if (d->async != async) {
d->async != asyncDescription
TRUEevaluated 8 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
FALSEnever evaluated
0-8
742 d->async = async;-
743 emit asynchronousChanged();-
744 if (d->componentComplete)
d->componentCompleteDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickshape
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_examples
4
745 d->_q_shapePathChanged();
executed 4 times by 1 test: d->_q_shapePathChanged();
Executed by:
  • tst_qquickshape
4
746 }
executed 8 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
8
747}
executed 8 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
8
748-
749/*!-
750 \qmlproperty bool QtQuick.Shapes::Shape::vendorExtensionsEnabled-
751-
752 This property controls the usage of non-standard OpenGL extensions like-
753 \c GL_NV_path_rendering. To disable Shape.NvprRenderer and force a uniform-
754 behavior regardless of the graphics card and drivers, set this property to-
755 \c false.-
756-
757 The default value is \c true.-
758 */-
759-
760bool QQuickShape::vendorExtensionsEnabled() const-
761{-
762 Q_D(const QQuickShape);-
763 return d->enableVendorExts;
executed 4 times by 1 test: return d->enableVendorExts;
Executed by:
  • tst_qquickshape
4
764}-
765-
766void QQuickShape::setVendorExtensionsEnabled(bool enable)-
767{-
768 Q_D(QQuickShape);-
769 if (d->enableVendorExts != enable) {
d->enableVendorExts != enableDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_qquickshape
FALSEnever evaluated
0-12
770 d->enableVendorExts = enable;-
771 emit vendorExtensionsEnabledChanged();-
772 }
executed 12 times by 1 test: end of block
Executed by:
  • tst_qquickshape
12
773}
executed 12 times by 1 test: end of block
Executed by:
  • tst_qquickshape
12
774-
775/*!-
776 \qmlproperty enumeration QtQuick.Shapes::Shape::status-
777-
778 This property determines the status of the Shape and is relevant when-
779 Shape.asynchronous is set to \c true.-
780-
781 \value Shape.Null-
782 Not yet initialized.-
783-
784 \value Shape.Ready-
785 The Shape has finished processing.-
786-
787 \value Shape.Processing-
788 The path is being processed.-
789 */-
790-
791QQuickShape::Status QQuickShape::status() const-
792{-
793 Q_D(const QQuickShape);-
794 return d->status;
executed 8 times by 2 tests: return d->status;
Executed by:
  • tst_examples
  • tst_qquickshape
8
795}-
796-
797/*!-
798 \qmlproperty enumeration QtQuick.Shapes::Shape::containsMode-
799 \since QtQuick.Shapes 1.11-
800-
801 This property determines the definition of \l {QQuickItem::contains()}{contains()}-
802 for the Shape. It is useful in case you add-
803 \l {Qt Quick Pointer Handlers QML Types}{Pointer Handlers} and you-
804 want to react only when the mouse or touchpoint is fully inside the Shape.-
805-
806 \value Shape.BoundingRectContains-
807 The default implementation of \l QQuickItem::contains() checks only-
808 whether the given point is inside the rectangular bounding box. This is-
809 the most efficient implementation, which is why it's the default.-
810-
811 \value Shape.FillContains-
812 Check whether the interior (the part that would be filled if you are-
813 rendering it with fill) of any \l ShapePath that makes up this Shape-
814 contains the given point. The more complex and numerous ShapePaths you-
815 add, the less efficient this is to check, which can potentially slow-
816 down event delivery in your application. So it should be used with care.-
817-
818 One way to speed up the \c FillContains check is to generate an approximate-
819 outline with as few points as possible, place that in a transparent Shape-
820 on top, and add your Pointer Handlers to that, so that the containment-
821 check is cheaper during event delivery.-
822*/-
823QQuickShape::ContainsMode QQuickShape::containsMode() const-
824{-
825 Q_D(const QQuickShape);-
826 return d->containsMode;
never executed: return d->containsMode;
0
827}-
828-
829void QQuickShape::setContainsMode(QQuickShape::ContainsMode containsMode)-
830{-
831 Q_D(QQuickShape);-
832 if (d->containsMode == containsMode)
d->containsMod...= containsModeDescription
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_examples
0-8
833 return;
never executed: return;
0
834-
835 d->containsMode = containsMode;-
836 emit containsModeChanged();-
837}
executed 8 times by 1 test: end of block
Executed by:
  • tst_examples
8
838-
839bool QQuickShape::contains(const QPointF &point) const-
840{-
841 Q_D(const QQuickShape);-
842 switch (d->containsMode) {-
843 case BoundingRectContains:
never executed: case BoundingRectContains:
0
844 return QQuickItem::contains(point);
never executed: return QQuickItem::contains(point);
0
845 case FillContains:
never executed: case FillContains:
0
846 for (QQuickShapePath *path : d->sp) {-
847 if (path->path().contains(point))
path->path().contains(point)Description
TRUEnever evaluated
FALSEnever evaluated
0
848 return true;
never executed: return true;
0
849 }
never executed: end of block
0
850 }
never executed: end of block
0
851 return false;
never executed: return false;
0
852}-
853-
854static void vpe_append(QQmlListProperty<QObject> *property, QObject *obj)-
855{-
856 QQuickShape *item = static_cast<QQuickShape *>(property->object);-
857 QQuickShapePrivate *d = QQuickShapePrivate::get(item);-
858 QQuickShapePath *path = qobject_cast<QQuickShapePath *>(obj);-
859 if (path)
pathDescription
TRUEevaluated 1072 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
FALSEevaluated 16 times by 1 test
Evaluated by:
  • tst_examples
16-1072
860 d->sp.append(path);
executed 1072 times by 2 tests: d->sp.append(path);
Executed by:
  • tst_examples
  • tst_qquickshape
1072
861-
862 QQuickItemPrivate::data_append(property, obj);-
863-
864 if (path && d->componentComplete) {
pathDescription
TRUEevaluated 1072 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
FALSEevaluated 16 times by 1 test
Evaluated by:
  • tst_examples
d->componentCompleteDescription
TRUEnever evaluated
FALSEevaluated 1072 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
0-1072
865 QObject::connect(path, SIGNAL(shapePathChanged()), item, SLOT(_q_shapePathChanged()));-
866 d->_q_shapePathChanged();-
867 }
never executed: end of block
0
868}
executed 1088 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
1088
869-
870static void vpe_clear(QQmlListProperty<QObject> *property)-
871{-
872 QQuickShape *item = static_cast<QQuickShape *>(property->object);-
873 QQuickShapePrivate *d = QQuickShapePrivate::get(item);-
874-
875 for (QQuickShapePath *p : d->sp)-
876 QObject::disconnect(p, SIGNAL(shapePathChanged()), item, SLOT(_q_shapePathChanged()));
never executed: QObject::disconnect(p, qFlagLocation("2""shapePathChanged()" "\0" __FILE__ ":" "876"), item, qFlagLocation("1""_q_shapePathChanged()" "\0" __FILE__ ":" "876"));
0
877-
878 d->sp.clear();-
879-
880 QQuickItemPrivate::data_clear(property);-
881-
882 if (d->componentComplete)
d->componentCompleteDescription
TRUEnever evaluated
FALSEnever evaluated
0
883 d->_q_shapePathChanged();
never executed: d->_q_shapePathChanged();
0
884}
never executed: end of block
0
885-
886/*!-
887 \qmlproperty list<Object> QtQuick.Shapes::Shape::data-
888-
889 This property holds the ShapePath objects that define the contents of the-
890 Shape. It can also contain any other type of objects, since Shape, like-
891 Item, allows adding any visual or non-visual objects as children.-
892-
893 \default-
894 */-
895-
896QQmlListProperty<QObject> QQuickShape::data()-
897{-
898 return QQmlListProperty<QObject>(this,
executed 118 times by 2 tests: return QQmlListProperty<QObject>(this, nullptr, vpe_append, QQuickItemPrivate::data_count, QQuickItemPrivate::data_at, vpe_clear);
Executed by:
  • tst_examples
  • tst_qquickshape
118
899 nullptr,
executed 118 times by 2 tests: return QQmlListProperty<QObject>(this, nullptr, vpe_append, QQuickItemPrivate::data_count, QQuickItemPrivate::data_at, vpe_clear);
Executed by:
  • tst_examples
  • tst_qquickshape
118
900 vpe_append,
executed 118 times by 2 tests: return QQmlListProperty<QObject>(this, nullptr, vpe_append, QQuickItemPrivate::data_count, QQuickItemPrivate::data_at, vpe_clear);
Executed by:
  • tst_examples
  • tst_qquickshape
118
901 QQuickItemPrivate::data_count,
executed 118 times by 2 tests: return QQmlListProperty<QObject>(this, nullptr, vpe_append, QQuickItemPrivate::data_count, QQuickItemPrivate::data_at, vpe_clear);
Executed by:
  • tst_examples
  • tst_qquickshape
118
902 QQuickItemPrivate::data_at,
executed 118 times by 2 tests: return QQmlListProperty<QObject>(this, nullptr, vpe_append, QQuickItemPrivate::data_count, QQuickItemPrivate::data_at, vpe_clear);
Executed by:
  • tst_examples
  • tst_qquickshape
118
903 vpe_clear);
executed 118 times by 2 tests: return QQmlListProperty<QObject>(this, nullptr, vpe_append, QQuickItemPrivate::data_count, QQuickItemPrivate::data_at, vpe_clear);
Executed by:
  • tst_examples
  • tst_qquickshape
118
904}-
905-
906void QQuickShape::classBegin()-
907{-
908 QQuickItem::classBegin();-
909}
executed 112 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
112
910-
911void QQuickShape::componentComplete()-
912{-
913 Q_D(QQuickShape);-
914-
915 QQuickItem::componentComplete();-
916-
917 for (QQuickShapePath *p : d->sp)-
918 connect(p, SIGNAL(shapePathChanged()), this, SLOT(_q_shapePathChanged()));
executed 1072 times by 2 tests: connect(p, qFlagLocation("2""shapePathChanged()" "\0" __FILE__ ":" "918"), this, qFlagLocation("1""_q_shapePathChanged()" "\0" __FILE__ ":" "918"));
Executed by:
  • tst_examples
  • tst_qquickshape
1072
919-
920 d->_q_shapePathChanged();-
921}
executed 112 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
112
922-
923void QQuickShape::updatePolish()-
924{-
925 Q_D(QQuickShape);-
926-
927 const int currentEffectRefCount = d->extra.isAllocated() ? d->extra->recursiveEffectRefCount : 0;
d->extra.isAllocated()Description
TRUEevaluated 91 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
FALSEnever evaluated
0-91
928 if (!d->spChanged && currentEffectRefCount <= d->effectRefCount)
!d->spChangedDescription
TRUEnever evaluated
FALSEevaluated 91 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
currentEffectR...effectRefCountDescription
TRUEnever evaluated
FALSEnever evaluated
0-91
929 return;
never executed: return;
0
930-
931 d->spChanged = false;-
932 d->effectRefCount = currentEffectRefCount;-
933-
934 if (!d->renderer) {
!d->rendererDescription
TRUEevaluated 91 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
FALSEnever evaluated
0-91
935 d->createRenderer();-
936 if (!d->renderer)
!d->rendererDescription
TRUEnever evaluated
FALSEevaluated 91 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
0-91
937 return;
never executed: return;
0
938 emit rendererChanged();-
939 }
executed 91 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
91
940-
941 // endSync() is where expensive calculations may happen (or get kicked off-
942 // on worker threads), depending on the backend. Therefore do this only-
943 // when the item is visible.-
944 if (isVisible() || d->effectRefCount > 0)
isVisible()Description
TRUEevaluated 91 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
FALSEnever evaluated
d->effectRefCount > 0Description
TRUEnever evaluated
FALSEnever evaluated
0-91
945 d->sync();
executed 91 times by 2 tests: d->sync();
Executed by:
  • tst_examples
  • tst_qquickshape
91
946-
947 update();-
948}
executed 91 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
91
949-
950void QQuickShape::itemChange(ItemChange change, const ItemChangeData &data)-
951{-
952 Q_D(QQuickShape);-
953-
954 // sync may have been deferred; do it now if the item became visible-
955 if (change == ItemVisibleHasChanged && data.boolValue)
change == Item...ibleHasChangedDescription
TRUEevaluated 82 times by 1 test
Evaluated by:
  • tst_examples
FALSEevaluated 440 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
data.boolValueDescription
TRUEevaluated 40 times by 1 test
Evaluated by:
  • tst_examples
FALSEevaluated 42 times by 1 test
Evaluated by:
  • tst_examples
40-440
956 d->_q_shapePathChanged();
executed 40 times by 1 test: d->_q_shapePathChanged();
Executed by:
  • tst_examples
40
957-
958 QQuickItem::itemChange(change, data);-
959}
executed 522 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
522
960-
961QSGNode *QQuickShape::updatePaintNode(QSGNode *node, UpdatePaintNodeData *)-
962{-
963 // Called on the render thread, with the gui thread blocked. We can now-
964 // safely access gui thread data.-
965-
966 Q_D(QQuickShape);-
967 if (d->renderer) {
d->rendererDescription
TRUEevaluated 91 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
FALSEnever evaluated
0-91
968 if (!node)
!nodeDescription
TRUEevaluated 91 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
FALSEnever evaluated
0-91
969 node = d->createNode();
executed 91 times by 2 tests: node = d->createNode();
Executed by:
  • tst_examples
  • tst_qquickshape
91
970 d->renderer->updateNode();-
971 }
executed 91 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
91
972 return node;
executed 91 times by 2 tests: return node;
Executed by:
  • tst_examples
  • tst_qquickshape
91
973}-
974-
975// the renderer object lives on the gui thread-
976void QQuickShapePrivate::createRenderer()-
977{-
978 Q_Q(QQuickShape);-
979 QSGRendererInterface *ri = q->window()->rendererInterface();-
980 if (!ri)
!riDescription
TRUEnever evaluated
FALSEevaluated 91 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
0-91
981 return;
never executed: return;
0
982-
983 switch (ri->graphicsApi()) {-
984#if QT_CONFIG(opengl)-
985 case QSGRendererInterface::OpenGL:
executed 83 times by 1 test: case QSGRendererInterface::OpenGL:
Executed by:
  • tst_examples
83
986 if (enableVendorExts && QQuickShapeNvprRenderNode::isSupported()) {
enableVendorExtsDescription
TRUEevaluated 83 times by 1 test
Evaluated by:
  • tst_examples
FALSEnever evaluated
QQuickShapeNvp...:isSupported()Description
TRUEnever evaluated
FALSEevaluated 83 times by 1 test
Evaluated by:
  • tst_examples
0-83
987 rendererType = QQuickShape::NvprRenderer;-
988 renderer = new QQuickShapeNvprRenderer;-
989 } else {
never executed: end of block
0
990 rendererType = QQuickShape::GeometryRenderer;-
991 renderer = new QQuickShapeGenericRenderer(q);-
992 }
executed 83 times by 1 test: end of block
Executed by:
  • tst_examples
83
993 break;
executed 83 times by 1 test: break;
Executed by:
  • tst_examples
83
994#endif-
995 case QSGRendererInterface::Software:
executed 8 times by 1 test: case QSGRendererInterface::Software:
Executed by:
  • tst_qquickshape
8
996 rendererType = QQuickShape::SoftwareRenderer;-
997 renderer = new QQuickShapeSoftwareRenderer;-
998 break;
executed 8 times by 1 test: break;
Executed by:
  • tst_qquickshape
8
999 default:
never executed: default:
0
1000 qWarning("No path backend for this graphics API yet");-
1001 break;
never executed: break;
0
1002 }-
1003}-
1004-
1005// the node lives on the render thread-
1006QSGNode *QQuickShapePrivate::createNode()-
1007{-
1008 Q_Q(QQuickShape);-
1009 QSGNode *node = nullptr;-
1010 if (!q->window())
!q->window()Description
TRUEnever evaluated
FALSEevaluated 91 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
0-91
1011 return node;
never executed: return node;
0
1012 QSGRendererInterface *ri = q->window()->rendererInterface();-
1013 if (!ri)
!riDescription
TRUEnever evaluated
FALSEevaluated 91 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
0-91
1014 return node;
never executed: return node;
0
1015-
1016 switch (ri->graphicsApi()) {-
1017#if QT_CONFIG(opengl)-
1018 case QSGRendererInterface::OpenGL:
executed 83 times by 1 test: case QSGRendererInterface::OpenGL:
Executed by:
  • tst_examples
83
1019 if (enableVendorExts && QQuickShapeNvprRenderNode::isSupported()) {
enableVendorExtsDescription
TRUEevaluated 83 times by 1 test
Evaluated by:
  • tst_examples
FALSEnever evaluated
QQuickShapeNvp...:isSupported()Description
TRUEnever evaluated
FALSEevaluated 83 times by 1 test
Evaluated by:
  • tst_examples
0-83
1020 node = new QQuickShapeNvprRenderNode;-
1021 static_cast<QQuickShapeNvprRenderer *>(renderer)->setNode(-
1022 static_cast<QQuickShapeNvprRenderNode *>(node));-
1023 } else {
never executed: end of block
0
1024 node = new QQuickShapeGenericNode;-
1025 static_cast<QQuickShapeGenericRenderer *>(renderer)->setRootNode(-
1026 static_cast<QQuickShapeGenericNode *>(node));-
1027 }
executed 83 times by 1 test: end of block
Executed by:
  • tst_examples
83
1028 break;
executed 83 times by 1 test: break;
Executed by:
  • tst_examples
83
1029#endif-
1030 case QSGRendererInterface::Software:
executed 8 times by 1 test: case QSGRendererInterface::Software:
Executed by:
  • tst_qquickshape
8
1031 node = new QQuickShapeSoftwareRenderNode(q);-
1032 static_cast<QQuickShapeSoftwareRenderer *>(renderer)->setNode(-
1033 static_cast<QQuickShapeSoftwareRenderNode *>(node));-
1034 break;
executed 8 times by 1 test: break;
Executed by:
  • tst_qquickshape
8
1035 default:
never executed: default:
0
1036 qWarning("No path backend for this graphics API yet");-
1037 break;
never executed: break;
0
1038 }-
1039-
1040 return node;
executed 91 times by 2 tests: return node;
Executed by:
  • tst_examples
  • tst_qquickshape
91
1041}-
1042-
1043void QQuickShapePrivate::asyncShapeReady(void *data)-
1044{-
1045 QQuickShapePrivate *self = static_cast<QQuickShapePrivate *>(data);-
1046 self->setStatus(QQuickShape::Ready);-
1047 if (self->syncTimingActive)
self->syncTimingActiveDescription
TRUEnever evaluated
FALSEnever evaluated
0
1048 qDebug("[Shape %p] [%d] [dirty=0x%x] async update took %lld ms",
never executed: QMessageLogger(__FILE__, 1048, __PRETTY_FUNCTION__).debug("[Shape %p] [%d] [dirty=0x%x] async update took %lld ms", self->q_func(), self->syncTimeCounter, self->syncTimingTotalDirty, self->syncTimer.elapsed());
0
1049 self->q_func(), self->syncTimeCounter, self->syncTimingTotalDirty, self->syncTimer.elapsed());
never executed: QMessageLogger(__FILE__, 1048, __PRETTY_FUNCTION__).debug("[Shape %p] [%d] [dirty=0x%x] async update took %lld ms", self->q_func(), self->syncTimeCounter, self->syncTimingTotalDirty, self->syncTimer.elapsed());
0
1050}
never executed: end of block
0
1051-
1052void QQuickShapePrivate::sync()-
1053{-
1054 syncTimingTotalDirty = 0;-
1055 syncTimingActive = QQSHAPE_LOG_TIME_DIRTY_SYNC().isDebugEnabled();-
1056 if (syncTimingActive)
syncTimingActiveDescription
TRUEnever evaluated
FALSEevaluated 91 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
0-91
1057 syncTimer.start();
never executed: syncTimer.start();
0
1058-
1059 const bool useAsync = async && renderer->flags().testFlag(QQuickAbstractPathRenderer::SupportsAsync);
asyncDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_examples
FALSEevaluated 87 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
renderer->flag...SupportsAsync)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_examples
FALSEnever evaluated
0-87
1060 if (useAsync) {
useAsyncDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_examples
FALSEevaluated 87 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
4-87
1061 setStatus(QQuickShape::Processing);-
1062 renderer->setAsyncCallback(asyncShapeReady, this);-
1063 }
executed 4 times by 1 test: end of block
Executed by:
  • tst_examples
4
1064-
1065 const int count = sp.count();-
1066 renderer->beginSync(count);-
1067-
1068 for (int i = 0; i < count; ++i) {
i < countDescription
TRUEevaluated 1051 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
FALSEevaluated 91 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
91-1051
1069 QQuickShapePath *p = sp[i];-
1070 int &dirty(QQuickShapePathPrivate::get(p)->dirty);-
1071 syncTimingTotalDirty |= dirty;-
1072-
1073 if (dirty & QQuickShapePathPrivate::DirtyPath)
dirty & QQuick...ate::DirtyPathDescription
TRUEevaluated 1051 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
FALSEnever evaluated
0-1051
1074 renderer->setPath(i, p);
executed 1051 times by 2 tests: renderer->setPath(i, p);
Executed by:
  • tst_examples
  • tst_qquickshape
1051
1075 if (dirty & QQuickShapePathPrivate::DirtyStrokeColor)
dirty & QQuick...rtyStrokeColorDescription
TRUEevaluated 1051 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
FALSEnever evaluated
0-1051
1076 renderer->setStrokeColor(i, p->strokeColor());
executed 1051 times by 2 tests: renderer->setStrokeColor(i, p->strokeColor());
Executed by:
  • tst_examples
  • tst_qquickshape
1051
1077 if (dirty & QQuickShapePathPrivate::DirtyStrokeWidth)
dirty & QQuick...rtyStrokeWidthDescription
TRUEevaluated 1051 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
FALSEnever evaluated
0-1051
1078 renderer->setStrokeWidth(i, p->strokeWidth());
executed 1051 times by 2 tests: renderer->setStrokeWidth(i, p->strokeWidth());
Executed by:
  • tst_examples
  • tst_qquickshape
1051
1079 if (dirty & QQuickShapePathPrivate::DirtyFillColor)
dirty & QQuick...DirtyFillColorDescription
TRUEevaluated 1051 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
FALSEnever evaluated
0-1051
1080 renderer->setFillColor(i, p->fillColor());
executed 1051 times by 2 tests: renderer->setFillColor(i, p->fillColor());
Executed by:
  • tst_examples
  • tst_qquickshape
1051
1081 if (dirty & QQuickShapePathPrivate::DirtyFillRule)
dirty & QQuick...:DirtyFillRuleDescription
TRUEevaluated 1051 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
FALSEnever evaluated
0-1051
1082 renderer->setFillRule(i, p->fillRule());
executed 1051 times by 2 tests: renderer->setFillRule(i, p->fillRule());
Executed by:
  • tst_examples
  • tst_qquickshape
1051
1083 if (dirty & QQuickShapePathPrivate::DirtyStyle) {
dirty & QQuick...te::DirtyStyleDescription
TRUEevaluated 1051 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
FALSEnever evaluated
0-1051
1084 renderer->setJoinStyle(i, p->joinStyle(), p->miterLimit());-
1085 renderer->setCapStyle(i, p->capStyle());-
1086 }
executed 1051 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
1051
1087 if (dirty & QQuickShapePathPrivate::DirtyDash)
dirty & QQuick...ate::DirtyDashDescription
TRUEevaluated 1051 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
FALSEnever evaluated
0-1051
1088 renderer->setStrokeStyle(i, p->strokeStyle(), p->dashOffset(), p->dashPattern());
executed 1051 times by 2 tests: renderer->setStrokeStyle(i, p->strokeStyle(), p->dashOffset(), p->dashPattern());
Executed by:
  • tst_examples
  • tst_qquickshape
1051
1089 if (dirty & QQuickShapePathPrivate::DirtyFillGradient)
dirty & QQuick...tyFillGradientDescription
TRUEevaluated 1051 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
FALSEnever evaluated
0-1051
1090 renderer->setFillGradient(i, p->fillGradient());
executed 1051 times by 2 tests: renderer->setFillGradient(i, p->fillGradient());
Executed by:
  • tst_examples
  • tst_qquickshape
1051
1091-
1092 dirty = 0;-
1093 }
executed 1051 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
1051
1094-
1095 if (syncTimingTotalDirty)
syncTimingTotalDirtyDescription
TRUEevaluated 91 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
FALSEnever evaluated
0-91
1096 ++syncTimeCounter;
executed 91 times by 2 tests: ++syncTimeCounter;
Executed by:
  • tst_examples
  • tst_qquickshape
91
1097 else-
1098 syncTimingActive = false;
never executed: syncTimingActive = false;
0
1099-
1100 renderer->endSync(useAsync);-
1101-
1102 if (!useAsync) {
!useAsyncDescription
TRUEevaluated 87 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_examples
4-87
1103 setStatus(QQuickShape::Ready);-
1104 if (syncTimingActive)
syncTimingActiveDescription
TRUEnever evaluated
FALSEevaluated 87 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
0-87
1105 qDebug("[Shape %p] [%d] [dirty=0x%x] update took %lld ms",
never executed: QMessageLogger(__FILE__, 1105, __PRETTY_FUNCTION__).debug("[Shape %p] [%d] [dirty=0x%x] update took %lld ms", q_func(), syncTimeCounter, syncTimingTotalDirty, syncTimer.elapsed());
0
1106 q_func(), syncTimeCounter, syncTimingTotalDirty, syncTimer.elapsed());
never executed: QMessageLogger(__FILE__, 1105, __PRETTY_FUNCTION__).debug("[Shape %p] [%d] [dirty=0x%x] update took %lld ms", q_func(), syncTimeCounter, syncTimingTotalDirty, syncTimer.elapsed());
0
1107 }
executed 87 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
87
1108}
executed 91 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
91
1109-
1110// ***** gradient support *****-
1111-
1112/*!-
1113 \qmltype ShapeGradient-
1114 \instantiates QQuickShapeGradient-
1115 \inqmlmodule QtQuick.Shapes-
1116 \ingroup qtquick-paths-
1117 \ingroup qtquick-views-
1118 \inherits Gradient-
1119 \brief Base type of Shape fill gradients.-
1120 \since 5.10-
1121-
1122 This is an abstract base class for gradients like LinearGradient and-
1123 cannot be created directly. It extends \l Gradient with properties like the-
1124 spread mode.-
1125 */-
1126-
1127QQuickShapeGradient::QQuickShapeGradient(QObject *parent)-
1128 : QQuickGradient(parent),-
1129 m_spread(PadSpread)-
1130{-
1131}
executed 32 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
32
1132-
1133/*!-
1134 \qmlproperty enumeration QtQuick.Shapes::ShapeGradient::spread-
1135-
1136 Specifies how the area outside the gradient area should be filled. The-
1137 default value is \c ShapeGradient.PadSpread.-
1138-
1139 \value ShapeGradient.PadSpread-
1140 The area is filled with the closest stop color.-
1141-
1142 \value ShapeGradient.RepeatSpread-
1143 The gradient is repeated outside the gradient area.-
1144-
1145 \value ShapeGradient.ReflectSpread-
1146 The gradient is reflected outside the gradient area.-
1147 */-
1148-
1149QQuickShapeGradient::SpreadMode QQuickShapeGradient::spread() const-
1150{-
1151 return m_spread;
executed 29 times by 2 tests: return m_spread;
Executed by:
  • tst_examples
  • tst_qquickshape
29
1152}-
1153-
1154void QQuickShapeGradient::setSpread(SpreadMode mode)-
1155{-
1156 if (m_spread != mode) {
m_spread != modeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1157 m_spread = mode;-
1158 emit spreadChanged();-
1159 emit updated();-
1160 }
never executed: end of block
0
1161}
never executed: end of block
0
1162-
1163/*!-
1164 \qmltype LinearGradient-
1165 \instantiates QQuickShapeLinearGradient-
1166 \inqmlmodule QtQuick.Shapes-
1167 \ingroup qtquick-paths-
1168 \ingroup qtquick-views-
1169 \inherits ShapeGradient-
1170 \brief Linear gradient.-
1171 \since 5.10-
1172-
1173 Linear gradients interpolate colors between start and end points in Shape-
1174 items. Outside these points the gradient is either padded, reflected or-
1175 repeated depending on the spread type.-
1176-
1177 \note LinearGradient is only supported in combination with Shape items. It-
1178 is not compatible with \l Rectangle, as that only supports \l Gradient.-
1179-
1180 \sa QLinearGradient-
1181 */-
1182-
1183QQuickShapeLinearGradient::QQuickShapeLinearGradient(QObject *parent)-
1184 : QQuickShapeGradient(parent)-
1185{-
1186}
executed 20 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
20
1187-
1188/*!-
1189 \qmlproperty real QtQuick.Shapes::LinearGradient::x1-
1190 \qmlproperty real QtQuick.Shapes::LinearGradient::y1-
1191 \qmlproperty real QtQuick.Shapes::LinearGradient::x2-
1192 \qmlproperty real QtQuick.Shapes::LinearGradient::y2-
1193-
1194 These properties define the start and end points between which color-
1195 interpolation occurs. By default both points are set to (0, 0).-
1196 */-
1197-
1198qreal QQuickShapeLinearGradient::x1() const-
1199{-
1200 return m_start.x();
executed 18 times by 2 tests: return m_start.x();
Executed by:
  • tst_examples
  • tst_qquickshape
18
1201}-
1202-
1203void QQuickShapeLinearGradient::setX1(qreal v)-
1204{-
1205 if (m_start.x() != v) {
m_start.x() != vDescription
TRUEevaluated 10 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
FALSEnever evaluated
0-10
1206 m_start.setX(v);-
1207 emit x1Changed();-
1208 emit updated();-
1209 }
executed 10 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
10
1210}
executed 10 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
10
1211-
1212qreal QQuickShapeLinearGradient::y1() const-
1213{-
1214 return m_start.y();
executed 16 times by 2 tests: return m_start.y();
Executed by:
  • tst_examples
  • tst_qquickshape
16
1215}-
1216-
1217void QQuickShapeLinearGradient::setY1(qreal v)-
1218{-
1219 if (m_start.y() != v) {
m_start.y() != vDescription
TRUEevaluated 14 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
FALSEnever evaluated
0-14
1220 m_start.setY(v);-
1221 emit y1Changed();-
1222 emit updated();-
1223 }
executed 14 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
14
1224}
executed 14 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
14
1225-
1226qreal QQuickShapeLinearGradient::x2() const-
1227{-
1228 return m_end.x();
executed 16 times by 2 tests: return m_end.x();
Executed by:
  • tst_examples
  • tst_qquickshape
16
1229}-
1230-
1231void QQuickShapeLinearGradient::setX2(qreal v)-
1232{-
1233 if (m_end.x() != v) {
m_end.x() != vDescription
TRUEevaluated 12 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
FALSEnever evaluated
0-12
1234 m_end.setX(v);-
1235 emit x2Changed();-
1236 emit updated();-
1237 }
executed 12 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
12
1238}
executed 12 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
12
1239-
1240qreal QQuickShapeLinearGradient::y2() const-
1241{-
1242 return m_end.y();
executed 16 times by 2 tests: return m_end.y();
Executed by:
  • tst_examples
  • tst_qquickshape
16
1243}-
1244-
1245void QQuickShapeLinearGradient::setY2(qreal v)-
1246{-
1247 if (m_end.y() != v) {
m_end.y() != vDescription
TRUEevaluated 20 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
FALSEnever evaluated
0-20
1248 m_end.setY(v);-
1249 emit y2Changed();-
1250 emit updated();-
1251 }
executed 20 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
20
1252}
executed 20 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
20
1253-
1254/*!-
1255 \qmltype RadialGradient-
1256 \instantiates QQuickShapeRadialGradient-
1257 \inqmlmodule QtQuick.Shapes-
1258 \ingroup qtquick-paths-
1259 \ingroup qtquick-views-
1260 \inherits ShapeGradient-
1261 \brief Radial gradient.-
1262 \since 5.10-
1263-
1264 Radial gradients interpolate colors between a focal circle and a center-
1265 circle in Shape items. Points outside the cone defined by the two circles-
1266 will be transparent.-
1267-
1268 Outside the end points the gradient is either padded, reflected or repeated-
1269 depending on the spread type.-
1270-
1271 Below is an example of a simple radial gradient. Here the colors are-
1272 interpolated between the specified point and the end points on a circle-
1273 specified by the radius:-
1274-
1275 \code-
1276 fillGradient: RadialGradient {-
1277 centerX: 50; centerY: 50-
1278 centerRadius: 100-
1279 focalX: centerX; focalY: centerY-
1280 GradientStop { position: 0; color: "blue" }-
1281 GradientStop { position: 0.2; color: "green" }-
1282 GradientStop { position: 0.4; color: "red" }-
1283 GradientStop { position: 0.6; color: "yellow" }-
1284 GradientStop { position: 1; color: "cyan" }-
1285 }-
1286 \endcode-
1287-
1288 \image shape-radial-gradient.png-
1289-
1290 Extended radial gradients, where a separate focal circle is specified, are-
1291 also supported.-
1292-
1293 \note RadialGradient is only supported in combination with Shape items. It-
1294 is not compatible with \l Rectangle, as that only supports \l Gradient.-
1295-
1296 \sa QRadialGradient-
1297 */-
1298-
1299QQuickShapeRadialGradient::QQuickShapeRadialGradient(QObject *parent)-
1300 : QQuickShapeGradient(parent)-
1301{-
1302}
executed 6 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
6
1303-
1304/*!-
1305 \qmlproperty real QtQuick.Shapes::RadialGradient::centerX-
1306 \qmlproperty real QtQuick.Shapes::RadialGradient::centerY-
1307 \qmlproperty real QtQuick.Shapes::RadialGradient::focalX-
1308 \qmlproperty real QtQuick.Shapes::RadialGradient::focalY-
1309-
1310 These properties define the center and focal points. To specify a simple-
1311 radial gradient, set focalX and focalY to the value of centerX and-
1312 centerY, respectively.-
1313 */-
1314-
1315qreal QQuickShapeRadialGradient::centerX() const-
1316{-
1317 return m_centerPoint.x();
executed 6 times by 2 tests: return m_centerPoint.x();
Executed by:
  • tst_examples
  • tst_qquickshape
6
1318}-
1319-
1320void QQuickShapeRadialGradient::setCenterX(qreal v)-
1321{-
1322 if (m_centerPoint.x() != v) {
m_centerPoint.x() != vDescription
TRUEevaluated 6 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
FALSEnever evaluated
0-6
1323 m_centerPoint.setX(v);-
1324 emit centerXChanged();-
1325 emit updated();-
1326 }
executed 6 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
6
1327}
executed 6 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
6
1328-
1329qreal QQuickShapeRadialGradient::centerY() const-
1330{-
1331 return m_centerPoint.y();
executed 6 times by 2 tests: return m_centerPoint.y();
Executed by:
  • tst_examples
  • tst_qquickshape
6
1332}-
1333-
1334void QQuickShapeRadialGradient::setCenterY(qreal v)-
1335{-
1336 if (m_centerPoint.y() != v) {
m_centerPoint.y() != vDescription
TRUEevaluated 6 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
FALSEnever evaluated
0-6
1337 m_centerPoint.setY(v);-
1338 emit centerYChanged();-
1339 emit updated();-
1340 }
executed 6 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
6
1341}
executed 6 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
6
1342-
1343/*!-
1344 \qmlproperty real QtQuick.Shapes::RadialGradient::centerRadius-
1345 \qmlproperty real QtQuick.Shapes::RadialGradient::focalRadius-
1346-
1347 These properties define the center and focal radius. For simple radial-
1348 gradients, focalRadius should be set to \c 0 (the default value).-
1349 */-
1350-
1351qreal QQuickShapeRadialGradient::centerRadius() const-
1352{-
1353 return m_centerRadius;
executed 6 times by 2 tests: return m_centerRadius;
Executed by:
  • tst_examples
  • tst_qquickshape
6
1354}-
1355-
1356void QQuickShapeRadialGradient::setCenterRadius(qreal v)-
1357{-
1358 if (m_centerRadius != v) {
m_centerRadius != vDescription
TRUEevaluated 6 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
FALSEnever evaluated
0-6
1359 m_centerRadius = v;-
1360 emit centerRadiusChanged();-
1361 emit updated();-
1362 }
executed 6 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
6
1363}
executed 6 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
6
1364-
1365qreal QQuickShapeRadialGradient::focalX() const-
1366{-
1367 return m_focalPoint.x();
executed 6 times by 2 tests: return m_focalPoint.x();
Executed by:
  • tst_examples
  • tst_qquickshape
6
1368}-
1369-
1370void QQuickShapeRadialGradient::setFocalX(qreal v)-
1371{-
1372 if (m_focalPoint.x() != v) {
m_focalPoint.x() != vDescription
TRUEevaluated 6 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
FALSEnever evaluated
0-6
1373 m_focalPoint.setX(v);-
1374 emit focalXChanged();-
1375 emit updated();-
1376 }
executed 6 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
6
1377}
executed 6 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
6
1378-
1379qreal QQuickShapeRadialGradient::focalY() const-
1380{-
1381 return m_focalPoint.y();
executed 6 times by 2 tests: return m_focalPoint.y();
Executed by:
  • tst_examples
  • tst_qquickshape
6
1382}-
1383-
1384void QQuickShapeRadialGradient::setFocalY(qreal v)-
1385{-
1386 if (m_focalPoint.y() != v) {
m_focalPoint.y() != vDescription
TRUEevaluated 6 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
FALSEnever evaluated
0-6
1387 m_focalPoint.setY(v);-
1388 emit focalYChanged();-
1389 emit updated();-
1390 }
executed 6 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
6
1391}
executed 6 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
6
1392-
1393qreal QQuickShapeRadialGradient::focalRadius() const-
1394{-
1395 return m_focalRadius;
executed 6 times by 2 tests: return m_focalRadius;
Executed by:
  • tst_examples
  • tst_qquickshape
6
1396}-
1397-
1398void QQuickShapeRadialGradient::setFocalRadius(qreal v)-
1399{-
1400 if (m_focalRadius != v) {
m_focalRadius != vDescription
TRUEevaluated 6 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
FALSEnever evaluated
0-6
1401 m_focalRadius = v;-
1402 emit focalRadiusChanged();-
1403 emit updated();-
1404 }
executed 6 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
6
1405}
executed 6 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
6
1406-
1407/*!-
1408 \qmltype ConicalGradient-
1409 \instantiates QQuickShapeConicalGradient-
1410 \inqmlmodule QtQuick.Shapes-
1411 \ingroup qtquick-paths-
1412 \ingroup qtquick-views-
1413 \inherits ShapeGradient-
1414 \brief Conical gradient.-
1415 \since 5.10-
1416-
1417 Conical gradients interpolate colors counter-clockwise around a center-
1418 point in Shape items.-
1419-
1420 \note The \l{ShapeGradient::spread}{spread mode} setting has no effect for-
1421 conical gradients.-
1422-
1423 \note ConicalGradient is only supported in combination with Shape items. It-
1424 is not compatible with \l Rectangle, as that only supports \l Gradient.-
1425-
1426 \sa QConicalGradient-
1427 */-
1428-
1429QQuickShapeConicalGradient::QQuickShapeConicalGradient(QObject *parent)-
1430 : QQuickShapeGradient(parent)-
1431{-
1432}
executed 6 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
6
1433-
1434/*!-
1435 \qmlproperty real QtQuick.Shapes::ConicalGradient::centerX-
1436 \qmlproperty real QtQuick.Shapes::ConicalGradient::centerY-
1437-
1438 These properties define the center point of the conical gradient.-
1439 */-
1440-
1441qreal QQuickShapeConicalGradient::centerX() const-
1442{-
1443 return m_centerPoint.x();
executed 5 times by 2 tests: return m_centerPoint.x();
Executed by:
  • tst_examples
  • tst_qquickshape
5
1444}-
1445-
1446void QQuickShapeConicalGradient::setCenterX(qreal v)-
1447{-
1448 if (m_centerPoint.x() != v) {
m_centerPoint.x() != vDescription
TRUEevaluated 6 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
FALSEnever evaluated
0-6
1449 m_centerPoint.setX(v);-
1450 emit centerXChanged();-
1451 emit updated();-
1452 }
executed 6 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
6
1453}
executed 6 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
6
1454-
1455qreal QQuickShapeConicalGradient::centerY() const-
1456{-
1457 return m_centerPoint.y();
executed 5 times by 2 tests: return m_centerPoint.y();
Executed by:
  • tst_examples
  • tst_qquickshape
5
1458}-
1459-
1460void QQuickShapeConicalGradient::setCenterY(qreal v)-
1461{-
1462 if (m_centerPoint.y() != v) {
m_centerPoint.y() != vDescription
TRUEevaluated 6 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickshape
FALSEnever evaluated
0-6
1463 m_centerPoint.setY(v);-
1464 emit centerYChanged();-
1465 emit updated();-
1466 }
executed 6 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
6
1467}
executed 6 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
6
1468-
1469/*!-
1470 \qmlproperty real QtQuick.Shapes::ConicalGradient::angle-
1471-
1472 This property defines the start angle for the conical gradient. The value-
1473 is in degrees (0-360).-
1474 */-
1475-
1476qreal QQuickShapeConicalGradient::angle() const-
1477{-
1478 return m_angle;
executed 9 times by 2 tests: return m_angle;
Executed by:
  • tst_examples
  • tst_qquickshape
9
1479}-
1480-
1481void QQuickShapeConicalGradient::setAngle(qreal v)-
1482{-
1483 if (m_angle != v) {
m_angle != vDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickshape
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_examples
2-4
1484 m_angle = v;-
1485 emit angleChanged();-
1486 emit updated();-
1487 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickshape
2
1488}
executed 6 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickshape
6
1489-
1490#if QT_CONFIG(opengl)-
1491-
1492// contexts sharing with each other get the same cache instance-
1493class QQuickShapeGradientCacheWrapper-
1494{-
1495public:-
1496 QQuickShapeGradientCache *get(QOpenGLContext *context)-
1497 {-
1498 return m_resource.value<QQuickShapeGradientCache>(context);
executed 15 times by 1 test: return m_resource.value<QQuickShapeGradientCache>(context);
Executed by:
  • tst_examples
15
1499 }-
1500-
1501private:-
1502 QOpenGLMultiGroupSharedResource m_resource;-
1503};-
1504-
1505QQuickShapeGradientCache *QQuickShapeGradientCache::currentCache()-
1506{-
1507 static QQuickShapeGradientCacheWrapper qt_path_gradient_caches;-
1508 return qt_path_gradient_caches.get(QOpenGLContext::currentContext());
executed 15 times by 1 test: return qt_path_gradient_caches.get(QOpenGLContext::currentContext());
Executed by:
  • tst_examples
15
1509}-
1510-
1511// let QOpenGLContext manage the lifetime of the cached textures-
1512QQuickShapeGradientCache::~QQuickShapeGradientCache()-
1513{-
1514 m_cache.clear();-
1515}
executed 11 times by 1 test: end of block
Executed by:
  • tst_examples
11
1516-
1517void QQuickShapeGradientCache::invalidateResource()-
1518{-
1519 m_cache.clear();-
1520}
executed 11 times by 1 test: end of block
Executed by:
  • tst_examples
11
1521-
1522void QQuickShapeGradientCache::freeResource(QOpenGLContext *)-
1523{-
1524 qDeleteAll(m_cache);-
1525 m_cache.clear();-
1526}
never executed: end of block
0
1527-
1528static void generateGradientColorTable(const QQuickShapeGradientCache::Key &gradient,-
1529 uint *colorTable, int size, float opacity)-
1530{-
1531 int pos = 0;-
1532 const QGradientStops &s = gradient.stops;-
1533 const bool colorInterpolation = true;-
1534-
1535 uint alpha = qRound(opacity * 256);-
1536 uint current_color = ARGB_COMBINE_ALPHA(s[0].second.rgba(), alpha);-
1537 qreal incr = 1.0 / qreal(size);-
1538 qreal fpos = 1.5 * incr;-
1539 colorTable[pos++] = ARGB2RGBA(qPremultiply(current_color));-
1540-
1541 while (fpos <= s.first().first) {
fpos <= s.first().firstDescription
TRUEnever evaluated
FALSEevaluated 15 times by 1 test
Evaluated by:
  • tst_examples
0-15
1542 colorTable[pos] = colorTable[pos - 1];-
1543 pos++;-
1544 fpos += incr;-
1545 }
never executed: end of block
0
1546-
1547 if (colorInterpolation)
colorInterpolationDescription
TRUEevaluated 15 times by 1 test
Evaluated by:
  • tst_examples
FALSEnever evaluated
0-15
1548 current_color = qPremultiply(current_color);
executed 15 times by 1 test: current_color = qPremultiply(current_color);
Executed by:
  • tst_examples
15
1549-
1550 const int sLast = s.size() - 1;-
1551 for (int i = 0; i < sLast; ++i) {
i < sLastDescription
TRUEevaluated 66 times by 1 test
Evaluated by:
  • tst_examples
FALSEevaluated 15 times by 1 test
Evaluated by:
  • tst_examples
15-66
1552 qreal delta = 1/(s[i+1].first - s[i].first);-
1553 uint next_color = ARGB_COMBINE_ALPHA(s[i + 1].second.rgba(), alpha);-
1554 if (colorInterpolation)
colorInterpolationDescription
TRUEevaluated 66 times by 1 test
Evaluated by:
  • tst_examples
FALSEnever evaluated
0-66
1555 next_color = qPremultiply(next_color);
executed 66 times by 1 test: next_color = qPremultiply(next_color);
Executed by:
  • tst_examples
66
1556-
1557 while (fpos < s[i+1].first && pos < size) {
fpos < s[i+1].firstDescription
TRUEevaluated 15345 times by 1 test
Evaluated by:
  • tst_examples
FALSEevaluated 66 times by 1 test
Evaluated by:
  • tst_examples
pos < sizeDescription
TRUEevaluated 15345 times by 1 test
Evaluated by:
  • tst_examples
FALSEnever evaluated
0-15345
1558 int dist = int(256 * ((fpos - s[i].first) * delta));-
1559 int idist = 256 - dist;-
1560 if (colorInterpolation)
colorInterpolationDescription
TRUEevaluated 15345 times by 1 test
Evaluated by:
  • tst_examples
FALSEnever evaluated
0-15345
1561 colorTable[pos] = ARGB2RGBA(INTERPOLATE_PIXEL_256(current_color, idist, next_color, dist));
executed 15345 times by 1 test: colorTable[pos] = ARGB2RGBA(INTERPOLATE_PIXEL_256(current_color, idist, next_color, dist));
Executed by:
  • tst_examples
15345
1562 else-
1563 colorTable[pos] = ARGB2RGBA(qPremultiply(INTERPOLATE_PIXEL_256(current_color, idist, next_color, dist)));
never executed: colorTable[pos] = ARGB2RGBA(qPremultiply(INTERPOLATE_PIXEL_256(current_color, idist, next_color, dist)));
0
1564 ++pos;-
1565 fpos += incr;-
1566 }
executed 15345 times by 1 test: end of block
Executed by:
  • tst_examples
15345
1567 current_color = next_color;-
1568 }
executed 66 times by 1 test: end of block
Executed by:
  • tst_examples
66
1569-
1570 Q_ASSERT(s.size() > 0);-
1571-
1572 uint last_color = ARGB2RGBA(qPremultiply(ARGB_COMBINE_ALPHA(s[sLast].second.rgba(), alpha)));-
1573 for ( ; pos < size; ++pos)
pos < sizeDescription
TRUEnever evaluated
FALSEevaluated 15 times by 1 test
Evaluated by:
  • tst_examples
0-15
1574 colorTable[pos] = last_color;
never executed: colorTable[pos] = last_color;
0
1575-
1576 colorTable[size-1] = last_color;-
1577}
executed 15 times by 1 test: end of block
Executed by:
  • tst_examples
15
1578-
1579QSGTexture *QQuickShapeGradientCache::get(const Key &grad)-
1580{-
1581 QSGPlainTexture *tx = m_cache[grad];-
1582 if (!tx) {
!txDescription
TRUEevaluated 15 times by 1 test
Evaluated by:
  • tst_examples
FALSEnever evaluated
0-15
1583 QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions();-
1584 GLuint id;-
1585 f->glGenTextures(1, &id);-
1586 f->glBindTexture(GL_TEXTURE_2D, id);-
1587 static const uint W = 1024; // texture size is 1024x1-
1588 uint buf[W];-
1589 generateGradientColorTable(grad, buf, W, 1.0f);-
1590 f->glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, W, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, buf);-
1591 tx = new QSGPlainTexture;-
1592 tx->setTextureId(id);-
1593 switch (grad.spread) {-
1594 case QQuickShapeGradient::PadSpread:
executed 12 times by 1 test: case QQuickShapeGradient::PadSpread:
Executed by:
  • tst_examples
12
1595 tx->setHorizontalWrapMode(QSGTexture::ClampToEdge);-
1596 tx->setVerticalWrapMode(QSGTexture::ClampToEdge);-
1597 break;
executed 12 times by 1 test: break;
Executed by:
  • tst_examples
12
1598 case QQuickShapeGradient::RepeatSpread:
executed 3 times by 1 test: case QQuickShapeGradient::RepeatSpread:
Executed by:
  • tst_examples
3
1599 tx->setHorizontalWrapMode(QSGTexture::Repeat);-
1600 tx->setVerticalWrapMode(QSGTexture::Repeat);-
1601 break;
executed 3 times by 1 test: break;
Executed by:
  • tst_examples
3
1602 case QQuickShapeGradient::ReflectSpread:
never executed: case QQuickShapeGradient::ReflectSpread:
0
1603 tx->setHorizontalWrapMode(QSGTexture::MirroredRepeat);-
1604 tx->setVerticalWrapMode(QSGTexture::MirroredRepeat);-
1605 break;
never executed: break;
0
1606 default:
never executed: default:
0
1607 qWarning("Unknown gradient spread mode %d", grad.spread);-
1608 break;
never executed: break;
0
1609 }-
1610 tx->setFiltering(QSGTexture::Linear);-
1611 m_cache[grad] = tx;-
1612 }
executed 15 times by 1 test: end of block
Executed by:
  • tst_examples
15
1613 return tx;
executed 15 times by 1 test: return tx;
Executed by:
  • tst_examples
15
1614}-
1615-
1616#endif // QT_CONFIG(opengl)-
1617-
1618QT_END_NAMESPACE-
1619-
1620#include "moc_qquickshape_p.cpp"-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.0