OpenCoverage

qsgsoftwarerenderablenodeupdater.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenodeupdater.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 "qsgsoftwarerenderablenodeupdater_p.h"-
41-
42#include "qsgabstractsoftwarerenderer_p.h"-
43#include "qsgsoftwareinternalimagenode_p.h"-
44#include "qsgsoftwareinternalrectanglenode_p.h"-
45#include "qsgsoftwareglyphnode_p.h"-
46#include "qsgsoftwarepublicnodes_p.h"-
47#include "qsgsoftwarepainternode_p.h"-
48#include "qsgsoftwarepixmaptexture_p.h"-
49-
50#include <QtQuick/qsgsimplerectnode.h>-
51#include <QtQuick/qsgsimpletexturenode.h>-
52#include <QtQuick/qsgrendernode.h>-
53-
54QT_BEGIN_NAMESPACE-
55-
56QSGSoftwareRenderableNodeUpdater::QSGSoftwareRenderableNodeUpdater(QSGAbstractSoftwareRenderer *renderer)-
57 : m_renderer(renderer)-
58{-
59 m_opacityState.push(1.0f);-
60 // Invalid RectF by default for no clip-
61 m_clipState.push(QRegion());-
62 m_hasClip = false;-
63 m_transformState.push(QTransform());-
64}
executed 8 times by 1 test: end of block
Executed by:
  • tst_qquickshape
8
65-
66QSGSoftwareRenderableNodeUpdater::~QSGSoftwareRenderableNodeUpdater()-
67{-
68-
69}-
70-
71bool QSGSoftwareRenderableNodeUpdater::visit(QSGTransformNode *node)-
72{-
73 m_transformState.push(node->matrix().toTransform() * m_transformState.top());-
74 m_stateMap[node] = currentState(node);-
75 return true;
executed 40 times by 1 test: return true;
Executed by:
  • tst_qquickshape
40
76}-
77-
78void QSGSoftwareRenderableNodeUpdater::endVisit(QSGTransformNode *)-
79{-
80 m_transformState.pop();-
81}
executed 40 times by 1 test: end of block
Executed by:
  • tst_qquickshape
40
82-
83bool QSGSoftwareRenderableNodeUpdater::visit(QSGClipNode *node)-
84{-
85 // Make sure to translate the clip rect into world coordinates-
86 if (m_clipState.count() == 0 || (m_clipState.count() == 1 && m_clipState.top().isNull())) {
m_clipState.count() == 0Description
TRUEnever evaluated
FALSEnever evaluated
m_clipState.count() == 1Description
TRUEnever evaluated
FALSEnever evaluated
m_clipState.top().isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
87 m_clipState.push(m_transformState.top().map(QRegion(node->clipRect().toRect())));-
88 m_hasClip = true;-
89 } else {
never executed: end of block
0
90 const QRegion transformedClipRect = m_transformState.top().map(QRegion(node->clipRect().toRect()));-
91 m_clipState.push(transformedClipRect.intersected(m_clipState.top()));-
92 }
never executed: end of block
0
93 m_stateMap[node] = currentState(node);-
94 return true;
never executed: return true;
0
95}-
96-
97void QSGSoftwareRenderableNodeUpdater::endVisit(QSGClipNode *)-
98{-
99 m_clipState.pop();-
100 if (m_clipState.count() == 0 || (m_clipState.count() == 1 && m_clipState.top().isNull()))
m_clipState.count() == 0Description
TRUEnever evaluated
FALSEnever evaluated
m_clipState.count() == 1Description
TRUEnever evaluated
FALSEnever evaluated
m_clipState.top().isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
101 m_hasClip = false;
never executed: m_hasClip = false;
0
102}
never executed: end of block
0
103-
104bool QSGSoftwareRenderableNodeUpdater::visit(QSGGeometryNode *node)-
105{-
106 if (QSGSimpleRectNode *rectNode = dynamic_cast<QSGSimpleRectNode *>(node)) {
QSGSimpleRectN...tNode *>(node)Description
TRUEnever evaluated
FALSEnever evaluated
0
107 return updateRenderableNode(QSGSoftwareRenderableNode::SimpleRect, rectNode);
never executed: return updateRenderableNode(QSGSoftwareRenderableNode::SimpleRect, rectNode);
0
108 } else if (QSGSimpleTextureNode *tn = dynamic_cast<QSGSimpleTextureNode *>(node)) {
QSGSimpleTextu...eNode *>(node)Description
TRUEnever evaluated
FALSEnever evaluated
0
109 return updateRenderableNode(QSGSoftwareRenderableNode::SimpleTexture, tn);
never executed: return updateRenderableNode(QSGSoftwareRenderableNode::SimpleTexture, tn);
0
110 } else if (QSGNinePatchNode *nn = dynamic_cast<QSGNinePatchNode *>(node)) {
QSGNinePatchNo...hNode *>(node)Description
TRUEnever evaluated
FALSEnever evaluated
0
111 return updateRenderableNode(QSGSoftwareRenderableNode::NinePatch, nn);
never executed: return updateRenderableNode(QSGSoftwareRenderableNode::NinePatch, nn);
0
112 } else if (QSGRectangleNode *rn = dynamic_cast<QSGRectangleNode *>(node)) {
QSGRectangleNo...eNode *>(node)Description
TRUEnever evaluated
FALSEnever evaluated
0
113 return updateRenderableNode(QSGSoftwareRenderableNode::SimpleRectangle, rn);
never executed: return updateRenderableNode(QSGSoftwareRenderableNode::SimpleRectangle, rn);
0
114 } else if (QSGImageNode *n = dynamic_cast<QSGImageNode *>(node)) {
QSGImageNode *...eNode *>(node)Description
TRUEnever evaluated
FALSEnever evaluated
0
115 return updateRenderableNode(QSGSoftwareRenderableNode::SimpleImage, n);
never executed: return updateRenderableNode(QSGSoftwareRenderableNode::SimpleImage, n);
0
116 } else {-
117 // We dont know, so skip-
118 return false;
never executed: return false;
0
119 }-
120}-
121-
122void QSGSoftwareRenderableNodeUpdater::endVisit(QSGGeometryNode *)-
123{-
124}-
125-
126bool QSGSoftwareRenderableNodeUpdater::visit(QSGOpacityNode *node)-
127{-
128 m_opacityState.push(m_opacityState.top() * node->opacity());-
129 m_stateMap[node] = currentState(node);-
130 return true;
never executed: return true;
0
131}-
132-
133void QSGSoftwareRenderableNodeUpdater::endVisit(QSGOpacityNode *)-
134{-
135 m_opacityState.pop();-
136}
never executed: end of block
0
137-
138bool QSGSoftwareRenderableNodeUpdater::visit(QSGInternalImageNode *node)-
139{-
140 return updateRenderableNode(QSGSoftwareRenderableNode::Image, node);
never executed: return updateRenderableNode(QSGSoftwareRenderableNode::Image, node);
0
141}-
142-
143void QSGSoftwareRenderableNodeUpdater::endVisit(QSGInternalImageNode *)-
144{-
145}-
146-
147bool QSGSoftwareRenderableNodeUpdater::visit(QSGPainterNode *node)-
148{-
149 return updateRenderableNode(QSGSoftwareRenderableNode::Painter, node);
never executed: return updateRenderableNode(QSGSoftwareRenderableNode::Painter, node);
0
150}-
151-
152void QSGSoftwareRenderableNodeUpdater::endVisit(QSGPainterNode *)-
153{-
154}-
155-
156bool QSGSoftwareRenderableNodeUpdater::visit(QSGInternalRectangleNode *node)-
157{-
158 return updateRenderableNode(QSGSoftwareRenderableNode::Rectangle, node);
never executed: return updateRenderableNode(QSGSoftwareRenderableNode::Rectangle, node);
0
159}-
160-
161void QSGSoftwareRenderableNodeUpdater::endVisit(QSGInternalRectangleNode *)-
162{-
163}-
164-
165bool QSGSoftwareRenderableNodeUpdater::visit(QSGGlyphNode *node)-
166{-
167 return updateRenderableNode(QSGSoftwareRenderableNode::Glyph, node);
never executed: return updateRenderableNode(QSGSoftwareRenderableNode::Glyph, node);
0
168}-
169-
170void QSGSoftwareRenderableNodeUpdater::endVisit(QSGGlyphNode *)-
171{-
172}-
173-
174bool QSGSoftwareRenderableNodeUpdater::visit(QSGRootNode *node)-
175{-
176 m_stateMap[node] = currentState(node);-
177 return true;
executed 8 times by 1 test: return true;
Executed by:
  • tst_qquickshape
8
178}-
179-
180void QSGSoftwareRenderableNodeUpdater::endVisit(QSGRootNode *)-
181{-
182}-
183-
184#if QT_CONFIG(quick_sprite)-
185bool QSGSoftwareRenderableNodeUpdater::visit(QSGSpriteNode *node)-
186{-
187 return updateRenderableNode(QSGSoftwareRenderableNode::SpriteNode, node);
never executed: return updateRenderableNode(QSGSoftwareRenderableNode::SpriteNode, node);
0
188}-
189-
190void QSGSoftwareRenderableNodeUpdater::endVisit(QSGSpriteNode *)-
191{-
192-
193}-
194#endif-
195-
196bool QSGSoftwareRenderableNodeUpdater::visit(QSGRenderNode *node)-
197{-
198 return updateRenderableNode(QSGSoftwareRenderableNode::RenderNode, node);
executed 8 times by 1 test: return updateRenderableNode(QSGSoftwareRenderableNode::RenderNode, node);
Executed by:
  • tst_qquickshape
8
199}-
200-
201void QSGSoftwareRenderableNodeUpdater::endVisit(QSGRenderNode *)-
202{-
203}-
204-
205void QSGSoftwareRenderableNodeUpdater::updateNodes(QSGNode *node, bool isNodeRemoved)-
206{-
207 m_opacityState.clear();-
208 m_clipState.clear();-
209 m_transformState.clear();-
210-
211 auto parentNode = node->parent();-
212 // If the node was deleted, it will have no parent-
213 // check if the state map has the previous parent-
214 if ((!parentNode || isNodeRemoved ) && m_stateMap.contains(node))
!parentNodeDescription
TRUEevaluated 16 times by 1 test
Evaluated by:
  • tst_qquickshape
FALSEevaluated 72 times by 1 test
Evaluated by:
  • tst_qquickshape
isNodeRemovedDescription
TRUEevaluated 32 times by 1 test
Evaluated by:
  • tst_qquickshape
FALSEevaluated 40 times by 1 test
Evaluated by:
  • tst_qquickshape
m_stateMap.contains(node)Description
TRUEevaluated 40 times by 1 test
Evaluated by:
  • tst_qquickshape
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquickshape
8-72
215 parentNode = m_stateMap[node].parent;
executed 40 times by 1 test: parentNode = m_stateMap[node].parent;
Executed by:
  • tst_qquickshape
40
216-
217 // If we find a parent, use its state for updating the new children-
218 if (parentNode && m_stateMap.contains(parentNode)) {
parentNodeDescription
TRUEevaluated 72 times by 1 test
Evaluated by:
  • tst_qquickshape
FALSEevaluated 16 times by 1 test
Evaluated by:
  • tst_qquickshape
m_stateMap.con...ns(parentNode)Description
TRUEevaluated 72 times by 1 test
Evaluated by:
  • tst_qquickshape
FALSEnever evaluated
0-72
219 auto state = m_stateMap[parentNode];-
220 m_opacityState.push(state.opacity);-
221 m_transformState.push(state.transform);-
222 m_clipState.push(state.clip);-
223 m_hasClip = state.hasClip;-
224 } else {
executed 72 times by 1 test: end of block
Executed by:
  • tst_qquickshape
72
225 // There is no parent, and no previous parent, so likely a root node-
226 m_opacityState.push(1.0f);-
227 m_transformState.push(QTransform());-
228 m_clipState.push(QRegion());-
229 m_hasClip = false;-
230 }
executed 16 times by 1 test: end of block
Executed by:
  • tst_qquickshape
16
231-
232 // If the node is being removed, then cleanup the state data-
233 // Then just visit the children without visiting the now removed node-
234 if (isNodeRemoved) {
isNodeRemovedDescription
TRUEevaluated 40 times by 1 test
Evaluated by:
  • tst_qquickshape
FALSEevaluated 48 times by 1 test
Evaluated by:
  • tst_qquickshape
40-48
235 m_stateMap.remove(node);-
236 return;
executed 40 times by 1 test: return;
Executed by:
  • tst_qquickshape
40
237 }-
238-
239 // Visit the current node itself first-
240 switch (node->type()) {-
241 case QSGNode::ClipNodeType: {
never executed: case QSGNode::ClipNodeType:
0
242 QSGClipNode *c = static_cast<QSGClipNode*>(node);-
243 if (visit(c))
visit(c)Description
TRUEnever evaluated
FALSEnever evaluated
0
244 visitChildren(c);
never executed: visitChildren(c);
0
245 endVisit(c);-
246 break;
never executed: break;
0
247 }-
248 case QSGNode::TransformNodeType: {
executed 32 times by 1 test: case QSGNode::TransformNodeType:
Executed by:
  • tst_qquickshape
32
249 QSGTransformNode *c = static_cast<QSGTransformNode*>(node);-
250 if (visit(c))
visit(c)Description
TRUEevaluated 32 times by 1 test
Evaluated by:
  • tst_qquickshape
FALSEnever evaluated
0-32
251 visitChildren(c);
executed 32 times by 1 test: visitChildren(c);
Executed by:
  • tst_qquickshape
32
252 endVisit(c);-
253 break;
executed 32 times by 1 test: break;
Executed by:
  • tst_qquickshape
32
254 }-
255 case QSGNode::OpacityNodeType: {
never executed: case QSGNode::OpacityNodeType:
0
256 QSGOpacityNode *c = static_cast<QSGOpacityNode*>(node);-
257 if (visit(c))
visit(c)Description
TRUEnever evaluated
FALSEnever evaluated
0
258 visitChildren(c);
never executed: visitChildren(c);
0
259 endVisit(c);-
260 break;
never executed: break;
0
261 }-
262 case QSGNode::GeometryNodeType: {
never executed: case QSGNode::GeometryNodeType:
0
263 if (node->flags() & QSGNode::IsVisitableNode) {
node->flags() ...sVisitableNodeDescription
TRUEnever evaluated
FALSEnever evaluated
0
264 QSGVisitableNode *v = static_cast<QSGVisitableNode*>(node);-
265 v->accept(this);-
266 } else {
never executed: end of block
0
267 QSGGeometryNode *c = static_cast<QSGGeometryNode*>(node);-
268 if (visit(c))
visit(c)Description
TRUEnever evaluated
FALSEnever evaluated
0
269 visitChildren(c);
never executed: visitChildren(c);
0
270 endVisit(c);-
271 }
never executed: end of block
0
272 break;
never executed: break;
0
273 }-
274 case QSGNode::RootNodeType: {
executed 8 times by 1 test: case QSGNode::RootNodeType:
Executed by:
  • tst_qquickshape
8
275 QSGRootNode *root = static_cast<QSGRootNode*>(node);-
276 if (visit(root))
visit(root)Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquickshape
FALSEnever evaluated
0-8
277 visitChildren(root);
executed 8 times by 1 test: visitChildren(root);
Executed by:
  • tst_qquickshape
8
278 endVisit(root);-
279 break;
executed 8 times by 1 test: break;
Executed by:
  • tst_qquickshape
8
280 }-
281 case QSGNode::BasicNodeType: {
never executed: case QSGNode::BasicNodeType:
0
282 visitChildren(node);-
283 break;
never executed: break;
0
284 }-
285 case QSGNode::RenderNodeType: {
executed 8 times by 1 test: case QSGNode::RenderNodeType:
Executed by:
  • tst_qquickshape
8
286 QSGRenderNode *r = static_cast<QSGRenderNode*>(node);-
287 if (visit(r))
visit(r)Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquickshape
FALSEnever evaluated
0-8
288 visitChildren(r);
executed 8 times by 1 test: visitChildren(r);
Executed by:
  • tst_qquickshape
8
289 endVisit(r);-
290 break;
executed 8 times by 1 test: break;
Executed by:
  • tst_qquickshape
8
291 }-
292 default:
never executed: default:
0
293 Q_UNREACHABLE();-
294 break;
never executed: break;
0
295 }-
296}-
297-
298QSGSoftwareRenderableNodeUpdater::NodeState QSGSoftwareRenderableNodeUpdater::currentState(QSGNode *node) const-
299{-
300 NodeState state;-
301 state.opacity = m_opacityState.top();-
302 state.clip = m_clipState.top();-
303 state.hasClip = m_hasClip;-
304 state.transform = m_transformState.top();-
305 state.parent = node->parent();-
306 return state;
executed 56 times by 1 test: return state;
Executed by:
  • tst_qquickshape
56
307}-
308-
309QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.0