Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/items/qquickimage.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||||||||
2 | - | |||||||||||||||||||||||||
3 | - | |||||||||||||||||||||||||
4 | - | |||||||||||||||||||||||||
5 | - | |||||||||||||||||||||||||
6 | - | |||||||||||||||||||||||||
7 | class QQuickImageTextureProvider : public QSGTextureProvider | - | ||||||||||||||||||||||||
8 | { | - | ||||||||||||||||||||||||
9 | public: | - | ||||||||||||||||||||||||
10 | #pragma GCC diagnostic push | - | ||||||||||||||||||||||||
11 | - | |||||||||||||||||||||||||
12 | #pragma GCC diagnostic ignored "-Wsuggest-override" | - | ||||||||||||||||||||||||
13 | static const QMetaObject staticMetaObject; virtual const QMetaObject *metaObject() const; virtual void *qt_metacast(const char *); virtual int qt_metacall(QMetaObject::Call, int, void **); static inline QString tr(const char *s, const char *c = nullptr, int n = -1) { return staticMetaObject.tr(s, c, n); } __attribute__ ((__deprecated__)) static inline QString trUtf8(const char *s, const char *c = nullptr, int n = -1) { return staticMetaObject.tr(s, c, n); } private: | - | ||||||||||||||||||||||||
14 | #pragma GCC diagnostic ignored "-Wattributes" | - | ||||||||||||||||||||||||
15 | __attribute__((visibility("hidden"))) static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); | - | ||||||||||||||||||||||||
16 | #pragma GCC diagnostic pop | - | ||||||||||||||||||||||||
17 | struct QPrivateSignal {}; | - | ||||||||||||||||||||||||
18 | public: | - | ||||||||||||||||||||||||
19 | QQuickImageTextureProvider() | - | ||||||||||||||||||||||||
20 | : m_texture(nullptr) | - | ||||||||||||||||||||||||
21 | , m_smooth(false) | - | ||||||||||||||||||||||||
22 | { | - | ||||||||||||||||||||||||
23 | } executed 4 times by 2 tests: end of block Executed by:
| 4 | ||||||||||||||||||||||||
24 | - | |||||||||||||||||||||||||
25 | void updateTexture(QSGTexture *texture) { | - | ||||||||||||||||||||||||
26 | if (m_texture == texture
| 4 | ||||||||||||||||||||||||
27 | return; executed 4 times by 2 tests: return; Executed by:
| 4 | ||||||||||||||||||||||||
28 | m_texture = texture; | - | ||||||||||||||||||||||||
29 | textureChanged(); | - | ||||||||||||||||||||||||
30 | } executed 4 times by 2 tests: end of block Executed by:
| 4 | ||||||||||||||||||||||||
31 | - | |||||||||||||||||||||||||
32 | QSGTexture *texture() const override { | - | ||||||||||||||||||||||||
33 | if (m_texture
| 0-16 | ||||||||||||||||||||||||
34 | m_texture->setFiltering(m_smooth ? QSGTexture::Linear : QSGTexture::Nearest); | - | ||||||||||||||||||||||||
35 | m_texture->setMipmapFiltering(m_mipmap ? QSGTexture::Linear : QSGTexture::None); | - | ||||||||||||||||||||||||
36 | m_texture->setHorizontalWrapMode(QSGTexture::ClampToEdge); | - | ||||||||||||||||||||||||
37 | m_texture->setVerticalWrapMode(QSGTexture::ClampToEdge); | - | ||||||||||||||||||||||||
38 | } executed 16 times by 2 tests: end of block Executed by:
| 16 | ||||||||||||||||||||||||
39 | return executed 16 times by 2 tests: m_texture;return m_texture; Executed by:
executed 16 times by 2 tests: return m_texture; Executed by:
| 16 | ||||||||||||||||||||||||
40 | } | - | ||||||||||||||||||||||||
41 | - | |||||||||||||||||||||||||
42 | friend class QQuickImage; | - | ||||||||||||||||||||||||
43 | - | |||||||||||||||||||||||||
44 | QSGTexture *m_texture; | - | ||||||||||||||||||||||||
45 | bool m_smooth; | - | ||||||||||||||||||||||||
46 | bool m_mipmap; | - | ||||||||||||||||||||||||
47 | }; | - | ||||||||||||||||||||||||
48 | - | |||||||||||||||||||||||||
49 | - | |||||||||||||||||||||||||
50 | QQuickImagePrivate::QQuickImagePrivate() | - | ||||||||||||||||||||||||
51 | : fillMode(QQuickImage::Stretch) | - | ||||||||||||||||||||||||
52 | , paintedWidth(0) | - | ||||||||||||||||||||||||
53 | , paintedHeight(0) | - | ||||||||||||||||||||||||
54 | , pixmapChanged(false) | - | ||||||||||||||||||||||||
55 | , mipmap(false) | - | ||||||||||||||||||||||||
56 | , hAlign(QQuickImage::AlignHCenter) | - | ||||||||||||||||||||||||
57 | , vAlign(QQuickImage::AlignVCenter) | - | ||||||||||||||||||||||||
58 | , provider(nullptr) | - | ||||||||||||||||||||||||
59 | { | - | ||||||||||||||||||||||||
60 | } executed 5486 times by 15 tests: end of block Executed by:
| 5486 | ||||||||||||||||||||||||
61 | QQuickImage::QQuickImage(QQuickItem *parent) | - | ||||||||||||||||||||||||
62 | : QQuickImageBase(*(new QQuickImagePrivate), parent) | - | ||||||||||||||||||||||||
63 | { | - | ||||||||||||||||||||||||
64 | } executed 5396 times by 14 tests: end of block Executed by:
| 5396 | ||||||||||||||||||||||||
65 | - | |||||||||||||||||||||||||
66 | QQuickImage::QQuickImage(QQuickImagePrivate &dd, QQuickItem *parent) | - | ||||||||||||||||||||||||
67 | : QQuickImageBase(dd, parent) | - | ||||||||||||||||||||||||
68 | { | - | ||||||||||||||||||||||||
69 | } executed 90 times by 2 tests: end of block Executed by:
| 90 | ||||||||||||||||||||||||
70 | - | |||||||||||||||||||||||||
71 | QQuickImage::~QQuickImage() | - | ||||||||||||||||||||||||
72 | { | - | ||||||||||||||||||||||||
73 | QQuickImagePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
74 | if (d->provider
| 0-4208 | ||||||||||||||||||||||||
75 | - | |||||||||||||||||||||||||
76 | - | |||||||||||||||||||||||||
77 | QQuickWindowQObjectCleanupJob::schedule(window(), d->provider); | - | ||||||||||||||||||||||||
78 | } never executed: end of block | 0 | ||||||||||||||||||||||||
79 | } executed 4208 times by 14 tests: end of block Executed by:
| 4208 | ||||||||||||||||||||||||
80 | - | |||||||||||||||||||||||||
81 | void QQuickImagePrivate::setImage(const QImage &image) | - | ||||||||||||||||||||||||
82 | { | - | ||||||||||||||||||||||||
83 | QQuickImage * const q = q_func(); | - | ||||||||||||||||||||||||
84 | pix.setImage(image); | - | ||||||||||||||||||||||||
85 | - | |||||||||||||||||||||||||
86 | q->pixmapChange(); | - | ||||||||||||||||||||||||
87 | status = pix.isNull()
| 0-188 | ||||||||||||||||||||||||
88 | - | |||||||||||||||||||||||||
89 | q->update(); | - | ||||||||||||||||||||||||
90 | } executed 188 times by 2 tests: end of block Executed by:
| 188 | ||||||||||||||||||||||||
91 | - | |||||||||||||||||||||||||
92 | void QQuickImagePrivate::setPixmap(const QQuickPixmap &pixmap) | - | ||||||||||||||||||||||||
93 | { | - | ||||||||||||||||||||||||
94 | QQuickImage * const q = q_func(); | - | ||||||||||||||||||||||||
95 | pix.setPixmap(pixmap); | - | ||||||||||||||||||||||||
96 | - | |||||||||||||||||||||||||
97 | q->pixmapChange(); | - | ||||||||||||||||||||||||
98 | status = pix.isNull()
| 0-404 | ||||||||||||||||||||||||
99 | - | |||||||||||||||||||||||||
100 | q->update(); | - | ||||||||||||||||||||||||
101 | } executed 404 times by 1 test: end of block Executed by:
| 404 | ||||||||||||||||||||||||
102 | QQuickImage::FillMode QQuickImage::fillMode() const | - | ||||||||||||||||||||||||
103 | { | - | ||||||||||||||||||||||||
104 | const QQuickImagePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
105 | return executed 98 times by 2 tests: d->fillMode;return d->fillMode; Executed by:
executed 98 times by 2 tests: return d->fillMode; Executed by:
| 98 | ||||||||||||||||||||||||
106 | } | - | ||||||||||||||||||||||||
107 | - | |||||||||||||||||||||||||
108 | void QQuickImage::setFillMode(FillMode mode) | - | ||||||||||||||||||||||||
109 | { | - | ||||||||||||||||||||||||
110 | QQuickImagePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
111 | if (d->fillMode == mode
| 12-106 | ||||||||||||||||||||||||
112 | return; executed 12 times by 1 test: return; Executed by:
| 12 | ||||||||||||||||||||||||
113 | d->fillMode = mode; | - | ||||||||||||||||||||||||
114 | if ((
| 26-80 | ||||||||||||||||||||||||
115 | d->providerOptions.setPreserveAspectRatioCrop(mode == PreserveAspectCrop); | - | ||||||||||||||||||||||||
116 | if (isComponentComplete()
| 4-22 | ||||||||||||||||||||||||
117 | load(); executed 4 times by 1 test: load(); Executed by:
| 4 | ||||||||||||||||||||||||
118 | } executed 26 times by 2 tests: else if ((end of block Executed by:
| 26-52 | ||||||||||||||||||||||||
119 | d->providerOptions.setPreserveAspectRatioFit(mode == PreserveAspectFit); | - | ||||||||||||||||||||||||
120 | if (isComponentComplete()
| 4-24 | ||||||||||||||||||||||||
121 | load(); executed 4 times by 1 test: load(); Executed by:
| 4 | ||||||||||||||||||||||||
122 | } executed 28 times by 2 tests: end of block Executed by:
| 28 | ||||||||||||||||||||||||
123 | update(); | - | ||||||||||||||||||||||||
124 | updatePaintedGeometry(); | - | ||||||||||||||||||||||||
125 | fillModeChanged(); | - | ||||||||||||||||||||||||
126 | } executed 106 times by 3 tests: end of block Executed by:
| 106 | ||||||||||||||||||||||||
127 | qreal QQuickImage::paintedWidth() const | - | ||||||||||||||||||||||||
128 | { | - | ||||||||||||||||||||||||
129 | const QQuickImagePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
130 | return executed 116 times by 1 test: d->paintedWidth;return d->paintedWidth; Executed by:
executed 116 times by 1 test: return d->paintedWidth; Executed by:
| 116 | ||||||||||||||||||||||||
131 | } | - | ||||||||||||||||||||||||
132 | - | |||||||||||||||||||||||||
133 | qreal QQuickImage::paintedHeight() const | - | ||||||||||||||||||||||||
134 | { | - | ||||||||||||||||||||||||
135 | const QQuickImagePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
136 | return executed 116 times by 1 test: d->paintedHeight;return d->paintedHeight; Executed by:
executed 116 times by 1 test: return d->paintedHeight; Executed by:
| 116 | ||||||||||||||||||||||||
137 | } | - | ||||||||||||||||||||||||
138 | void QQuickImage::updatePaintedGeometry() | - | ||||||||||||||||||||||||
139 | { | - | ||||||||||||||||||||||||
140 | QQuickImagePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
141 | - | |||||||||||||||||||||||||
142 | if (d->fillMode == PreserveAspectFit
| 96-13850 | ||||||||||||||||||||||||
143 | if (!d->pix.width()
| 0-60 | ||||||||||||||||||||||||
144 | setImplicitSize(0, 0); | - | ||||||||||||||||||||||||
145 | return; executed 36 times by 2 tests: return; Executed by:
| 36 | ||||||||||||||||||||||||
146 | } | - | ||||||||||||||||||||||||
147 | const qreal pixWidth = d->pix.width() / d->devicePixelRatio; | - | ||||||||||||||||||||||||
148 | const qreal pixHeight = d->pix.height() / d->devicePixelRatio; | - | ||||||||||||||||||||||||
149 | const qreal w = widthValid()
| 22-38 | ||||||||||||||||||||||||
150 | const qreal widthScale = w / pixWidth; | - | ||||||||||||||||||||||||
151 | const qreal h = heightValid()
| 24-36 | ||||||||||||||||||||||||
152 | const qreal heightScale = h / pixHeight; | - | ||||||||||||||||||||||||
153 | if (widthScale <= heightScale
| 20-40 | ||||||||||||||||||||||||
154 | d->paintedWidth = w; | - | ||||||||||||||||||||||||
155 | d->paintedHeight = widthScale * pixHeight; | - | ||||||||||||||||||||||||
156 | } executed 40 times by 2 tests: else if (heightScale < widthScaleend of block Executed by:
| 0-40 | ||||||||||||||||||||||||
157 | d->paintedWidth = heightScale * pixWidth; | - | ||||||||||||||||||||||||
158 | d->paintedHeight = h; | - | ||||||||||||||||||||||||
159 | } executed 20 times by 1 test: end of block Executed by:
| 20 | ||||||||||||||||||||||||
160 | const qreal iHeight = (widthValid()
| 10-38 | ||||||||||||||||||||||||
161 | const qreal iWidth = (heightValid()
| 10-36 | ||||||||||||||||||||||||
162 | setImplicitSize(iWidth, iHeight); | - | ||||||||||||||||||||||||
163 | - | |||||||||||||||||||||||||
164 | } executed 60 times by 2 tests: else if (d->fillMode == PreserveAspectCropend of block Executed by:
| 60-13760 | ||||||||||||||||||||||||
165 | if (!d->pix.width()
| 0-50 | ||||||||||||||||||||||||
166 | return; executed 40 times by 2 tests: return; Executed by:
| 40 | ||||||||||||||||||||||||
167 | const qreal pixWidth = d->pix.width() / d->devicePixelRatio; | - | ||||||||||||||||||||||||
168 | const qreal pixHeight = d->pix.height() / d->devicePixelRatio; | - | ||||||||||||||||||||||||
169 | qreal widthScale = width() / pixWidth; | - | ||||||||||||||||||||||||
170 | qreal heightScale = height() / pixHeight; | - | ||||||||||||||||||||||||
171 | if (widthScale < heightScale
| 20-30 | ||||||||||||||||||||||||
172 | widthScale = heightScale; | - | ||||||||||||||||||||||||
173 | } executed 20 times by 2 tests: else if (heightScale < widthScaleend of block Executed by:
| 8-22 | ||||||||||||||||||||||||
174 | heightScale = widthScale; | - | ||||||||||||||||||||||||
175 | } executed 22 times by 2 tests: end of block Executed by:
| 22 | ||||||||||||||||||||||||
176 | - | |||||||||||||||||||||||||
177 | d->paintedHeight = heightScale * pixHeight; | - | ||||||||||||||||||||||||
178 | d->paintedWidth = widthScale * pixWidth; | - | ||||||||||||||||||||||||
179 | } executed 50 times by 2 tests: else if (d->fillMode == Padend of block Executed by:
| 6-13754 | ||||||||||||||||||||||||
180 | d->paintedWidth = d->pix.width() / d->devicePixelRatio; | - | ||||||||||||||||||||||||
181 | d->paintedHeight = d->pix.height() / d->devicePixelRatio; | - | ||||||||||||||||||||||||
182 | } executed 6 times by 1 test: else {end of block Executed by:
| 6 | ||||||||||||||||||||||||
183 | d->paintedWidth = width(); | - | ||||||||||||||||||||||||
184 | d->paintedHeight = height(); | - | ||||||||||||||||||||||||
185 | } executed 13754 times by 11 tests: end of block Executed by:
| 13754 | ||||||||||||||||||||||||
186 | paintedGeometryChanged(); | - | ||||||||||||||||||||||||
187 | } executed 13870 times by 11 tests: end of block Executed by:
| 13870 | ||||||||||||||||||||||||
188 | - | |||||||||||||||||||||||||
189 | void QQuickImage::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) | - | ||||||||||||||||||||||||
190 | { | - | ||||||||||||||||||||||||
191 | QQuickImageBase::geometryChanged(newGeometry, oldGeometry); | - | ||||||||||||||||||||||||
192 | if (newGeometry.size() != oldGeometry.size()
| 7834-11902 | ||||||||||||||||||||||||
193 | updatePaintedGeometry(); executed 7834 times by 11 tests: updatePaintedGeometry(); Executed by:
| 7834 | ||||||||||||||||||||||||
194 | } executed 19736 times by 12 tests: end of block Executed by:
| 19736 | ||||||||||||||||||||||||
195 | - | |||||||||||||||||||||||||
196 | QRectF QQuickImage::boundingRect() const | - | ||||||||||||||||||||||||
197 | { | - | ||||||||||||||||||||||||
198 | const QQuickImagePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
199 | return executed 96 times by 1 test: QRectF(0, 0, qMax(width(), d->paintedWidth), qMax(height(), d->paintedHeight));return QRectF(0, 0, qMax(width(), d->paintedWidth), qMax(height(), d->paintedHeight)); Executed by:
executed 96 times by 1 test: return QRectF(0, 0, qMax(width(), d->paintedWidth), qMax(height(), d->paintedHeight)); Executed by:
| 96 | ||||||||||||||||||||||||
200 | } | - | ||||||||||||||||||||||||
201 | - | |||||||||||||||||||||||||
202 | QSGTextureProvider *QQuickImage::textureProvider() const | - | ||||||||||||||||||||||||
203 | { | - | ||||||||||||||||||||||||
204 | const QQuickImagePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
205 | - | |||||||||||||||||||||||||
206 | - | |||||||||||||||||||||||||
207 | - | |||||||||||||||||||||||||
208 | - | |||||||||||||||||||||||||
209 | - | |||||||||||||||||||||||||
210 | if (QQuickItem::isTextureProvider()
| 0-4 | ||||||||||||||||||||||||
211 | return never executed: QQuickItem::textureProvider();return QQuickItem::textureProvider(); never executed: return QQuickItem::textureProvider(); | 0 | ||||||||||||||||||||||||
212 | - | |||||||||||||||||||||||||
213 | if (!d->window
| 0-4 | ||||||||||||||||||||||||
214 | QMessageLogger(__FILE__, 627, __PRETTY_FUNCTION__).warning("QQuickImage::textureProvider: can only be queried on the rendering thread of an exposed window"); | - | ||||||||||||||||||||||||
215 | return never executed: nullptr;return nullptr; never executed: return nullptr; | 0 | ||||||||||||||||||||||||
216 | } | - | ||||||||||||||||||||||||
217 | - | |||||||||||||||||||||||||
218 | if (!d->provider
| 0-4 | ||||||||||||||||||||||||
219 | QQuickImagePrivate *dd = const_cast<QQuickImagePrivate *>(d); | - | ||||||||||||||||||||||||
220 | dd->provider = new QQuickImageTextureProvider; | - | ||||||||||||||||||||||||
221 | dd->provider->m_smooth = d->smooth; | - | ||||||||||||||||||||||||
222 | dd->provider->m_mipmap = d->mipmap; | - | ||||||||||||||||||||||||
223 | dd->provider->updateTexture(d->sceneGraphRenderContext()->textureForFactory(d->pix.textureFactory(), window())); | - | ||||||||||||||||||||||||
224 | } executed 4 times by 2 tests: end of block Executed by:
| 4 | ||||||||||||||||||||||||
225 | - | |||||||||||||||||||||||||
226 | return executed 4 times by 2 tests: d->provider;return d->provider; Executed by:
executed 4 times by 2 tests: return d->provider; Executed by:
| 4 | ||||||||||||||||||||||||
227 | } | - | ||||||||||||||||||||||||
228 | - | |||||||||||||||||||||||||
229 | void QQuickImage::invalidateSceneGraph() | - | ||||||||||||||||||||||||
230 | { | - | ||||||||||||||||||||||||
231 | QQuickImagePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
232 | delete d->provider; | - | ||||||||||||||||||||||||
233 | d->provider = nullptr; | - | ||||||||||||||||||||||||
234 | } executed 86 times by 3 tests: end of block Executed by:
| 86 | ||||||||||||||||||||||||
235 | - | |||||||||||||||||||||||||
236 | void QQuickImage::releaseResources() | - | ||||||||||||||||||||||||
237 | { | - | ||||||||||||||||||||||||
238 | QQuickImagePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
239 | if (d->provider
| 2-4040 | ||||||||||||||||||||||||
240 | QQuickWindowQObjectCleanupJob::schedule(window(), d->provider); | - | ||||||||||||||||||||||||
241 | d->provider = nullptr; | - | ||||||||||||||||||||||||
242 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
243 | } executed 4042 times by 8 tests: end of block Executed by:
| 4042 | ||||||||||||||||||||||||
244 | - | |||||||||||||||||||||||||
245 | QSGNode *QQuickImage::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) | - | ||||||||||||||||||||||||
246 | { | - | ||||||||||||||||||||||||
247 | QQuickImagePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
248 | - | |||||||||||||||||||||||||
249 | QSGTexture *texture = d->sceneGraphRenderContext()->textureForFactory(d->pix.textureFactory(), window()); | - | ||||||||||||||||||||||||
250 | - | |||||||||||||||||||||||||
251 | - | |||||||||||||||||||||||||
252 | if (d->provider
| 4-5185 | ||||||||||||||||||||||||
253 | d->provider->m_smooth = d->smooth; | - | ||||||||||||||||||||||||
254 | d->provider->m_mipmap = d->mipmap; | - | ||||||||||||||||||||||||
255 | d->provider->updateTexture(texture); | - | ||||||||||||||||||||||||
256 | } executed 4 times by 2 tests: end of block Executed by:
| 4 | ||||||||||||||||||||||||
257 | - | |||||||||||||||||||||||||
258 | if (!texture
| 0-5087 | ||||||||||||||||||||||||
259 | delete oldNode; | - | ||||||||||||||||||||||||
260 | return executed 104 times by 2 tests: nullptr;return nullptr; Executed by:
executed 104 times by 2 tests: return nullptr; Executed by:
| 104 | ||||||||||||||||||||||||
261 | } | - | ||||||||||||||||||||||||
262 | - | |||||||||||||||||||||||||
263 | QSGInternalImageNode *node = static_cast<QSGInternalImageNode *>(oldNode); | - | ||||||||||||||||||||||||
264 | if (!node
| 60-5025 | ||||||||||||||||||||||||
265 | d->pixmapChanged = true; | - | ||||||||||||||||||||||||
266 | node = d->sceneGraphContext()->createInternalImageNode(); | - | ||||||||||||||||||||||||
267 | } executed 5025 times by 8 tests: end of block Executed by:
| 5025 | ||||||||||||||||||||||||
268 | - | |||||||||||||||||||||||||
269 | QRectF targetRect; | - | ||||||||||||||||||||||||
270 | QRectF sourceRect; | - | ||||||||||||||||||||||||
271 | QSGTexture::WrapMode hWrap = QSGTexture::ClampToEdge; | - | ||||||||||||||||||||||||
272 | QSGTexture::WrapMode vWrap = QSGTexture::ClampToEdge; | - | ||||||||||||||||||||||||
273 | - | |||||||||||||||||||||||||
274 | qreal pixWidth = (
| 2-5083 | ||||||||||||||||||||||||
275 | qreal pixHeight = (
| 2-5083 | ||||||||||||||||||||||||
276 | - | |||||||||||||||||||||||||
277 | int xOffset = 0; | - | ||||||||||||||||||||||||
278 | if (d->hAlign == QQuickImage::AlignHCenter
| 0-5085 | ||||||||||||||||||||||||
279 | xOffset = qCeil((width() - pixWidth) / 2.); executed 5085 times by 8 tests: xOffset = qCeil((width() - pixWidth) / 2.); Executed by:
| 5085 | ||||||||||||||||||||||||
280 | else if (d->hAlign == QQuickImage::AlignRight
| 0 | ||||||||||||||||||||||||
281 | xOffset = qCeil(width() - pixWidth); never executed: xOffset = qCeil(width() - pixWidth); | 0 | ||||||||||||||||||||||||
282 | - | |||||||||||||||||||||||||
283 | int yOffset = 0; | - | ||||||||||||||||||||||||
284 | if (d->vAlign == QQuickImage::AlignVCenter
| 0-5085 | ||||||||||||||||||||||||
285 | yOffset = qCeil((height() - pixHeight) / 2.); executed 5085 times by 8 tests: yOffset = qCeil((height() - pixHeight) / 2.); Executed by:
| 5085 | ||||||||||||||||||||||||
286 | else if (d->vAlign == QQuickImage::AlignBottom
| 0 | ||||||||||||||||||||||||
287 | yOffset = qCeil(height() - pixHeight); never executed: yOffset = qCeil(height() - pixHeight); | 0 | ||||||||||||||||||||||||
288 | - | |||||||||||||||||||||||||
289 | switch (d->fillMode) { | - | ||||||||||||||||||||||||
290 | default never executed: :default: never executed: default: | 0 | ||||||||||||||||||||||||
291 | case executed 5053 times by 8 tests: Stretch:case Stretch: Executed by:
executed 5053 times by 8 tests: case Stretch: Executed by:
| 5053 | ||||||||||||||||||||||||
292 | targetRect = QRectF(0, 0, width(), height()); | - | ||||||||||||||||||||||||
293 | sourceRect = d->pix.rect(); | - | ||||||||||||||||||||||||
294 | break; executed 5053 times by 8 tests: break; Executed by:
| 5053 | ||||||||||||||||||||||||
295 | - | |||||||||||||||||||||||||
296 | case executed 2 times by 1 test: PreserveAspectFit:case PreserveAspectFit: Executed by:
executed 2 times by 1 test: case PreserveAspectFit: Executed by:
| 2 | ||||||||||||||||||||||||
297 | targetRect = QRectF(xOffset, yOffset, d->paintedWidth, d->paintedHeight); | - | ||||||||||||||||||||||||
298 | sourceRect = d->pix.rect(); | - | ||||||||||||||||||||||||
299 | break; executed 2 times by 1 test: break; Executed by:
| 2 | ||||||||||||||||||||||||
300 | - | |||||||||||||||||||||||||
301 | case executed 16 times by 2 tests: PreserveAspectCrop:case PreserveAspectCrop: Executed by:
executed 16 times by 2 tests: {case PreserveAspectCrop: Executed by:
| 16 | ||||||||||||||||||||||||
302 | targetRect = QRect(0, 0, width(), height()); | - | ||||||||||||||||||||||||
303 | qreal wscale = width() / qreal(d->pix.width()); | - | ||||||||||||||||||||||||
304 | qreal hscale = height() / qreal(d->pix.height()); | - | ||||||||||||||||||||||||
305 | - | |||||||||||||||||||||||||
306 | if (wscale > hscale
| 4-12 | ||||||||||||||||||||||||
307 | int src = (hscale / wscale) * qreal(d->pix.height()); | - | ||||||||||||||||||||||||
308 | int y = 0; | - | ||||||||||||||||||||||||
309 | if (d->vAlign == QQuickImage::AlignVCenter
| 0-4 | ||||||||||||||||||||||||
310 | y = qCeil((d->pix.height() - src) / 2.); executed 4 times by 2 tests: y = qCeil((d->pix.height() - src) / 2.); Executed by:
| 4 | ||||||||||||||||||||||||
311 | else if (d->vAlign == QQuickImage::AlignBottom
| 0 | ||||||||||||||||||||||||
312 | y = qCeil(d->pix.height() - src); never executed: y = qCeil(d->pix.height() - src); | 0 | ||||||||||||||||||||||||
313 | sourceRect = QRectF(0, y, d->pix.width(), src); | - | ||||||||||||||||||||||||
314 | - | |||||||||||||||||||||||||
315 | } executed 4 times by 2 tests: else {end of block Executed by:
| 4 | ||||||||||||||||||||||||
316 | int src = (wscale / hscale) * qreal(d->pix.width()); | - | ||||||||||||||||||||||||
317 | int x = 0; | - | ||||||||||||||||||||||||
318 | if (d->hAlign == QQuickImage::AlignHCenter
| 0-12 | ||||||||||||||||||||||||
319 | x = qCeil((d->pix.width() - src) / 2.); executed 12 times by 1 test: x = qCeil((d->pix.width() - src) / 2.); Executed by:
| 12 | ||||||||||||||||||||||||
320 | else if (d->hAlign == QQuickImage::AlignRight
| 0 | ||||||||||||||||||||||||
321 | x = qCeil(d->pix.width() - src); never executed: x = qCeil(d->pix.width() - src); | 0 | ||||||||||||||||||||||||
322 | sourceRect = QRectF(x, 0, src, d->pix.height()); | - | ||||||||||||||||||||||||
323 | } executed 12 times by 1 test: end of block Executed by:
| 12 | ||||||||||||||||||||||||
324 | } | - | ||||||||||||||||||||||||
325 | break; executed 16 times by 2 tests: break; Executed by:
| 16 | ||||||||||||||||||||||||
326 | - | |||||||||||||||||||||||||
327 | case executed 2 times by 1 test: Tile:case Tile: Executed by:
executed 2 times by 1 test: case Tile: Executed by:
| 2 | ||||||||||||||||||||||||
328 | targetRect = QRectF(0, 0, width(), height()); | - | ||||||||||||||||||||||||
329 | sourceRect = QRectF(-xOffset, -yOffset, width(), height()); | - | ||||||||||||||||||||||||
330 | hWrap = QSGTexture::Repeat; | - | ||||||||||||||||||||||||
331 | vWrap = QSGTexture::Repeat; | - | ||||||||||||||||||||||||
332 | break; executed 2 times by 1 test: break; Executed by:
| 2 | ||||||||||||||||||||||||
333 | - | |||||||||||||||||||||||||
334 | case executed 6 times by 2 tests: TileHorizontally:case TileHorizontally: Executed by:
executed 6 times by 2 tests: case TileHorizontally: Executed by:
| 6 | ||||||||||||||||||||||||
335 | targetRect = QRectF(0, 0, width(), height()); | - | ||||||||||||||||||||||||
336 | sourceRect = QRectF(-xOffset, 0, width(), d->pix.height()); | - | ||||||||||||||||||||||||
337 | hWrap = QSGTexture::Repeat; | - | ||||||||||||||||||||||||
338 | break; executed 6 times by 2 tests: break; Executed by:
| 6 | ||||||||||||||||||||||||
339 | - | |||||||||||||||||||||||||
340 | case executed 4 times by 1 test: TileVertically:case TileVertically: Executed by:
executed 4 times by 1 test: case TileVertically: Executed by:
| 4 | ||||||||||||||||||||||||
341 | targetRect = QRectF(0, 0, width(), height()); | - | ||||||||||||||||||||||||
342 | sourceRect = QRectF(0, -yOffset, d->pix.width(), height()); | - | ||||||||||||||||||||||||
343 | vWrap = QSGTexture::Repeat; | - | ||||||||||||||||||||||||
344 | break; executed 4 times by 1 test: break; Executed by:
| 4 | ||||||||||||||||||||||||
345 | - | |||||||||||||||||||||||||
346 | case executed 2 times by 1 test: Pad:case Pad: Executed by:
executed 2 times by 1 test: case Pad: Executed by:
| 2 | ||||||||||||||||||||||||
347 | qreal w = qMin(qreal(pixWidth), width()); | - | ||||||||||||||||||||||||
348 | qreal h = qMin(qreal(pixHeight), height()); | - | ||||||||||||||||||||||||
349 | qreal x = (
| 0-2 | ||||||||||||||||||||||||
350 | qreal y = (
| 0-2 | ||||||||||||||||||||||||
351 | targetRect = QRectF(x + xOffset, y + yOffset, w, h); | - | ||||||||||||||||||||||||
352 | sourceRect = QRectF(x, y, w, h); | - | ||||||||||||||||||||||||
353 | break; executed 2 times by 1 test: break; Executed by:
| 2 | ||||||||||||||||||||||||
354 | }; | - | ||||||||||||||||||||||||
355 | - | |||||||||||||||||||||||||
356 | qreal nsWidth = (hWrap == QSGTexture::Repeat
| 2-5077 | ||||||||||||||||||||||||
357 | qreal nsHeight = (vWrap == QSGTexture::Repeat
| 2-5079 | ||||||||||||||||||||||||
358 | QRectF nsrect(sourceRect.x() / nsWidth, | - | ||||||||||||||||||||||||
359 | sourceRect.y() / nsHeight, | - | ||||||||||||||||||||||||
360 | sourceRect.width() / nsWidth, | - | ||||||||||||||||||||||||
361 | sourceRect.height() / nsHeight); | - | ||||||||||||||||||||||||
362 | - | |||||||||||||||||||||||||
363 | if (targetRect.isEmpty()
| 0-5085 | ||||||||||||||||||||||||
364 | || !qt_is_finite(targetRect.width())
| 0-5085 | ||||||||||||||||||||||||
365 | || nsrect.isEmpty()
| 0-5085 | ||||||||||||||||||||||||
366 | || !qt_is_finite(nsrect.width())
| 0-5085 | ||||||||||||||||||||||||
367 | delete node; | - | ||||||||||||||||||||||||
368 | return never executed: nullptr;return nullptr; never executed: return nullptr; | 0 | ||||||||||||||||||||||||
369 | } | - | ||||||||||||||||||||||||
370 | - | |||||||||||||||||||||||||
371 | if (d->pixmapChanged
| 4-5081 | ||||||||||||||||||||||||
372 | - | |||||||||||||||||||||||||
373 | - | |||||||||||||||||||||||||
374 | if (texture->isAtlasTexture()
| 2-4935 | ||||||||||||||||||||||||
375 | node->setTexture(texture->removedFromAtlas()); executed 12 times by 2 tests: node->setTexture(texture->removedFromAtlas()); Executed by:
| 12 | ||||||||||||||||||||||||
376 | else | - | ||||||||||||||||||||||||
377 | node->setTexture(texture); executed 5069 times by 8 tests: node->setTexture(texture); Executed by:
| 5069 | ||||||||||||||||||||||||
378 | d->pixmapChanged = false; | - | ||||||||||||||||||||||||
379 | } executed 5081 times by 8 tests: end of block Executed by:
| 5081 | ||||||||||||||||||||||||
380 | - | |||||||||||||||||||||||||
381 | node->setMipmapFiltering(d->mipmap ? QSGTexture::Linear : QSGTexture::None); | - | ||||||||||||||||||||||||
382 | node->setHorizontalWrapMode(hWrap); | - | ||||||||||||||||||||||||
383 | node->setVerticalWrapMode(vWrap); | - | ||||||||||||||||||||||||
384 | node->setFiltering(d->smooth ? QSGTexture::Linear : QSGTexture::Nearest); | - | ||||||||||||||||||||||||
385 | - | |||||||||||||||||||||||||
386 | node->setTargetRect(targetRect); | - | ||||||||||||||||||||||||
387 | node->setInnerTargetRect(targetRect); | - | ||||||||||||||||||||||||
388 | node->setSubSourceRect(nsrect); | - | ||||||||||||||||||||||||
389 | node->setMirror(d->mirror); | - | ||||||||||||||||||||||||
390 | node->setAntialiasing(d->antialiasing); | - | ||||||||||||||||||||||||
391 | node->update(); | - | ||||||||||||||||||||||||
392 | - | |||||||||||||||||||||||||
393 | return executed 5085 times by 8 tests: node;return node; Executed by:
executed 5085 times by 8 tests: return node; Executed by:
| 5085 | ||||||||||||||||||||||||
394 | } | - | ||||||||||||||||||||||||
395 | - | |||||||||||||||||||||||||
396 | void QQuickImage::pixmapChange() | - | ||||||||||||||||||||||||
397 | { | - | ||||||||||||||||||||||||
398 | QQuickImagePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
399 | - | |||||||||||||||||||||||||
400 | - | |||||||||||||||||||||||||
401 | - | |||||||||||||||||||||||||
402 | - | |||||||||||||||||||||||||
403 | if (d->fillMode != PreserveAspectFit
| 26-5980 | ||||||||||||||||||||||||
404 | QQuickImageBase::pixmapChange(); executed 5980 times by 11 tests: QQuickImageBase::pixmapChange(); Executed by:
| 5980 | ||||||||||||||||||||||||
405 | updatePaintedGeometry(); | - | ||||||||||||||||||||||||
406 | d->pixmapChanged = true; | - | ||||||||||||||||||||||||
407 | - | |||||||||||||||||||||||||
408 | - | |||||||||||||||||||||||||
409 | update(); | - | ||||||||||||||||||||||||
410 | } executed 6006 times by 11 tests: end of block Executed by:
| 6006 | ||||||||||||||||||||||||
411 | - | |||||||||||||||||||||||||
412 | QQuickImage::VAlignment QQuickImage::verticalAlignment() const | - | ||||||||||||||||||||||||
413 | { | - | ||||||||||||||||||||||||
414 | const QQuickImagePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
415 | return never executed: d->vAlign;return d->vAlign; never executed: return d->vAlign; | 0 | ||||||||||||||||||||||||
416 | } | - | ||||||||||||||||||||||||
417 | - | |||||||||||||||||||||||||
418 | void QQuickImage::setVerticalAlignment(VAlignment align) | - | ||||||||||||||||||||||||
419 | { | - | ||||||||||||||||||||||||
420 | QQuickImagePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
421 | if (d->vAlign == align
| 0 | ||||||||||||||||||||||||
422 | return; never executed: return; | 0 | ||||||||||||||||||||||||
423 | - | |||||||||||||||||||||||||
424 | d->vAlign = align; | - | ||||||||||||||||||||||||
425 | update(); | - | ||||||||||||||||||||||||
426 | updatePaintedGeometry(); | - | ||||||||||||||||||||||||
427 | verticalAlignmentChanged(align); | - | ||||||||||||||||||||||||
428 | } never executed: end of block | 0 | ||||||||||||||||||||||||
429 | - | |||||||||||||||||||||||||
430 | QQuickImage::HAlignment QQuickImage::horizontalAlignment() const | - | ||||||||||||||||||||||||
431 | { | - | ||||||||||||||||||||||||
432 | const QQuickImagePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
433 | return never executed: d->hAlign;return d->hAlign; never executed: return d->hAlign; | 0 | ||||||||||||||||||||||||
434 | } | - | ||||||||||||||||||||||||
435 | - | |||||||||||||||||||||||||
436 | void QQuickImage::setHorizontalAlignment(HAlignment align) | - | ||||||||||||||||||||||||
437 | { | - | ||||||||||||||||||||||||
438 | QQuickImagePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
439 | if (d->hAlign == align
| 0 | ||||||||||||||||||||||||
440 | return; never executed: return; | 0 | ||||||||||||||||||||||||
441 | - | |||||||||||||||||||||||||
442 | d->hAlign = align; | - | ||||||||||||||||||||||||
443 | update(); | - | ||||||||||||||||||||||||
444 | updatePaintedGeometry(); | - | ||||||||||||||||||||||||
445 | horizontalAlignmentChanged(align); | - | ||||||||||||||||||||||||
446 | } never executed: end of block | 0 | ||||||||||||||||||||||||
447 | bool QQuickImage::mipmap() const | - | ||||||||||||||||||||||||
448 | { | - | ||||||||||||||||||||||||
449 | const QQuickImagePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
450 | return never executed: d->mipmap;return d->mipmap; never executed: return d->mipmap; | 0 | ||||||||||||||||||||||||
451 | } | - | ||||||||||||||||||||||||
452 | - | |||||||||||||||||||||||||
453 | void QQuickImage::setMipmap(bool use) | - | ||||||||||||||||||||||||
454 | { | - | ||||||||||||||||||||||||
455 | QQuickImagePrivate * const d = d_func(); | - | ||||||||||||||||||||||||
456 | if (d->mipmap == use
| 0-4 | ||||||||||||||||||||||||
457 | return; never executed: return; | 0 | ||||||||||||||||||||||||
458 | d->mipmap = use; | - | ||||||||||||||||||||||||
459 | mipmapChanged(d->mipmap); | - | ||||||||||||||||||||||||
460 | - | |||||||||||||||||||||||||
461 | d->pixmapChanged = true; | - | ||||||||||||||||||||||||
462 | update(); | - | ||||||||||||||||||||||||
463 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||
464 | - | |||||||||||||||||||||||||
Switch to Source code | Preprocessed file |