| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/items/qquickimage.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 "qquickimage_p.h" | - | ||||||||||||||||||||||||
| 41 | #include "qquickimage_p_p.h" | - | ||||||||||||||||||||||||
| 42 | - | |||||||||||||||||||||||||
| 43 | #include <QtQuick/qsgtextureprovider.h> | - | ||||||||||||||||||||||||
| 44 | - | |||||||||||||||||||||||||
| 45 | #include <QtQuick/private/qsgcontext_p.h> | - | ||||||||||||||||||||||||
| 46 | #include <private/qsgadaptationlayer_p.h> | - | ||||||||||||||||||||||||
| 47 | #include <private/qnumeric_p.h> | - | ||||||||||||||||||||||||
| 48 | - | |||||||||||||||||||||||||
| 49 | #include <QtCore/qmath.h> | - | ||||||||||||||||||||||||
| 50 | #include <QtGui/qpainter.h> | - | ||||||||||||||||||||||||
| 51 | #include <QtCore/QRunnable> | - | ||||||||||||||||||||||||
| 52 | - | |||||||||||||||||||||||||
| 53 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||||||||
| 54 | - | |||||||||||||||||||||||||
| 55 | class QQuickImageTextureProvider : public QSGTextureProvider | - | ||||||||||||||||||||||||
| 56 | { | - | ||||||||||||||||||||||||
| 57 | Q_OBJECT | - | ||||||||||||||||||||||||
| 58 | public: | - | ||||||||||||||||||||||||
| 59 | QQuickImageTextureProvider() | - | ||||||||||||||||||||||||
| 60 | : m_texture(nullptr) | - | ||||||||||||||||||||||||
| 61 | , m_smooth(false) | - | ||||||||||||||||||||||||
| 62 | { | - | ||||||||||||||||||||||||
| 63 | } executed 4 times by 2 tests: end of blockExecuted by:
| 4 | ||||||||||||||||||||||||
| 64 | - | |||||||||||||||||||||||||
| 65 | void updateTexture(QSGTexture *texture) { | - | ||||||||||||||||||||||||
| 66 | if (m_texture == texture)
| 4 | ||||||||||||||||||||||||
| 67 | return; executed 4 times by 2 tests: return;Executed by:
| 4 | ||||||||||||||||||||||||
| 68 | m_texture = texture; | - | ||||||||||||||||||||||||
| 69 | emit textureChanged(); | - | ||||||||||||||||||||||||
| 70 | } executed 4 times by 2 tests: end of blockExecuted by:
| 4 | ||||||||||||||||||||||||
| 71 | - | |||||||||||||||||||||||||
| 72 | QSGTexture *texture() const override { | - | ||||||||||||||||||||||||
| 73 | if (m_texture) {
| 0-16 | ||||||||||||||||||||||||
| 74 | m_texture->setFiltering(m_smooth ? QSGTexture::Linear : QSGTexture::Nearest); | - | ||||||||||||||||||||||||
| 75 | m_texture->setMipmapFiltering(m_mipmap ? QSGTexture::Linear : QSGTexture::None); | - | ||||||||||||||||||||||||
| 76 | m_texture->setHorizontalWrapMode(QSGTexture::ClampToEdge); | - | ||||||||||||||||||||||||
| 77 | m_texture->setVerticalWrapMode(QSGTexture::ClampToEdge); | - | ||||||||||||||||||||||||
| 78 | } executed 16 times by 2 tests: end of blockExecuted by:
| 16 | ||||||||||||||||||||||||
| 79 | return m_texture; executed 16 times by 2 tests: return m_texture;Executed by:
| 16 | ||||||||||||||||||||||||
| 80 | } | - | ||||||||||||||||||||||||
| 81 | - | |||||||||||||||||||||||||
| 82 | friend class QQuickImage; | - | ||||||||||||||||||||||||
| 83 | - | |||||||||||||||||||||||||
| 84 | QSGTexture *m_texture; | - | ||||||||||||||||||||||||
| 85 | bool m_smooth; | - | ||||||||||||||||||||||||
| 86 | bool m_mipmap; | - | ||||||||||||||||||||||||
| 87 | }; | - | ||||||||||||||||||||||||
| 88 | - | |||||||||||||||||||||||||
| 89 | #include "qquickimage.moc" | - | ||||||||||||||||||||||||
| 90 | #include "moc_qquickimage_p.cpp" | - | ||||||||||||||||||||||||
| 91 | - | |||||||||||||||||||||||||
| 92 | QQuickImagePrivate::QQuickImagePrivate() | - | ||||||||||||||||||||||||
| 93 | : fillMode(QQuickImage::Stretch) | - | ||||||||||||||||||||||||
| 94 | , paintedWidth(0) | - | ||||||||||||||||||||||||
| 95 | , paintedHeight(0) | - | ||||||||||||||||||||||||
| 96 | , pixmapChanged(false) | - | ||||||||||||||||||||||||
| 97 | , mipmap(false) | - | ||||||||||||||||||||||||
| 98 | , hAlign(QQuickImage::AlignHCenter) | - | ||||||||||||||||||||||||
| 99 | , vAlign(QQuickImage::AlignVCenter) | - | ||||||||||||||||||||||||
| 100 | , provider(nullptr) | - | ||||||||||||||||||||||||
| 101 | { | - | ||||||||||||||||||||||||
| 102 | } executed 5486 times by 15 tests: end of blockExecuted by:
| 5486 | ||||||||||||||||||||||||
| 103 | - | |||||||||||||||||||||||||
| 104 | /*! | - | ||||||||||||||||||||||||
| 105 | \qmltype Image | - | ||||||||||||||||||||||||
| 106 | \instantiates QQuickImage | - | ||||||||||||||||||||||||
| 107 | \inqmlmodule QtQuick | - | ||||||||||||||||||||||||
| 108 | \ingroup qtquick-visual | - | ||||||||||||||||||||||||
| 109 | \inherits Item | - | ||||||||||||||||||||||||
| 110 | \brief Displays an image. | - | ||||||||||||||||||||||||
| 111 | - | |||||||||||||||||||||||||
| 112 | The Image type displays an image. | - | ||||||||||||||||||||||||
| 113 | - | |||||||||||||||||||||||||
| 114 | The source of the image is specified as a URL using the \l source property. | - | ||||||||||||||||||||||||
| 115 | Images can be supplied in any of the standard image formats supported by Qt, | - | ||||||||||||||||||||||||
| 116 | including bitmap formats such as PNG and JPEG, and vector graphics formats | - | ||||||||||||||||||||||||
| 117 | such as SVG. If you need to display animated images, use \l AnimatedSprite | - | ||||||||||||||||||||||||
| 118 | or \l AnimatedImage. | - | ||||||||||||||||||||||||
| 119 | - | |||||||||||||||||||||||||
| 120 | If the \l{Item::width}{width} and \l{Item::height}{height} properties are not | - | ||||||||||||||||||||||||
| 121 | specified, the Image automatically uses the size of the loaded image. | - | ||||||||||||||||||||||||
| 122 | By default, specifying the width and height of the item causes the image | - | ||||||||||||||||||||||||
| 123 | to be scaled to that size. This behavior can be changed by setting the | - | ||||||||||||||||||||||||
| 124 | \l fillMode property, allowing the image to be stretched and tiled instead. | - | ||||||||||||||||||||||||
| 125 | - | |||||||||||||||||||||||||
| 126 | \section1 Example Usage | - | ||||||||||||||||||||||||
| 127 | - | |||||||||||||||||||||||||
| 128 | The following example shows the simplest usage of the Image type. | - | ||||||||||||||||||||||||
| 129 | - | |||||||||||||||||||||||||
| 130 | \snippet qml/image.qml document | - | ||||||||||||||||||||||||
| 131 | - | |||||||||||||||||||||||||
| 132 | \beginfloatleft | - | ||||||||||||||||||||||||
| 133 | \image declarative-qtlogo.png | - | ||||||||||||||||||||||||
| 134 | \endfloat | - | ||||||||||||||||||||||||
| 135 | - | |||||||||||||||||||||||||
| 136 | \clearfloat | - | ||||||||||||||||||||||||
| 137 | - | |||||||||||||||||||||||||
| 138 | \section1 OpenGL Texture Files | - | ||||||||||||||||||||||||
| 139 | - | |||||||||||||||||||||||||
| 140 | When the default OpenGL \l{Qt Quick Scene Graph}{scene graph} backend is in | - | ||||||||||||||||||||||||
| 141 | use, images can also be supplied in compressed texture files. The content | - | ||||||||||||||||||||||||
| 142 | must be a simple RGB(A) format 2D texture. Supported compression schemes | - | ||||||||||||||||||||||||
| 143 | are only limited by the underlying OpenGL driver and GPU. The following | - | ||||||||||||||||||||||||
| 144 | container file formats are supported: | - | ||||||||||||||||||||||||
| 145 | - | |||||||||||||||||||||||||
| 146 | \list | - | ||||||||||||||||||||||||
| 147 | \li \c PKM (since Qt 5.10) | - | ||||||||||||||||||||||||
| 148 | \li \c KTX (since Qt 5.11) | - | ||||||||||||||||||||||||
| 149 | \endlist | - | ||||||||||||||||||||||||
| 150 | - | |||||||||||||||||||||||||
| 151 | \note Semi-transparent original images require alpha pre-multiplication | - | ||||||||||||||||||||||||
| 152 | prior to texture compression in order to be correctly displayed in Qt | - | ||||||||||||||||||||||||
| 153 | Quick. This can be done with the following ImageMagick command | - | ||||||||||||||||||||||||
| 154 | line: | - | ||||||||||||||||||||||||
| 155 | \badcode | - | ||||||||||||||||||||||||
| 156 | convert MYORIGIMAGE \( +clone -alpha Extract \) -channel RGB -compose Multiply -composite MYPMIMAGE | - | ||||||||||||||||||||||||
| 157 | \endcode | - | ||||||||||||||||||||||||
| 158 | - | |||||||||||||||||||||||||
| 159 | \section1 Automatic Detection of File Extension | - | ||||||||||||||||||||||||
| 160 | - | |||||||||||||||||||||||||
| 161 | If the \l source URL indicates a non-existing local file or resource, the | - | ||||||||||||||||||||||||
| 162 | Image element attempts to auto-detect the file extension. If an existing | - | ||||||||||||||||||||||||
| 163 | file can be found by appending any of the supported image file extensions | - | ||||||||||||||||||||||||
| 164 | to the \l source URL, then that file will be loaded. | - | ||||||||||||||||||||||||
| 165 | - | |||||||||||||||||||||||||
| 166 | If the OpenGL \l{Qt Quick Scene Graph}{scene graph} backend is in use, the | - | ||||||||||||||||||||||||
| 167 | file search the attempts the OpenGL texture file extensions first. If the | - | ||||||||||||||||||||||||
| 168 | search is unsuccessful, it attempts to search with the file extensions for | - | ||||||||||||||||||||||||
| 169 | the \l{QImageReader::supportedImageFormats()}{conventional image file | - | ||||||||||||||||||||||||
| 170 | types}. For example: | - | ||||||||||||||||||||||||
| 171 | - | |||||||||||||||||||||||||
| 172 | \snippet qml/image-ext.qml ext | - | ||||||||||||||||||||||||
| 173 | - | |||||||||||||||||||||||||
| 174 | This functionality facilitates deploying different image asset file types | - | ||||||||||||||||||||||||
| 175 | on different target platforms. This can be useful in order to tune | - | ||||||||||||||||||||||||
| 176 | application performance and adapt to different graphics hardware. | - | ||||||||||||||||||||||||
| 177 | - | |||||||||||||||||||||||||
| 178 | This functionality was introduced in Qt 5.11. | - | ||||||||||||||||||||||||
| 179 | - | |||||||||||||||||||||||||
| 180 | \section1 Performance | - | ||||||||||||||||||||||||
| 181 | - | |||||||||||||||||||||||||
| 182 | By default, locally available images are loaded immediately, and the user interface | - | ||||||||||||||||||||||||
| 183 | is blocked until loading is complete. If a large image is to be loaded, it may be | - | ||||||||||||||||||||||||
| 184 | preferable to load the image in a low priority thread, by enabling the \l asynchronous | - | ||||||||||||||||||||||||
| 185 | property. | - | ||||||||||||||||||||||||
| 186 | - | |||||||||||||||||||||||||
| 187 | If the image is obtained from a network rather than a local resource, it is | - | ||||||||||||||||||||||||
| 188 | automatically loaded asynchronously, and the \l progress and \l status properties | - | ||||||||||||||||||||||||
| 189 | are updated as appropriate. | - | ||||||||||||||||||||||||
| 190 | - | |||||||||||||||||||||||||
| 191 | Images are cached and shared internally, so if several Image items have the same \l source, | - | ||||||||||||||||||||||||
| 192 | only one copy of the image will be loaded. | - | ||||||||||||||||||||||||
| 193 | - | |||||||||||||||||||||||||
| 194 | \b Note: Images are often the greatest user of memory in QML user interfaces. It is recommended | - | ||||||||||||||||||||||||
| 195 | that images which do not form part of the user interface have their | - | ||||||||||||||||||||||||
| 196 | size bounded via the \l sourceSize property. This is especially important for content | - | ||||||||||||||||||||||||
| 197 | that is loaded from external sources or provided by the user. | - | ||||||||||||||||||||||||
| 198 | - | |||||||||||||||||||||||||
| 199 | \sa {Qt Quick Examples - Image Elements}, QQuickImageProvider, QImageReader::setAutoDetectImageFormat() | - | ||||||||||||||||||||||||
| 200 | */ | - | ||||||||||||||||||||||||
| 201 | - | |||||||||||||||||||||||||
| 202 | QQuickImage::QQuickImage(QQuickItem *parent) | - | ||||||||||||||||||||||||
| 203 | : QQuickImageBase(*(new QQuickImagePrivate), parent) | - | ||||||||||||||||||||||||
| 204 | { | - | ||||||||||||||||||||||||
| 205 | } executed 5396 times by 14 tests: end of blockExecuted by:
| 5396 | ||||||||||||||||||||||||
| 206 | - | |||||||||||||||||||||||||
| 207 | QQuickImage::QQuickImage(QQuickImagePrivate &dd, QQuickItem *parent) | - | ||||||||||||||||||||||||
| 208 | : QQuickImageBase(dd, parent) | - | ||||||||||||||||||||||||
| 209 | { | - | ||||||||||||||||||||||||
| 210 | } executed 90 times by 2 tests: end of blockExecuted by:
| 90 | ||||||||||||||||||||||||
| 211 | - | |||||||||||||||||||||||||
| 212 | QQuickImage::~QQuickImage() | - | ||||||||||||||||||||||||
| 213 | { | - | ||||||||||||||||||||||||
| 214 | Q_D(QQuickImage); | - | ||||||||||||||||||||||||
| 215 | if (d->provider) {
| 0-4208 | ||||||||||||||||||||||||
| 216 | // We're guaranteed to have a window() here because the provider would have | - | ||||||||||||||||||||||||
| 217 | // been released in releaseResources() if we were gone from a window. | - | ||||||||||||||||||||||||
| 218 | QQuickWindowQObjectCleanupJob::schedule(window(), d->provider); | - | ||||||||||||||||||||||||
| 219 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 220 | } executed 4208 times by 14 tests: end of blockExecuted by:
| 4208 | ||||||||||||||||||||||||
| 221 | - | |||||||||||||||||||||||||
| 222 | void QQuickImagePrivate::setImage(const QImage &image) | - | ||||||||||||||||||||||||
| 223 | { | - | ||||||||||||||||||||||||
| 224 | Q_Q(QQuickImage); | - | ||||||||||||||||||||||||
| 225 | pix.setImage(image); | - | ||||||||||||||||||||||||
| 226 | - | |||||||||||||||||||||||||
| 227 | q->pixmapChange(); | - | ||||||||||||||||||||||||
| 228 | status = pix.isNull() ? QQuickImageBase::Null : QQuickImageBase::Ready;
| 0-188 | ||||||||||||||||||||||||
| 229 | - | |||||||||||||||||||||||||
| 230 | q->update(); | - | ||||||||||||||||||||||||
| 231 | } executed 188 times by 2 tests: end of blockExecuted by:
| 188 | ||||||||||||||||||||||||
| 232 | - | |||||||||||||||||||||||||
| 233 | void QQuickImagePrivate::setPixmap(const QQuickPixmap &pixmap) | - | ||||||||||||||||||||||||
| 234 | { | - | ||||||||||||||||||||||||
| 235 | Q_Q(QQuickImage); | - | ||||||||||||||||||||||||
| 236 | pix.setPixmap(pixmap); | - | ||||||||||||||||||||||||
| 237 | - | |||||||||||||||||||||||||
| 238 | q->pixmapChange(); | - | ||||||||||||||||||||||||
| 239 | status = pix.isNull() ? QQuickImageBase::Null : QQuickImageBase::Ready;
| 0-404 | ||||||||||||||||||||||||
| 240 | - | |||||||||||||||||||||||||
| 241 | q->update(); | - | ||||||||||||||||||||||||
| 242 | } executed 404 times by 1 test: end of blockExecuted by:
| 404 | ||||||||||||||||||||||||
| 243 | - | |||||||||||||||||||||||||
| 244 | /*! | - | ||||||||||||||||||||||||
| 245 | \qmlproperty enumeration QtQuick::Image::fillMode | - | ||||||||||||||||||||||||
| 246 | - | |||||||||||||||||||||||||
| 247 | Set this property to define what happens when the source image has a different size | - | ||||||||||||||||||||||||
| 248 | than the item. | - | ||||||||||||||||||||||||
| 249 | \list | - | ||||||||||||||||||||||||
| 250 | \li Image.Stretch - the image is scaled to fit | - | ||||||||||||||||||||||||
| 251 | \li Image.PreserveAspectFit - the image is scaled uniformly to fit without cropping | - | ||||||||||||||||||||||||
| 252 | \li Image.PreserveAspectCrop - the image is scaled uniformly to fill, cropping if necessary | - | ||||||||||||||||||||||||
| 253 | \li Image.Tile - the image is duplicated horizontally and vertically | - | ||||||||||||||||||||||||
| 254 | \li Image.TileVertically - the image is stretched horizontally and tiled vertically | - | ||||||||||||||||||||||||
| 255 | \li Image.TileHorizontally - the image is stretched vertically and tiled horizontally | - | ||||||||||||||||||||||||
| 256 | \li Image.Pad - the image is not transformed | - | ||||||||||||||||||||||||
| 257 | \endlist | - | ||||||||||||||||||||||||
| 258 | - | |||||||||||||||||||||||||
| 259 | \table | - | ||||||||||||||||||||||||
| 260 | - | |||||||||||||||||||||||||
| 261 | \row | - | ||||||||||||||||||||||||
| 262 | \li \image declarative-qtlogo-stretch.png | - | ||||||||||||||||||||||||
| 263 | \li Stretch (default) | - | ||||||||||||||||||||||||
| 264 | \qml | - | ||||||||||||||||||||||||
| 265 | Image { | - | ||||||||||||||||||||||||
| 266 | width: 130; height: 100 | - | ||||||||||||||||||||||||
| 267 | source: "qtlogo.png" | - | ||||||||||||||||||||||||
| 268 | } | - | ||||||||||||||||||||||||
| 269 | \endqml | - | ||||||||||||||||||||||||
| 270 | - | |||||||||||||||||||||||||
| 271 | \row | - | ||||||||||||||||||||||||
| 272 | \li \image declarative-qtlogo-preserveaspectfit.png | - | ||||||||||||||||||||||||
| 273 | \li PreserveAspectFit | - | ||||||||||||||||||||||||
| 274 | \qml | - | ||||||||||||||||||||||||
| 275 | Image { | - | ||||||||||||||||||||||||
| 276 | width: 130; height: 100 | - | ||||||||||||||||||||||||
| 277 | fillMode: Image.PreserveAspectFit | - | ||||||||||||||||||||||||
| 278 | source: "qtlogo.png" | - | ||||||||||||||||||||||||
| 279 | } | - | ||||||||||||||||||||||||
| 280 | \endqml | - | ||||||||||||||||||||||||
| 281 | - | |||||||||||||||||||||||||
| 282 | \row | - | ||||||||||||||||||||||||
| 283 | \li \image declarative-qtlogo-preserveaspectcrop.png | - | ||||||||||||||||||||||||
| 284 | \li PreserveAspectCrop | - | ||||||||||||||||||||||||
| 285 | \qml | - | ||||||||||||||||||||||||
| 286 | Image { | - | ||||||||||||||||||||||||
| 287 | width: 130; height: 100 | - | ||||||||||||||||||||||||
| 288 | fillMode: Image.PreserveAspectCrop | - | ||||||||||||||||||||||||
| 289 | source: "qtlogo.png" | - | ||||||||||||||||||||||||
| 290 | clip: true | - | ||||||||||||||||||||||||
| 291 | } | - | ||||||||||||||||||||||||
| 292 | \endqml | - | ||||||||||||||||||||||||
| 293 | - | |||||||||||||||||||||||||
| 294 | \row | - | ||||||||||||||||||||||||
| 295 | \li \image declarative-qtlogo-tile.png | - | ||||||||||||||||||||||||
| 296 | \li Tile | - | ||||||||||||||||||||||||
| 297 | \qml | - | ||||||||||||||||||||||||
| 298 | Image { | - | ||||||||||||||||||||||||
| 299 | width: 120; height: 120 | - | ||||||||||||||||||||||||
| 300 | fillMode: Image.Tile | - | ||||||||||||||||||||||||
| 301 | horizontalAlignment: Image.AlignLeft | - | ||||||||||||||||||||||||
| 302 | verticalAlignment: Image.AlignTop | - | ||||||||||||||||||||||||
| 303 | source: "qtlogo.png" | - | ||||||||||||||||||||||||
| 304 | } | - | ||||||||||||||||||||||||
| 305 | \endqml | - | ||||||||||||||||||||||||
| 306 | - | |||||||||||||||||||||||||
| 307 | \row | - | ||||||||||||||||||||||||
| 308 | \li \image declarative-qtlogo-tilevertically.png | - | ||||||||||||||||||||||||
| 309 | \li TileVertically | - | ||||||||||||||||||||||||
| 310 | \qml | - | ||||||||||||||||||||||||
| 311 | Image { | - | ||||||||||||||||||||||||
| 312 | width: 120; height: 120 | - | ||||||||||||||||||||||||
| 313 | fillMode: Image.TileVertically | - | ||||||||||||||||||||||||
| 314 | verticalAlignment: Image.AlignTop | - | ||||||||||||||||||||||||
| 315 | source: "qtlogo.png" | - | ||||||||||||||||||||||||
| 316 | } | - | ||||||||||||||||||||||||
| 317 | \endqml | - | ||||||||||||||||||||||||
| 318 | - | |||||||||||||||||||||||||
| 319 | \row | - | ||||||||||||||||||||||||
| 320 | \li \image declarative-qtlogo-tilehorizontally.png | - | ||||||||||||||||||||||||
| 321 | \li TileHorizontally | - | ||||||||||||||||||||||||
| 322 | \qml | - | ||||||||||||||||||||||||
| 323 | Image { | - | ||||||||||||||||||||||||
| 324 | width: 120; height: 120 | - | ||||||||||||||||||||||||
| 325 | fillMode: Image.TileHorizontally | - | ||||||||||||||||||||||||
| 326 | verticalAlignment: Image.AlignLeft | - | ||||||||||||||||||||||||
| 327 | source: "qtlogo.png" | - | ||||||||||||||||||||||||
| 328 | } | - | ||||||||||||||||||||||||
| 329 | \endqml | - | ||||||||||||||||||||||||
| 330 | - | |||||||||||||||||||||||||
| 331 | \endtable | - | ||||||||||||||||||||||||
| 332 | - | |||||||||||||||||||||||||
| 333 | Note that \c clip is \c false by default which means that the item might | - | ||||||||||||||||||||||||
| 334 | paint outside its bounding rectangle even if the fillMode is set to \c PreserveAspectCrop. | - | ||||||||||||||||||||||||
| 335 | - | |||||||||||||||||||||||||
| 336 | \sa {Qt Quick Examples - Image Elements} | - | ||||||||||||||||||||||||
| 337 | */ | - | ||||||||||||||||||||||||
| 338 | QQuickImage::FillMode QQuickImage::fillMode() const | - | ||||||||||||||||||||||||
| 339 | { | - | ||||||||||||||||||||||||
| 340 | Q_D(const QQuickImage); | - | ||||||||||||||||||||||||
| 341 | return d->fillMode; executed 98 times by 2 tests: return d->fillMode;Executed by:
| 98 | ||||||||||||||||||||||||
| 342 | } | - | ||||||||||||||||||||||||
| 343 | - | |||||||||||||||||||||||||
| 344 | void QQuickImage::setFillMode(FillMode mode) | - | ||||||||||||||||||||||||
| 345 | { | - | ||||||||||||||||||||||||
| 346 | Q_D(QQuickImage); | - | ||||||||||||||||||||||||
| 347 | if (d->fillMode == mode)
| 12-106 | ||||||||||||||||||||||||
| 348 | return; executed 12 times by 1 test: return;Executed by:
| 12 | ||||||||||||||||||||||||
| 349 | d->fillMode = mode; | - | ||||||||||||||||||||||||
| 350 | if ((mode == PreserveAspectCrop) != d->providerOptions.preserveAspectRatioCrop()) {
| 26-80 | ||||||||||||||||||||||||
| 351 | d->providerOptions.setPreserveAspectRatioCrop(mode == PreserveAspectCrop); | - | ||||||||||||||||||||||||
| 352 | if (isComponentComplete())
| 4-22 | ||||||||||||||||||||||||
| 353 | load(); executed 4 times by 1 test: load();Executed by:
| 4 | ||||||||||||||||||||||||
| 354 | } else if ((mode == PreserveAspectFit) != d->providerOptions.preserveAspectRatioFit()) { executed 26 times by 2 tests: end of blockExecuted by:
| 26-52 | ||||||||||||||||||||||||
| 355 | d->providerOptions.setPreserveAspectRatioFit(mode == PreserveAspectFit); | - | ||||||||||||||||||||||||
| 356 | if (isComponentComplete())
| 4-24 | ||||||||||||||||||||||||
| 357 | load(); executed 4 times by 1 test: load();Executed by:
| 4 | ||||||||||||||||||||||||
| 358 | } executed 28 times by 2 tests: end of blockExecuted by:
| 28 | ||||||||||||||||||||||||
| 359 | update(); | - | ||||||||||||||||||||||||
| 360 | updatePaintedGeometry(); | - | ||||||||||||||||||||||||
| 361 | emit fillModeChanged(); | - | ||||||||||||||||||||||||
| 362 | } executed 106 times by 3 tests: end of blockExecuted by:
| 106 | ||||||||||||||||||||||||
| 363 | - | |||||||||||||||||||||||||
| 364 | /*! | - | ||||||||||||||||||||||||
| 365 | - | |||||||||||||||||||||||||
| 366 | \qmlproperty real QtQuick::Image::paintedWidth | - | ||||||||||||||||||||||||
| 367 | \qmlproperty real QtQuick::Image::paintedHeight | - | ||||||||||||||||||||||||
| 368 | - | |||||||||||||||||||||||||
| 369 | These properties hold the size of the image that is actually painted. | - | ||||||||||||||||||||||||
| 370 | In most cases it is the same as \c width and \c height, but when using an | - | ||||||||||||||||||||||||
| 371 | \l {fillMode}{Image.PreserveAspectFit} or an \l {fillMode}{Image.PreserveAspectCrop} | - | ||||||||||||||||||||||||
| 372 | \c paintedWidth or \c paintedHeight can be smaller or larger than | - | ||||||||||||||||||||||||
| 373 | \c width and \c height of the Image item. | - | ||||||||||||||||||||||||
| 374 | */ | - | ||||||||||||||||||||||||
| 375 | qreal QQuickImage::paintedWidth() const | - | ||||||||||||||||||||||||
| 376 | { | - | ||||||||||||||||||||||||
| 377 | Q_D(const QQuickImage); | - | ||||||||||||||||||||||||
| 378 | return d->paintedWidth; executed 116 times by 1 test: return d->paintedWidth;Executed by:
| 116 | ||||||||||||||||||||||||
| 379 | } | - | ||||||||||||||||||||||||
| 380 | - | |||||||||||||||||||||||||
| 381 | qreal QQuickImage::paintedHeight() const | - | ||||||||||||||||||||||||
| 382 | { | - | ||||||||||||||||||||||||
| 383 | Q_D(const QQuickImage); | - | ||||||||||||||||||||||||
| 384 | return d->paintedHeight; executed 116 times by 1 test: return d->paintedHeight;Executed by:
| 116 | ||||||||||||||||||||||||
| 385 | } | - | ||||||||||||||||||||||||
| 386 | - | |||||||||||||||||||||||||
| 387 | /*! | - | ||||||||||||||||||||||||
| 388 | \qmlproperty enumeration QtQuick::Image::status | - | ||||||||||||||||||||||||
| 389 | - | |||||||||||||||||||||||||
| 390 | This property holds the status of image loading. It can be one of: | - | ||||||||||||||||||||||||
| 391 | \list | - | ||||||||||||||||||||||||
| 392 | \li Image.Null - no image has been set | - | ||||||||||||||||||||||||
| 393 | \li Image.Ready - the image has been loaded | - | ||||||||||||||||||||||||
| 394 | \li Image.Loading - the image is currently being loaded | - | ||||||||||||||||||||||||
| 395 | \li Image.Error - an error occurred while loading the image | - | ||||||||||||||||||||||||
| 396 | \endlist | - | ||||||||||||||||||||||||
| 397 | - | |||||||||||||||||||||||||
| 398 | Use this status to provide an update or respond to the status change in some way. | - | ||||||||||||||||||||||||
| 399 | For example, you could: | - | ||||||||||||||||||||||||
| 400 | - | |||||||||||||||||||||||||
| 401 | \list | - | ||||||||||||||||||||||||
| 402 | \li Trigger a state change: | - | ||||||||||||||||||||||||
| 403 | \qml | - | ||||||||||||||||||||||||
| 404 | State { name: 'loaded'; when: image.status == Image.Ready } | - | ||||||||||||||||||||||||
| 405 | \endqml | - | ||||||||||||||||||||||||
| 406 | - | |||||||||||||||||||||||||
| 407 | \li Implement an \c onStatusChanged signal handler: | - | ||||||||||||||||||||||||
| 408 | \qml | - | ||||||||||||||||||||||||
| 409 | Image { | - | ||||||||||||||||||||||||
| 410 | id: image | - | ||||||||||||||||||||||||
| 411 | onStatusChanged: if (image.status == Image.Ready) console.log('Loaded') | - | ||||||||||||||||||||||||
| 412 | } | - | ||||||||||||||||||||||||
| 413 | \endqml | - | ||||||||||||||||||||||||
| 414 | - | |||||||||||||||||||||||||
| 415 | \li Bind to the status value: | - | ||||||||||||||||||||||||
| 416 | \qml | - | ||||||||||||||||||||||||
| 417 | Text { text: image.status == Image.Ready ? 'Loaded' : 'Not loaded' } | - | ||||||||||||||||||||||||
| 418 | \endqml | - | ||||||||||||||||||||||||
| 419 | \endlist | - | ||||||||||||||||||||||||
| 420 | - | |||||||||||||||||||||||||
| 421 | \sa progress | - | ||||||||||||||||||||||||
| 422 | */ | - | ||||||||||||||||||||||||
| 423 | - | |||||||||||||||||||||||||
| 424 | /*! | - | ||||||||||||||||||||||||
| 425 | \qmlproperty real QtQuick::Image::progress | - | ||||||||||||||||||||||||
| 426 | - | |||||||||||||||||||||||||
| 427 | This property holds the progress of image loading, from 0.0 (nothing loaded) | - | ||||||||||||||||||||||||
| 428 | to 1.0 (finished). | - | ||||||||||||||||||||||||
| 429 | - | |||||||||||||||||||||||||
| 430 | \sa status | - | ||||||||||||||||||||||||
| 431 | */ | - | ||||||||||||||||||||||||
| 432 | - | |||||||||||||||||||||||||
| 433 | /*! | - | ||||||||||||||||||||||||
| 434 | \qmlproperty bool QtQuick::Image::smooth | - | ||||||||||||||||||||||||
| 435 | - | |||||||||||||||||||||||||
| 436 | This property holds whether the image is smoothly filtered when scaled or | - | ||||||||||||||||||||||||
| 437 | transformed. Smooth filtering gives better visual quality, but it may be slower | - | ||||||||||||||||||||||||
| 438 | on some hardware. If the image is displayed at its natural size, this property has | - | ||||||||||||||||||||||||
| 439 | no visual or performance effect. | - | ||||||||||||||||||||||||
| 440 | - | |||||||||||||||||||||||||
| 441 | By default, this property is set to true. | - | ||||||||||||||||||||||||
| 442 | - | |||||||||||||||||||||||||
| 443 | \sa mipmap | - | ||||||||||||||||||||||||
| 444 | */ | - | ||||||||||||||||||||||||
| 445 | - | |||||||||||||||||||||||||
| 446 | /*! | - | ||||||||||||||||||||||||
| 447 | \qmlproperty QSize QtQuick::Image::sourceSize | - | ||||||||||||||||||||||||
| 448 | - | |||||||||||||||||||||||||
| 449 | This property holds the actual width and height of the loaded image. | - | ||||||||||||||||||||||||
| 450 | - | |||||||||||||||||||||||||
| 451 | Unlike the \l {Item::}{width} and \l {Item::}{height} properties, which scale | - | ||||||||||||||||||||||||
| 452 | the painting of the image, this property sets the actual number of pixels | - | ||||||||||||||||||||||||
| 453 | stored for the loaded image so that large images do not use more | - | ||||||||||||||||||||||||
| 454 | memory than necessary. For example, this ensures the image in memory is no | - | ||||||||||||||||||||||||
| 455 | larger than 1024x1024 pixels, regardless of the Image's \l {Item::}{width} and | - | ||||||||||||||||||||||||
| 456 | \l {Item::}{height} values: | - | ||||||||||||||||||||||||
| 457 | - | |||||||||||||||||||||||||
| 458 | \code | - | ||||||||||||||||||||||||
| 459 | Rectangle { | - | ||||||||||||||||||||||||
| 460 | width: ... | - | ||||||||||||||||||||||||
| 461 | height: ... | - | ||||||||||||||||||||||||
| 462 | - | |||||||||||||||||||||||||
| 463 | Image { | - | ||||||||||||||||||||||||
| 464 | anchors.fill: parent | - | ||||||||||||||||||||||||
| 465 | source: "reallyBigImage.jpg" | - | ||||||||||||||||||||||||
| 466 | sourceSize.width: 1024 | - | ||||||||||||||||||||||||
| 467 | sourceSize.height: 1024 | - | ||||||||||||||||||||||||
| 468 | } | - | ||||||||||||||||||||||||
| 469 | } | - | ||||||||||||||||||||||||
| 470 | \endcode | - | ||||||||||||||||||||||||
| 471 | - | |||||||||||||||||||||||||
| 472 | If the image's actual size is larger than the sourceSize, the image is scaled down. | - | ||||||||||||||||||||||||
| 473 | If only one dimension of the size is set to greater than 0, the | - | ||||||||||||||||||||||||
| 474 | other dimension is set in proportion to preserve the source image's aspect ratio. | - | ||||||||||||||||||||||||
| 475 | (The \l fillMode is independent of this.) | - | ||||||||||||||||||||||||
| 476 | - | |||||||||||||||||||||||||
| 477 | If both the sourceSize.width and sourceSize.height are set the image will be scaled | - | ||||||||||||||||||||||||
| 478 | down to fit within the specified size (unless PreserveAspectCrop or PreserveAspectFit | - | ||||||||||||||||||||||||
| 479 | are used, then it will be scaled to match the optimal size for cropping/fitting), | - | ||||||||||||||||||||||||
| 480 | maintaining the image's aspect ratio. The actual | - | ||||||||||||||||||||||||
| 481 | size of the image after scaling is available via \l Item::implicitWidth and \l Item::implicitHeight. | - | ||||||||||||||||||||||||
| 482 | - | |||||||||||||||||||||||||
| 483 | If the source is an intrinsically scalable image (eg. SVG), this property | - | ||||||||||||||||||||||||
| 484 | determines the size of the loaded image regardless of intrinsic size. | - | ||||||||||||||||||||||||
| 485 | Avoid changing this property dynamically; rendering an SVG is \e slow compared | - | ||||||||||||||||||||||||
| 486 | to an image. | - | ||||||||||||||||||||||||
| 487 | - | |||||||||||||||||||||||||
| 488 | If the source is a non-scalable image (eg. JPEG), the loaded image will | - | ||||||||||||||||||||||||
| 489 | be no greater than this property specifies. For some formats (currently only JPEG), | - | ||||||||||||||||||||||||
| 490 | the whole image will never actually be loaded into memory. | - | ||||||||||||||||||||||||
| 491 | - | |||||||||||||||||||||||||
| 492 | sourceSize can be cleared to the natural size of the image | - | ||||||||||||||||||||||||
| 493 | by setting sourceSize to \c undefined. | - | ||||||||||||||||||||||||
| 494 | - | |||||||||||||||||||||||||
| 495 | \note \e {Changing this property dynamically causes the image source to be reloaded, | - | ||||||||||||||||||||||||
| 496 | potentially even from the network, if it is not in the disk cache.} | - | ||||||||||||||||||||||||
| 497 | */ | - | ||||||||||||||||||||||||
| 498 | - | |||||||||||||||||||||||||
| 499 | /*! | - | ||||||||||||||||||||||||
| 500 | \qmlproperty url QtQuick::Image::source | - | ||||||||||||||||||||||||
| 501 | - | |||||||||||||||||||||||||
| 502 | Image can handle any image format supported by Qt, loaded from any URL scheme supported by Qt. | - | ||||||||||||||||||||||||
| 503 | - | |||||||||||||||||||||||||
| 504 | The URL may be absolute, or relative to the URL of the component. | - | ||||||||||||||||||||||||
| 505 | - | |||||||||||||||||||||||||
| 506 | \sa QQuickImageProvider {OpenGL Texture Files} {Automatic Detection of File Extension} | - | ||||||||||||||||||||||||
| 507 | */ | - | ||||||||||||||||||||||||
| 508 | - | |||||||||||||||||||||||||
| 509 | /*! | - | ||||||||||||||||||||||||
| 510 | \qmlproperty bool QtQuick::Image::asynchronous | - | ||||||||||||||||||||||||
| 511 | - | |||||||||||||||||||||||||
| 512 | Specifies that images on the local filesystem should be loaded | - | ||||||||||||||||||||||||
| 513 | asynchronously in a separate thread. The default value is | - | ||||||||||||||||||||||||
| 514 | false, causing the user interface thread to block while the | - | ||||||||||||||||||||||||
| 515 | image is loaded. Setting \a asynchronous to true is useful where | - | ||||||||||||||||||||||||
| 516 | maintaining a responsive user interface is more desirable | - | ||||||||||||||||||||||||
| 517 | than having images immediately visible. | - | ||||||||||||||||||||||||
| 518 | - | |||||||||||||||||||||||||
| 519 | Note that this property is only valid for images read from the | - | ||||||||||||||||||||||||
| 520 | local filesystem. Images loaded via a network resource (e.g. HTTP) | - | ||||||||||||||||||||||||
| 521 | are always loaded asynchronously. | - | ||||||||||||||||||||||||
| 522 | */ | - | ||||||||||||||||||||||||
| 523 | - | |||||||||||||||||||||||||
| 524 | /*! | - | ||||||||||||||||||||||||
| 525 | \qmlproperty bool QtQuick::Image::cache | - | ||||||||||||||||||||||||
| 526 | - | |||||||||||||||||||||||||
| 527 | Specifies whether the image should be cached. The default value is | - | ||||||||||||||||||||||||
| 528 | true. Setting \a cache to false is useful when dealing with large images, | - | ||||||||||||||||||||||||
| 529 | to make sure that they aren't cached at the expense of small 'ui element' images. | - | ||||||||||||||||||||||||
| 530 | */ | - | ||||||||||||||||||||||||
| 531 | - | |||||||||||||||||||||||||
| 532 | /*! | - | ||||||||||||||||||||||||
| 533 | \qmlproperty bool QtQuick::Image::mirror | - | ||||||||||||||||||||||||
| 534 | - | |||||||||||||||||||||||||
| 535 | This property holds whether the image should be horizontally inverted | - | ||||||||||||||||||||||||
| 536 | (effectively displaying a mirrored image). | - | ||||||||||||||||||||||||
| 537 | - | |||||||||||||||||||||||||
| 538 | The default value is false. | - | ||||||||||||||||||||||||
| 539 | */ | - | ||||||||||||||||||||||||
| 540 | - | |||||||||||||||||||||||||
| 541 | /*! | - | ||||||||||||||||||||||||
| 542 | \qmlproperty enumeration QtQuick::Image::horizontalAlignment | - | ||||||||||||||||||||||||
| 543 | \qmlproperty enumeration QtQuick::Image::verticalAlignment | - | ||||||||||||||||||||||||
| 544 | - | |||||||||||||||||||||||||
| 545 | Sets the horizontal and vertical alignment of the image. By default, the image is center aligned. | - | ||||||||||||||||||||||||
| 546 | - | |||||||||||||||||||||||||
| 547 | The valid values for \c horizontalAlignment are \c Image.AlignLeft, \c Image.AlignRight and \c Image.AlignHCenter. | - | ||||||||||||||||||||||||
| 548 | The valid values for \c verticalAlignment are \c Image.AlignTop, \c Image.AlignBottom | - | ||||||||||||||||||||||||
| 549 | and \c Image.AlignVCenter. | - | ||||||||||||||||||||||||
| 550 | */ | - | ||||||||||||||||||||||||
| 551 | void QQuickImage::updatePaintedGeometry() | - | ||||||||||||||||||||||||
| 552 | { | - | ||||||||||||||||||||||||
| 553 | Q_D(QQuickImage); | - | ||||||||||||||||||||||||
| 554 | - | |||||||||||||||||||||||||
| 555 | if (d->fillMode == PreserveAspectFit) {
| 96-13850 | ||||||||||||||||||||||||
| 556 | if (!d->pix.width() || !d->pix.height()) {
| 0-60 | ||||||||||||||||||||||||
| 557 | setImplicitSize(0, 0); | - | ||||||||||||||||||||||||
| 558 | return; executed 36 times by 2 tests: return;Executed by:
| 36 | ||||||||||||||||||||||||
| 559 | } | - | ||||||||||||||||||||||||
| 560 | const qreal pixWidth = d->pix.width() / d->devicePixelRatio; | - | ||||||||||||||||||||||||
| 561 | const qreal pixHeight = d->pix.height() / d->devicePixelRatio; | - | ||||||||||||||||||||||||
| 562 | const qreal w = widthValid() ? width() : pixWidth;
| 22-38 | ||||||||||||||||||||||||
| 563 | const qreal widthScale = w / pixWidth; | - | ||||||||||||||||||||||||
| 564 | const qreal h = heightValid() ? height() : pixHeight;
| 24-36 | ||||||||||||||||||||||||
| 565 | const qreal heightScale = h / pixHeight; | - | ||||||||||||||||||||||||
| 566 | if (widthScale <= heightScale) {
| 20-40 | ||||||||||||||||||||||||
| 567 | d->paintedWidth = w; | - | ||||||||||||||||||||||||
| 568 | d->paintedHeight = widthScale * pixHeight; | - | ||||||||||||||||||||||||
| 569 | } else if (heightScale < widthScale) { executed 40 times by 2 tests: end of blockExecuted by:
| 0-40 | ||||||||||||||||||||||||
| 570 | d->paintedWidth = heightScale * pixWidth; | - | ||||||||||||||||||||||||
| 571 | d->paintedHeight = h; | - | ||||||||||||||||||||||||
| 572 | } executed 20 times by 1 test: end of blockExecuted by:
| 20 | ||||||||||||||||||||||||
| 573 | const qreal iHeight = (widthValid() && !heightValid()) ? d->paintedHeight : pixHeight;
| 10-38 | ||||||||||||||||||||||||
| 574 | const qreal iWidth = (heightValid() && !widthValid()) ? d->paintedWidth : pixWidth;
| 10-36 | ||||||||||||||||||||||||
| 575 | setImplicitSize(iWidth, iHeight); | - | ||||||||||||||||||||||||
| 576 | - | |||||||||||||||||||||||||
| 577 | } else if (d->fillMode == PreserveAspectCrop) { executed 60 times by 2 tests: end of blockExecuted by:
| 60-13760 | ||||||||||||||||||||||||
| 578 | if (!d->pix.width() || !d->pix.height())
| 0-50 | ||||||||||||||||||||||||
| 579 | return; executed 40 times by 2 tests: return;Executed by:
| 40 | ||||||||||||||||||||||||
| 580 | const qreal pixWidth = d->pix.width() / d->devicePixelRatio; | - | ||||||||||||||||||||||||
| 581 | const qreal pixHeight = d->pix.height() / d->devicePixelRatio; | - | ||||||||||||||||||||||||
| 582 | qreal widthScale = width() / pixWidth; | - | ||||||||||||||||||||||||
| 583 | qreal heightScale = height() / pixHeight; | - | ||||||||||||||||||||||||
| 584 | if (widthScale < heightScale) {
| 20-30 | ||||||||||||||||||||||||
| 585 | widthScale = heightScale; | - | ||||||||||||||||||||||||
| 586 | } else if (heightScale < widthScale) { executed 20 times by 2 tests: end of blockExecuted by:
| 8-22 | ||||||||||||||||||||||||
| 587 | heightScale = widthScale; | - | ||||||||||||||||||||||||
| 588 | } executed 22 times by 2 tests: end of blockExecuted by:
| 22 | ||||||||||||||||||||||||
| 589 | - | |||||||||||||||||||||||||
| 590 | d->paintedHeight = heightScale * pixHeight; | - | ||||||||||||||||||||||||
| 591 | d->paintedWidth = widthScale * pixWidth; | - | ||||||||||||||||||||||||
| 592 | } else if (d->fillMode == Pad) { executed 50 times by 2 tests: end of blockExecuted by:
| 6-13754 | ||||||||||||||||||||||||
| 593 | d->paintedWidth = d->pix.width() / d->devicePixelRatio; | - | ||||||||||||||||||||||||
| 594 | d->paintedHeight = d->pix.height() / d->devicePixelRatio; | - | ||||||||||||||||||||||||
| 595 | } else { executed 6 times by 1 test: end of blockExecuted by:
| 6 | ||||||||||||||||||||||||
| 596 | d->paintedWidth = width(); | - | ||||||||||||||||||||||||
| 597 | d->paintedHeight = height(); | - | ||||||||||||||||||||||||
| 598 | } executed 13754 times by 11 tests: end of blockExecuted by:
| 13754 | ||||||||||||||||||||||||
| 599 | emit paintedGeometryChanged(); | - | ||||||||||||||||||||||||
| 600 | } executed 13870 times by 11 tests: end of blockExecuted by:
| 13870 | ||||||||||||||||||||||||
| 601 | - | |||||||||||||||||||||||||
| 602 | void QQuickImage::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) | - | ||||||||||||||||||||||||
| 603 | { | - | ||||||||||||||||||||||||
| 604 | QQuickImageBase::geometryChanged(newGeometry, oldGeometry); | - | ||||||||||||||||||||||||
| 605 | if (newGeometry.size() != oldGeometry.size())
| 7834-11902 | ||||||||||||||||||||||||
| 606 | updatePaintedGeometry(); executed 7834 times by 11 tests: updatePaintedGeometry();Executed by:
| 7834 | ||||||||||||||||||||||||
| 607 | } executed 19736 times by 12 tests: end of blockExecuted by:
| 19736 | ||||||||||||||||||||||||
| 608 | - | |||||||||||||||||||||||||
| 609 | QRectF QQuickImage::boundingRect() const | - | ||||||||||||||||||||||||
| 610 | { | - | ||||||||||||||||||||||||
| 611 | Q_D(const QQuickImage); | - | ||||||||||||||||||||||||
| 612 | return QRectF(0, 0, qMax(width(), d->paintedWidth), qMax(height(), d->paintedHeight)); executed 96 times by 1 test: return QRectF(0, 0, qMax(width(), d->paintedWidth), qMax(height(), d->paintedHeight));Executed by:
| 96 | ||||||||||||||||||||||||
| 613 | } | - | ||||||||||||||||||||||||
| 614 | - | |||||||||||||||||||||||||
| 615 | QSGTextureProvider *QQuickImage::textureProvider() const | - | ||||||||||||||||||||||||
| 616 | { | - | ||||||||||||||||||||||||
| 617 | Q_D(const QQuickImage); | - | ||||||||||||||||||||||||
| 618 | - | |||||||||||||||||||||||||
| 619 | // When Item::layer::enabled == true, QQuickItem will be a texture | - | ||||||||||||||||||||||||
| 620 | // provider. In this case we should prefer to return the layer rather | - | ||||||||||||||||||||||||
| 621 | // than the image itself. The layer will include any children and any | - | ||||||||||||||||||||||||
| 622 | // the image's wrap and fill mode. | - | ||||||||||||||||||||||||
| 623 | if (QQuickItem::isTextureProvider())
| 0-4 | ||||||||||||||||||||||||
| 624 | return QQuickItem::textureProvider(); never executed: return QQuickItem::textureProvider(); | 0 | ||||||||||||||||||||||||
| 625 | - | |||||||||||||||||||||||||
| 626 | if (!d->window || !d->sceneGraphRenderContext() || QThread::currentThread() != d->sceneGraphRenderContext()->thread()) {
| 0-4 | ||||||||||||||||||||||||
| 627 | qWarning("QQuickImage::textureProvider: can only be queried on the rendering thread of an exposed window"); | - | ||||||||||||||||||||||||
| 628 | return nullptr; never executed: return nullptr; | 0 | ||||||||||||||||||||||||
| 629 | } | - | ||||||||||||||||||||||||
| 630 | - | |||||||||||||||||||||||||
| 631 | if (!d->provider) {
| 0-4 | ||||||||||||||||||||||||
| 632 | QQuickImagePrivate *dd = const_cast<QQuickImagePrivate *>(d); | - | ||||||||||||||||||||||||
| 633 | dd->provider = new QQuickImageTextureProvider; | - | ||||||||||||||||||||||||
| 634 | dd->provider->m_smooth = d->smooth; | - | ||||||||||||||||||||||||
| 635 | dd->provider->m_mipmap = d->mipmap; | - | ||||||||||||||||||||||||
| 636 | dd->provider->updateTexture(d->sceneGraphRenderContext()->textureForFactory(d->pix.textureFactory(), window())); | - | ||||||||||||||||||||||||
| 637 | } executed 4 times by 2 tests: end of blockExecuted by:
| 4 | ||||||||||||||||||||||||
| 638 | - | |||||||||||||||||||||||||
| 639 | return d->provider; executed 4 times by 2 tests: return d->provider;Executed by:
| 4 | ||||||||||||||||||||||||
| 640 | } | - | ||||||||||||||||||||||||
| 641 | - | |||||||||||||||||||||||||
| 642 | void QQuickImage::invalidateSceneGraph() | - | ||||||||||||||||||||||||
| 643 | { | - | ||||||||||||||||||||||||
| 644 | Q_D(QQuickImage); | - | ||||||||||||||||||||||||
| 645 | delete d->provider; | - | ||||||||||||||||||||||||
| 646 | d->provider = nullptr; | - | ||||||||||||||||||||||||
| 647 | } executed 86 times by 3 tests: end of blockExecuted by:
| 86 | ||||||||||||||||||||||||
| 648 | - | |||||||||||||||||||||||||
| 649 | void QQuickImage::releaseResources() | - | ||||||||||||||||||||||||
| 650 | { | - | ||||||||||||||||||||||||
| 651 | Q_D(QQuickImage); | - | ||||||||||||||||||||||||
| 652 | if (d->provider) {
| 2-4040 | ||||||||||||||||||||||||
| 653 | QQuickWindowQObjectCleanupJob::schedule(window(), d->provider); | - | ||||||||||||||||||||||||
| 654 | d->provider = nullptr; | - | ||||||||||||||||||||||||
| 655 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||||||||
| 656 | } executed 4042 times by 8 tests: end of blockExecuted by:
| 4042 | ||||||||||||||||||||||||
| 657 | - | |||||||||||||||||||||||||
| 658 | QSGNode *QQuickImage::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) | - | ||||||||||||||||||||||||
| 659 | { | - | ||||||||||||||||||||||||
| 660 | Q_D(QQuickImage); | - | ||||||||||||||||||||||||
| 661 | - | |||||||||||||||||||||||||
| 662 | QSGTexture *texture = d->sceneGraphRenderContext()->textureForFactory(d->pix.textureFactory(), window()); | - | ||||||||||||||||||||||||
| 663 | - | |||||||||||||||||||||||||
| 664 | // Copy over the current texture state into the texture provider... | - | ||||||||||||||||||||||||
| 665 | if (d->provider) {
| 4-5185 | ||||||||||||||||||||||||
| 666 | d->provider->m_smooth = d->smooth; | - | ||||||||||||||||||||||||
| 667 | d->provider->m_mipmap = d->mipmap; | - | ||||||||||||||||||||||||
| 668 | d->provider->updateTexture(texture); | - | ||||||||||||||||||||||||
| 669 | } executed 4 times by 2 tests: end of blockExecuted by:
| 4 | ||||||||||||||||||||||||
| 670 | - | |||||||||||||||||||||||||
| 671 | if (!texture || width() <= 0 || height() <= 0) {
| 0-5087 | ||||||||||||||||||||||||
| 672 | delete oldNode; | - | ||||||||||||||||||||||||
| 673 | return nullptr; executed 104 times by 2 tests: return nullptr;Executed by:
| 104 | ||||||||||||||||||||||||
| 674 | } | - | ||||||||||||||||||||||||
| 675 | - | |||||||||||||||||||||||||
| 676 | QSGInternalImageNode *node = static_cast<QSGInternalImageNode *>(oldNode); | - | ||||||||||||||||||||||||
| 677 | if (!node) {
| 60-5025 | ||||||||||||||||||||||||
| 678 | d->pixmapChanged = true; | - | ||||||||||||||||||||||||
| 679 | node = d->sceneGraphContext()->createInternalImageNode(); | - | ||||||||||||||||||||||||
| 680 | } executed 5025 times by 8 tests: end of blockExecuted by:
| 5025 | ||||||||||||||||||||||||
| 681 | - | |||||||||||||||||||||||||
| 682 | QRectF targetRect; | - | ||||||||||||||||||||||||
| 683 | QRectF sourceRect; | - | ||||||||||||||||||||||||
| 684 | QSGTexture::WrapMode hWrap = QSGTexture::ClampToEdge; | - | ||||||||||||||||||||||||
| 685 | QSGTexture::WrapMode vWrap = QSGTexture::ClampToEdge; | - | ||||||||||||||||||||||||
| 686 | - | |||||||||||||||||||||||||
| 687 | qreal pixWidth = (d->fillMode == PreserveAspectFit) ? d->paintedWidth : d->pix.width() / d->devicePixelRatio;
| 2-5083 | ||||||||||||||||||||||||
| 688 | qreal pixHeight = (d->fillMode == PreserveAspectFit) ? d->paintedHeight : d->pix.height() / d->devicePixelRatio;
| 2-5083 | ||||||||||||||||||||||||
| 689 | - | |||||||||||||||||||||||||
| 690 | int xOffset = 0; | - | ||||||||||||||||||||||||
| 691 | if (d->hAlign == QQuickImage::AlignHCenter)
| 0-5085 | ||||||||||||||||||||||||
| 692 | xOffset = qCeil((width() - pixWidth) / 2.); executed 5085 times by 8 tests: xOffset = qCeil((width() - pixWidth) / 2.);Executed by:
| 5085 | ||||||||||||||||||||||||
| 693 | else if (d->hAlign == QQuickImage::AlignRight)
| 0 | ||||||||||||||||||||||||
| 694 | xOffset = qCeil(width() - pixWidth); never executed: xOffset = qCeil(width() - pixWidth); | 0 | ||||||||||||||||||||||||
| 695 | - | |||||||||||||||||||||||||
| 696 | int yOffset = 0; | - | ||||||||||||||||||||||||
| 697 | if (d->vAlign == QQuickImage::AlignVCenter)
| 0-5085 | ||||||||||||||||||||||||
| 698 | yOffset = qCeil((height() - pixHeight) / 2.); executed 5085 times by 8 tests: yOffset = qCeil((height() - pixHeight) / 2.);Executed by:
| 5085 | ||||||||||||||||||||||||
| 699 | else if (d->vAlign == QQuickImage::AlignBottom)
| 0 | ||||||||||||||||||||||||
| 700 | yOffset = qCeil(height() - pixHeight); never executed: yOffset = qCeil(height() - pixHeight); | 0 | ||||||||||||||||||||||||
| 701 | - | |||||||||||||||||||||||||
| 702 | switch (d->fillMode) { | - | ||||||||||||||||||||||||
| 703 | default: never executed: default: | 0 | ||||||||||||||||||||||||
| 704 | case Stretch: executed 5053 times by 8 tests: case Stretch:Executed by:
| 5053 | ||||||||||||||||||||||||
| 705 | targetRect = QRectF(0, 0, width(), height()); | - | ||||||||||||||||||||||||
| 706 | sourceRect = d->pix.rect(); | - | ||||||||||||||||||||||||
| 707 | break; executed 5053 times by 8 tests: break;Executed by:
| 5053 | ||||||||||||||||||||||||
| 708 | - | |||||||||||||||||||||||||
| 709 | case PreserveAspectFit: executed 2 times by 1 test: case PreserveAspectFit:Executed by:
| 2 | ||||||||||||||||||||||||
| 710 | targetRect = QRectF(xOffset, yOffset, d->paintedWidth, d->paintedHeight); | - | ||||||||||||||||||||||||
| 711 | sourceRect = d->pix.rect(); | - | ||||||||||||||||||||||||
| 712 | break; executed 2 times by 1 test: break;Executed by:
| 2 | ||||||||||||||||||||||||
| 713 | - | |||||||||||||||||||||||||
| 714 | case PreserveAspectCrop: { executed 16 times by 2 tests: case PreserveAspectCrop:Executed by:
| 16 | ||||||||||||||||||||||||
| 715 | targetRect = QRect(0, 0, width(), height()); | - | ||||||||||||||||||||||||
| 716 | qreal wscale = width() / qreal(d->pix.width()); | - | ||||||||||||||||||||||||
| 717 | qreal hscale = height() / qreal(d->pix.height()); | - | ||||||||||||||||||||||||
| 718 | - | |||||||||||||||||||||||||
| 719 | if (wscale > hscale) {
| 4-12 | ||||||||||||||||||||||||
| 720 | int src = (hscale / wscale) * qreal(d->pix.height()); | - | ||||||||||||||||||||||||
| 721 | int y = 0; | - | ||||||||||||||||||||||||
| 722 | if (d->vAlign == QQuickImage::AlignVCenter)
| 0-4 | ||||||||||||||||||||||||
| 723 | y = qCeil((d->pix.height() - src) / 2.); executed 4 times by 2 tests: y = qCeil((d->pix.height() - src) / 2.);Executed by:
| 4 | ||||||||||||||||||||||||
| 724 | else if (d->vAlign == QQuickImage::AlignBottom)
| 0 | ||||||||||||||||||||||||
| 725 | y = qCeil(d->pix.height() - src); never executed: y = qCeil(d->pix.height() - src); | 0 | ||||||||||||||||||||||||
| 726 | sourceRect = QRectF(0, y, d->pix.width(), src); | - | ||||||||||||||||||||||||
| 727 | - | |||||||||||||||||||||||||
| 728 | } else { executed 4 times by 2 tests: end of blockExecuted by:
| 4 | ||||||||||||||||||||||||
| 729 | int src = (wscale / hscale) * qreal(d->pix.width()); | - | ||||||||||||||||||||||||
| 730 | int x = 0; | - | ||||||||||||||||||||||||
| 731 | if (d->hAlign == QQuickImage::AlignHCenter)
| 0-12 | ||||||||||||||||||||||||
| 732 | x = qCeil((d->pix.width() - src) / 2.); executed 12 times by 1 test: x = qCeil((d->pix.width() - src) / 2.);Executed by:
| 12 | ||||||||||||||||||||||||
| 733 | else if (d->hAlign == QQuickImage::AlignRight)
| 0 | ||||||||||||||||||||||||
| 734 | x = qCeil(d->pix.width() - src); never executed: x = qCeil(d->pix.width() - src); | 0 | ||||||||||||||||||||||||
| 735 | sourceRect = QRectF(x, 0, src, d->pix.height()); | - | ||||||||||||||||||||||||
| 736 | } executed 12 times by 1 test: end of blockExecuted by:
| 12 | ||||||||||||||||||||||||
| 737 | } | - | ||||||||||||||||||||||||
| 738 | break; executed 16 times by 2 tests: break;Executed by:
| 16 | ||||||||||||||||||||||||
| 739 | - | |||||||||||||||||||||||||
| 740 | case Tile: executed 2 times by 1 test: case Tile:Executed by:
| 2 | ||||||||||||||||||||||||
| 741 | targetRect = QRectF(0, 0, width(), height()); | - | ||||||||||||||||||||||||
| 742 | sourceRect = QRectF(-xOffset, -yOffset, width(), height()); | - | ||||||||||||||||||||||||
| 743 | hWrap = QSGTexture::Repeat; | - | ||||||||||||||||||||||||
| 744 | vWrap = QSGTexture::Repeat; | - | ||||||||||||||||||||||||
| 745 | break; executed 2 times by 1 test: break;Executed by:
| 2 | ||||||||||||||||||||||||
| 746 | - | |||||||||||||||||||||||||
| 747 | case TileHorizontally: executed 6 times by 2 tests: case TileHorizontally:Executed by:
| 6 | ||||||||||||||||||||||||
| 748 | targetRect = QRectF(0, 0, width(), height()); | - | ||||||||||||||||||||||||
| 749 | sourceRect = QRectF(-xOffset, 0, width(), d->pix.height()); | - | ||||||||||||||||||||||||
| 750 | hWrap = QSGTexture::Repeat; | - | ||||||||||||||||||||||||
| 751 | break; executed 6 times by 2 tests: break;Executed by:
| 6 | ||||||||||||||||||||||||
| 752 | - | |||||||||||||||||||||||||
| 753 | case TileVertically: executed 4 times by 1 test: case TileVertically:Executed by:
| 4 | ||||||||||||||||||||||||
| 754 | targetRect = QRectF(0, 0, width(), height()); | - | ||||||||||||||||||||||||
| 755 | sourceRect = QRectF(0, -yOffset, d->pix.width(), height()); | - | ||||||||||||||||||||||||
| 756 | vWrap = QSGTexture::Repeat; | - | ||||||||||||||||||||||||
| 757 | break; executed 4 times by 1 test: break;Executed by:
| 4 | ||||||||||||||||||||||||
| 758 | - | |||||||||||||||||||||||||
| 759 | case Pad: executed 2 times by 1 test: case Pad:Executed by:
| 2 | ||||||||||||||||||||||||
| 760 | qreal w = qMin(qreal(pixWidth), width()); | - | ||||||||||||||||||||||||
| 761 | qreal h = qMin(qreal(pixHeight), height()); | - | ||||||||||||||||||||||||
| 762 | qreal x = (pixWidth > width()) ? -xOffset : 0;
| 0-2 | ||||||||||||||||||||||||
| 763 | qreal y = (pixHeight > height()) ? -yOffset : 0;
| 0-2 | ||||||||||||||||||||||||
| 764 | targetRect = QRectF(x + xOffset, y + yOffset, w, h); | - | ||||||||||||||||||||||||
| 765 | sourceRect = QRectF(x, y, w, h); | - | ||||||||||||||||||||||||
| 766 | break; executed 2 times by 1 test: break;Executed by:
| 2 | ||||||||||||||||||||||||
| 767 | }; | - | ||||||||||||||||||||||||
| 768 | - | |||||||||||||||||||||||||
| 769 | qreal nsWidth = (hWrap == QSGTexture::Repeat || d->fillMode == Pad) ? d->pix.width() / d->devicePixelRatio : d->pix.width();
| 2-5077 | ||||||||||||||||||||||||
| 770 | qreal nsHeight = (vWrap == QSGTexture::Repeat || d->fillMode == Pad) ? d->pix.height() / d->devicePixelRatio : d->pix.height();
| 2-5079 | ||||||||||||||||||||||||
| 771 | QRectF nsrect(sourceRect.x() / nsWidth, | - | ||||||||||||||||||||||||
| 772 | sourceRect.y() / nsHeight, | - | ||||||||||||||||||||||||
| 773 | sourceRect.width() / nsWidth, | - | ||||||||||||||||||||||||
| 774 | sourceRect.height() / nsHeight); | - | ||||||||||||||||||||||||
| 775 | - | |||||||||||||||||||||||||
| 776 | if (targetRect.isEmpty()
| 0-5085 | ||||||||||||||||||||||||
| 777 | || !qt_is_finite(targetRect.width()) || !qt_is_finite(targetRect.height())
| 0-5085 | ||||||||||||||||||||||||
| 778 | || nsrect.isEmpty()
| 0-5085 | ||||||||||||||||||||||||
| 779 | || !qt_is_finite(nsrect.width()) || !qt_is_finite(nsrect.height())) {
| 0-5085 | ||||||||||||||||||||||||
| 780 | delete node; | - | ||||||||||||||||||||||||
| 781 | return nullptr; never executed: return nullptr; | 0 | ||||||||||||||||||||||||
| 782 | } | - | ||||||||||||||||||||||||
| 783 | - | |||||||||||||||||||||||||
| 784 | if (d->pixmapChanged) {
| 4-5081 | ||||||||||||||||||||||||
| 785 | // force update the texture in the node to trigger reconstruction of | - | ||||||||||||||||||||||||
| 786 | // geometry and the likes when a atlas segment has changed. | - | ||||||||||||||||||||||||
| 787 | if (texture->isAtlasTexture() && (hWrap == QSGTexture::Repeat || vWrap == QSGTexture::Repeat || d->mipmap))
| 2-4935 | ||||||||||||||||||||||||
| 788 | node->setTexture(texture->removedFromAtlas()); executed 12 times by 2 tests: node->setTexture(texture->removedFromAtlas());Executed by:
| 12 | ||||||||||||||||||||||||
| 789 | else | - | ||||||||||||||||||||||||
| 790 | node->setTexture(texture); executed 5069 times by 8 tests: node->setTexture(texture);Executed by:
| 5069 | ||||||||||||||||||||||||
| 791 | d->pixmapChanged = false; | - | ||||||||||||||||||||||||
| 792 | } executed 5081 times by 8 tests: end of blockExecuted by:
| 5081 | ||||||||||||||||||||||||
| 793 | - | |||||||||||||||||||||||||
| 794 | node->setMipmapFiltering(d->mipmap ? QSGTexture::Linear : QSGTexture::None); | - | ||||||||||||||||||||||||
| 795 | node->setHorizontalWrapMode(hWrap); | - | ||||||||||||||||||||||||
| 796 | node->setVerticalWrapMode(vWrap); | - | ||||||||||||||||||||||||
| 797 | node->setFiltering(d->smooth ? QSGTexture::Linear : QSGTexture::Nearest); | - | ||||||||||||||||||||||||
| 798 | - | |||||||||||||||||||||||||
| 799 | node->setTargetRect(targetRect); | - | ||||||||||||||||||||||||
| 800 | node->setInnerTargetRect(targetRect); | - | ||||||||||||||||||||||||
| 801 | node->setSubSourceRect(nsrect); | - | ||||||||||||||||||||||||
| 802 | node->setMirror(d->mirror); | - | ||||||||||||||||||||||||
| 803 | node->setAntialiasing(d->antialiasing); | - | ||||||||||||||||||||||||
| 804 | node->update(); | - | ||||||||||||||||||||||||
| 805 | - | |||||||||||||||||||||||||
| 806 | return node; executed 5085 times by 8 tests: return node;Executed by:
| 5085 | ||||||||||||||||||||||||
| 807 | } | - | ||||||||||||||||||||||||
| 808 | - | |||||||||||||||||||||||||
| 809 | void QQuickImage::pixmapChange() | - | ||||||||||||||||||||||||
| 810 | { | - | ||||||||||||||||||||||||
| 811 | Q_D(QQuickImage); | - | ||||||||||||||||||||||||
| 812 | // PreserveAspectFit calculates the implicit size differently so we | - | ||||||||||||||||||||||||
| 813 | // don't call our superclass pixmapChange(), since that would | - | ||||||||||||||||||||||||
| 814 | // result in the implicit size being set incorrectly, then updated | - | ||||||||||||||||||||||||
| 815 | // in updatePaintedGeometry() | - | ||||||||||||||||||||||||
| 816 | if (d->fillMode != PreserveAspectFit)
| 26-5980 | ||||||||||||||||||||||||
| 817 | QQuickImageBase::pixmapChange(); executed 5980 times by 11 tests: QQuickImageBase::pixmapChange();Executed by:
| 5980 | ||||||||||||||||||||||||
| 818 | updatePaintedGeometry(); | - | ||||||||||||||||||||||||
| 819 | d->pixmapChanged = true; | - | ||||||||||||||||||||||||
| 820 | - | |||||||||||||||||||||||||
| 821 | // When the pixmap changes, such as being deleted, we need to update the textures | - | ||||||||||||||||||||||||
| 822 | update(); | - | ||||||||||||||||||||||||
| 823 | } executed 6006 times by 11 tests: end of blockExecuted by:
| 6006 | ||||||||||||||||||||||||
| 824 | - | |||||||||||||||||||||||||
| 825 | QQuickImage::VAlignment QQuickImage::verticalAlignment() const | - | ||||||||||||||||||||||||
| 826 | { | - | ||||||||||||||||||||||||
| 827 | Q_D(const QQuickImage); | - | ||||||||||||||||||||||||
| 828 | return d->vAlign; never executed: return d->vAlign; | 0 | ||||||||||||||||||||||||
| 829 | } | - | ||||||||||||||||||||||||
| 830 | - | |||||||||||||||||||||||||
| 831 | void QQuickImage::setVerticalAlignment(VAlignment align) | - | ||||||||||||||||||||||||
| 832 | { | - | ||||||||||||||||||||||||
| 833 | Q_D(QQuickImage); | - | ||||||||||||||||||||||||
| 834 | if (d->vAlign == align)
| 0 | ||||||||||||||||||||||||
| 835 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 836 | - | |||||||||||||||||||||||||
| 837 | d->vAlign = align; | - | ||||||||||||||||||||||||
| 838 | update(); | - | ||||||||||||||||||||||||
| 839 | updatePaintedGeometry(); | - | ||||||||||||||||||||||||
| 840 | emit verticalAlignmentChanged(align); | - | ||||||||||||||||||||||||
| 841 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 842 | - | |||||||||||||||||||||||||
| 843 | QQuickImage::HAlignment QQuickImage::horizontalAlignment() const | - | ||||||||||||||||||||||||
| 844 | { | - | ||||||||||||||||||||||||
| 845 | Q_D(const QQuickImage); | - | ||||||||||||||||||||||||
| 846 | return d->hAlign; never executed: return d->hAlign; | 0 | ||||||||||||||||||||||||
| 847 | } | - | ||||||||||||||||||||||||
| 848 | - | |||||||||||||||||||||||||
| 849 | void QQuickImage::setHorizontalAlignment(HAlignment align) | - | ||||||||||||||||||||||||
| 850 | { | - | ||||||||||||||||||||||||
| 851 | Q_D(QQuickImage); | - | ||||||||||||||||||||||||
| 852 | if (d->hAlign == align)
| 0 | ||||||||||||||||||||||||
| 853 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 854 | - | |||||||||||||||||||||||||
| 855 | d->hAlign = align; | - | ||||||||||||||||||||||||
| 856 | update(); | - | ||||||||||||||||||||||||
| 857 | updatePaintedGeometry(); | - | ||||||||||||||||||||||||
| 858 | emit horizontalAlignmentChanged(align); | - | ||||||||||||||||||||||||
| 859 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 860 | - | |||||||||||||||||||||||||
| 861 | /*! | - | ||||||||||||||||||||||||
| 862 | \qmlproperty bool QtQuick::Image::mipmap | - | ||||||||||||||||||||||||
| 863 | \since 5.3 | - | ||||||||||||||||||||||||
| 864 | - | |||||||||||||||||||||||||
| 865 | This property holds whether the image uses mipmap filtering when scaled or | - | ||||||||||||||||||||||||
| 866 | transformed. | - | ||||||||||||||||||||||||
| 867 | - | |||||||||||||||||||||||||
| 868 | Mipmap filtering gives better visual quality when scaling down | - | ||||||||||||||||||||||||
| 869 | compared to smooth, but it may come at a performance cost (both when | - | ||||||||||||||||||||||||
| 870 | initializing the image and during rendering). | - | ||||||||||||||||||||||||
| 871 | - | |||||||||||||||||||||||||
| 872 | By default, this property is set to false. | - | ||||||||||||||||||||||||
| 873 | - | |||||||||||||||||||||||||
| 874 | \sa smooth | - | ||||||||||||||||||||||||
| 875 | */ | - | ||||||||||||||||||||||||
| 876 | - | |||||||||||||||||||||||||
| 877 | bool QQuickImage::mipmap() const | - | ||||||||||||||||||||||||
| 878 | { | - | ||||||||||||||||||||||||
| 879 | Q_D(const QQuickImage); | - | ||||||||||||||||||||||||
| 880 | return d->mipmap; never executed: return d->mipmap; | 0 | ||||||||||||||||||||||||
| 881 | } | - | ||||||||||||||||||||||||
| 882 | - | |||||||||||||||||||||||||
| 883 | void QQuickImage::setMipmap(bool use) | - | ||||||||||||||||||||||||
| 884 | { | - | ||||||||||||||||||||||||
| 885 | Q_D(QQuickImage); | - | ||||||||||||||||||||||||
| 886 | if (d->mipmap == use)
| 0-4 | ||||||||||||||||||||||||
| 887 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 888 | d->mipmap = use; | - | ||||||||||||||||||||||||
| 889 | emit mipmapChanged(d->mipmap); | - | ||||||||||||||||||||||||
| 890 | - | |||||||||||||||||||||||||
| 891 | d->pixmapChanged = true; | - | ||||||||||||||||||||||||
| 892 | update(); | - | ||||||||||||||||||||||||
| 893 | } executed 4 times by 1 test: end of blockExecuted by:
| 4 | ||||||||||||||||||||||||
| 894 | - | |||||||||||||||||||||||||
| 895 | /*! | - | ||||||||||||||||||||||||
| 896 | \qmlproperty bool QtQuick::Image::autoTransform | - | ||||||||||||||||||||||||
| 897 | \since 5.5 | - | ||||||||||||||||||||||||
| 898 | - | |||||||||||||||||||||||||
| 899 | This property holds whether the image should automatically apply | - | ||||||||||||||||||||||||
| 900 | image transformation metadata such as EXIF orientation. | - | ||||||||||||||||||||||||
| 901 | - | |||||||||||||||||||||||||
| 902 | By default, this property is set to false. | - | ||||||||||||||||||||||||
| 903 | */ | - | ||||||||||||||||||||||||
| 904 | - | |||||||||||||||||||||||||
| 905 | QT_END_NAMESPACE | - | ||||||||||||||||||||||||
| Source code | Switch to Preprocessed file |