Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/items/qquickborderimage.cpp |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||||||||||||||
2 | ** | - | ||||||||||||||||||
3 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||||||||||||||
4 | ** Contact: https://www.qt.io/licensing/ | - | ||||||||||||||||||
5 | ** | - | ||||||||||||||||||
6 | ** This file is part of the QtQuick module of the Qt Toolkit. | - | ||||||||||||||||||
7 | ** | - | ||||||||||||||||||
8 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||||||||||||||
9 | ** Commercial License Usage | - | ||||||||||||||||||
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||||||||
11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||||||||
12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||||||||
13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||||||||
14 | ** and conditions see https://www.qt.io/terms-conditions. For further | - | ||||||||||||||||||
15 | ** information use the contact form at https://www.qt.io/contact-us. | - | ||||||||||||||||||
16 | ** | - | ||||||||||||||||||
17 | ** GNU Lesser General Public License Usage | - | ||||||||||||||||||
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||||||||
19 | ** General Public License version 3 as published by the Free Software | - | ||||||||||||||||||
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||||||||||||||
21 | ** packaging of this file. Please review the following information to | - | ||||||||||||||||||
22 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||||||||||||||
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||||||||||||||
24 | ** | - | ||||||||||||||||||
25 | ** GNU General Public License Usage | - | ||||||||||||||||||
26 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||||||||||||||
27 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||||||||||||||
28 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||||||||||||||
29 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||||||||||||||
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||||||||||||||
31 | ** included in the packaging of this file. Please review the following | - | ||||||||||||||||||
32 | ** information to ensure the GNU General Public License requirements will | - | ||||||||||||||||||
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||||||||||||||
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||||||||||||||
35 | ** | - | ||||||||||||||||||
36 | ** $QT_END_LICENSE$ | - | ||||||||||||||||||
37 | ** | - | ||||||||||||||||||
38 | ****************************************************************************/ | - | ||||||||||||||||||
39 | - | |||||||||||||||||||
40 | #include "qquickborderimage_p.h" | - | ||||||||||||||||||
41 | #include "qquickborderimage_p_p.h" | - | ||||||||||||||||||
42 | - | |||||||||||||||||||
43 | #include <QtQml/qqmlinfo.h> | - | ||||||||||||||||||
44 | #include <QtQml/qqmlfile.h> | - | ||||||||||||||||||
45 | #include <QtQml/qqmlengine.h> | - | ||||||||||||||||||
46 | #if QT_CONFIG(qml_network) | - | ||||||||||||||||||
47 | #include <QtNetwork/qnetworkreply.h> | - | ||||||||||||||||||
48 | #endif | - | ||||||||||||||||||
49 | #include <QtCore/qfile.h> | - | ||||||||||||||||||
50 | #include <QtCore/qmath.h> | - | ||||||||||||||||||
51 | #include <QtGui/qguiapplication.h> | - | ||||||||||||||||||
52 | - | |||||||||||||||||||
53 | #include <private/qqmlglobal_p.h> | - | ||||||||||||||||||
54 | #include <private/qsgadaptationlayer_p.h> | - | ||||||||||||||||||
55 | - | |||||||||||||||||||
56 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||
57 | - | |||||||||||||||||||
58 | - | |||||||||||||||||||
59 | /*! | - | ||||||||||||||||||
60 | \qmltype BorderImage | - | ||||||||||||||||||
61 | \instantiates QQuickBorderImage | - | ||||||||||||||||||
62 | \inqmlmodule QtQuick | - | ||||||||||||||||||
63 | \brief Paints a border based on an image. | - | ||||||||||||||||||
64 | \inherits Item | - | ||||||||||||||||||
65 | \ingroup qtquick-visual | - | ||||||||||||||||||
66 | - | |||||||||||||||||||
67 | The BorderImage type is used to create borders out of images by scaling or tiling | - | ||||||||||||||||||
68 | parts of each image. | - | ||||||||||||||||||
69 | - | |||||||||||||||||||
70 | A BorderImage breaks a source image, specified using the \l source property, | - | ||||||||||||||||||
71 | into 9 regions, as shown below: | - | ||||||||||||||||||
72 | - | |||||||||||||||||||
73 | \image declarative-scalegrid.png | - | ||||||||||||||||||
74 | - | |||||||||||||||||||
75 | When the image is scaled, regions of the source image are scaled or tiled to | - | ||||||||||||||||||
76 | create the displayed border image in the following way: | - | ||||||||||||||||||
77 | - | |||||||||||||||||||
78 | \list | - | ||||||||||||||||||
79 | \li The corners (regions 1, 3, 7, and 9) are not scaled at all. | - | ||||||||||||||||||
80 | \li Regions 2 and 8 are scaled according to | - | ||||||||||||||||||
81 | \l{BorderImage::horizontalTileMode}{horizontalTileMode}. | - | ||||||||||||||||||
82 | \li Regions 4 and 6 are scaled according to | - | ||||||||||||||||||
83 | \l{BorderImage::verticalTileMode}{verticalTileMode}. | - | ||||||||||||||||||
84 | \li The middle (region 5) is scaled according to both | - | ||||||||||||||||||
85 | \l{BorderImage::horizontalTileMode}{horizontalTileMode} and | - | ||||||||||||||||||
86 | \l{BorderImage::verticalTileMode}{verticalTileMode}. | - | ||||||||||||||||||
87 | \endlist | - | ||||||||||||||||||
88 | - | |||||||||||||||||||
89 | The regions of the image are defined using the \l border property group, which | - | ||||||||||||||||||
90 | describes the distance from each edge of the source image to use as a border. | - | ||||||||||||||||||
91 | - | |||||||||||||||||||
92 | \section1 Example Usage | - | ||||||||||||||||||
93 | - | |||||||||||||||||||
94 | The following examples show the effects of the different modes on an image. | - | ||||||||||||||||||
95 | Guide lines are overlaid onto the image to show the different regions of the | - | ||||||||||||||||||
96 | image as described above. | - | ||||||||||||||||||
97 | - | |||||||||||||||||||
98 | \beginfloatleft | - | ||||||||||||||||||
99 | \image qml-borderimage-normal-image.png | - | ||||||||||||||||||
100 | \endfloat | - | ||||||||||||||||||
101 | - | |||||||||||||||||||
102 | An unscaled image is displayed using an Image. The \l border property is | - | ||||||||||||||||||
103 | used to determine the parts of the image that will lie inside the unscaled corner | - | ||||||||||||||||||
104 | areas and the parts that will be stretched horizontally and vertically. | - | ||||||||||||||||||
105 | - | |||||||||||||||||||
106 | \snippet qml/borderimage/normal-image.qml normal image | - | ||||||||||||||||||
107 | - | |||||||||||||||||||
108 | \clearfloat | - | ||||||||||||||||||
109 | \beginfloatleft | - | ||||||||||||||||||
110 | \image qml-borderimage-scaled.png | - | ||||||||||||||||||
111 | \endfloat | - | ||||||||||||||||||
112 | - | |||||||||||||||||||
113 | A BorderImage is used to display the image, and it is given a size that is | - | ||||||||||||||||||
114 | larger than the original image. Since the \l horizontalTileMode property is set to | - | ||||||||||||||||||
115 | \l{BorderImage::horizontalTileMode}{BorderImage.Stretch}, the parts of image in | - | ||||||||||||||||||
116 | regions 2 and 8 are stretched horizontally. Since the \l verticalTileMode property | - | ||||||||||||||||||
117 | is set to \l{BorderImage::verticalTileMode}{BorderImage.Stretch}, the parts of image | - | ||||||||||||||||||
118 | in regions 4 and 6 are stretched vertically. | - | ||||||||||||||||||
119 | - | |||||||||||||||||||
120 | \snippet qml/borderimage/borderimage-scaled.qml scaled border image | - | ||||||||||||||||||
121 | - | |||||||||||||||||||
122 | \clearfloat | - | ||||||||||||||||||
123 | \beginfloatleft | - | ||||||||||||||||||
124 | \image qml-borderimage-tiled.png | - | ||||||||||||||||||
125 | \endfloat | - | ||||||||||||||||||
126 | - | |||||||||||||||||||
127 | Again, a large BorderImage is used to display the image. With the | - | ||||||||||||||||||
128 | \l horizontalTileMode property set to \l{BorderImage::horizontalTileMode}{BorderImage.Repeat}, | - | ||||||||||||||||||
129 | the parts of image in regions 2 and 8 are tiled so that they fill the space at the | - | ||||||||||||||||||
130 | top and bottom of the item. Similarly, the \l verticalTileMode property is set to | - | ||||||||||||||||||
131 | \l{BorderImage::verticalTileMode}{BorderImage.Repeat}, the parts of image in regions | - | ||||||||||||||||||
132 | 4 and 6 are tiled so that they fill the space at the left and right of the item. | - | ||||||||||||||||||
133 | - | |||||||||||||||||||
134 | \snippet qml/borderimage/borderimage-tiled.qml tiled border image | - | ||||||||||||||||||
135 | - | |||||||||||||||||||
136 | \clearfloat | - | ||||||||||||||||||
137 | In some situations, the width of regions 2 and 8 may not be an exact multiple of the width | - | ||||||||||||||||||
138 | of the corresponding regions in the source image. Similarly, the height of regions 4 and 6 | - | ||||||||||||||||||
139 | may not be an exact multiple of the height of the corresponding regions. It can be useful | - | ||||||||||||||||||
140 | to use \l{BorderImage::horizontalTileMode}{BorderImage.Round} instead of | - | ||||||||||||||||||
141 | \l{BorderImage::horizontalTileMode}{BorderImage.Repeat} in cases like these. | - | ||||||||||||||||||
142 | - | |||||||||||||||||||
143 | The Border Image example in \l{Qt Quick Examples - Image Elements} shows how a BorderImage | - | ||||||||||||||||||
144 | can be used to simulate a shadow effect on a rectangular item. | - | ||||||||||||||||||
145 | - | |||||||||||||||||||
146 | \section1 Image Loading | - | ||||||||||||||||||
147 | - | |||||||||||||||||||
148 | The source image may not be loaded instantaneously, depending on its original location. | - | ||||||||||||||||||
149 | Loading progress can be monitored with the \l progress property. | - | ||||||||||||||||||
150 | - | |||||||||||||||||||
151 | \sa Image, AnimatedImage | - | ||||||||||||||||||
152 | */ | - | ||||||||||||||||||
153 | - | |||||||||||||||||||
154 | /*! | - | ||||||||||||||||||
155 | \qmlproperty bool QtQuick::BorderImage::asynchronous | - | ||||||||||||||||||
156 | - | |||||||||||||||||||
157 | Specifies that images on the local filesystem should be loaded | - | ||||||||||||||||||
158 | asynchronously in a separate thread. The default value is | - | ||||||||||||||||||
159 | false, causing the user interface thread to block while the | - | ||||||||||||||||||
160 | image is loaded. Setting \a asynchronous to true is useful where | - | ||||||||||||||||||
161 | maintaining a responsive user interface is more desirable | - | ||||||||||||||||||
162 | than having images immediately visible. | - | ||||||||||||||||||
163 | - | |||||||||||||||||||
164 | Note that this property is only valid for images read from the | - | ||||||||||||||||||
165 | local filesystem. Images loaded via a network resource (e.g. HTTP) | - | ||||||||||||||||||
166 | are always loaded asynchronously. | - | ||||||||||||||||||
167 | */ | - | ||||||||||||||||||
168 | QQuickBorderImage::QQuickBorderImage(QQuickItem *parent) | - | ||||||||||||||||||
169 | : QQuickImageBase(*(new QQuickBorderImagePrivate), parent) | - | ||||||||||||||||||
170 | { | - | ||||||||||||||||||
171 | } executed 138 times by 2 tests: end of block Executed by:
| 138 | ||||||||||||||||||
172 | - | |||||||||||||||||||
173 | QQuickBorderImage::~QQuickBorderImage() | - | ||||||||||||||||||
174 | { | - | ||||||||||||||||||
175 | #if QT_CONFIG(qml_network) | - | ||||||||||||||||||
176 | Q_D(QQuickBorderImage); | - | ||||||||||||||||||
177 | if (d->sciReply)
| 2-136 | ||||||||||||||||||
178 | d->sciReply->deleteLater(); executed 2 times by 1 test: d->sciReply->deleteLater(); Executed by:
| 2 | ||||||||||||||||||
179 | #endif | - | ||||||||||||||||||
180 | } executed 138 times by 2 tests: end of block Executed by:
| 138 | ||||||||||||||||||
181 | - | |||||||||||||||||||
182 | /*! | - | ||||||||||||||||||
183 | \qmlproperty enumeration QtQuick::BorderImage::status | - | ||||||||||||||||||
184 | - | |||||||||||||||||||
185 | This property describes the status of image loading. It can be one of: | - | ||||||||||||||||||
186 | - | |||||||||||||||||||
187 | \list | - | ||||||||||||||||||
188 | \li BorderImage.Null - no image has been set | - | ||||||||||||||||||
189 | \li BorderImage.Ready - the image has been loaded | - | ||||||||||||||||||
190 | \li BorderImage.Loading - the image is currently being loaded | - | ||||||||||||||||||
191 | \li BorderImage.Error - an error occurred while loading the image | - | ||||||||||||||||||
192 | \endlist | - | ||||||||||||||||||
193 | - | |||||||||||||||||||
194 | \sa progress | - | ||||||||||||||||||
195 | */ | - | ||||||||||||||||||
196 | - | |||||||||||||||||||
197 | /*! | - | ||||||||||||||||||
198 | \qmlproperty real QtQuick::BorderImage::progress | - | ||||||||||||||||||
199 | - | |||||||||||||||||||
200 | This property holds the progress of image loading, from 0.0 (nothing loaded) | - | ||||||||||||||||||
201 | to 1.0 (finished). | - | ||||||||||||||||||
202 | - | |||||||||||||||||||
203 | \sa status | - | ||||||||||||||||||
204 | */ | - | ||||||||||||||||||
205 | - | |||||||||||||||||||
206 | /*! | - | ||||||||||||||||||
207 | \qmlproperty bool QtQuick::BorderImage::smooth | - | ||||||||||||||||||
208 | - | |||||||||||||||||||
209 | This property holds whether the image is smoothly filtered when scaled or | - | ||||||||||||||||||
210 | transformed. Smooth filtering gives better visual quality, but it may be slower | - | ||||||||||||||||||
211 | on some hardware. If the image is displayed at its natural size, this property | - | ||||||||||||||||||
212 | has no visual or performance effect. | - | ||||||||||||||||||
213 | - | |||||||||||||||||||
214 | By default, this property is set to true. | - | ||||||||||||||||||
215 | */ | - | ||||||||||||||||||
216 | - | |||||||||||||||||||
217 | /*! | - | ||||||||||||||||||
218 | \qmlproperty bool QtQuick::BorderImage::cache | - | ||||||||||||||||||
219 | - | |||||||||||||||||||
220 | Specifies whether the image should be cached. The default value is | - | ||||||||||||||||||
221 | true. Setting \a cache to false is useful when dealing with large images, | - | ||||||||||||||||||
222 | to make sure that they aren't cached at the expense of small 'ui element' images. | - | ||||||||||||||||||
223 | */ | - | ||||||||||||||||||
224 | - | |||||||||||||||||||
225 | /*! | - | ||||||||||||||||||
226 | \qmlproperty bool QtQuick::BorderImage::mirror | - | ||||||||||||||||||
227 | - | |||||||||||||||||||
228 | This property holds whether the image should be horizontally inverted | - | ||||||||||||||||||
229 | (effectively displaying a mirrored image). | - | ||||||||||||||||||
230 | - | |||||||||||||||||||
231 | The default value is false. | - | ||||||||||||||||||
232 | */ | - | ||||||||||||||||||
233 | - | |||||||||||||||||||
234 | /*! | - | ||||||||||||||||||
235 | \qmlproperty url QtQuick::BorderImage::source | - | ||||||||||||||||||
236 | - | |||||||||||||||||||
237 | This property holds the URL that refers to the source image. | - | ||||||||||||||||||
238 | - | |||||||||||||||||||
239 | BorderImage can handle any image format supported by Qt, loaded from any | - | ||||||||||||||||||
240 | URL scheme supported by Qt. | - | ||||||||||||||||||
241 | - | |||||||||||||||||||
242 | This property can also be used to refer to .sci files, which are | - | ||||||||||||||||||
243 | written in a QML-specific, text-based format that specifies the | - | ||||||||||||||||||
244 | borders, the image file and the tile rules for a given border image. | - | ||||||||||||||||||
245 | - | |||||||||||||||||||
246 | The following .sci file sets the borders to 10 on each side for the | - | ||||||||||||||||||
247 | image \c picture.png: | - | ||||||||||||||||||
248 | - | |||||||||||||||||||
249 | \code | - | ||||||||||||||||||
250 | border.left: 10 | - | ||||||||||||||||||
251 | border.top: 10 | - | ||||||||||||||||||
252 | border.bottom: 10 | - | ||||||||||||||||||
253 | border.right: 10 | - | ||||||||||||||||||
254 | source: "picture.png" | - | ||||||||||||||||||
255 | \endcode | - | ||||||||||||||||||
256 | - | |||||||||||||||||||
257 | The URL may be absolute, or relative to the URL of the component. | - | ||||||||||||||||||
258 | - | |||||||||||||||||||
259 | \sa QQuickImageProvider | - | ||||||||||||||||||
260 | */ | - | ||||||||||||||||||
261 | - | |||||||||||||||||||
262 | /*! | - | ||||||||||||||||||
263 | \qmlproperty QSize QtQuick::BorderImage::sourceSize | - | ||||||||||||||||||
264 | - | |||||||||||||||||||
265 | This property holds the actual width and height of the loaded image. | - | ||||||||||||||||||
266 | - | |||||||||||||||||||
267 | In BorderImage, this property is read-only. | - | ||||||||||||||||||
268 | - | |||||||||||||||||||
269 | \sa Image::sourceSize | - | ||||||||||||||||||
270 | */ | - | ||||||||||||||||||
271 | void QQuickBorderImage::setSource(const QUrl &url) | - | ||||||||||||||||||
272 | { | - | ||||||||||||||||||
273 | Q_D(QQuickBorderImage); | - | ||||||||||||||||||
274 | - | |||||||||||||||||||
275 | if (url == d->url)
| 14-156 | ||||||||||||||||||
276 | return; executed 14 times by 1 test: return; Executed by:
| 14 | ||||||||||||||||||
277 | - | |||||||||||||||||||
278 | #if QT_CONFIG(qml_network) | - | ||||||||||||||||||
279 | if (d->sciReply) {
| 0-156 | ||||||||||||||||||
280 | d->sciReply->deleteLater(); | - | ||||||||||||||||||
281 | d->sciReply = nullptr; | - | ||||||||||||||||||
282 | } never executed: end of block | 0 | ||||||||||||||||||
283 | #endif | - | ||||||||||||||||||
284 | - | |||||||||||||||||||
285 | d->url = url; | - | ||||||||||||||||||
286 | d->sciurl = QUrl(); | - | ||||||||||||||||||
287 | emit sourceChanged(d->url); | - | ||||||||||||||||||
288 | - | |||||||||||||||||||
289 | if (isComponentComplete())
| 32-124 | ||||||||||||||||||
290 | load(); executed 32 times by 1 test: load(); Executed by:
| 32 | ||||||||||||||||||
291 | } executed 156 times by 2 tests: end of block Executed by:
| 156 | ||||||||||||||||||
292 | - | |||||||||||||||||||
293 | void QQuickBorderImage::load() | - | ||||||||||||||||||
294 | { | - | ||||||||||||||||||
295 | Q_D(QQuickBorderImage); | - | ||||||||||||||||||
296 | - | |||||||||||||||||||
297 | if (d->url.isEmpty()) {
| 8-148 | ||||||||||||||||||
298 | d->pix.clear(this); | - | ||||||||||||||||||
299 | d->status = Null; | - | ||||||||||||||||||
300 | setImplicitSize(0, 0); | - | ||||||||||||||||||
301 | emit statusChanged(d->status); | - | ||||||||||||||||||
302 | if (d->progress != 0.0) {
| 0-8 | ||||||||||||||||||
303 | d->progress = 0.0; | - | ||||||||||||||||||
304 | emit progressChanged(d->progress); | - | ||||||||||||||||||
305 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||||||||
306 | if (sourceSize() != d->oldSourceSize) {
| 0-8 | ||||||||||||||||||
307 | d->oldSourceSize = sourceSize(); | - | ||||||||||||||||||
308 | emit sourceSizeChanged(); | - | ||||||||||||||||||
309 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||||||||
310 | pixmapChange(); | - | ||||||||||||||||||
311 | return; executed 8 times by 1 test: return; Executed by:
| 8 | ||||||||||||||||||
312 | } else { | - | ||||||||||||||||||
313 | if (d->url.path().endsWith(QLatin1String("sci"))) {
| 30-118 | ||||||||||||||||||
314 | QString lf = QQmlFile::urlToLocalFileOrQrc(d->url); | - | ||||||||||||||||||
315 | if (!lf.isEmpty()) {
| 10-20 | ||||||||||||||||||
316 | QFile file(lf); | - | ||||||||||||||||||
317 | file.open(QIODevice::ReadOnly); | - | ||||||||||||||||||
318 | setGridScaledImage(QQuickGridScaledImage(&file)); | - | ||||||||||||||||||
319 | return; executed 20 times by 2 tests: return; Executed by:
| 20 | ||||||||||||||||||
320 | } else { | - | ||||||||||||||||||
321 | #if QT_CONFIG(qml_network) | - | ||||||||||||||||||
322 | if (d->progress != 0.0) {
| 0-10 | ||||||||||||||||||
323 | d->progress = 0.0; | - | ||||||||||||||||||
324 | emit progressChanged(d->progress); | - | ||||||||||||||||||
325 | } never executed: end of block | 0 | ||||||||||||||||||
326 | d->status = Loading; | - | ||||||||||||||||||
327 | QNetworkRequest req(d->url); | - | ||||||||||||||||||
328 | d->sciReply = qmlEngine(this)->networkAccessManager()->get(req); | - | ||||||||||||||||||
329 | qmlobject_connect(d->sciReply, QNetworkReply, SIGNAL(finished()), executed 2 times by 1 test: end of block Executed by:
executed 2 times by 1 test: methodIdx = QQuickBorderImage::staticMetaObject.indexOfSlot(method+1); Executed by:
never executed: methodIdx = QQuickBorderImage::staticMetaObject.indexOfSignal(method+1);
| 0-8 | ||||||||||||||||||
330 | this, QQuickBorderImage, SLOT(sciRequestFinished())) | - | ||||||||||||||||||
331 | #endif | - | ||||||||||||||||||
332 | } executed 10 times by 1 test: end of block Executed by:
| 10 | ||||||||||||||||||
333 | } else { | - | ||||||||||||||||||
334 | QQuickPixmap::Options options; | - | ||||||||||||||||||
335 | if (d->async)
| 0-118 | ||||||||||||||||||
336 | options |= QQuickPixmap::Asynchronous; never executed: options |= QQuickPixmap::Asynchronous; | 0 | ||||||||||||||||||
337 | if (d->cache)
| 0-118 | ||||||||||||||||||
338 | options |= QQuickPixmap::Cache; executed 118 times by 2 tests: options |= QQuickPixmap::Cache; Executed by:
| 118 | ||||||||||||||||||
339 | d->pix.clear(this); | - | ||||||||||||||||||
340 | - | |||||||||||||||||||
341 | const qreal targetDevicePixelRatio = (window() ? window()->effectiveDevicePixelRatio() : qGuiApp->devicePixelRatio());
| 46-72 | ||||||||||||||||||
342 | d->devicePixelRatio = 1.0; | - | ||||||||||||||||||
343 | - | |||||||||||||||||||
344 | QUrl loadUrl = d->url; | - | ||||||||||||||||||
345 | resolve2xLocalFile(d->url, targetDevicePixelRatio, &loadUrl, &d->devicePixelRatio); | - | ||||||||||||||||||
346 | d->pix.load(qmlEngine(this), loadUrl, d->sourcesize * d->devicePixelRatio, options); | - | ||||||||||||||||||
347 | - | |||||||||||||||||||
348 | if (d->pix.isLoading()) {
| 20-98 | ||||||||||||||||||
349 | if (d->progress != 0.0) {
| 6-14 | ||||||||||||||||||
350 | d->progress = 0.0; | - | ||||||||||||||||||
351 | emit progressChanged(d->progress); | - | ||||||||||||||||||
352 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||||||||
353 | d->status = Loading; | - | ||||||||||||||||||
354 | - | |||||||||||||||||||
355 | static int thisRequestProgress = -1; | - | ||||||||||||||||||
356 | static int thisRequestFinished = -1; | - | ||||||||||||||||||
357 | if (thisRequestProgress == -1) {
| 2-18 | ||||||||||||||||||
358 | thisRequestProgress = | - | ||||||||||||||||||
359 | QQuickImageBase::staticMetaObject.indexOfSlot("requestProgress(qint64,qint64)"); | - | ||||||||||||||||||
360 | thisRequestFinished = | - | ||||||||||||||||||
361 | QQuickImageBase::staticMetaObject.indexOfSlot("requestFinished()"); | - | ||||||||||||||||||
362 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||
363 | d->pix.connectFinished(this, thisRequestFinished); | - | ||||||||||||||||||
364 | d->pix.connectDownloadProgress(this, thisRequestProgress); | - | ||||||||||||||||||
365 | - | |||||||||||||||||||
366 | update(); //pixmap may have invalidated texture, updatePaintNode needs to be called before the next repaint | - | ||||||||||||||||||
367 | } else { executed 20 times by 1 test: end of block Executed by:
| 20 | ||||||||||||||||||
368 | requestFinished(); | - | ||||||||||||||||||
369 | return; executed 98 times by 2 tests: return; Executed by:
| 98 | ||||||||||||||||||
370 | } | - | ||||||||||||||||||
371 | } | - | ||||||||||||||||||
372 | } | - | ||||||||||||||||||
373 | - | |||||||||||||||||||
374 | emit statusChanged(d->status); | - | ||||||||||||||||||
375 | } executed 30 times by 1 test: end of block Executed by:
| 30 | ||||||||||||||||||
376 | - | |||||||||||||||||||
377 | /*! | - | ||||||||||||||||||
378 | \qmlpropertygroup QtQuick::BorderImage::border | - | ||||||||||||||||||
379 | \qmlproperty int QtQuick::BorderImage::border.left | - | ||||||||||||||||||
380 | \qmlproperty int QtQuick::BorderImage::border.right | - | ||||||||||||||||||
381 | \qmlproperty int QtQuick::BorderImage::border.top | - | ||||||||||||||||||
382 | \qmlproperty int QtQuick::BorderImage::border.bottom | - | ||||||||||||||||||
383 | - | |||||||||||||||||||
384 | The 4 border lines (2 horizontal and 2 vertical) break the image into 9 sections, | - | ||||||||||||||||||
385 | as shown below: | - | ||||||||||||||||||
386 | - | |||||||||||||||||||
387 | \image declarative-scalegrid.png | - | ||||||||||||||||||
388 | - | |||||||||||||||||||
389 | Each border line (left, right, top, and bottom) specifies an offset in pixels | - | ||||||||||||||||||
390 | from the respective edge of the source image. By default, each border line has | - | ||||||||||||||||||
391 | a value of 0. | - | ||||||||||||||||||
392 | - | |||||||||||||||||||
393 | For example, the following definition sets the bottom line 10 pixels up from | - | ||||||||||||||||||
394 | the bottom of the image: | - | ||||||||||||||||||
395 | - | |||||||||||||||||||
396 | \qml | - | ||||||||||||||||||
397 | BorderImage { | - | ||||||||||||||||||
398 | border.bottom: 10 | - | ||||||||||||||||||
399 | // ... | - | ||||||||||||||||||
400 | } | - | ||||||||||||||||||
401 | \endqml | - | ||||||||||||||||||
402 | - | |||||||||||||||||||
403 | The border lines can also be specified using a | - | ||||||||||||||||||
404 | \l {BorderImage::source}{.sci file}. | - | ||||||||||||||||||
405 | */ | - | ||||||||||||||||||
406 | - | |||||||||||||||||||
407 | QQuickScaleGrid *QQuickBorderImage::border() | - | ||||||||||||||||||
408 | { | - | ||||||||||||||||||
409 | Q_D(QQuickBorderImage); | - | ||||||||||||||||||
410 | return d->getScaleGrid(); executed 138 times by 2 tests: return d->getScaleGrid(); Executed by:
| 138 | ||||||||||||||||||
411 | } | - | ||||||||||||||||||
412 | - | |||||||||||||||||||
413 | /*! | - | ||||||||||||||||||
414 | \qmlproperty enumeration QtQuick::BorderImage::horizontalTileMode | - | ||||||||||||||||||
415 | \qmlproperty enumeration QtQuick::BorderImage::verticalTileMode | - | ||||||||||||||||||
416 | - | |||||||||||||||||||
417 | This property describes how to repeat or stretch the middle parts of the border image. | - | ||||||||||||||||||
418 | - | |||||||||||||||||||
419 | \list | - | ||||||||||||||||||
420 | \li BorderImage.Stretch - Scales the image to fit to the available area. | - | ||||||||||||||||||
421 | \li BorderImage.Repeat - Tile the image until there is no more space. May crop the last image. | - | ||||||||||||||||||
422 | \li BorderImage.Round - Like Repeat, but scales the images down to ensure that the last image is not cropped. | - | ||||||||||||||||||
423 | \endlist | - | ||||||||||||||||||
424 | - | |||||||||||||||||||
425 | The default tile mode for each property is BorderImage.Stretch. | - | ||||||||||||||||||
426 | */ | - | ||||||||||||||||||
427 | QQuickBorderImage::TileMode QQuickBorderImage::horizontalTileMode() const | - | ||||||||||||||||||
428 | { | - | ||||||||||||||||||
429 | Q_D(const QQuickBorderImage); | - | ||||||||||||||||||
430 | return d->horizontalTileMode; executed 32 times by 1 test: return d->horizontalTileMode; Executed by:
| 32 | ||||||||||||||||||
431 | } | - | ||||||||||||||||||
432 | - | |||||||||||||||||||
433 | void QQuickBorderImage::setHorizontalTileMode(TileMode t) | - | ||||||||||||||||||
434 | { | - | ||||||||||||||||||
435 | Q_D(QQuickBorderImage); | - | ||||||||||||||||||
436 | if (t != d->horizontalTileMode) {
| 2-6 | ||||||||||||||||||
437 | d->horizontalTileMode = t; | - | ||||||||||||||||||
438 | emit horizontalTileModeChanged(); | - | ||||||||||||||||||
439 | update(); | - | ||||||||||||||||||
440 | } executed 6 times by 2 tests: end of block Executed by:
| 6 | ||||||||||||||||||
441 | } executed 8 times by 2 tests: end of block Executed by:
| 8 | ||||||||||||||||||
442 | - | |||||||||||||||||||
443 | QQuickBorderImage::TileMode QQuickBorderImage::verticalTileMode() const | - | ||||||||||||||||||
444 | { | - | ||||||||||||||||||
445 | Q_D(const QQuickBorderImage); | - | ||||||||||||||||||
446 | return d->verticalTileMode; executed 32 times by 1 test: return d->verticalTileMode; Executed by:
| 32 | ||||||||||||||||||
447 | } | - | ||||||||||||||||||
448 | - | |||||||||||||||||||
449 | void QQuickBorderImage::setVerticalTileMode(TileMode t) | - | ||||||||||||||||||
450 | { | - | ||||||||||||||||||
451 | Q_D(QQuickBorderImage); | - | ||||||||||||||||||
452 | if (t != d->verticalTileMode) {
| 2-6 | ||||||||||||||||||
453 | d->verticalTileMode = t; | - | ||||||||||||||||||
454 | emit verticalTileModeChanged(); | - | ||||||||||||||||||
455 | update(); | - | ||||||||||||||||||
456 | } executed 6 times by 2 tests: end of block Executed by:
| 6 | ||||||||||||||||||
457 | } executed 8 times by 2 tests: end of block Executed by:
| 8 | ||||||||||||||||||
458 | - | |||||||||||||||||||
459 | void QQuickBorderImage::setGridScaledImage(const QQuickGridScaledImage& sci) | - | ||||||||||||||||||
460 | { | - | ||||||||||||||||||
461 | Q_D(QQuickBorderImage); | - | ||||||||||||||||||
462 | if (!sci.isValid()) {
| 4-22 | ||||||||||||||||||
463 | d->status = Error; | - | ||||||||||||||||||
464 | emit statusChanged(d->status); | - | ||||||||||||||||||
465 | } else { executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||
466 | QQuickScaleGrid *sg = border(); | - | ||||||||||||||||||
467 | sg->setTop(sci.gridTop()); | - | ||||||||||||||||||
468 | sg->setBottom(sci.gridBottom()); | - | ||||||||||||||||||
469 | sg->setLeft(sci.gridLeft()); | - | ||||||||||||||||||
470 | sg->setRight(sci.gridRight()); | - | ||||||||||||||||||
471 | d->horizontalTileMode = sci.horizontalTileRule(); | - | ||||||||||||||||||
472 | d->verticalTileMode = sci.verticalTileRule(); | - | ||||||||||||||||||
473 | - | |||||||||||||||||||
474 | d->sciurl = d->url.resolved(QUrl(sci.pixmapUrl())); | - | ||||||||||||||||||
475 | - | |||||||||||||||||||
476 | QQuickPixmap::Options options; | - | ||||||||||||||||||
477 | if (d->async)
| 0-22 | ||||||||||||||||||
478 | options |= QQuickPixmap::Asynchronous; never executed: options |= QQuickPixmap::Asynchronous; | 0 | ||||||||||||||||||
479 | if (d->cache)
| 0-22 | ||||||||||||||||||
480 | options |= QQuickPixmap::Cache; executed 22 times by 2 tests: options |= QQuickPixmap::Cache; Executed by:
| 22 | ||||||||||||||||||
481 | d->pix.clear(this); | - | ||||||||||||||||||
482 | d->pix.load(qmlEngine(this), d->sciurl, options); | - | ||||||||||||||||||
483 | - | |||||||||||||||||||
484 | if (d->pix.isLoading()) {
| 6-16 | ||||||||||||||||||
485 | if (d->progress != 0.0) {
| 0-6 | ||||||||||||||||||
486 | d->progress = 0.0; | - | ||||||||||||||||||
487 | emit progressChanged(d->progress); | - | ||||||||||||||||||
488 | } never executed: end of block | 0 | ||||||||||||||||||
489 | if (d->status != Loading) {
| 0-6 | ||||||||||||||||||
490 | d->status = Loading; | - | ||||||||||||||||||
491 | emit statusChanged(d->status); | - | ||||||||||||||||||
492 | } never executed: end of block | 0 | ||||||||||||||||||
493 | static int thisRequestProgress = -1; | - | ||||||||||||||||||
494 | static int thisRequestFinished = -1; | - | ||||||||||||||||||
495 | if (thisRequestProgress == -1) {
| 2-4 | ||||||||||||||||||
496 | thisRequestProgress = | - | ||||||||||||||||||
497 | QQuickBorderImage::staticMetaObject.indexOfSlot("requestProgress(qint64,qint64)"); | - | ||||||||||||||||||
498 | thisRequestFinished = | - | ||||||||||||||||||
499 | QQuickBorderImage::staticMetaObject.indexOfSlot("requestFinished()"); | - | ||||||||||||||||||
500 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||
501 | - | |||||||||||||||||||
502 | d->pix.connectFinished(this, thisRequestFinished); | - | ||||||||||||||||||
503 | d->pix.connectDownloadProgress(this, thisRequestProgress); | - | ||||||||||||||||||
504 | - | |||||||||||||||||||
505 | } else { executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||||||||
506 | requestFinished(); | - | ||||||||||||||||||
507 | } executed 16 times by 2 tests: end of block Executed by:
| 16 | ||||||||||||||||||
508 | } | - | ||||||||||||||||||
509 | } | - | ||||||||||||||||||
510 | - | |||||||||||||||||||
511 | void QQuickBorderImage::requestFinished() | - | ||||||||||||||||||
512 | { | - | ||||||||||||||||||
513 | Q_D(QQuickBorderImage); | - | ||||||||||||||||||
514 | - | |||||||||||||||||||
515 | QSize impsize = d->pix.implicitSize(); | - | ||||||||||||||||||
516 | if (d->pix.isError()) {
| 16-116 | ||||||||||||||||||
517 | d->status = Error; | - | ||||||||||||||||||
518 | qmlWarning(this) << d->pix.error(); | - | ||||||||||||||||||
519 | if (d->progress != 0) {
| 0-16 | ||||||||||||||||||
520 | d->progress = 0; | - | ||||||||||||||||||
521 | emit progressChanged(d->progress); | - | ||||||||||||||||||
522 | } never executed: end of block | 0 | ||||||||||||||||||
523 | } else { executed 16 times by 2 tests: end of block Executed by:
| 16 | ||||||||||||||||||
524 | d->status = Ready; | - | ||||||||||||||||||
525 | if (d->progress != 1.0) {
| 22-94 | ||||||||||||||||||
526 | d->progress = 1.0; | - | ||||||||||||||||||
527 | emit progressChanged(d->progress); | - | ||||||||||||||||||
528 | } executed 94 times by 2 tests: end of block Executed by:
| 94 | ||||||||||||||||||
529 | } executed 116 times by 2 tests: end of block Executed by:
| 116 | ||||||||||||||||||
530 | - | |||||||||||||||||||
531 | setImplicitSize(impsize.width() / d->devicePixelRatio, impsize.height() / d->devicePixelRatio); | - | ||||||||||||||||||
532 | emit statusChanged(d->status); | - | ||||||||||||||||||
533 | if (sourceSize() != d->oldSourceSize) {
| 4-128 | ||||||||||||||||||
534 | d->oldSourceSize = sourceSize(); | - | ||||||||||||||||||
535 | emit sourceSizeChanged(); | - | ||||||||||||||||||
536 | } executed 128 times by 2 tests: end of block Executed by:
| 128 | ||||||||||||||||||
537 | - | |||||||||||||||||||
538 | pixmapChange(); | - | ||||||||||||||||||
539 | } executed 132 times by 2 tests: end of block Executed by:
| 132 | ||||||||||||||||||
540 | - | |||||||||||||||||||
541 | #if QT_CONFIG(qml_network) | - | ||||||||||||||||||
542 | #define BORDERIMAGE_MAX_REDIRECT 16 | - | ||||||||||||||||||
543 | - | |||||||||||||||||||
544 | void QQuickBorderImage::sciRequestFinished() | - | ||||||||||||||||||
545 | { | - | ||||||||||||||||||
546 | Q_D(QQuickBorderImage); | - | ||||||||||||||||||
547 | - | |||||||||||||||||||
548 | d->redirectCount++; | - | ||||||||||||||||||
549 | if (d->redirectCount < BORDERIMAGE_MAX_REDIRECT) {
| 0-8 | ||||||||||||||||||
550 | QVariant redirect = d->sciReply->attribute(QNetworkRequest::RedirectionTargetAttribute); | - | ||||||||||||||||||
551 | if (redirect.isValid()) {
| 0-8 | ||||||||||||||||||
552 | QUrl url = d->sciReply->url().resolved(redirect.toUrl()); | - | ||||||||||||||||||
553 | setSource(url); | - | ||||||||||||||||||
554 | return; never executed: return; | 0 | ||||||||||||||||||
555 | } | - | ||||||||||||||||||
556 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||||||||
557 | d->redirectCount=0; | - | ||||||||||||||||||
558 | - | |||||||||||||||||||
559 | if (d->sciReply->error() != QNetworkReply::NoError) {
| 2-6 | ||||||||||||||||||
560 | d->status = Error; | - | ||||||||||||||||||
561 | d->sciReply->deleteLater(); | - | ||||||||||||||||||
562 | d->sciReply = nullptr; | - | ||||||||||||||||||
563 | emit statusChanged(d->status); | - | ||||||||||||||||||
564 | } else { executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||
565 | QQuickGridScaledImage sci(d->sciReply); | - | ||||||||||||||||||
566 | d->sciReply->deleteLater(); | - | ||||||||||||||||||
567 | d->sciReply = nullptr; | - | ||||||||||||||||||
568 | setGridScaledImage(sci); | - | ||||||||||||||||||
569 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||||||||
570 | } | - | ||||||||||||||||||
571 | #endif // qml_network | - | ||||||||||||||||||
572 | - | |||||||||||||||||||
573 | void QQuickBorderImage::doUpdate() | - | ||||||||||||||||||
574 | { | - | ||||||||||||||||||
575 | update(); | - | ||||||||||||||||||
576 | } executed 376 times by 2 tests: end of block Executed by:
| 376 | ||||||||||||||||||
577 | - | |||||||||||||||||||
578 | void QQuickBorderImagePrivate::calculateRects(const QQuickScaleGrid *border, | - | ||||||||||||||||||
579 | const QSize &sourceSize, | - | ||||||||||||||||||
580 | const QSizeF &targetSize, | - | ||||||||||||||||||
581 | int horizontalTileMode, | - | ||||||||||||||||||
582 | int verticalTileMode, | - | ||||||||||||||||||
583 | qreal devicePixelRatio, | - | ||||||||||||||||||
584 | QRectF *targetRect, | - | ||||||||||||||||||
585 | QRectF *innerTargetRect, | - | ||||||||||||||||||
586 | QRectF *innerSourceRect, | - | ||||||||||||||||||
587 | QRectF *subSourceRect) | - | ||||||||||||||||||
588 | { | - | ||||||||||||||||||
589 | *innerSourceRect = QRectF(0, 0, 1, 1); | - | ||||||||||||||||||
590 | *targetRect = QRectF(0, 0, targetSize.width(), targetSize.height()); | - | ||||||||||||||||||
591 | *innerTargetRect = *targetRect; | - | ||||||||||||||||||
592 | - | |||||||||||||||||||
593 | if (border) {
| 0-72 | ||||||||||||||||||
594 | *innerSourceRect = QRectF(border->left() * devicePixelRatio / qreal(sourceSize.width()), | - | ||||||||||||||||||
595 | border->top() * devicePixelRatio / qreal(sourceSize.height()), | - | ||||||||||||||||||
596 | qMax<qreal>(0, sourceSize.width() - (border->right() + border->left()) * devicePixelRatio) / sourceSize.width(), | - | ||||||||||||||||||
597 | qMax<qreal>(0, sourceSize.height() - (border->bottom() + border->top()) * devicePixelRatio) / sourceSize.height()); | - | ||||||||||||||||||
598 | *innerTargetRect = QRectF(border->left(), | - | ||||||||||||||||||
599 | border->top(), | - | ||||||||||||||||||
600 | qMax<qreal>(0, targetSize.width() - (border->right() + border->left())), | - | ||||||||||||||||||
601 | qMax<qreal>(0, targetSize.height() - (border->bottom() + border->top()))); | - | ||||||||||||||||||
602 | } executed 72 times by 2 tests: end of block Executed by:
| 72 | ||||||||||||||||||
603 | - | |||||||||||||||||||
604 | qreal hTiles = 1; | - | ||||||||||||||||||
605 | qreal vTiles = 1; | - | ||||||||||||||||||
606 | const QSizeF innerTargetSize = innerTargetRect->size() * devicePixelRatio; | - | ||||||||||||||||||
607 | if (innerSourceRect->width() != 0
| 0-72 | ||||||||||||||||||
608 | && horizontalTileMode != QQuickBorderImage::Stretch) {
| 0-72 | ||||||||||||||||||
609 | hTiles = innerTargetSize.width() / qreal(innerSourceRect->width() * sourceSize.width()); | - | ||||||||||||||||||
610 | if (horizontalTileMode == QQuickBorderImage::Round)
| 0 | ||||||||||||||||||
611 | hTiles = qCeil(hTiles); never executed: hTiles = qCeil(hTiles); | 0 | ||||||||||||||||||
612 | } never executed: end of block | 0 | ||||||||||||||||||
613 | if (innerSourceRect->height() != 0
| 0-72 | ||||||||||||||||||
614 | && verticalTileMode != QQuickBorderImage::Stretch) {
| 0-72 | ||||||||||||||||||
615 | vTiles = innerTargetSize.height() / qreal(innerSourceRect->height() * sourceSize.height()); | - | ||||||||||||||||||
616 | if (verticalTileMode == QQuickBorderImage::Round)
| 0 | ||||||||||||||||||
617 | vTiles = qCeil(vTiles); never executed: vTiles = qCeil(vTiles); | 0 | ||||||||||||||||||
618 | } never executed: end of block | 0 | ||||||||||||||||||
619 | - | |||||||||||||||||||
620 | *subSourceRect = QRectF(0, 0, hTiles, vTiles); | - | ||||||||||||||||||
621 | } executed 72 times by 2 tests: end of block Executed by:
| 72 | ||||||||||||||||||
622 | - | |||||||||||||||||||
623 | - | |||||||||||||||||||
624 | QSGNode *QQuickBorderImage::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) | - | ||||||||||||||||||
625 | { | - | ||||||||||||||||||
626 | Q_D(QQuickBorderImage); | - | ||||||||||||||||||
627 | - | |||||||||||||||||||
628 | QSGTexture *texture = d->sceneGraphRenderContext()->textureForFactory(d->pix.textureFactory(), window()); | - | ||||||||||||||||||
629 | - | |||||||||||||||||||
630 | if (!texture || width() <= 0 || height() <= 0) {
| 0-70 | ||||||||||||||||||
631 | delete oldNode; | - | ||||||||||||||||||
632 | return nullptr; executed 10 times by 1 test: return nullptr; Executed by:
| 10 | ||||||||||||||||||
633 | } | - | ||||||||||||||||||
634 | - | |||||||||||||||||||
635 | QSGInternalImageNode *node = static_cast<QSGInternalImageNode *>(oldNode); | - | ||||||||||||||||||
636 | - | |||||||||||||||||||
637 | bool updatePixmap = d->pixmapChanged; | - | ||||||||||||||||||
638 | d->pixmapChanged = false; | - | ||||||||||||||||||
639 | if (!node) {
| 0-70 | ||||||||||||||||||
640 | node = d->sceneGraphContext()->createInternalImageNode(); | - | ||||||||||||||||||
641 | updatePixmap = true; | - | ||||||||||||||||||
642 | } executed 70 times by 2 tests: end of block Executed by:
| 70 | ||||||||||||||||||
643 | - | |||||||||||||||||||
644 | if (updatePixmap)
| 0-70 | ||||||||||||||||||
645 | node->setTexture(texture); executed 70 times by 2 tests: node->setTexture(texture); Executed by:
| 70 | ||||||||||||||||||
646 | - | |||||||||||||||||||
647 | // Don't implicitly create the scalegrid in the rendering thread... | - | ||||||||||||||||||
648 | QRectF targetRect; | - | ||||||||||||||||||
649 | QRectF innerTargetRect; | - | ||||||||||||||||||
650 | QRectF innerSourceRect; | - | ||||||||||||||||||
651 | QRectF subSourceRect; | - | ||||||||||||||||||
652 | d->calculateRects(d->border, | - | ||||||||||||||||||
653 | QSize(d->pix.width(), d->pix.height()), QSizeF(width(), height()), | - | ||||||||||||||||||
654 | d->horizontalTileMode, d->verticalTileMode, d->devicePixelRatio, | - | ||||||||||||||||||
655 | &targetRect, &innerTargetRect, | - | ||||||||||||||||||
656 | &innerSourceRect, &subSourceRect); | - | ||||||||||||||||||
657 | - | |||||||||||||||||||
658 | node->setTargetRect(targetRect); | - | ||||||||||||||||||
659 | node->setInnerSourceRect(innerSourceRect); | - | ||||||||||||||||||
660 | node->setInnerTargetRect(innerTargetRect); | - | ||||||||||||||||||
661 | node->setSubSourceRect(subSourceRect); | - | ||||||||||||||||||
662 | node->setMirror(d->mirror); | - | ||||||||||||||||||
663 | - | |||||||||||||||||||
664 | node->setMipmapFiltering(QSGTexture::None); | - | ||||||||||||||||||
665 | node->setFiltering(d->smooth ? QSGTexture::Linear : QSGTexture::Nearest); | - | ||||||||||||||||||
666 | if (innerSourceRect == QRectF(0, 0, 1, 1) && (subSourceRect.width() > 1 || subSourceRect.height() > 1)) {
| 0-70 | ||||||||||||||||||
667 | node->setHorizontalWrapMode(QSGTexture::Repeat); | - | ||||||||||||||||||
668 | node->setVerticalWrapMode(QSGTexture::Repeat); | - | ||||||||||||||||||
669 | } else { never executed: end of block | 0 | ||||||||||||||||||
670 | node->setHorizontalWrapMode(QSGTexture::ClampToEdge); | - | ||||||||||||||||||
671 | node->setVerticalWrapMode(QSGTexture::ClampToEdge); | - | ||||||||||||||||||
672 | } executed 70 times by 2 tests: end of block Executed by:
| 70 | ||||||||||||||||||
673 | node->setAntialiasing(d->antialiasing); | - | ||||||||||||||||||
674 | node->update(); | - | ||||||||||||||||||
675 | - | |||||||||||||||||||
676 | return node; executed 70 times by 2 tests: return node; Executed by:
| 70 | ||||||||||||||||||
677 | } | - | ||||||||||||||||||
678 | - | |||||||||||||||||||
679 | void QQuickBorderImage::pixmapChange() | - | ||||||||||||||||||
680 | { | - | ||||||||||||||||||
681 | Q_D(QQuickBorderImage); | - | ||||||||||||||||||
682 | d->pixmapChanged = true; | - | ||||||||||||||||||
683 | update(); | - | ||||||||||||||||||
684 | } executed 140 times by 2 tests: end of block Executed by:
| 140 | ||||||||||||||||||
685 | - | |||||||||||||||||||
686 | QT_END_NAMESPACE | - | ||||||||||||||||||
687 | - | |||||||||||||||||||
688 | #include "moc_qquickborderimage_p.cpp" | - | ||||||||||||||||||
Source code | Switch to Preprocessed file |