OpenCoverage

qquickshapesoftwarerenderer.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quickshapes/qquickshapesoftwarerenderer.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 "qquickshapesoftwarerenderer_p.h"-
41#include <private/qquickpath_p_p.h>-
42-
43QT_BEGIN_NAMESPACE-
44-
45void QQuickShapeSoftwareRenderer::beginSync(int totalCount)-
46{-
47 if (m_sp.count() != totalCount) {
m_sp.count() != totalCountDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquickshape
FALSEnever evaluated
0-8
48 m_sp.resize(totalCount);-
49 m_accDirty |= DirtyList;-
50 }
executed 8 times by 1 test: end of block
Executed by:
  • tst_qquickshape
8
51}
executed 8 times by 1 test: end of block
Executed by:
  • tst_qquickshape
8
52-
53void QQuickShapeSoftwareRenderer::setPath(int index, const QQuickPath *path)-
54{-
55 ShapePathGuiData &d(m_sp[index]);-
56 d.path = path ? path->path() : QPainterPath();
pathDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_qquickshape
FALSEnever evaluated
0-12
57 d.dirty |= DirtyPath;-
58 m_accDirty |= DirtyPath;-
59}
executed 12 times by 1 test: end of block
Executed by:
  • tst_qquickshape
12
60-
61void QQuickShapeSoftwareRenderer::setStrokeColor(int index, const QColor &color)-
62{-
63 ShapePathGuiData &d(m_sp[index]);-
64 d.pen.setColor(color);-
65 d.dirty |= DirtyPen;-
66 m_accDirty |= DirtyPen;-
67}
executed 12 times by 1 test: end of block
Executed by:
  • tst_qquickshape
12
68-
69void QQuickShapeSoftwareRenderer::setStrokeWidth(int index, qreal w)-
70{-
71 ShapePathGuiData &d(m_sp[index]);-
72 d.strokeWidth = w;-
73 if (w >= 0.0f)
w >= 0.0fDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_qquickshape
FALSEnever evaluated
0-12
74 d.pen.setWidthF(w);
executed 12 times by 1 test: d.pen.setWidthF(w);
Executed by:
  • tst_qquickshape
12
75 d.dirty |= DirtyPen;-
76 m_accDirty |= DirtyPen;-
77}
executed 12 times by 1 test: end of block
Executed by:
  • tst_qquickshape
12
78-
79void QQuickShapeSoftwareRenderer::setFillColor(int index, const QColor &color)-
80{-
81 ShapePathGuiData &d(m_sp[index]);-
82 d.fillColor = color;-
83 d.brush.setColor(color);-
84 d.dirty |= DirtyBrush;-
85 m_accDirty |= DirtyBrush;-
86}
executed 12 times by 1 test: end of block
Executed by:
  • tst_qquickshape
12
87-
88void QQuickShapeSoftwareRenderer::setFillRule(int index, QQuickShapePath::FillRule fillRule)-
89{-
90 ShapePathGuiData &d(m_sp[index]);-
91 d.fillRule = Qt::FillRule(fillRule);-
92 d.dirty |= DirtyFillRule;-
93 m_accDirty |= DirtyFillRule;-
94}
executed 12 times by 1 test: end of block
Executed by:
  • tst_qquickshape
12
95-
96void QQuickShapeSoftwareRenderer::setJoinStyle(int index, QQuickShapePath::JoinStyle joinStyle, int miterLimit)-
97{-
98 ShapePathGuiData &d(m_sp[index]);-
99 d.pen.setJoinStyle(Qt::PenJoinStyle(joinStyle));-
100 d.pen.setMiterLimit(miterLimit);-
101 d.dirty |= DirtyPen;-
102 m_accDirty |= DirtyPen;-
103}
executed 12 times by 1 test: end of block
Executed by:
  • tst_qquickshape
12
104-
105void QQuickShapeSoftwareRenderer::setCapStyle(int index, QQuickShapePath::CapStyle capStyle)-
106{-
107 ShapePathGuiData &d(m_sp[index]);-
108 d.pen.setCapStyle(Qt::PenCapStyle(capStyle));-
109 d.dirty |= DirtyPen;-
110 m_accDirty |= DirtyPen;-
111}
executed 12 times by 1 test: end of block
Executed by:
  • tst_qquickshape
12
112-
113void QQuickShapeSoftwareRenderer::setStrokeStyle(int index, QQuickShapePath::StrokeStyle strokeStyle,-
114 qreal dashOffset, const QVector<qreal> &dashPattern)-
115{-
116 ShapePathGuiData &d(m_sp[index]);-
117 switch (strokeStyle) {-
118 case QQuickShapePath::SolidLine:
executed 6 times by 1 test: case QQuickShapePath::SolidLine:
Executed by:
  • tst_qquickshape
6
119 d.pen.setStyle(Qt::SolidLine);-
120 break;
executed 6 times by 1 test: break;
Executed by:
  • tst_qquickshape
6
121 case QQuickShapePath::DashLine:
executed 6 times by 1 test: case QQuickShapePath::DashLine:
Executed by:
  • tst_qquickshape
6
122 d.pen.setStyle(Qt::CustomDashLine);-
123 d.pen.setDashPattern(dashPattern);-
124 d.pen.setDashOffset(dashOffset);-
125 break;
executed 6 times by 1 test: break;
Executed by:
  • tst_qquickshape
6
126 default:
never executed: default:
0
127 break;
never executed: break;
0
128 }-
129 d.dirty |= DirtyPen;-
130 m_accDirty |= DirtyPen;-
131}
executed 12 times by 1 test: end of block
Executed by:
  • tst_qquickshape
12
132-
133static inline void setupPainterGradient(QGradient *painterGradient, const QQuickShapeGradient &g)-
134{-
135 painterGradient->setStops(g.gradientStops()); // sorted-
136 switch (g.spread()) {-
137 case QQuickShapeGradient::PadSpread:
executed 8 times by 1 test: case QQuickShapeGradient::PadSpread:
Executed by:
  • tst_qquickshape
8
138 painterGradient->setSpread(QGradient::PadSpread);-
139 break;
executed 8 times by 1 test: break;
Executed by:
  • tst_qquickshape
8
140 case QQuickShapeGradient::RepeatSpread:
never executed: case QQuickShapeGradient::RepeatSpread:
0
141 painterGradient->setSpread(QGradient::RepeatSpread);-
142 break;
never executed: break;
0
143 case QQuickShapeGradient::ReflectSpread:
never executed: case QQuickShapeGradient::ReflectSpread:
0
144 painterGradient->setSpread(QGradient::ReflectSpread);-
145 break;
never executed: break;
0
146 default:
never executed: default:
0
147 break;
never executed: break;
0
148 }-
149}-
150-
151void QQuickShapeSoftwareRenderer::setFillGradient(int index, QQuickShapeGradient *gradient)-
152{-
153 ShapePathGuiData &d(m_sp[index]);-
154 if (QQuickShapeLinearGradient *g = qobject_cast<QQuickShapeLinearGradient *>(gradient)) {
QQuickShapeLin...t *>(gradient)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickshape
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquickshape
4-8
155 QLinearGradient painterGradient(g->x1(), g->y1(), g->x2(), g->y2());-
156 setupPainterGradient(&painterGradient, *g);-
157 d.brush = QBrush(painterGradient);-
158 } else if (QQuickShapeRadialGradient *g = qobject_cast<QQuickShapeRadialGradient *>(gradient)) {
executed 4 times by 1 test: end of block
Executed by:
  • tst_qquickshape
QQuickShapeRad...t *>(gradient)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickshape
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_qquickshape
2-6
159 QRadialGradient painterGradient(g->centerX(), g->centerY(), g->centerRadius(),-
160 g->focalX(), g->focalY(), g->focalRadius());-
161 setupPainterGradient(&painterGradient, *g);-
162 d.brush = QBrush(painterGradient);-
163 } else if (QQuickShapeConicalGradient *g = qobject_cast<QQuickShapeConicalGradient *>(gradient)) {
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickshape
QQuickShapeCon...t *>(gradient)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickshape
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickshape
2-4
164 QConicalGradient painterGradient(g->centerX(), g->centerY(), g->angle());-
165 setupPainterGradient(&painterGradient, *g);-
166 d.brush = QBrush(painterGradient);-
167 } else {
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickshape
2
168 d.brush = QBrush(d.fillColor);-
169 }
executed 4 times by 1 test: end of block
Executed by:
  • tst_qquickshape
4
170 d.dirty |= DirtyBrush;-
171 m_accDirty |= DirtyBrush;-
172}
executed 12 times by 1 test: end of block
Executed by:
  • tst_qquickshape
12
173-
174void QQuickShapeSoftwareRenderer::endSync(bool)-
175{-
176}-
177-
178void QQuickShapeSoftwareRenderer::setNode(QQuickShapeSoftwareRenderNode *node)-
179{-
180 if (m_node != node) {
m_node != nodeDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquickshape
FALSEnever evaluated
0-8
181 m_node = node;-
182 m_accDirty |= DirtyList;-
183 }
executed 8 times by 1 test: end of block
Executed by:
  • tst_qquickshape
8
184}
executed 8 times by 1 test: end of block
Executed by:
  • tst_qquickshape
8
185-
186void QQuickShapeSoftwareRenderer::updateNode()-
187{-
188 if (!m_accDirty)
!m_accDirtyDescription
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquickshape
0-8
189 return;
never executed: return;
0
190-
191 const int count = m_sp.count();-
192 const bool listChanged = m_accDirty & DirtyList;-
193 if (listChanged)
listChangedDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquickshape
FALSEnever evaluated
0-8
194 m_node->m_sp.resize(count);
executed 8 times by 1 test: m_node->m_sp.resize(count);
Executed by:
  • tst_qquickshape
8
195-
196 m_node->m_boundingRect = QRectF();-
197-
198 for (int i = 0; i < count; ++i) {
i < countDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_qquickshape
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquickshape
8-12
199 ShapePathGuiData &src(m_sp[i]);-
200 QQuickShapeSoftwareRenderNode::ShapePathRenderData &dst(m_node->m_sp[i]);-
201-
202 if (listChanged || (src.dirty & DirtyPath)) {
listChangedDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_qquickshape
FALSEnever evaluated
(src.dirty & DirtyPath)Description
TRUEnever evaluated
FALSEnever evaluated
0-12
203 dst.path = src.path;-
204 dst.path.setFillRule(src.fillRule);-
205 }
executed 12 times by 1 test: end of block
Executed by:
  • tst_qquickshape
12
206-
207 if (listChanged || (src.dirty & DirtyFillRule))
listChangedDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_qquickshape
FALSEnever evaluated
(src.dirty & DirtyFillRule)Description
TRUEnever evaluated
FALSEnever evaluated
0-12
208 dst.path.setFillRule(src.fillRule);
executed 12 times by 1 test: dst.path.setFillRule(src.fillRule);
Executed by:
  • tst_qquickshape
12
209-
210 if (listChanged || (src.dirty & DirtyPen)) {
listChangedDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_qquickshape
FALSEnever evaluated
(src.dirty & DirtyPen)Description
TRUEnever evaluated
FALSEnever evaluated
0-12
211 dst.pen = src.pen;-
212 dst.strokeWidth = src.strokeWidth;-
213 }
executed 12 times by 1 test: end of block
Executed by:
  • tst_qquickshape
12
214-
215 if (listChanged || (src.dirty & DirtyBrush))
listChangedDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_qquickshape
FALSEnever evaluated
(src.dirty & DirtyBrush)Description
TRUEnever evaluated
FALSEnever evaluated
0-12
216 dst.brush = src.brush;
executed 12 times by 1 test: dst.brush = src.brush;
Executed by:
  • tst_qquickshape
12
217-
218 src.dirty = 0;-
219-
220 QRectF br = dst.path.boundingRect();-
221 const float sw = qMax(1.0f, dst.strokeWidth);-
222 br.adjust(-sw, -sw, sw, sw);-
223 m_node->m_boundingRect |= br;-
224 }
executed 12 times by 1 test: end of block
Executed by:
  • tst_qquickshape
12
225-
226 m_node->markDirty(QSGNode::DirtyMaterial);-
227 m_accDirty = 0;-
228}
executed 8 times by 1 test: end of block
Executed by:
  • tst_qquickshape
8
229-
230QQuickShapeSoftwareRenderNode::QQuickShapeSoftwareRenderNode(QQuickShape *item)-
231 : m_item(item)-
232{-
233}
executed 8 times by 1 test: end of block
Executed by:
  • tst_qquickshape
8
234-
235QQuickShapeSoftwareRenderNode::~QQuickShapeSoftwareRenderNode()-
236{-
237 releaseResources();-
238}
executed 8 times by 1 test: end of block
Executed by:
  • tst_qquickshape
8
239-
240void QQuickShapeSoftwareRenderNode::releaseResources()-
241{-
242}-
243-
244void QQuickShapeSoftwareRenderNode::render(const RenderState *state)-
245{-
246 if (m_sp.isEmpty())
m_sp.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquickshape
0-8
247 return;
never executed: return;
0
248-
249 QSGRendererInterface *rif = m_item->window()->rendererInterface();-
250 QPainter *p = static_cast<QPainter *>(rif->getResource(m_item->window(), QSGRendererInterface::PainterResource));-
251 Q_ASSERT(p);-
252-
253 const QRegion *clipRegion = state->clipRegion();-
254 if (clipRegion && !clipRegion->isEmpty())
clipRegionDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquickshape
FALSEnever evaluated
!clipRegion->isEmpty()Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquickshape
FALSEnever evaluated
0-8
255 p->setClipRegion(*clipRegion, Qt::ReplaceClip); // must be done before setTransform
executed 8 times by 1 test: p->setClipRegion(*clipRegion, Qt::ReplaceClip);
Executed by:
  • tst_qquickshape
8
256-
257 p->setTransform(matrix()->toTransform());-
258 p->setOpacity(inheritedOpacity());-
259-
260 for (const ShapePathRenderData &d : qAsConst(m_sp)) {-
261 p->setPen(d.strokeWidth >= 0.0f && d.pen.color() != Qt::transparent ? d.pen : Qt::NoPen);-
262 p->setBrush(d.brush.color() != Qt::transparent ? d.brush : Qt::NoBrush);-
263 p->drawPath(d.path);-
264 }
executed 12 times by 1 test: end of block
Executed by:
  • tst_qquickshape
12
265}
executed 8 times by 1 test: end of block
Executed by:
  • tst_qquickshape
8
266-
267QSGRenderNode::StateFlags QQuickShapeSoftwareRenderNode::changedStates() const-
268{-
269 return nullptr;
never executed: return nullptr;
0
270}-
271-
272QSGRenderNode::RenderingFlags QQuickShapeSoftwareRenderNode::flags() const-
273{-
274 return BoundedRectRendering; // avoid fullscreen updates by saying we won't draw outside rect()
executed 16 times by 1 test: return BoundedRectRendering;
Executed by:
  • tst_qquickshape
16
275}-
276-
277QRectF QQuickShapeSoftwareRenderNode::rect() const-
278{-
279 return m_boundingRect;
executed 8 times by 1 test: return m_boundingRect;
Executed by:
  • tst_qquickshape
8
280}-
281-
282QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.0