OpenCoverage

qsgbasicinternalimagenode.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/scenegraph/qsgbasicinternalimagenode.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 "qsgbasicinternalimagenode_p.h"-
41-
42#include <QtCore/qvarlengtharray.h>-
43#include <QtCore/qmath.h>-
44-
45QT_BEGIN_NAMESPACE-
46-
47namespace-
48{-
49 struct SmoothVertex-
50 {-
51 float x, y, u, v;-
52 float dx, dy, du, dv;-
53 };-
54-
55 const QSGGeometry::AttributeSet &smoothAttributeSet()-
56 {-
57 static QSGGeometry::Attribute data[] = {-
58 QSGGeometry::Attribute::createWithAttributeType(0, 2, QSGGeometry::FloatType, QSGGeometry::PositionAttribute),-
59 QSGGeometry::Attribute::createWithAttributeType(1, 2, QSGGeometry::FloatType, QSGGeometry::TexCoordAttribute),-
60 QSGGeometry::Attribute::createWithAttributeType(2, 2, QSGGeometry::FloatType, QSGGeometry::TexCoord1Attribute),-
61 QSGGeometry::Attribute::createWithAttributeType(3, 2, QSGGeometry::FloatType, QSGGeometry::TexCoord2Attribute)-
62 };-
63 static QSGGeometry::AttributeSet attrs = { 4, sizeof(SmoothVertex), data };-
64 return attrs;
never executed: return attrs;
0
65 }-
66}-
67-
68QSGBasicInternalImageNode::QSGBasicInternalImageNode()-
69 : m_innerSourceRect(0, 0, 1, 1)-
70 , m_subSourceRect(0, 0, 1, 1)-
71 , m_antialiasing(false)-
72 , m_mirror(false)-
73 , m_dirtyGeometry(false)-
74 , m_geometry(QSGGeometry::defaultAttributes_TexturedPoint2D(), 4)-
75 , m_dynamicTexture(nullptr)-
76{-
77 setGeometry(&m_geometry);-
78-
79#ifdef QSG_RUNTIME_DESCRIPTION-
80 qsgnode_set_description(this, QLatin1String("internalimage"));-
81#endif-
82}
executed 5189 times by 10 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickitemlayer
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_qquicktext
  • tst_scenegraph
5189
83-
84void QSGBasicInternalImageNode::setTargetRect(const QRectF &rect)-
85{-
86 if (rect == m_targetRect)
rect == m_targetRectDescription
TRUEevaluated 98 times by 2 tests
Evaluated by:
  • tst_qquickanimatedimage
  • tst_qquickitemlayer
FALSEevaluated 5207 times by 10 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickitemlayer
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_qquicktext
  • tst_scenegraph
98-5207
87 return;
executed 98 times by 2 tests: return;
Executed by:
  • tst_qquickanimatedimage
  • tst_qquickitemlayer
98
88 m_targetRect = rect;-
89 m_dirtyGeometry = true;-
90}
executed 5207 times by 10 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickitemlayer
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_qquicktext
  • tst_scenegraph
5207
91-
92void QSGBasicInternalImageNode::setInnerTargetRect(const QRectF &rect)-
93{-
94 if (rect == m_innerTargetRect)
rect == m_innerTargetRectDescription
TRUEevaluated 98 times by 2 tests
Evaluated by:
  • tst_qquickanimatedimage
  • tst_qquickitemlayer
FALSEevaluated 5207 times by 10 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickitemlayer
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_qquicktext
  • tst_scenegraph
98-5207
95 return;
executed 98 times by 2 tests: return;
Executed by:
  • tst_qquickanimatedimage
  • tst_qquickitemlayer
98
96 m_innerTargetRect = rect;-
97 m_dirtyGeometry = true;-
98}
executed 5207 times by 10 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickitemlayer
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_qquicktext
  • tst_scenegraph
5207
99-
100void QSGBasicInternalImageNode::setInnerSourceRect(const QRectF &rect)-
101{-
102 if (rect == m_innerSourceRect)
rect == m_innerSourceRectDescription
TRUEnever evaluated
FALSEevaluated 70 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickborderimage
0-70
103 return;
never executed: return;
0
104 m_innerSourceRect = rect;-
105 m_dirtyGeometry = true;-
106}
executed 70 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickborderimage
70
107-
108void QSGBasicInternalImageNode::setSubSourceRect(const QRectF &rect)-
109{-
110 if (rect == m_subSourceRect)
rect == m_subSourceRectDescription
TRUEevaluated 5129 times by 8 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_scenegraph
FALSEevaluated 26 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickimage
26-5129
111 return;
executed 5129 times by 8 tests: return;
Executed by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_scenegraph
5129
112 m_subSourceRect = rect;-
113 m_dirtyGeometry = true;-
114}
executed 26 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickimage
26
115-
116void QSGBasicInternalImageNode::setTexture(QSGTexture *texture)-
117{-
118 Q_ASSERT(texture);-
119-
120 setMaterialTexture(texture);-
121 updateMaterialBlending();-
122-
123 markDirty(DirtyMaterial);-
124-
125 // Because the texture can be a different part of the atlas, we need to update it...-
126 m_dirtyGeometry = true;-
127}
executed 5245 times by 10 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickitemlayer
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_qquicktext
  • tst_scenegraph
5245
128-
129void QSGBasicInternalImageNode::setAntialiasing(bool antialiasing)-
130{-
131 if (antialiasing == m_antialiasing)
antialiasing == m_antialiasingDescription
TRUEevaluated 5155 times by 8 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_scenegraph
FALSEnever evaluated
0-5155
132 return;
executed 5155 times by 8 tests: return;
Executed by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_scenegraph
5155
133 m_antialiasing = antialiasing;-
134 if (m_antialiasing) {
m_antialiasingDescription
TRUEnever evaluated
FALSEnever evaluated
0
135 setGeometry(new QSGGeometry(smoothAttributeSet(), 0));-
136 setFlag(OwnsGeometry, true);-
137 } else {
never executed: end of block
0
138 setGeometry(&m_geometry);-
139 setFlag(OwnsGeometry, false);-
140 }
never executed: end of block
0
141 updateMaterialAntialiasing();-
142 m_dirtyGeometry = true;-
143}
never executed: end of block
0
144-
145void QSGBasicInternalImageNode::setMirror(bool mirror)-
146{-
147 if (mirror == m_mirror)
mirror == m_mirrorDescription
TRUEevaluated 5133 times by 8 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_scenegraph
FALSEevaluated 22 times by 3 tests
Evaluated by:
  • tst_qquickanimatedimage
  • tst_qquickborderimage
  • tst_qquickimage
22-5133
148 return;
executed 5133 times by 8 tests: return;
Executed by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_scenegraph
5133
149 m_mirror = mirror;-
150 m_dirtyGeometry = true;-
151}
executed 22 times by 3 tests: end of block
Executed by:
  • tst_qquickanimatedimage
  • tst_qquickborderimage
  • tst_qquickimage
22
152-
153-
154void QSGBasicInternalImageNode::update()-
155{-
156 if (m_dirtyGeometry)
m_dirtyGeometryDescription
TRUEevaluated 5249 times by 10 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickitemlayer
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_qquicktext
  • tst_scenegraph
FALSEevaluated 56 times by 1 test
Evaluated by:
  • tst_qquickitemlayer
56-5249
157 updateGeometry();
executed 5249 times by 10 tests: updateGeometry();
Executed by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickitemlayer
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_qquicktext
  • tst_scenegraph
5249
158}
executed 5305 times by 10 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickitemlayer
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_qquicktext
  • tst_scenegraph
5305
159-
160void QSGBasicInternalImageNode::preprocess()-
161{-
162 bool doDirty = false;-
163 QSGDynamicTexture *t = qobject_cast<QSGDynamicTexture *>(materialTexture());-
164 if (t) {
tDescription
TRUEevaluated 126 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickitemlayer
FALSEnever evaluated
0-126
165 doDirty = t->updateTexture();-
166 if (doDirty) {
doDirtyDescription
TRUEevaluated 31 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickitemlayer
FALSEevaluated 95 times by 1 test
Evaluated by:
  • tst_qquickitemlayer
31-95
167 // The geometry may need updating. This is expensive however, so do-
168 // it only when something relevant has changed.-
169 if (t != m_dynamicTexture
t != m_dynamicTextureDescription
TRUEevaluated 31 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickitemlayer
FALSEnever evaluated
0-31
170 || t->textureSize() != m_dynamicTextureSize
t->textureSize...micTextureSizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
171 || t->normalizedTextureSubRect() != m_dynamicTextureSubRect) {
t->normalizedT...TextureSubRectDescription
TRUEnever evaluated
FALSEnever evaluated
0
172 updateGeometry();-
173 m_dynamicTextureSize = t->textureSize();-
174 m_dynamicTextureSubRect = t->normalizedTextureSubRect();-
175 }
executed 31 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickitemlayer
31
176 }
executed 31 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickitemlayer
31
177 }
executed 126 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickitemlayer
126
178 m_dynamicTexture = t;-
179-
180 if (updateMaterialBlending())
updateMaterialBlending()Description
TRUEnever evaluated
FALSEevaluated 126 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickitemlayer
0-126
181 doDirty = true;
never executed: doDirty = true;
0
182-
183 if (doDirty)
doDirtyDescription
TRUEevaluated 31 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickitemlayer
FALSEevaluated 95 times by 1 test
Evaluated by:
  • tst_qquickitemlayer
31-95
184 markDirty(DirtyMaterial);
executed 31 times by 2 tests: markDirty(DirtyMaterial);
Executed by:
  • tst_examples
  • tst_qquickitemlayer
31
185}
executed 126 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickitemlayer
126
186-
187namespace {-
188 struct X { float x, tx; };-
189 struct Y { float y, ty; };-
190}-
191-
192static inline void appendQuad(quint16 **indices, quint16 topLeft, quint16 topRight,-
193 quint16 bottomLeft, quint16 bottomRight)-
194{-
195 *(*indices)++ = topLeft;-
196 *(*indices)++ = bottomLeft;-
197 *(*indices)++ = bottomRight;-
198 *(*indices)++ = bottomRight;-
199 *(*indices)++ = topRight;-
200 *(*indices)++ = topLeft;-
201}
executed 636 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickborderimage
636
202-
203QSGGeometry *QSGBasicInternalImageNode::updateGeometry(const QRectF &targetRect,-
204 const QRectF &innerTargetRect,-
205 const QRectF &sourceRect,-
206 const QRectF &innerSourceRect,-
207 const QRectF &subSourceRect,-
208 QSGGeometry *geometry,-
209 bool mirror,-
210 bool antialiasing)-
211{-
212 int floorLeft = qFloor(subSourceRect.left());-
213 int ceilRight = qCeil(subSourceRect.right());-
214 int floorTop = qFloor(subSourceRect.top());-
215 int ceilBottom = qCeil(subSourceRect.bottom());-
216 int hTiles = ceilRight - floorLeft;-
217 int vTiles = ceilBottom - floorTop;-
218-
219 int hCells = hTiles;-
220 int vCells = vTiles;-
221 if (innerTargetRect.width() == 0)
innerTargetRect.width() == 0Description
TRUEnever evaluated
FALSEevaluated 72 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickborderimage
0-72
222 hCells = 0;
never executed: hCells = 0;
0
223 if (innerTargetRect.left() != targetRect.left())
innerTargetRec...getRect.left()Description
TRUEevaluated 70 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickborderimage
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_examples
2-70
224 ++hCells;
executed 70 times by 2 tests: ++hCells;
Executed by:
  • tst_examples
  • tst_qquickborderimage
70
225 if (innerTargetRect.right() != targetRect.right())
innerTargetRec...etRect.right()Description
TRUEevaluated 70 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickborderimage
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_examples
2-70
226 ++hCells;
executed 70 times by 2 tests: ++hCells;
Executed by:
  • tst_examples
  • tst_qquickborderimage
70
227 if (innerTargetRect.height() == 0)
innerTargetRect.height() == 0Description
TRUEnever evaluated
FALSEevaluated 72 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickborderimage
0-72
228 vCells = 0;
never executed: vCells = 0;
0
229 if (innerTargetRect.top() != targetRect.top())
innerTargetRec...rgetRect.top()Description
TRUEevaluated 72 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickborderimage
FALSEnever evaluated
0-72
230 ++vCells;
executed 72 times by 2 tests: ++vCells;
Executed by:
  • tst_examples
  • tst_qquickborderimage
72
231 if (innerTargetRect.bottom() != targetRect.bottom())
innerTargetRec...tRect.bottom()Description
TRUEevaluated 72 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickborderimage
FALSEnever evaluated
0-72
232 ++vCells;
executed 72 times by 2 tests: ++vCells;
Executed by:
  • tst_examples
  • tst_qquickborderimage
72
233 QVarLengthArray<X, 32> xData(2 * hCells);-
234 QVarLengthArray<Y, 32> yData(2 * vCells);-
235 X *xs = xData.data();-
236 Y *ys = yData.data();-
237-
238 if (innerTargetRect.left() != targetRect.left()) {
innerTargetRec...getRect.left()Description
TRUEevaluated 70 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickborderimage
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_examples
2-70
239 xs[0].x = targetRect.left();-
240 xs[0].tx = sourceRect.left();-
241 xs[1].x = innerTargetRect.left();-
242 xs[1].tx = innerSourceRect.left();-
243 xs += 2;-
244 }
executed 70 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickborderimage
70
245 if (innerTargetRect.width() != 0) {
innerTargetRect.width() != 0Description
TRUEevaluated 72 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickborderimage
FALSEnever evaluated
0-72
246 xs[0].x = innerTargetRect.left();-
247 xs[0].tx = innerSourceRect.x() + (subSourceRect.left() - floorLeft) * innerSourceRect.width();-
248 ++xs;-
249 float b = innerTargetRect.width() / subSourceRect.width();-
250 float a = innerTargetRect.x() - subSourceRect.x() * b;-
251 for (int i = floorLeft + 1; i <= ceilRight - 1; ++i) {
i <= ceilRight - 1Description
TRUEnever evaluated
FALSEevaluated 72 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickborderimage
0-72
252 xs[0].x = xs[1].x = a + b * i;-
253 xs[0].tx = innerSourceRect.right();-
254 xs[1].tx = innerSourceRect.left();-
255 xs += 2;-
256 }
never executed: end of block
0
257 xs[0].x = innerTargetRect.right();-
258 xs[0].tx = innerSourceRect.x() + (subSourceRect.right() - ceilRight + 1) * innerSourceRect.width();-
259 ++xs;-
260 }
executed 72 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickborderimage
72
261 if (innerTargetRect.right() != targetRect.right()) {
innerTargetRec...etRect.right()Description
TRUEevaluated 70 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickborderimage
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_examples
2-70
262 xs[0].x = innerTargetRect.right();-
263 xs[0].tx = innerSourceRect.right();-
264 xs[1].x = targetRect.right();-
265 xs[1].tx = sourceRect.right();-
266 xs += 2;-
267 }
executed 70 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickborderimage
70
268 Q_ASSERT(xs == xData.data() + xData.size());-
269 if (mirror) {
mirrorDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickborderimage
FALSEevaluated 70 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickborderimage
2-70
270 float leftPlusRight = targetRect.left() + targetRect.right();-
271 int count = xData.size();-
272 xs = xData.data();-
273 for (int i = 0; i < count >> 1; ++i)
i < count >> 1Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_qquickborderimage
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickborderimage
2-6
274 qSwap(xs[i], xs[count - 1 - i]);
executed 6 times by 1 test: qSwap(xs[i], xs[count - 1 - i]);
Executed by:
  • tst_qquickborderimage
6
275 for (int i = 0; i < count; ++i)
i < countDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_qquickborderimage
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickborderimage
2-12
276 xs[i].x = leftPlusRight - xs[i].x;
executed 12 times by 1 test: xs[i].x = leftPlusRight - xs[i].x;
Executed by:
  • tst_qquickborderimage
12
277 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickborderimage
2
278-
279 if (innerTargetRect.top() != targetRect.top()) {
innerTargetRec...rgetRect.top()Description
TRUEevaluated 72 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickborderimage
FALSEnever evaluated
0-72
280 ys[0].y = targetRect.top();-
281 ys[0].ty = sourceRect.top();-
282 ys[1].y = innerTargetRect.top();-
283 ys[1].ty = innerSourceRect.top();-
284 ys += 2;-
285 }
executed 72 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickborderimage
72
286 if (innerTargetRect.height() != 0) {
innerTargetRect.height() != 0Description
TRUEevaluated 72 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickborderimage
FALSEnever evaluated
0-72
287 ys[0].y = innerTargetRect.top();-
288 ys[0].ty = innerSourceRect.y() + (subSourceRect.top() - floorTop) * innerSourceRect.height();-
289 ++ys;-
290 float b = innerTargetRect.height() / subSourceRect.height();-
291 float a = innerTargetRect.y() - subSourceRect.y() * b;-
292 for (int i = floorTop + 1; i <= ceilBottom - 1; ++i) {
i <= ceilBottom - 1Description
TRUEnever evaluated
FALSEevaluated 72 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickborderimage
0-72
293 ys[0].y = ys[1].y = a + b * i;-
294 ys[0].ty = innerSourceRect.bottom();-
295 ys[1].ty = innerSourceRect.top();-
296 ys += 2;-
297 }
never executed: end of block
0
298 ys[0].y = innerTargetRect.bottom();-
299 ys[0].ty = innerSourceRect.y() + (subSourceRect.bottom() - ceilBottom + 1) * innerSourceRect.height();-
300 ++ys;-
301 }
executed 72 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickborderimage
72
302 if (innerTargetRect.bottom() != targetRect.bottom()) {
innerTargetRec...tRect.bottom()Description
TRUEevaluated 72 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickborderimage
FALSEnever evaluated
0-72
303 ys[0].y = innerTargetRect.bottom();-
304 ys[0].ty = innerSourceRect.bottom();-
305 ys[1].y = targetRect.bottom();-
306 ys[1].ty = sourceRect.bottom();-
307 ys += 2;-
308 }
executed 72 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickborderimage
72
309 Q_ASSERT(ys == yData.data() + yData.size());-
310-
311 if (antialiasing) {
antialiasingDescription
TRUEnever evaluated
FALSEevaluated 72 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickborderimage
0-72
312 QSGGeometry *g = geometry;-
313 Q_ASSERT(g);-
314-
315 g->allocate(hCells * vCells * 4 + (hCells + vCells - 1) * 4,-
316 hCells * vCells * 6 + (hCells + vCells) * 12);-
317 g->setDrawingMode(QSGGeometry::DrawTriangles);-
318 SmoothVertex *vertices = reinterpret_cast<SmoothVertex *>(g->vertexData());-
319 memset(vertices, 0, g->vertexCount() * g->sizeOfVertex());-
320 quint16 *indices = g->indexDataAsUShort();-
321-
322 // The deltas are how much the fuzziness can reach into the image.-
323 // Only the border vertices are moved by the vertex shader, so the fuzziness-
324 // can't reach further into the image than the closest interior vertices.-
325 float leftDx = xData.at(1).x - xData.at(0).x;-
326 float rightDx = xData.at(xData.size() - 1).x - xData.at(xData.size() - 2).x;-
327 float topDy = yData.at(1).y - yData.at(0).y;-
328 float bottomDy = yData.at(yData.size() - 1).y - yData.at(yData.size() - 2).y;-
329-
330 float leftDu = xData.at(1).tx - xData.at(0).tx;-
331 float rightDu = xData.at(xData.size() - 1).tx - xData.at(xData.size() - 2).tx;-
332 float topDv = yData.at(1).ty - yData.at(0).ty;-
333 float bottomDv = yData.at(yData.size() - 1).ty - yData.at(yData.size() - 2).ty;-
334-
335 if (hCells == 1) {
hCells == 1Description
TRUEnever evaluated
FALSEnever evaluated
0
336 leftDx = rightDx *= 0.5f;-
337 leftDu = rightDu *= 0.5f;-
338 }
never executed: end of block
0
339 if (vCells == 1) {
vCells == 1Description
TRUEnever evaluated
FALSEnever evaluated
0
340 topDy = bottomDy *= 0.5f;-
341 topDv = bottomDv *= 0.5f;-
342 }
never executed: end of block
0
343-
344 // This delta is how much the fuzziness can reach out from the image.-
345 float delta = float(qAbs(targetRect.width()) < qAbs(targetRect.height())-
346 ? targetRect.width() : targetRect.height()) * 0.5f;-
347-
348 quint16 index = 0;-
349 ys = yData.data();-
350 for (int j = 0; j < vCells; ++j, ys += 2) {
j < vCellsDescription
TRUEnever evaluated
FALSEnever evaluated
0
351 xs = xData.data();-
352 bool isTop = j == 0;-
353 bool isBottom = j == vCells - 1;-
354 for (int i = 0; i < hCells; ++i, xs += 2) {
i < hCellsDescription
TRUEnever evaluated
FALSEnever evaluated
0
355 bool isLeft = i == 0;-
356 bool isRight = i == hCells - 1;-
357-
358 SmoothVertex *v = vertices + index;-
359-
360 quint16 topLeft = index;-
361 for (int k = (isTop || isLeft ? 2 : 1); k--; ++v, ++index) {
k--Description
TRUEnever evaluated
FALSEnever evaluated
0
362 v->x = xs[0].x;-
363 v->u = xs[0].tx;-
364 v->y = ys[0].y;-
365 v->v = ys[0].ty;-
366 }
never executed: end of block
0
367-
368 quint16 topRight = index;-
369 for (int k = (isTop || isRight ? 2 : 1); k--; ++v, ++index) {
k--Description
TRUEnever evaluated
FALSEnever evaluated
0
370 v->x = xs[1].x;-
371 v->u = xs[1].tx;-
372 v->y = ys[0].y;-
373 v->v = ys[0].ty;-
374 }
never executed: end of block
0
375-
376 quint16 bottomLeft = index;-
377 for (int k = (isBottom || isLeft ? 2 : 1); k--; ++v, ++index) {
k--Description
TRUEnever evaluated
FALSEnever evaluated
0
378 v->x = xs[0].x;-
379 v->u = xs[0].tx;-
380 v->y = ys[1].y;-
381 v->v = ys[1].ty;-
382 }
never executed: end of block
0
383-
384 quint16 bottomRight = index;-
385 for (int k = (isBottom || isRight ? 2 : 1); k--; ++v, ++index) {
k--Description
TRUEnever evaluated
FALSEnever evaluated
0
386 v->x = xs[1].x;-
387 v->u = xs[1].tx;-
388 v->y = ys[1].y;-
389 v->v = ys[1].ty;-
390 }
never executed: end of block
0
391-
392 appendQuad(&indices, topLeft, topRight, bottomLeft, bottomRight);-
393-
394 if (isTop) {
isTopDescription
TRUEnever evaluated
FALSEnever evaluated
0
395 vertices[topLeft].dy = vertices[topRight].dy = topDy;-
396 vertices[topLeft].dv = vertices[topRight].dv = topDv;-
397 vertices[topLeft + 1].dy = vertices[topRight + 1].dy = -delta;-
398 appendQuad(&indices, topLeft + 1, topRight + 1, topLeft, topRight);-
399 }
never executed: end of block
0
400-
401 if (isBottom) {
isBottomDescription
TRUEnever evaluated
FALSEnever evaluated
0
402 vertices[bottomLeft].dy = vertices[bottomRight].dy = -bottomDy;-
403 vertices[bottomLeft].dv = vertices[bottomRight].dv = -bottomDv;-
404 vertices[bottomLeft + 1].dy = vertices[bottomRight + 1].dy = delta;-
405 appendQuad(&indices, bottomLeft, bottomRight, bottomLeft + 1, bottomRight + 1);-
406 }
never executed: end of block
0
407-
408 if (isLeft) {
isLeftDescription
TRUEnever evaluated
FALSEnever evaluated
0
409 vertices[topLeft].dx = vertices[bottomLeft].dx = leftDx;-
410 vertices[topLeft].du = vertices[bottomLeft].du = leftDu;-
411 vertices[topLeft + 1].dx = vertices[bottomLeft + 1].dx = -delta;-
412 appendQuad(&indices, topLeft + 1, topLeft, bottomLeft + 1, bottomLeft);-
413 }
never executed: end of block
0
414-
415 if (isRight) {
isRightDescription
TRUEnever evaluated
FALSEnever evaluated
0
416 vertices[topRight].dx = vertices[bottomRight].dx = -rightDx;-
417 vertices[topRight].du = vertices[bottomRight].du = -rightDu;-
418 vertices[topRight + 1].dx = vertices[bottomRight + 1].dx = delta;-
419 appendQuad(&indices, topRight, topRight + 1, bottomRight, bottomRight + 1);-
420 }
never executed: end of block
0
421 }
never executed: end of block
0
422 }
never executed: end of block
0
423-
424 Q_ASSERT(index == g->vertexCount());-
425 Q_ASSERT(indices - g->indexCount() == g->indexData());-
426 } else {
never executed: end of block
0
427 if (!geometry) {
!geometryDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickborderimage
FALSEevaluated 70 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickborderimage
2-70
428 geometry = new QSGGeometry(QSGGeometry::defaultAttributes_TexturedPoint2D(),-
429 hCells * vCells * 4, hCells * vCells * 6,-
430 QSGGeometry::UnsignedShortType);-
431 } else {
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickborderimage
2
432 geometry->allocate(hCells * vCells * 4, hCells * vCells * 6);-
433 }
executed 70 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickborderimage
70
434 geometry->setDrawingMode(QSGGeometry::DrawTriangles);-
435 QSGGeometry::TexturedPoint2D *vertices = geometry->vertexDataAsTexturedPoint2D();-
436 ys = yData.data();-
437 for (int j = 0; j < vCells; ++j, ys += 2) {
j < vCellsDescription
TRUEevaluated 216 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickborderimage
FALSEevaluated 72 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickborderimage
72-216
438 xs = xData.data();-
439 for (int i = 0; i < hCells; ++i, xs += 2) {
i < hCellsDescription
TRUEevaluated 636 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickborderimage
FALSEevaluated 216 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickborderimage
216-636
440 vertices[0].x = vertices[2].x = xs[0].x;-
441 vertices[0].tx = vertices[2].tx = xs[0].tx;-
442 vertices[1].x = vertices[3].x = xs[1].x;-
443 vertices[1].tx = vertices[3].tx = xs[1].tx;-
444-
445 vertices[0].y = vertices[1].y = ys[0].y;-
446 vertices[0].ty = vertices[1].ty = ys[0].ty;-
447 vertices[2].y = vertices[3].y = ys[1].y;-
448 vertices[2].ty = vertices[3].ty = ys[1].ty;-
449-
450 vertices += 4;-
451 }
executed 636 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickborderimage
636
452 }
executed 216 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickborderimage
216
453-
454 quint16 *indices = geometry->indexDataAsUShort();-
455 for (int i = 0; i < 4 * vCells * hCells; i += 4)
i < 4 * vCells * hCellsDescription
TRUEevaluated 636 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickborderimage
FALSEevaluated 72 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickborderimage
72-636
456 appendQuad(&indices, i, i + 1, i + 2, i + 3);
executed 636 times by 2 tests: appendQuad(&indices, i, i + 1, i + 2, i + 3);
Executed by:
  • tst_examples
  • tst_qquickborderimage
636
457 }
executed 72 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickborderimage
72
458 return geometry;
executed 72 times by 2 tests: return geometry;
Executed by:
  • tst_examples
  • tst_qquickborderimage
72
459}-
460-
461void QSGBasicInternalImageNode::updateGeometry()-
462{-
463 Q_ASSERT(!m_targetRect.isEmpty());-
464 const QSGTexture *t = materialTexture();-
465 if (!t) {
!tDescription
TRUEnever evaluated
FALSEevaluated 5280 times by 10 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickitemlayer
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_qquicktext
  • tst_scenegraph
0-5280
466 QSGGeometry *g = geometry();-
467 g->allocate(4);-
468 g->setDrawingMode(QSGGeometry::DrawTriangleStrip);-
469 memset(g->vertexData(), 0, g->sizeOfVertex() * 4);-
470 } else {
never executed: end of block
0
471 QRectF sourceRect = t->normalizedTextureSubRect();-
472-
473 QRectF innerSourceRect(sourceRect.x() + m_innerSourceRect.x() * sourceRect.width(),-
474 sourceRect.y() + m_innerSourceRect.y() * sourceRect.height(),-
475 m_innerSourceRect.width() * sourceRect.width(),-
476 m_innerSourceRect.height() * sourceRect.height());-
477-
478 bool hasMargins = m_targetRect != m_innerTargetRect;-
479-
480 int floorLeft = qFloor(m_subSourceRect.left());-
481 int ceilRight = qCeil(m_subSourceRect.right());-
482 int floorTop = qFloor(m_subSourceRect.top());-
483 int ceilBottom = qCeil(m_subSourceRect.bottom());-
484 int hTiles = ceilRight - floorLeft;-
485 int vTiles = ceilBottom - floorTop;-
486-
487 bool hasTiles = hTiles != 1 || vTiles != 1;
hTiles != 1Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_qquickimage
FALSEevaluated 5274 times by 10 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickitemlayer
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_qquicktext
  • tst_scenegraph
vTiles != 1Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickimage
FALSEevaluated 5270 times by 10 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickitemlayer
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_qquicktext
  • tst_scenegraph
4-5274
488 bool fullTexture = innerSourceRect == QRectF(0, 0, 1, 1);-
489-
490 // An image can be rendered as a single quad if:-
491 // - There are no margins, and either:-
492 // - the image isn't repeated-
493 // - the source rectangle fills the entire texture so that texture wrapping can be used,-
494 // and NPOT is supported-
495 if (!hasMargins && (!hasTiles || (fullTexture && supportsWrap(t->textureSize())))) {
!hasMarginsDescription
TRUEevaluated 5210 times by 10 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickitemlayer
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_qquicktext
  • tst_scenegraph
FALSEevaluated 70 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickborderimage
!hasTilesDescription
TRUEevaluated 5200 times by 10 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickitemlayer
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_qquicktext
  • tst_scenegraph
FALSEevaluated 10 times by 1 test
Evaluated by:
  • tst_qquickimage
fullTextureDescription
TRUEevaluated 10 times by 1 test
Evaluated by:
  • tst_qquickimage
FALSEnever evaluated
supportsWrap(t->textureSize())Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • tst_qquickimage
FALSEnever evaluated
0-5210
496 QRectF sr;-
497 if (!fullTexture) {
!fullTextureDescription
TRUEevaluated 4947 times by 9 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickitemlayer
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_scenegraph
FALSEevaluated 263 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qquickimage
  • tst_qquickitemlayer
  • tst_qquicktext
  • tst_scenegraph
263-4947
498 sr = QRectF(innerSourceRect.x() + (m_subSourceRect.left() - floorLeft) * innerSourceRect.width(),-
499 innerSourceRect.y() + (m_subSourceRect.top() - floorTop) * innerSourceRect.height(),-
500 m_subSourceRect.width() * innerSourceRect.width(),-
501 m_subSourceRect.height() * innerSourceRect.height());-
502 } else {
executed 4947 times by 9 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickitemlayer
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_scenegraph
4947
503 sr = QRectF(m_subSourceRect.left() - floorLeft, m_subSourceRect.top() - floorTop,-
504 m_subSourceRect.width(), m_subSourceRect.height());-
505 }
executed 263 times by 5 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickimage
  • tst_qquickitemlayer
  • tst_qquicktext
  • tst_scenegraph
263
506 if (m_mirror) {
m_mirrorDescription
TRUEevaluated 22 times by 2 tests
Evaluated by:
  • tst_qquickanimatedimage
  • tst_qquickimage
FALSEevaluated 5188 times by 10 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickitemlayer
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_qquicktext
  • tst_scenegraph
22-5188
507 qreal oldLeft = sr.left();-
508 sr.setLeft(sr.right());-
509 sr.setRight(oldLeft);-
510 }
executed 22 times by 2 tests: end of block
Executed by:
  • tst_qquickanimatedimage
  • tst_qquickimage
22
511-
512 if (m_antialiasing) {
m_antialiasingDescription
TRUEnever evaluated
FALSEevaluated 5210 times by 10 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickitemlayer
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_qquicktext
  • tst_scenegraph
0-5210
513 QSGGeometry *g = geometry();-
514 Q_ASSERT(g != &m_geometry);-
515 g->allocate(8, 14);-
516 g->setDrawingMode(QSGGeometry::DrawTriangleStrip);-
517 SmoothVertex *vertices = reinterpret_cast<SmoothVertex *>(g->vertexData());-
518 float delta = float(qAbs(m_targetRect.width()) < qAbs(m_targetRect.height())-
519 ? m_targetRect.width() : m_targetRect.height()) * 0.5f;-
520 float sx = float(sr.width() / m_targetRect.width());-
521 float sy = float(sr.height() / m_targetRect.height());-
522 for (int d = -1; d <= 1; d += 2) {
d <= 1Description
TRUEnever evaluated
FALSEnever evaluated
0
523 for (int j = 0; j < 2; ++j) {
j < 2Description
TRUEnever evaluated
FALSEnever evaluated
0
524 for (int i = 0; i < 2; ++i, ++vertices) {
i < 2Description
TRUEnever evaluated
FALSEnever evaluated
0
525 vertices->x = m_targetRect.x() + i * m_targetRect.width();-
526 vertices->y = m_targetRect.y() + j * m_targetRect.height();-
527 vertices->u = sr.x() + i * sr.width();-
528 vertices->v = sr.y() + j * sr.height();-
529 vertices->dx = (i == 0 ? delta : -delta) * d;
i == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
530 vertices->dy = (j == 0 ? delta : -delta) * d;
j == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
531 vertices->du = (d < 0 ? 0 : vertices->dx * sx);
d < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
532 vertices->dv = (d < 0 ? 0 : vertices->dy * sy);
d < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
533 }
never executed: end of block
0
534 }
never executed: end of block
0
535 }
never executed: end of block
0
536 Q_ASSERT(vertices - g->vertexCount() == g->vertexData());-
537 static const quint16 indices[] = {-
538 0, 4, 1, 5, 3, 7, 2, 6, 0, 4,-
539 4, 6, 5, 7-
540 };-
541 Q_ASSERT(g->sizeOfIndex() * g->indexCount() == sizeof(indices));-
542 memcpy(g->indexDataAsUShort(), indices, sizeof(indices));-
543 } else {
never executed: end of block
0
544 m_geometry.allocate(4);-
545 m_geometry.setDrawingMode(QSGGeometry::DrawTriangleStrip);-
546 QSGGeometry::updateTexturedRectGeometry(&m_geometry, m_targetRect, sr);-
547 }
executed 5210 times by 10 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickitemlayer
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_qquicktext
  • tst_scenegraph
5210
548 } else {-
549 QSGGeometry *g = m_antialiasing ? geometry() : &m_geometry;
m_antialiasingDescription
TRUEnever evaluated
FALSEevaluated 70 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickborderimage
0-70
550 updateGeometry(m_targetRect, m_innerTargetRect,-
551 sourceRect, innerSourceRect, m_subSourceRect,-
552 g, m_mirror, m_antialiasing);-
553 }
executed 70 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickborderimage
70
554 }-
555 markDirty(DirtyGeometry);-
556 m_dirtyGeometry = false;-
557}
executed 5280 times by 10 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickitemlayer
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_qquicktext
  • tst_scenegraph
5280
558-
559QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.0