OpenCoverage

qquickpainteditem.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/items/qquickpainteditem.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6class QQuickPaintedItemTextureProvider : public QSGTextureProvider-
7{-
8public:-
9 QSGPainterNode *node;-
10 QSGTexture *texture() const override { return
never executed: return node ? node->texture() : nullptr;
node ? node->texture() : nullptr;
never executed: return node ? node->texture() : nullptr;
}
0
11 void fireTextureChanged() { textureChanged(); }
never executed: end of block
0
12};-
13QQuickPaintedItemPrivate::QQuickPaintedItemPrivate()-
14 : QQuickItemPrivate()-
15 , contentsScale(1.0)-
16 , fillColor(Qt::transparent)-
17 , renderTarget(QQuickPaintedItem::Image)-
18 , performanceHints(nullptr)-
19 , opaquePainting(false)-
20 , antialiasing(false)-
21 , mipmap(false)-
22 , textureProvider(nullptr)-
23 , node(nullptr)-
24{-
25}
executed 20 times by 1 test: end of block
Executed by:
  • tst_qquickpainteditem
20
26-
27-
28-
29-
30QQuickPaintedItem::QQuickPaintedItem(QQuickItem *parent)-
31 : QQuickItem(*(new QQuickPaintedItemPrivate), parent)-
32{-
33 setFlag(ItemHasContents);-
34}
executed 20 times by 1 test: end of block
Executed by:
  • tst_qquickpainteditem
20
35-
36-
37-
38-
39QQuickPaintedItem::QQuickPaintedItem(QQuickPaintedItemPrivate &dd, QQuickItem *parent)-
40 : QQuickItem(dd, parent)-
41{-
42 setFlag(ItemHasContents);-
43}
never executed: end of block
0
44-
45-
46-
47-
48QQuickPaintedItem::~QQuickPaintedItem()-
49{-
50 QQuickPaintedItemPrivate * const d = d_func();-
51 if (d->textureProvider
d->textureProviderDescription
TRUEnever evaluated
FALSEevaluated 20 times by 1 test
Evaluated by:
  • tst_qquickpainteditem
)
0-20
52 QQuickWindowQObjectCleanupJob::schedule(window(), d->textureProvider);
never executed: QQuickWindowQObjectCleanupJob::schedule(window(), d->textureProvider);
0
53}
executed 20 times by 1 test: end of block
Executed by:
  • tst_qquickpainteditem
20
54void QQuickPaintedItem::update(const QRect &rect)-
55{-
56 QQuickPaintedItemPrivate * const d = d_func();-
57-
58 if (rect.isNull()
rect.isNull()Description
TRUEevaluated 52 times by 1 test
Evaluated by:
  • tst_qquickpainteditem
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_qquickpainteditem
&& !d->dirtyRect.isNull()
!d->dirtyRect.isNull()Description
TRUEnever evaluated
FALSEevaluated 52 times by 1 test
Evaluated by:
  • tst_qquickpainteditem
)
0-52
59 d->dirtyRect = contentsBoundingRect().toAlignedRect();
never executed: d->dirtyRect = contentsBoundingRect().toAlignedRect();
0
60 else-
61 d->dirtyRect |= (contentsBoundingRect() & rect).toAlignedRect();
executed 58 times by 1 test: d->dirtyRect |= (contentsBoundingRect() & rect).toAlignedRect();
Executed by:
  • tst_qquickpainteditem
58
62 QQuickItem::update();-
63}
executed 58 times by 1 test: end of block
Executed by:
  • tst_qquickpainteditem
58
64bool QQuickPaintedItem::opaquePainting() const-
65{-
66 const QQuickPaintedItemPrivate * const d = d_func();-
67 return
executed 10 times by 1 test: return d->opaquePainting;
Executed by:
  • tst_qquickpainteditem
d->opaquePainting;
executed 10 times by 1 test: return d->opaquePainting;
Executed by:
  • tst_qquickpainteditem
10
68}-
69void QQuickPaintedItem::setOpaquePainting(bool opaque)-
70{-
71 QQuickPaintedItemPrivate * const d = d_func();-
72-
73 if (d->opaquePainting == opaque
d->opaquePainting == opaqueDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickpainteditem
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickpainteditem
)
4
74 return;
executed 4 times by 1 test: return;
Executed by:
  • tst_qquickpainteditem
4
75-
76 d->opaquePainting = opaque;-
77 QQuickItem::update();-
78}
executed 4 times by 1 test: end of block
Executed by:
  • tst_qquickpainteditem
4
79bool QQuickPaintedItem::antialiasing() const-
80{-
81 const QQuickPaintedItemPrivate * const d = d_func();-
82 return
executed 10 times by 1 test: return d->antialiasing;
Executed by:
  • tst_qquickpainteditem
d->antialiasing;
executed 10 times by 1 test: return d->antialiasing;
Executed by:
  • tst_qquickpainteditem
10
83}-
84void QQuickPaintedItem::setAntialiasing(bool enable)-
85{-
86 QQuickPaintedItemPrivate * const d = d_func();-
87-
88 if (d->antialiasing == enable
d->antialiasing == enableDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickpainteditem
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickpainteditem
)
4
89 return;
executed 4 times by 1 test: return;
Executed by:
  • tst_qquickpainteditem
4
90-
91 d->antialiasing = enable;-
92 update();-
93}
executed 4 times by 1 test: end of block
Executed by:
  • tst_qquickpainteditem
4
94bool QQuickPaintedItem::mipmap() const-
95{-
96 const QQuickPaintedItemPrivate * const d = d_func();-
97 return
executed 10 times by 1 test: return d->mipmap;
Executed by:
  • tst_qquickpainteditem
d->mipmap;
executed 10 times by 1 test: return d->mipmap;
Executed by:
  • tst_qquickpainteditem
10
98}-
99void QQuickPaintedItem::setMipmap(bool enable)-
100{-
101 QQuickPaintedItemPrivate * const d = d_func();-
102-
103 if (d->mipmap == enable
d->mipmap == enableDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickpainteditem
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickpainteditem
)
4
104 return;
executed 4 times by 1 test: return;
Executed by:
  • tst_qquickpainteditem
4
105-
106 d->mipmap = enable;-
107 update();-
108}
executed 4 times by 1 test: end of block
Executed by:
  • tst_qquickpainteditem
4
109QQuickPaintedItem::PerformanceHints QQuickPaintedItem::performanceHints() const-
110{-
111 const QQuickPaintedItemPrivate * const d = d_func();-
112 return
executed 10 times by 1 test: return d->performanceHints;
Executed by:
  • tst_qquickpainteditem
d->performanceHints;
executed 10 times by 1 test: return d->performanceHints;
Executed by:
  • tst_qquickpainteditem
10
113}-
114void QQuickPaintedItem::setPerformanceHint(QQuickPaintedItem::PerformanceHint hint, bool enabled)-
115{-
116 QQuickPaintedItemPrivate * const d = d_func();-
117 PerformanceHints oldHints = d->performanceHints;-
118 if (enabled
enabledDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickpainteditem
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickpainteditem
)
2
119 d->performanceHints |= hint;
executed 2 times by 1 test: d->performanceHints |= hint;
Executed by:
  • tst_qquickpainteditem
2
120 else-
121 d->performanceHints &= ~hint;
executed 2 times by 1 test: d->performanceHints &= ~hint;
Executed by:
  • tst_qquickpainteditem
2
122 if (oldHints != d->performanceHints
oldHints != d-...rformanceHintsDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickpainteditem
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickpainteditem
)
2
123 update();
executed 2 times by 1 test: update();
Executed by:
  • tst_qquickpainteditem
2
124}
executed 4 times by 1 test: end of block
Executed by:
  • tst_qquickpainteditem
4
125void QQuickPaintedItem::setPerformanceHints(QQuickPaintedItem::PerformanceHints hints)-
126{-
127 QQuickPaintedItemPrivate * const d = d_func();-
128 if (d->performanceHints == hints
d->performanceHints == hintsDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickpainteditem
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickpainteditem
)
2
129 return;
executed 2 times by 1 test: return;
Executed by:
  • tst_qquickpainteditem
2
130 d->performanceHints = hints;-
131 update();-
132}
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickpainteditem
2
133-
134QSize QQuickPaintedItem::textureSize() const-
135{-
136 const QQuickPaintedItemPrivate * const d = d_func();-
137 return
never executed: return d->textureSize;
d->textureSize;
never executed: return d->textureSize;
0
138}-
139void QQuickPaintedItem::setTextureSize(const QSize &size)-
140{-
141 QQuickPaintedItemPrivate * const d = d_func();-
142 if (d->textureSize == size
d->textureSize == sizeDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
143 return;
never executed: return;
0
144 d->textureSize = size;-
145 textureSizeChanged();-
146}
never executed: end of block
0
147QRectF QQuickPaintedItem::contentsBoundingRect() const-
148{-
149 const QQuickPaintedItemPrivate * const d = d_func();-
150-
151 qreal w = d->width;-
152 QSizeF sz = d->contentsSize * d->contentsScale;-
153 if (w < sz.width()
w < sz.width()Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquickpainteditem
FALSEevaluated 72 times by 1 test
Evaluated by:
  • tst_qquickpainteditem
)
8-72
154 w = sz.width();
executed 8 times by 1 test: w = sz.width();
Executed by:
  • tst_qquickpainteditem
8
155 qreal h = d->height;-
156 if (h < sz.height()
h < sz.height()Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • tst_qquickpainteditem
FALSEevaluated 60 times by 1 test
Evaluated by:
  • tst_qquickpainteditem
)
20-60
157 h = sz.height();
executed 20 times by 1 test: h = sz.height();
Executed by:
  • tst_qquickpainteditem
20
158-
159 return
executed 80 times by 1 test: return QRectF(0, 0, w, h);
Executed by:
  • tst_qquickpainteditem
QRectF(0, 0, w, h);
executed 80 times by 1 test: return QRectF(0, 0, w, h);
Executed by:
  • tst_qquickpainteditem
80
160}-
161QSize QQuickPaintedItem::contentsSize() const-
162{-
163 const QQuickPaintedItemPrivate * const d = d_func();-
164 return
executed 10 times by 1 test: return d->contentsSize;
Executed by:
  • tst_qquickpainteditem
d->contentsSize;
executed 10 times by 1 test: return d->contentsSize;
Executed by:
  • tst_qquickpainteditem
10
165}-
166-
167void QQuickPaintedItem::setContentsSize(const QSize &size)-
168{-
169 QQuickPaintedItemPrivate * const d = d_func();-
170-
171 if (d->contentsSize == size
d->contentsSize == sizeDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickpainteditem
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquickpainteditem
)
4-8
172 return;
executed 4 times by 1 test: return;
Executed by:
  • tst_qquickpainteditem
4
173-
174 d->contentsSize = size;-
175 update();-
176-
177 contentsSizeChanged();-
178}
executed 8 times by 1 test: end of block
Executed by:
  • tst_qquickpainteditem
8
179-
180-
181-
182-
183-
184void QQuickPaintedItem::resetContentsSize()-
185{-
186 setContentsSize(QSize());-
187}
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickpainteditem
2
188qreal QQuickPaintedItem::contentsScale() const-
189{-
190 const QQuickPaintedItemPrivate * const d = d_func();-
191 return
executed 10 times by 1 test: return d->contentsScale;
Executed by:
  • tst_qquickpainteditem
d->contentsScale;
executed 10 times by 1 test: return d->contentsScale;
Executed by:
  • tst_qquickpainteditem
10
192}-
193-
194void QQuickPaintedItem::setContentsScale(qreal scale)-
195{-
196 QQuickPaintedItemPrivate * const d = d_func();-
197-
198 if (d->contentsScale == scale
d->contentsScale == scaleDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickpainteditem
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquickpainteditem
)
4-8
199 return;
executed 4 times by 1 test: return;
Executed by:
  • tst_qquickpainteditem
4
200-
201 d->contentsScale = scale;-
202 update();-
203-
204 contentsScaleChanged();-
205}
executed 8 times by 1 test: end of block
Executed by:
  • tst_qquickpainteditem
8
206-
207-
208-
209-
210-
211-
212-
213QColor QQuickPaintedItem::fillColor() const-
214{-
215 const QQuickPaintedItemPrivate * const d = d_func();-
216 return
executed 10 times by 1 test: return d->fillColor;
Executed by:
  • tst_qquickpainteditem
d->fillColor;
executed 10 times by 1 test: return d->fillColor;
Executed by:
  • tst_qquickpainteditem
10
217}-
218-
219void QQuickPaintedItem::setFillColor(const QColor &c)-
220{-
221 QQuickPaintedItemPrivate * const d = d_func();-
222-
223 if (d->fillColor == c
d->fillColor == cDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickpainteditem
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickpainteditem
)
4
224 return;
executed 4 times by 1 test: return;
Executed by:
  • tst_qquickpainteditem
4
225-
226 d->fillColor = c;-
227 update();-
228-
229 fillColorChanged();-
230}
executed 4 times by 1 test: end of block
Executed by:
  • tst_qquickpainteditem
4
231QQuickPaintedItem::RenderTarget QQuickPaintedItem::renderTarget() const-
232{-
233 const QQuickPaintedItemPrivate * const d = d_func();-
234 return
executed 10 times by 1 test: return d->renderTarget;
Executed by:
  • tst_qquickpainteditem
d->renderTarget;
executed 10 times by 1 test: return d->renderTarget;
Executed by:
  • tst_qquickpainteditem
10
235}-
236-
237void QQuickPaintedItem::setRenderTarget(RenderTarget target)-
238{-
239 QQuickPaintedItemPrivate * const d = d_func();-
240-
241 if (d->renderTarget == target
d->renderTarget == targetDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickpainteditem
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickpainteditem
)
4
242 return;
executed 4 times by 1 test: return;
Executed by:
  • tst_qquickpainteditem
4
243-
244 d->renderTarget = target;-
245 update();-
246-
247 renderTargetChanged();-
248}
executed 4 times by 1 test: end of block
Executed by:
  • tst_qquickpainteditem
4
249QSGNode *QQuickPaintedItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data)-
250{-
251 (void)data;;-
252 QQuickPaintedItemPrivate * const d = d_func();-
253-
254 if (width() <= 0
width() <= 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickpainteditem
FALSEevaluated 50 times by 1 test
Evaluated by:
  • tst_qquickpainteditem
|| height() <= 0
height() <= 0Description
TRUEnever evaluated
FALSEevaluated 50 times by 1 test
Evaluated by:
  • tst_qquickpainteditem
) {
0-50
255 delete oldNode;-
256 if (d->textureProvider
d->textureProviderDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickpainteditem
) {
0-2
257 d->textureProvider->node = nullptr;-
258 d->textureProvider->fireTextureChanged();-
259 }
never executed: end of block
0
260 return
executed 2 times by 1 test: return nullptr;
Executed by:
  • tst_qquickpainteditem
nullptr;
executed 2 times by 1 test: return nullptr;
Executed by:
  • tst_qquickpainteditem
2
261 }-
262-
263 QSGPainterNode *node = static_cast<QSGPainterNode *>(oldNode);-
264 if (!node
!nodeDescription
TRUEevaluated 16 times by 1 test
Evaluated by:
  • tst_qquickpainteditem
FALSEevaluated 34 times by 1 test
Evaluated by:
  • tst_qquickpainteditem
) {
16-34
265 node = d->sceneGraphContext()->createPainterNode(this);-
266 d->node = node;-
267 }
executed 16 times by 1 test: end of block
Executed by:
  • tst_qquickpainteditem
16
268-
269 bool hasTextureSize = d->textureSize.width() > 0
d->textureSize.width() > 0Description
TRUEnever evaluated
FALSEevaluated 50 times by 1 test
Evaluated by:
  • tst_qquickpainteditem
&& d->textureSize.height() > 0
d->textureSize.height() > 0Description
TRUEnever evaluated
FALSEnever evaluated
;
0-50
270-
271-
272-
273 if (!hasTextureSize
!hasTextureSizeDescription
TRUEevaluated 50 times by 1 test
Evaluated by:
  • tst_qquickpainteditem
FALSEnever evaluated
0-50
274 && (d->contentsScale != 1
d->contentsScale != 1Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • tst_qquickpainteditem
FALSEevaluated 40 times by 1 test
Evaluated by:
  • tst_qquickpainteditem
10-40
275 || (d->contentsSize.width() > 0
d->contentsSize.width() > 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickpainteditem
FALSEevaluated 38 times by 1 test
Evaluated by:
  • tst_qquickpainteditem
&& d->contentsSize.height() > 0
d->contentsSize.height() > 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickpainteditem
FALSEnever evaluated
))) {
0-38
276 QRectF br = contentsBoundingRect();-
277 node->setContentsScale(d->contentsScale);-
278 QSize size = QSize(qRound(br.width()), qRound(br.height()));-
279 node->setSize(size);-
280 node->setTextureSize(size);-
281 }
executed 12 times by 1 test: end of block
Executed by:
  • tst_qquickpainteditem
else {
12
282-
283 node->setContentsScale(1);-
284 QSize itemSize(qRound(width()), qRound(height()));-
285 node->setSize(itemSize);-
286 QSize textureSize = (hasTextureSize
hasTextureSizeDescription
TRUEnever evaluated
FALSEevaluated 38 times by 1 test
Evaluated by:
  • tst_qquickpainteditem
? d->textureSize : itemSize)
0-38
287 * window()->effectiveDevicePixelRatio();-
288 node->setTextureSize(textureSize);-
289 }
executed 38 times by 1 test: end of block
Executed by:
  • tst_qquickpainteditem
38
290-
291 node->setPreferredRenderTarget(d->renderTarget);-
292 node->setFastFBOResizing(d->performanceHints & FastFBOResizing);-
293 node->setSmoothPainting(d->antialiasing);-
294 node->setLinearFiltering(d->smooth);-
295 node->setMipmapping(d->mipmap);-
296 node->setOpaquePainting(d->opaquePainting);-
297 node->setFillColor(d->fillColor);-
298 node->setDirty(d->dirtyRect);-
299 node->update();-
300-
301 d->dirtyRect = QRect();-
302-
303 if (d->textureProvider
d->textureProviderDescription
TRUEnever evaluated
FALSEevaluated 50 times by 1 test
Evaluated by:
  • tst_qquickpainteditem
) {
0-50
304 d->textureProvider->node = node;-
305 d->textureProvider->fireTextureChanged();-
306 }
never executed: end of block
0
307-
308 return
executed 50 times by 1 test: return node;
Executed by:
  • tst_qquickpainteditem
node;
executed 50 times by 1 test: return node;
Executed by:
  • tst_qquickpainteditem
50
309}-
310-
311-
312-
313-
314void QQuickPaintedItem::releaseResources()-
315{-
316 QQuickPaintedItemPrivate * const d = d_func();-
317 if (d->textureProvider
d->textureProviderDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
318 QQuickWindowQObjectCleanupJob::schedule(window(), d->textureProvider);-
319 d->textureProvider = nullptr;-
320 }
never executed: end of block
0
321 d->node = nullptr;-
322}
never executed: end of block
0
323-
324void QQuickPaintedItem::invalidateSceneGraph()-
325{-
326 QQuickPaintedItemPrivate * const d = d_func();-
327 delete d->textureProvider;-
328 d->textureProvider = nullptr;-
329 d->node = nullptr;-
330}
never executed: end of block
0
331-
332-
333-
334-
335bool QQuickPaintedItem::isTextureProvider() const-
336{-
337 return
never executed: return true;
true;
never executed: return true;
0
338}-
339-
340-
341-
342-
343QSGTextureProvider *QQuickPaintedItem::textureProvider() const-
344{-
345-
346-
347-
348-
349 if (QQuickItem::isTextureProvider()
QQuickItem::is...tureProvider()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
350 return
never executed: return QQuickItem::textureProvider();
QQuickItem::textureProvider();
never executed: return QQuickItem::textureProvider();
0
351-
352 const QQuickPaintedItemPrivate * const d = d_func();-
353-
354 QQuickWindow *w = window();-
355 if (!w
!wDescription
TRUEnever evaluated
FALSEnever evaluated
|| !w->openglContext()
!w->openglContext()Description
TRUEnever evaluated
FALSEnever evaluated
|| QThread::currentThread() != w->openglContext()->thread()
QThread::curre...xt()->thread()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
356 QMessageLogger(__FILE__, 668, __PRETTY_FUNCTION__).warning("QQuickPaintedItem::textureProvider: can only be queried on the rendering thread of an exposed window");-
357 return
never executed: return nullptr;
nullptr;
never executed: return nullptr;
0
358 }-
359-
360 if (!d->textureProvider
!d->textureProviderDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
361 d->textureProvider = new QQuickPaintedItemTextureProvider();
never executed: d->textureProvider = new QQuickPaintedItemTextureProvider();
0
362 d->textureProvider->node = d->node;-
363 return
never executed: return d->textureProvider;
d->textureProvider;
never executed: return d->textureProvider;
0
364}-
365-
366-
367-
368-
369-
370void QQuickPaintedItem::itemChange(ItemChange change, const ItemChangeData &value)-
371{-
372 if (change == ItemDevicePixelRatioHasChanged
change == Item...atioHasChangedDescription
TRUEnever evaluated
FALSEevaluated 32 times by 1 test
Evaluated by:
  • tst_qquickpainteditem
)
0-32
373 update();
never executed: update();
0
374 QQuickItem::itemChange(change, value);-
375}
executed 32 times by 1 test: end of block
Executed by:
  • tst_qquickpainteditem
32
376-
377-
378-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.0