Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/scenegraph/qsgbasicinternalimagenode.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||||||||
2 | - | |||||||||||||||||||||||||
3 | - | |||||||||||||||||||||||||
4 | - | |||||||||||||||||||||||||
5 | namespace | - | ||||||||||||||||||||||||
6 | { | - | ||||||||||||||||||||||||
7 | struct SmoothVertex | - | ||||||||||||||||||||||||
8 | { | - | ||||||||||||||||||||||||
9 | float x, y, u, v; | - | ||||||||||||||||||||||||
10 | float dx, dy, du, dv; | - | ||||||||||||||||||||||||
11 | }; | - | ||||||||||||||||||||||||
12 | - | |||||||||||||||||||||||||
13 | const QSGGeometry::AttributeSet &smoothAttributeSet() | - | ||||||||||||||||||||||||
14 | { | - | ||||||||||||||||||||||||
15 | static QSGGeometry::Attribute data[] = { | - | ||||||||||||||||||||||||
16 | QSGGeometry::Attribute::createWithAttributeType(0, 2, QSGGeometry::FloatType, QSGGeometry::PositionAttribute), | - | ||||||||||||||||||||||||
17 | QSGGeometry::Attribute::createWithAttributeType(1, 2, QSGGeometry::FloatType, QSGGeometry::TexCoordAttribute), | - | ||||||||||||||||||||||||
18 | QSGGeometry::Attribute::createWithAttributeType(2, 2, QSGGeometry::FloatType, QSGGeometry::TexCoord1Attribute), | - | ||||||||||||||||||||||||
19 | QSGGeometry::Attribute::createWithAttributeType(3, 2, QSGGeometry::FloatType, QSGGeometry::TexCoord2Attribute) | - | ||||||||||||||||||||||||
20 | }; | - | ||||||||||||||||||||||||
21 | static QSGGeometry::AttributeSet attrs = { 4, sizeof(SmoothVertex), data }; | - | ||||||||||||||||||||||||
22 | return never executed: attrs;return attrs; never executed: return attrs; | 0 | ||||||||||||||||||||||||
23 | } | - | ||||||||||||||||||||||||
24 | } | - | ||||||||||||||||||||||||
25 | - | |||||||||||||||||||||||||
26 | QSGBasicInternalImageNode::QSGBasicInternalImageNode() | - | ||||||||||||||||||||||||
27 | : m_innerSourceRect(0, 0, 1, 1) | - | ||||||||||||||||||||||||
28 | , m_subSourceRect(0, 0, 1, 1) | - | ||||||||||||||||||||||||
29 | , m_antialiasing(false) | - | ||||||||||||||||||||||||
30 | , m_mirror(false) | - | ||||||||||||||||||||||||
31 | , m_dirtyGeometry(false) | - | ||||||||||||||||||||||||
32 | , m_geometry(QSGGeometry::defaultAttributes_TexturedPoint2D(), 4) | - | ||||||||||||||||||||||||
33 | , m_dynamicTexture(nullptr) | - | ||||||||||||||||||||||||
34 | { | - | ||||||||||||||||||||||||
35 | setGeometry(&m_geometry); | - | ||||||||||||||||||||||||
36 | - | |||||||||||||||||||||||||
37 | - | |||||||||||||||||||||||||
38 | qsgnode_set_description(this, QLatin1String("internalimage")); | - | ||||||||||||||||||||||||
39 | - | |||||||||||||||||||||||||
40 | } executed 5189 times by 10 tests: end of block Executed by:
| 5189 | ||||||||||||||||||||||||
41 | - | |||||||||||||||||||||||||
42 | void QSGBasicInternalImageNode::setTargetRect(const QRectF &rect) | - | ||||||||||||||||||||||||
43 | { | - | ||||||||||||||||||||||||
44 | if (rect == m_targetRect
| 98-5207 | ||||||||||||||||||||||||
45 | return; executed 98 times by 2 tests: return; Executed by:
| 98 | ||||||||||||||||||||||||
46 | m_targetRect = rect; | - | ||||||||||||||||||||||||
47 | m_dirtyGeometry = true; | - | ||||||||||||||||||||||||
48 | } executed 5207 times by 10 tests: end of block Executed by:
| 5207 | ||||||||||||||||||||||||
49 | - | |||||||||||||||||||||||||
50 | void QSGBasicInternalImageNode::setInnerTargetRect(const QRectF &rect) | - | ||||||||||||||||||||||||
51 | { | - | ||||||||||||||||||||||||
52 | if (rect == m_innerTargetRect
| 98-5207 | ||||||||||||||||||||||||
53 | return; executed 98 times by 2 tests: return; Executed by:
| 98 | ||||||||||||||||||||||||
54 | m_innerTargetRect = rect; | - | ||||||||||||||||||||||||
55 | m_dirtyGeometry = true; | - | ||||||||||||||||||||||||
56 | } executed 5207 times by 10 tests: end of block Executed by:
| 5207 | ||||||||||||||||||||||||
57 | - | |||||||||||||||||||||||||
58 | void QSGBasicInternalImageNode::setInnerSourceRect(const QRectF &rect) | - | ||||||||||||||||||||||||
59 | { | - | ||||||||||||||||||||||||
60 | if (rect == m_innerSourceRect
| 0-70 | ||||||||||||||||||||||||
61 | return; never executed: return; | 0 | ||||||||||||||||||||||||
62 | m_innerSourceRect = rect; | - | ||||||||||||||||||||||||
63 | m_dirtyGeometry = true; | - | ||||||||||||||||||||||||
64 | } executed 70 times by 2 tests: end of block Executed by:
| 70 | ||||||||||||||||||||||||
65 | - | |||||||||||||||||||||||||
66 | void QSGBasicInternalImageNode::setSubSourceRect(const QRectF &rect) | - | ||||||||||||||||||||||||
67 | { | - | ||||||||||||||||||||||||
68 | if (rect == m_subSourceRect
| 26-5129 | ||||||||||||||||||||||||
69 | return; executed 5129 times by 8 tests: return; Executed by:
| 5129 | ||||||||||||||||||||||||
70 | m_subSourceRect = rect; | - | ||||||||||||||||||||||||
71 | m_dirtyGeometry = true; | - | ||||||||||||||||||||||||
72 | } executed 26 times by 2 tests: end of block Executed by:
| 26 | ||||||||||||||||||||||||
73 | - | |||||||||||||||||||||||||
74 | void QSGBasicInternalImageNode::setTexture(QSGTexture *texture) | - | ||||||||||||||||||||||||
75 | { | - | ||||||||||||||||||||||||
76 | ((texture) ? static_cast<void>(0) : qt_assert("texture", __FILE__, 118)); | - | ||||||||||||||||||||||||
77 | - | |||||||||||||||||||||||||
78 | setMaterialTexture(texture); | - | ||||||||||||||||||||||||
79 | updateMaterialBlending(); | - | ||||||||||||||||||||||||
80 | - | |||||||||||||||||||||||||
81 | markDirty(DirtyMaterial); | - | ||||||||||||||||||||||||
82 | - | |||||||||||||||||||||||||
83 | - | |||||||||||||||||||||||||
84 | m_dirtyGeometry = true; | - | ||||||||||||||||||||||||
85 | } executed 5245 times by 10 tests: end of block Executed by:
| 5245 | ||||||||||||||||||||||||
86 | - | |||||||||||||||||||||||||
87 | void QSGBasicInternalImageNode::setAntialiasing(bool antialiasing) | - | ||||||||||||||||||||||||
88 | { | - | ||||||||||||||||||||||||
89 | if (antialiasing == m_antialiasing
| 0-5155 | ||||||||||||||||||||||||
90 | return; executed 5155 times by 8 tests: return; Executed by:
| 5155 | ||||||||||||||||||||||||
91 | m_antialiasing = antialiasing; | - | ||||||||||||||||||||||||
92 | if (m_antialiasing
| 0 | ||||||||||||||||||||||||
93 | setGeometry(new QSGGeometry(smoothAttributeSet(), 0)); | - | ||||||||||||||||||||||||
94 | setFlag(OwnsGeometry, true); | - | ||||||||||||||||||||||||
95 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
96 | setGeometry(&m_geometry); | - | ||||||||||||||||||||||||
97 | setFlag(OwnsGeometry, false); | - | ||||||||||||||||||||||||
98 | } never executed: end of block | 0 | ||||||||||||||||||||||||
99 | updateMaterialAntialiasing(); | - | ||||||||||||||||||||||||
100 | m_dirtyGeometry = true; | - | ||||||||||||||||||||||||
101 | } never executed: end of block | 0 | ||||||||||||||||||||||||
102 | - | |||||||||||||||||||||||||
103 | void QSGBasicInternalImageNode::setMirror(bool mirror) | - | ||||||||||||||||||||||||
104 | { | - | ||||||||||||||||||||||||
105 | if (mirror == m_mirror
| 22-5133 | ||||||||||||||||||||||||
106 | return; executed 5133 times by 8 tests: return; Executed by:
| 5133 | ||||||||||||||||||||||||
107 | m_mirror = mirror; | - | ||||||||||||||||||||||||
108 | m_dirtyGeometry = true; | - | ||||||||||||||||||||||||
109 | } executed 22 times by 3 tests: end of block Executed by:
| 22 | ||||||||||||||||||||||||
110 | - | |||||||||||||||||||||||||
111 | - | |||||||||||||||||||||||||
112 | void QSGBasicInternalImageNode::update() | - | ||||||||||||||||||||||||
113 | { | - | ||||||||||||||||||||||||
114 | if (m_dirtyGeometry
| 56-5249 | ||||||||||||||||||||||||
115 | updateGeometry(); executed 5249 times by 10 tests: updateGeometry(); Executed by:
| 5249 | ||||||||||||||||||||||||
116 | } executed 5305 times by 10 tests: end of block Executed by:
| 5305 | ||||||||||||||||||||||||
117 | - | |||||||||||||||||||||||||
118 | void QSGBasicInternalImageNode::preprocess() | - | ||||||||||||||||||||||||
119 | { | - | ||||||||||||||||||||||||
120 | bool doDirty = false; | - | ||||||||||||||||||||||||
121 | QSGDynamicTexture *t = qobject_cast<QSGDynamicTexture *>(materialTexture()); | - | ||||||||||||||||||||||||
122 | if (t
| 0-126 | ||||||||||||||||||||||||
123 | doDirty = t->updateTexture(); | - | ||||||||||||||||||||||||
124 | if (doDirty
| 31-95 | ||||||||||||||||||||||||
125 | - | |||||||||||||||||||||||||
126 | - | |||||||||||||||||||||||||
127 | if (t != m_dynamicTexture
| 0-31 | ||||||||||||||||||||||||
128 | || t->textureSize() != m_dynamicTextureSize
| 0 | ||||||||||||||||||||||||
129 | || t->normalizedTextureSubRect() != m_dynamicTextureSubRect
| 0 | ||||||||||||||||||||||||
130 | updateGeometry(); | - | ||||||||||||||||||||||||
131 | m_dynamicTextureSize = t->textureSize(); | - | ||||||||||||||||||||||||
132 | m_dynamicTextureSubRect = t->normalizedTextureSubRect(); | - | ||||||||||||||||||||||||
133 | } executed 31 times by 2 tests: end of block Executed by:
| 31 | ||||||||||||||||||||||||
134 | } executed 31 times by 2 tests: end of block Executed by:
| 31 | ||||||||||||||||||||||||
135 | } executed 126 times by 2 tests: end of block Executed by:
| 126 | ||||||||||||||||||||||||
136 | m_dynamicTexture = t; | - | ||||||||||||||||||||||||
137 | - | |||||||||||||||||||||||||
138 | if (updateMaterialBlending()
| 0-126 | ||||||||||||||||||||||||
139 | doDirty = true; never executed: doDirty = true; | 0 | ||||||||||||||||||||||||
140 | - | |||||||||||||||||||||||||
141 | if (doDirty
| 31-95 | ||||||||||||||||||||||||
142 | markDirty(DirtyMaterial); executed 31 times by 2 tests: markDirty(DirtyMaterial); Executed by:
| 31 | ||||||||||||||||||||||||
143 | } executed 126 times by 2 tests: end of block Executed by:
| 126 | ||||||||||||||||||||||||
144 | - | |||||||||||||||||||||||||
145 | namespace { | - | ||||||||||||||||||||||||
146 | struct X { float x, tx; }; | - | ||||||||||||||||||||||||
147 | struct Y { float y, ty; }; | - | ||||||||||||||||||||||||
148 | } | - | ||||||||||||||||||||||||
149 | - | |||||||||||||||||||||||||
150 | static inline void appendQuad(quint16 **indices, quint16 topLeft, quint16 topRight, | - | ||||||||||||||||||||||||
151 | quint16 bottomLeft, quint16 bottomRight) | - | ||||||||||||||||||||||||
152 | { | - | ||||||||||||||||||||||||
153 | *(*indices)++ = topLeft; | - | ||||||||||||||||||||||||
154 | *(*indices)++ = bottomLeft; | - | ||||||||||||||||||||||||
155 | *(*indices)++ = bottomRight; | - | ||||||||||||||||||||||||
156 | *(*indices)++ = bottomRight; | - | ||||||||||||||||||||||||
157 | *(*indices)++ = topRight; | - | ||||||||||||||||||||||||
158 | *(*indices)++ = topLeft; | - | ||||||||||||||||||||||||
159 | } executed 636 times by 2 tests: end of block Executed by:
| 636 | ||||||||||||||||||||||||
160 | - | |||||||||||||||||||||||||
161 | QSGGeometry *QSGBasicInternalImageNode::updateGeometry(const QRectF &targetRect, | - | ||||||||||||||||||||||||
162 | const QRectF &innerTargetRect, | - | ||||||||||||||||||||||||
163 | const QRectF &sourceRect, | - | ||||||||||||||||||||||||
164 | const QRectF &innerSourceRect, | - | ||||||||||||||||||||||||
165 | const QRectF &subSourceRect, | - | ||||||||||||||||||||||||
166 | QSGGeometry *geometry, | - | ||||||||||||||||||||||||
167 | bool mirror, | - | ||||||||||||||||||||||||
168 | bool antialiasing) | - | ||||||||||||||||||||||||
169 | { | - | ||||||||||||||||||||||||
170 | int floorLeft = qFloor(subSourceRect.left()); | - | ||||||||||||||||||||||||
171 | int ceilRight = qCeil(subSourceRect.right()); | - | ||||||||||||||||||||||||
172 | int floorTop = qFloor(subSourceRect.top()); | - | ||||||||||||||||||||||||
173 | int ceilBottom = qCeil(subSourceRect.bottom()); | - | ||||||||||||||||||||||||
174 | int hTiles = ceilRight - floorLeft; | - | ||||||||||||||||||||||||
175 | int vTiles = ceilBottom - floorTop; | - | ||||||||||||||||||||||||
176 | - | |||||||||||||||||||||||||
177 | int hCells = hTiles; | - | ||||||||||||||||||||||||
178 | int vCells = vTiles; | - | ||||||||||||||||||||||||
179 | if (innerTargetRect.width() == 0
| 0-72 | ||||||||||||||||||||||||
180 | hCells = 0; never executed: hCells = 0; | 0 | ||||||||||||||||||||||||
181 | if (innerTargetRect.left() != targetRect.left()
| 2-70 | ||||||||||||||||||||||||
182 | ++ executed 70 times by 2 tests: hCells;++hCells; Executed by:
executed 70 times by 2 tests: ++hCells; Executed by:
| 70 | ||||||||||||||||||||||||
183 | if (innerTargetRect.right() != targetRect.right()
| 2-70 | ||||||||||||||||||||||||
184 | ++ executed 70 times by 2 tests: hCells;++hCells; Executed by:
executed 70 times by 2 tests: ++hCells; Executed by:
| 70 | ||||||||||||||||||||||||
185 | if (innerTargetRect.height() == 0
| 0-72 | ||||||||||||||||||||||||
186 | vCells = 0; never executed: vCells = 0; | 0 | ||||||||||||||||||||||||
187 | if (innerTargetRect.top() != targetRect.top()
| 0-72 | ||||||||||||||||||||||||
188 | ++ executed 72 times by 2 tests: vCells;++vCells; Executed by:
executed 72 times by 2 tests: ++vCells; Executed by:
| 72 | ||||||||||||||||||||||||
189 | if (innerTargetRect.bottom() != targetRect.bottom()
| 0-72 | ||||||||||||||||||||||||
190 | ++ executed 72 times by 2 tests: vCells;++vCells; Executed by:
executed 72 times by 2 tests: ++vCells; Executed by:
| 72 | ||||||||||||||||||||||||
191 | QVarLengthArray<X, 32> xData(2 * hCells); | - | ||||||||||||||||||||||||
192 | QVarLengthArray<Y, 32> yData(2 * vCells); | - | ||||||||||||||||||||||||
193 | X *xs = xData.data(); | - | ||||||||||||||||||||||||
194 | Y *ys = yData.data(); | - | ||||||||||||||||||||||||
195 | - | |||||||||||||||||||||||||
196 | if (innerTargetRect.left() != targetRect.left()
| 2-70 | ||||||||||||||||||||||||
197 | xs[0].x = targetRect.left(); | - | ||||||||||||||||||||||||
198 | xs[0].tx = sourceRect.left(); | - | ||||||||||||||||||||||||
199 | xs[1].x = innerTargetRect.left(); | - | ||||||||||||||||||||||||
200 | xs[1].tx = innerSourceRect.left(); | - | ||||||||||||||||||||||||
201 | xs += 2; | - | ||||||||||||||||||||||||
202 | } executed 70 times by 2 tests: end of block Executed by:
| 70 | ||||||||||||||||||||||||
203 | if (innerTargetRect.width() != 0
| 0-72 | ||||||||||||||||||||||||
204 | xs[0].x = innerTargetRect.left(); | - | ||||||||||||||||||||||||
205 | xs[0].tx = innerSourceRect.x() + (subSourceRect.left() - floorLeft) * innerSourceRect.width(); | - | ||||||||||||||||||||||||
206 | ++xs; | - | ||||||||||||||||||||||||
207 | float b = innerTargetRect.width() / subSourceRect.width(); | - | ||||||||||||||||||||||||
208 | float a = innerTargetRect.x() - subSourceRect.x() * b; | - | ||||||||||||||||||||||||
209 | for (int i = floorLeft + 1; i <= ceilRight - 1
| 0-72 | ||||||||||||||||||||||||
210 | xs[0].x = xs[1].x = a + b * i; | - | ||||||||||||||||||||||||
211 | xs[0].tx = innerSourceRect.right(); | - | ||||||||||||||||||||||||
212 | xs[1].tx = innerSourceRect.left(); | - | ||||||||||||||||||||||||
213 | xs += 2; | - | ||||||||||||||||||||||||
214 | } never executed: end of block | 0 | ||||||||||||||||||||||||
215 | xs[0].x = innerTargetRect.right(); | - | ||||||||||||||||||||||||
216 | xs[0].tx = innerSourceRect.x() + (subSourceRect.right() - ceilRight + 1) * innerSourceRect.width(); | - | ||||||||||||||||||||||||
217 | ++xs; | - | ||||||||||||||||||||||||
218 | } executed 72 times by 2 tests: end of block Executed by:
| 72 | ||||||||||||||||||||||||
219 | if (innerTargetRect.right() != targetRect.right()
| 2-70 | ||||||||||||||||||||||||
220 | xs[0].x = innerTargetRect.right(); | - | ||||||||||||||||||||||||
221 | xs[0].tx = innerSourceRect.right(); | - | ||||||||||||||||||||||||
222 | xs[1].x = targetRect.right(); | - | ||||||||||||||||||||||||
223 | xs[1].tx = sourceRect.right(); | - | ||||||||||||||||||||||||
224 | xs += 2; | - | ||||||||||||||||||||||||
225 | } executed 70 times by 2 tests: end of block Executed by:
| 70 | ||||||||||||||||||||||||
226 | ((xs == xData.data() + xData.size()) ? static_cast<void>(0) : qt_assert("xs == xData.data() + xData.size()", __FILE__, 268)); | - | ||||||||||||||||||||||||
227 | if (mirror
| 2-70 | ||||||||||||||||||||||||
228 | float leftPlusRight = targetRect.left() + targetRect.right(); | - | ||||||||||||||||||||||||
229 | int count = xData.size(); | - | ||||||||||||||||||||||||
230 | xs = xData.data(); | - | ||||||||||||||||||||||||
231 | for (int i = 0; i < count >> 1
| 2-6 | ||||||||||||||||||||||||
232 | qSwap(xs[i], xs[count - 1 - i]); executed 6 times by 1 test: qSwap(xs[i], xs[count - 1 - i]); Executed by:
| 6 | ||||||||||||||||||||||||
233 | for (int i = 0; i < count
| 2-12 | ||||||||||||||||||||||||
234 | xs[i].x = leftPlusRight - xs[i].x; executed 12 times by 1 test: xs[i].x = leftPlusRight - xs[i].x; Executed by:
| 12 | ||||||||||||||||||||||||
235 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
236 | - | |||||||||||||||||||||||||
237 | if (innerTargetRect.top() != targetRect.top()
| 0-72 | ||||||||||||||||||||||||
238 | ys[0].y = targetRect.top(); | - | ||||||||||||||||||||||||
239 | ys[0].ty = sourceRect.top(); | - | ||||||||||||||||||||||||
240 | ys[1].y = innerTargetRect.top(); | - | ||||||||||||||||||||||||
241 | ys[1].ty = innerSourceRect.top(); | - | ||||||||||||||||||||||||
242 | ys += 2; | - | ||||||||||||||||||||||||
243 | } executed 72 times by 2 tests: end of block Executed by:
| 72 | ||||||||||||||||||||||||
244 | if (innerTargetRect.height() != 0
| 0-72 | ||||||||||||||||||||||||
245 | ys[0].y = innerTargetRect.top(); | - | ||||||||||||||||||||||||
246 | ys[0].ty = innerSourceRect.y() + (subSourceRect.top() - floorTop) * innerSourceRect.height(); | - | ||||||||||||||||||||||||
247 | ++ys; | - | ||||||||||||||||||||||||
248 | float b = innerTargetRect.height() / subSourceRect.height(); | - | ||||||||||||||||||||||||
249 | float a = innerTargetRect.y() - subSourceRect.y() * b; | - | ||||||||||||||||||||||||
250 | for (int i = floorTop + 1; i <= ceilBottom - 1
| 0-72 | ||||||||||||||||||||||||
251 | ys[0].y = ys[1].y = a + b * i; | - | ||||||||||||||||||||||||
252 | ys[0].ty = innerSourceRect.bottom(); | - | ||||||||||||||||||||||||
253 | ys[1].ty = innerSourceRect.top(); | - | ||||||||||||||||||||||||
254 | ys += 2; | - | ||||||||||||||||||||||||
255 | } never executed: end of block | 0 | ||||||||||||||||||||||||
256 | ys[0].y = innerTargetRect.bottom(); | - | ||||||||||||||||||||||||
257 | ys[0].ty = innerSourceRect.y() + (subSourceRect.bottom() - ceilBottom + 1) * innerSourceRect.height(); | - | ||||||||||||||||||||||||
258 | ++ys; | - | ||||||||||||||||||||||||
259 | } executed 72 times by 2 tests: end of block Executed by:
| 72 | ||||||||||||||||||||||||
260 | if (innerTargetRect.bottom() != targetRect.bottom()
| 0-72 | ||||||||||||||||||||||||
261 | ys[0].y = innerTargetRect.bottom(); | - | ||||||||||||||||||||||||
262 | ys[0].ty = innerSourceRect.bottom(); | - | ||||||||||||||||||||||||
263 | ys[1].y = targetRect.bottom(); | - | ||||||||||||||||||||||||
264 | ys[1].ty = sourceRect.bottom(); | - | ||||||||||||||||||||||||
265 | ys += 2; | - | ||||||||||||||||||||||||
266 | } executed 72 times by 2 tests: end of block Executed by:
| 72 | ||||||||||||||||||||||||
267 | ((ys == yData.data() + yData.size()) ? static_cast<void>(0) : qt_assert("ys == yData.data() + yData.size()", __FILE__, 309)); | - | ||||||||||||||||||||||||
268 | - | |||||||||||||||||||||||||
269 | if (antialiasing
| 0-72 | ||||||||||||||||||||||||
270 | QSGGeometry *g = geometry; | - | ||||||||||||||||||||||||
271 | ((g) ? static_cast<void>(0) : qt_assert("g", __FILE__, 313)); | - | ||||||||||||||||||||||||
272 | - | |||||||||||||||||||||||||
273 | g->allocate(hCells * vCells * 4 + (hCells + vCells - 1) * 4, | - | ||||||||||||||||||||||||
274 | hCells * vCells * 6 + (hCells + vCells) * 12); | - | ||||||||||||||||||||||||
275 | g->setDrawingMode(QSGGeometry::DrawTriangles); | - | ||||||||||||||||||||||||
276 | SmoothVertex *vertices = reinterpret_cast<SmoothVertex *>(g->vertexData()); | - | ||||||||||||||||||||||||
277 | memset(vertices, 0, g->vertexCount() * g->sizeOfVertex()); | - | ||||||||||||||||||||||||
278 | quint16 *indices = g->indexDataAsUShort(); | - | ||||||||||||||||||||||||
279 | - | |||||||||||||||||||||||||
280 | - | |||||||||||||||||||||||||
281 | - | |||||||||||||||||||||||||
282 | - | |||||||||||||||||||||||||
283 | float leftDx = xData.at(1).x - xData.at(0).x; | - | ||||||||||||||||||||||||
284 | float rightDx = xData.at(xData.size() - 1).x - xData.at(xData.size() - 2).x; | - | ||||||||||||||||||||||||
285 | float topDy = yData.at(1).y - yData.at(0).y; | - | ||||||||||||||||||||||||
286 | float bottomDy = yData.at(yData.size() - 1).y - yData.at(yData.size() - 2).y; | - | ||||||||||||||||||||||||
287 | - | |||||||||||||||||||||||||
288 | float leftDu = xData.at(1).tx - xData.at(0).tx; | - | ||||||||||||||||||||||||
289 | float rightDu = xData.at(xData.size() - 1).tx - xData.at(xData.size() - 2).tx; | - | ||||||||||||||||||||||||
290 | float topDv = yData.at(1).ty - yData.at(0).ty; | - | ||||||||||||||||||||||||
291 | float bottomDv = yData.at(yData.size() - 1).ty - yData.at(yData.size() - 2).ty; | - | ||||||||||||||||||||||||
292 | - | |||||||||||||||||||||||||
293 | if (hCells == 1
| 0 | ||||||||||||||||||||||||
294 | leftDx = rightDx *= 0.5f; | - | ||||||||||||||||||||||||
295 | leftDu = rightDu *= 0.5f; | - | ||||||||||||||||||||||||
296 | } never executed: end of block | 0 | ||||||||||||||||||||||||
297 | if (vCells == 1
| 0 | ||||||||||||||||||||||||
298 | topDy = bottomDy *= 0.5f; | - | ||||||||||||||||||||||||
299 | topDv = bottomDv *= 0.5f; | - | ||||||||||||||||||||||||
300 | } never executed: end of block | 0 | ||||||||||||||||||||||||
301 | - | |||||||||||||||||||||||||
302 | - | |||||||||||||||||||||||||
303 | float delta = float(qAbs(targetRect.width()) < qAbs(targetRect.height()) | - | ||||||||||||||||||||||||
304 | ? targetRect.width() : targetRect.height()) * 0.5f; | - | ||||||||||||||||||||||||
305 | - | |||||||||||||||||||||||||
306 | quint16 index = 0; | - | ||||||||||||||||||||||||
307 | ys = yData.data(); | - | ||||||||||||||||||||||||
308 | for (int j = 0; j < vCells
| 0 | ||||||||||||||||||||||||
309 | xs = xData.data(); | - | ||||||||||||||||||||||||
310 | bool isTop = j == 0; | - | ||||||||||||||||||||||||
311 | bool isBottom = j == vCells - 1; | - | ||||||||||||||||||||||||
312 | for (int i = 0; i < hCells
| 0 | ||||||||||||||||||||||||
313 | bool isLeft = i == 0; | - | ||||||||||||||||||||||||
314 | bool isRight = i == hCells - 1; | - | ||||||||||||||||||||||||
315 | - | |||||||||||||||||||||||||
316 | SmoothVertex *v = vertices + index; | - | ||||||||||||||||||||||||
317 | - | |||||||||||||||||||||||||
318 | quint16 topLeft = index; | - | ||||||||||||||||||||||||
319 | for (int k = (isTop || isLeft ? 2 : 1); k--
| 0 | ||||||||||||||||||||||||
320 | v->x = xs[0].x; | - | ||||||||||||||||||||||||
321 | v->u = xs[0].tx; | - | ||||||||||||||||||||||||
322 | v->y = ys[0].y; | - | ||||||||||||||||||||||||
323 | v->v = ys[0].ty; | - | ||||||||||||||||||||||||
324 | } never executed: end of block | 0 | ||||||||||||||||||||||||
325 | - | |||||||||||||||||||||||||
326 | quint16 topRight = index; | - | ||||||||||||||||||||||||
327 | for (int k = (isTop || isRight ? 2 : 1); k--
| 0 | ||||||||||||||||||||||||
328 | v->x = xs[1].x; | - | ||||||||||||||||||||||||
329 | v->u = xs[1].tx; | - | ||||||||||||||||||||||||
330 | v->y = ys[0].y; | - | ||||||||||||||||||||||||
331 | v->v = ys[0].ty; | - | ||||||||||||||||||||||||
332 | } never executed: end of block | 0 | ||||||||||||||||||||||||
333 | - | |||||||||||||||||||||||||
334 | quint16 bottomLeft = index; | - | ||||||||||||||||||||||||
335 | for (int k = (isBottom || isLeft ? 2 : 1); k--
| 0 | ||||||||||||||||||||||||
336 | v->x = xs[0].x; | - | ||||||||||||||||||||||||
337 | v->u = xs[0].tx; | - | ||||||||||||||||||||||||
338 | v->y = ys[1].y; | - | ||||||||||||||||||||||||
339 | v->v = ys[1].ty; | - | ||||||||||||||||||||||||
340 | } never executed: end of block | 0 | ||||||||||||||||||||||||
341 | - | |||||||||||||||||||||||||
342 | quint16 bottomRight = index; | - | ||||||||||||||||||||||||
343 | for (int k = (isBottom || isRight ? 2 : 1); k--
| 0 | ||||||||||||||||||||||||
344 | v->x = xs[1].x; | - | ||||||||||||||||||||||||
345 | v->u = xs[1].tx; | - | ||||||||||||||||||||||||
346 | v->y = ys[1].y; | - | ||||||||||||||||||||||||
347 | v->v = ys[1].ty; | - | ||||||||||||||||||||||||
348 | } never executed: end of block | 0 | ||||||||||||||||||||||||
349 | - | |||||||||||||||||||||||||
350 | appendQuad(&indices, topLeft, topRight, bottomLeft, bottomRight); | - | ||||||||||||||||||||||||
351 | - | |||||||||||||||||||||||||
352 | if (isTop
| 0 | ||||||||||||||||||||||||
353 | vertices[topLeft].dy = vertices[topRight].dy = topDy; | - | ||||||||||||||||||||||||
354 | vertices[topLeft].dv = vertices[topRight].dv = topDv; | - | ||||||||||||||||||||||||
355 | vertices[topLeft + 1].dy = vertices[topRight + 1].dy = -delta; | - | ||||||||||||||||||||||||
356 | appendQuad(&indices, topLeft + 1, topRight + 1, topLeft, topRight); | - | ||||||||||||||||||||||||
357 | } never executed: end of block | 0 | ||||||||||||||||||||||||
358 | - | |||||||||||||||||||||||||
359 | if (isBottom
| 0 | ||||||||||||||||||||||||
360 | vertices[bottomLeft].dy = vertices[bottomRight].dy = -bottomDy; | - | ||||||||||||||||||||||||
361 | vertices[bottomLeft].dv = vertices[bottomRight].dv = -bottomDv; | - | ||||||||||||||||||||||||
362 | vertices[bottomLeft + 1].dy = vertices[bottomRight + 1].dy = delta; | - | ||||||||||||||||||||||||
363 | appendQuad(&indices, bottomLeft, bottomRight, bottomLeft + 1, bottomRight + 1); | - | ||||||||||||||||||||||||
364 | } never executed: end of block | 0 | ||||||||||||||||||||||||
365 | - | |||||||||||||||||||||||||
366 | if (isLeft
| 0 | ||||||||||||||||||||||||
367 | vertices[topLeft].dx = vertices[bottomLeft].dx = leftDx; | - | ||||||||||||||||||||||||
368 | vertices[topLeft].du = vertices[bottomLeft].du = leftDu; | - | ||||||||||||||||||||||||
369 | vertices[topLeft + 1].dx = vertices[bottomLeft + 1].dx = -delta; | - | ||||||||||||||||||||||||
370 | appendQuad(&indices, topLeft + 1, topLeft, bottomLeft + 1, bottomLeft); | - | ||||||||||||||||||||||||
371 | } never executed: end of block | 0 | ||||||||||||||||||||||||
372 | - | |||||||||||||||||||||||||
373 | if (isRight
| 0 | ||||||||||||||||||||||||
374 | vertices[topRight].dx = vertices[bottomRight].dx = -rightDx; | - | ||||||||||||||||||||||||
375 | vertices[topRight].du = vertices[bottomRight].du = -rightDu; | - | ||||||||||||||||||||||||
376 | vertices[topRight + 1].dx = vertices[bottomRight + 1].dx = delta; | - | ||||||||||||||||||||||||
377 | appendQuad(&indices, topRight, topRight + 1, bottomRight, bottomRight + 1); | - | ||||||||||||||||||||||||
378 | } never executed: end of block | 0 | ||||||||||||||||||||||||
379 | } never executed: end of block | 0 | ||||||||||||||||||||||||
380 | } never executed: end of block | 0 | ||||||||||||||||||||||||
381 | - | |||||||||||||||||||||||||
382 | ((index == g->vertexCount()) ? static_cast<void>(0) : qt_assert("index == g->vertexCount()", __FILE__, 424)); | - | ||||||||||||||||||||||||
383 | ((indices - g->indexCount() == g->indexData()) ? static_cast<void>(0) : qt_assert("indices - g->indexCount() == g->indexData()", __FILE__, 425)); | - | ||||||||||||||||||||||||
384 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
385 | if (!geometry
| 2-70 | ||||||||||||||||||||||||
386 | geometry = new QSGGeometry(QSGGeometry::defaultAttributes_TexturedPoint2D(), | - | ||||||||||||||||||||||||
387 | hCells * vCells * 4, hCells * vCells * 6, | - | ||||||||||||||||||||||||
388 | QSGGeometry::UnsignedShortType); | - | ||||||||||||||||||||||||
389 | } executed 2 times by 1 test: else {end of block Executed by:
| 2 | ||||||||||||||||||||||||
390 | geometry->allocate(hCells * vCells * 4, hCells * vCells * 6); | - | ||||||||||||||||||||||||
391 | } executed 70 times by 2 tests: end of block Executed by:
| 70 | ||||||||||||||||||||||||
392 | geometry->setDrawingMode(QSGGeometry::DrawTriangles); | - | ||||||||||||||||||||||||
393 | QSGGeometry::TexturedPoint2D *vertices = geometry->vertexDataAsTexturedPoint2D(); | - | ||||||||||||||||||||||||
394 | ys = yData.data(); | - | ||||||||||||||||||||||||
395 | for (int j = 0; j < vCells
| 72-216 | ||||||||||||||||||||||||
396 | xs = xData.data(); | - | ||||||||||||||||||||||||
397 | for (int i = 0; i < hCells
| 216-636 | ||||||||||||||||||||||||
398 | vertices[0].x = vertices[2].x = xs[0].x; | - | ||||||||||||||||||||||||
399 | vertices[0].tx = vertices[2].tx = xs[0].tx; | - | ||||||||||||||||||||||||
400 | vertices[1].x = vertices[3].x = xs[1].x; | - | ||||||||||||||||||||||||
401 | vertices[1].tx = vertices[3].tx = xs[1].tx; | - | ||||||||||||||||||||||||
402 | - | |||||||||||||||||||||||||
403 | vertices[0].y = vertices[1].y = ys[0].y; | - | ||||||||||||||||||||||||
404 | vertices[0].ty = vertices[1].ty = ys[0].ty; | - | ||||||||||||||||||||||||
405 | vertices[2].y = vertices[3].y = ys[1].y; | - | ||||||||||||||||||||||||
406 | vertices[2].ty = vertices[3].ty = ys[1].ty; | - | ||||||||||||||||||||||||
407 | - | |||||||||||||||||||||||||
408 | vertices += 4; | - | ||||||||||||||||||||||||
409 | } executed 636 times by 2 tests: end of block Executed by:
| 636 | ||||||||||||||||||||||||
410 | } executed 216 times by 2 tests: end of block Executed by:
| 216 | ||||||||||||||||||||||||
411 | - | |||||||||||||||||||||||||
412 | quint16 *indices = geometry->indexDataAsUShort(); | - | ||||||||||||||||||||||||
413 | for (int i = 0; i < 4 * vCells * hCells
| 72-636 | ||||||||||||||||||||||||
414 | 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:
| 636 | ||||||||||||||||||||||||
415 | } executed 72 times by 2 tests: end of block Executed by:
| 72 | ||||||||||||||||||||||||
416 | return executed 72 times by 2 tests: geometry;return geometry; Executed by:
executed 72 times by 2 tests: return geometry; Executed by:
| 72 | ||||||||||||||||||||||||
417 | } | - | ||||||||||||||||||||||||
418 | - | |||||||||||||||||||||||||
419 | void QSGBasicInternalImageNode::updateGeometry() | - | ||||||||||||||||||||||||
420 | { | - | ||||||||||||||||||||||||
421 | ((!m_targetRect.isEmpty()) ? static_cast<void>(0) : qt_assert("!m_targetRect.isEmpty()", __FILE__, 463)); | - | ||||||||||||||||||||||||
422 | const QSGTexture *t = materialTexture(); | - | ||||||||||||||||||||||||
423 | if (!t
| 0-5280 | ||||||||||||||||||||||||
424 | QSGGeometry *g = geometry(); | - | ||||||||||||||||||||||||
425 | g->allocate(4); | - | ||||||||||||||||||||||||
426 | g->setDrawingMode(QSGGeometry::DrawTriangleStrip); | - | ||||||||||||||||||||||||
427 | memset(g->vertexData(), 0, g->sizeOfVertex() * 4); | - | ||||||||||||||||||||||||
428 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
429 | QRectF sourceRect = t->normalizedTextureSubRect(); | - | ||||||||||||||||||||||||
430 | - | |||||||||||||||||||||||||
431 | QRectF innerSourceRect(sourceRect.x() + m_innerSourceRect.x() * sourceRect.width(), | - | ||||||||||||||||||||||||
432 | sourceRect.y() + m_innerSourceRect.y() * sourceRect.height(), | - | ||||||||||||||||||||||||
433 | m_innerSourceRect.width() * sourceRect.width(), | - | ||||||||||||||||||||||||
434 | m_innerSourceRect.height() * sourceRect.height()); | - | ||||||||||||||||||||||||
435 | - | |||||||||||||||||||||||||
436 | bool hasMargins = m_targetRect != m_innerTargetRect; | - | ||||||||||||||||||||||||
437 | - | |||||||||||||||||||||||||
438 | int floorLeft = qFloor(m_subSourceRect.left()); | - | ||||||||||||||||||||||||
439 | int ceilRight = qCeil(m_subSourceRect.right()); | - | ||||||||||||||||||||||||
440 | int floorTop = qFloor(m_subSourceRect.top()); | - | ||||||||||||||||||||||||
441 | int ceilBottom = qCeil(m_subSourceRect.bottom()); | - | ||||||||||||||||||||||||
442 | int hTiles = ceilRight - floorLeft; | - | ||||||||||||||||||||||||
443 | int vTiles = ceilBottom - floorTop; | - | ||||||||||||||||||||||||
444 | - | |||||||||||||||||||||||||
445 | bool hasTiles = hTiles != 1
| 4-5274 | ||||||||||||||||||||||||
446 | bool fullTexture = innerSourceRect == QRectF(0, 0, 1, 1); | - | ||||||||||||||||||||||||
447 | - | |||||||||||||||||||||||||
448 | - | |||||||||||||||||||||||||
449 | - | |||||||||||||||||||||||||
450 | - | |||||||||||||||||||||||||
451 | - | |||||||||||||||||||||||||
452 | - | |||||||||||||||||||||||||
453 | if (!hasMargins
| 0-5210 | ||||||||||||||||||||||||
454 | QRectF sr; | - | ||||||||||||||||||||||||
455 | if (!fullTexture
| 263-4947 | ||||||||||||||||||||||||
456 | sr = QRectF(innerSourceRect.x() + (m_subSourceRect.left() - floorLeft) * innerSourceRect.width(), | - | ||||||||||||||||||||||||
457 | innerSourceRect.y() + (m_subSourceRect.top() - floorTop) * innerSourceRect.height(), | - | ||||||||||||||||||||||||
458 | m_subSourceRect.width() * innerSourceRect.width(), | - | ||||||||||||||||||||||||
459 | m_subSourceRect.height() * innerSourceRect.height()); | - | ||||||||||||||||||||||||
460 | } executed 4947 times by 9 tests: else {end of block Executed by:
| 4947 | ||||||||||||||||||||||||
461 | sr = QRectF(m_subSourceRect.left() - floorLeft, m_subSourceRect.top() - floorTop, | - | ||||||||||||||||||||||||
462 | m_subSourceRect.width(), m_subSourceRect.height()); | - | ||||||||||||||||||||||||
463 | } executed 263 times by 5 tests: end of block Executed by:
| 263 | ||||||||||||||||||||||||
464 | if (m_mirror
| 22-5188 | ||||||||||||||||||||||||
465 | qreal oldLeft = sr.left(); | - | ||||||||||||||||||||||||
466 | sr.setLeft(sr.right()); | - | ||||||||||||||||||||||||
467 | sr.setRight(oldLeft); | - | ||||||||||||||||||||||||
468 | } executed 22 times by 2 tests: end of block Executed by:
| 22 | ||||||||||||||||||||||||
469 | - | |||||||||||||||||||||||||
470 | if (m_antialiasing
| 0-5210 | ||||||||||||||||||||||||
471 | QSGGeometry *g = geometry(); | - | ||||||||||||||||||||||||
472 | ((g != &m_geometry) ? static_cast<void>(0) : qt_assert("g != &m_geometry", __FILE__, 514)); | - | ||||||||||||||||||||||||
473 | g->allocate(8, 14); | - | ||||||||||||||||||||||||
474 | g->setDrawingMode(QSGGeometry::DrawTriangleStrip); | - | ||||||||||||||||||||||||
475 | SmoothVertex *vertices = reinterpret_cast<SmoothVertex *>(g->vertexData()); | - | ||||||||||||||||||||||||
476 | float delta = float(qAbs(m_targetRect.width()) < qAbs(m_targetRect.height()) | - | ||||||||||||||||||||||||
477 | ? m_targetRect.width() : m_targetRect.height()) * 0.5f; | - | ||||||||||||||||||||||||
478 | float sx = float(sr.width() / m_targetRect.width()); | - | ||||||||||||||||||||||||
479 | float sy = float(sr.height() / m_targetRect.height()); | - | ||||||||||||||||||||||||
480 | for (int d = -1; d <= 1
| 0 | ||||||||||||||||||||||||
481 | for (int j = 0; j < 2
| 0 | ||||||||||||||||||||||||
482 | for (int i = 0; i < 2
| 0 | ||||||||||||||||||||||||
483 | vertices->x = m_targetRect.x() + i * m_targetRect.width(); | - | ||||||||||||||||||||||||
484 | vertices->y = m_targetRect.y() + j * m_targetRect.height(); | - | ||||||||||||||||||||||||
485 | vertices->u = sr.x() + i * sr.width(); | - | ||||||||||||||||||||||||
486 | vertices->v = sr.y() + j * sr.height(); | - | ||||||||||||||||||||||||
487 | vertices->dx = (i == 0
| 0 | ||||||||||||||||||||||||
488 | vertices->dy = (j == 0
| 0 | ||||||||||||||||||||||||
489 | vertices->du = (d < 0
| 0 | ||||||||||||||||||||||||
490 | vertices->dv = (d < 0
| 0 | ||||||||||||||||||||||||
491 | } never executed: end of block | 0 | ||||||||||||||||||||||||
492 | } never executed: end of block | 0 | ||||||||||||||||||||||||
493 | } never executed: end of block | 0 | ||||||||||||||||||||||||
494 | ((vertices - g->vertexCount() == g->vertexData()) ? static_cast<void>(0) : qt_assert("vertices - g->vertexCount() == g->vertexData()", __FILE__, 536)); | - | ||||||||||||||||||||||||
495 | static const quint16 indices[] = { | - | ||||||||||||||||||||||||
496 | 0, 4, 1, 5, 3, 7, 2, 6, 0, 4, | - | ||||||||||||||||||||||||
497 | 4, 6, 5, 7 | - | ||||||||||||||||||||||||
498 | }; | - | ||||||||||||||||||||||||
499 | ((g->sizeOfIndex() * g->indexCount() == sizeof(indices)) ? static_cast<void>(0) : qt_assert("g->sizeOfIndex() * g->indexCount() == sizeof(indices)", __FILE__, 541)); | - | ||||||||||||||||||||||||
500 | memcpy(g->indexDataAsUShort(), indices, sizeof(indices)); | - | ||||||||||||||||||||||||
501 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
502 | m_geometry.allocate(4); | - | ||||||||||||||||||||||||
503 | m_geometry.setDrawingMode(QSGGeometry::DrawTriangleStrip); | - | ||||||||||||||||||||||||
504 | QSGGeometry::updateTexturedRectGeometry(&m_geometry, m_targetRect, sr); | - | ||||||||||||||||||||||||
505 | } executed 5210 times by 10 tests: end of block Executed by:
| 5210 | ||||||||||||||||||||||||
506 | } else { | - | ||||||||||||||||||||||||
507 | QSGGeometry *g = m_antialiasing
| 0-70 | ||||||||||||||||||||||||
508 | updateGeometry(m_targetRect, m_innerTargetRect, | - | ||||||||||||||||||||||||
509 | sourceRect, innerSourceRect, m_subSourceRect, | - | ||||||||||||||||||||||||
510 | g, m_mirror, m_antialiasing); | - | ||||||||||||||||||||||||
511 | } executed 70 times by 2 tests: end of block Executed by:
| 70 | ||||||||||||||||||||||||
512 | } | - | ||||||||||||||||||||||||
513 | markDirty(DirtyGeometry); | - | ||||||||||||||||||||||||
514 | m_dirtyGeometry = false; | - | ||||||||||||||||||||||||
515 | } executed 5280 times by 10 tests: end of block Executed by:
| 5280 | ||||||||||||||||||||||||
516 | - | |||||||||||||||||||||||||
517 | - | |||||||||||||||||||||||||
Switch to Source code | Preprocessed file |