| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/image/qpixmap_raster.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 QtGui 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 "qpixmap.h" | - | ||||||||||||
| 41 | - | |||||||||||||
| 42 | #include <private/qfont_p.h> | - | ||||||||||||
| 43 | - | |||||||||||||
| 44 | #include "qpixmap_raster_p.h" | - | ||||||||||||
| 45 | #include "qnativeimage_p.h" | - | ||||||||||||
| 46 | #include "qimage_p.h" | - | ||||||||||||
| 47 | #include "qpaintengine.h" | - | ||||||||||||
| 48 | - | |||||||||||||
| 49 | #include "qbitmap.h" | - | ||||||||||||
| 50 | #include "qimage.h" | - | ||||||||||||
| 51 | #include <QBuffer> | - | ||||||||||||
| 52 | #include <QImageReader> | - | ||||||||||||
| 53 | #include <private/qimage_p.h> | - | ||||||||||||
| 54 | #include <private/qsimd_p.h> | - | ||||||||||||
| 55 | #include <private/qdrawhelper_p.h> | - | ||||||||||||
| 56 | - | |||||||||||||
| 57 | QT_BEGIN_NAMESPACE | - | ||||||||||||
| 58 | - | |||||||||||||
| 59 | QPixmap qt_toRasterPixmap(const QImage &image) | - | ||||||||||||
| 60 | { | - | ||||||||||||
| 61 | QPlatformPixmap *data = | - | ||||||||||||
| 62 | new QRasterPlatformPixmap(image.depth() == 1 | - | ||||||||||||
| 63 | ? QPlatformPixmap::BitmapType | - | ||||||||||||
| 64 | : QPlatformPixmap::PixmapType); | - | ||||||||||||
| 65 | - | |||||||||||||
| 66 | data->fromImage(image, Qt::AutoColor); | - | ||||||||||||
| 67 | - | |||||||||||||
| 68 | return QPixmap(data); never executed: return QPixmap(data); | 0 | ||||||||||||
| 69 | } | - | ||||||||||||
| 70 | - | |||||||||||||
| 71 | QPixmap qt_toRasterPixmap(const QPixmap &pixmap) | - | ||||||||||||
| 72 | { | - | ||||||||||||
| 73 | if (pixmap.isNull())
| 0 | ||||||||||||
| 74 | return QPixmap(); never executed: return QPixmap(); | 0 | ||||||||||||
| 75 | - | |||||||||||||
| 76 | if (QPixmap(pixmap).data_ptr()->classId() == QPlatformPixmap::RasterClass)
| 0 | ||||||||||||
| 77 | return pixmap; never executed: return pixmap; | 0 | ||||||||||||
| 78 | - | |||||||||||||
| 79 | return qt_toRasterPixmap(pixmap.toImage()); never executed: return qt_toRasterPixmap(pixmap.toImage()); | 0 | ||||||||||||
| 80 | } | - | ||||||||||||
| 81 | - | |||||||||||||
| 82 | QRasterPlatformPixmap::QRasterPlatformPixmap(PixelType type) | - | ||||||||||||
| 83 | : QPlatformPixmap(type, RasterClass) | - | ||||||||||||
| 84 | { | - | ||||||||||||
| 85 | } never executed: end of block | 0 | ||||||||||||
| 86 | - | |||||||||||||
| 87 | QRasterPlatformPixmap::~QRasterPlatformPixmap() | - | ||||||||||||
| 88 | { | - | ||||||||||||
| 89 | } | - | ||||||||||||
| 90 | - | |||||||||||||
| 91 | QPlatformPixmap *QRasterPlatformPixmap::createCompatiblePlatformPixmap() const | - | ||||||||||||
| 92 | { | - | ||||||||||||
| 93 | return new QRasterPlatformPixmap(pixelType()); never executed: return new QRasterPlatformPixmap(pixelType()); | 0 | ||||||||||||
| 94 | } | - | ||||||||||||
| 95 | - | |||||||||||||
| 96 | void QRasterPlatformPixmap::resize(int width, int height) | - | ||||||||||||
| 97 | { | - | ||||||||||||
| 98 | QImage::Format format; | - | ||||||||||||
| 99 | if (pixelType() == BitmapType)
| 0 | ||||||||||||
| 100 | format = QImage::Format_MonoLSB; never executed: format = QImage::Format_MonoLSB; | 0 | ||||||||||||
| 101 | else | - | ||||||||||||
| 102 | format = QNativeImage::systemFormat(); never executed: format = QNativeImage::systemFormat(); | 0 | ||||||||||||
| 103 | - | |||||||||||||
| 104 | image = QImage(width, height, format); | - | ||||||||||||
| 105 | w = width; | - | ||||||||||||
| 106 | h = height; | - | ||||||||||||
| 107 | d = image.depth(); | - | ||||||||||||
| 108 | is_null = (w <= 0 || h <= 0);
| 0 | ||||||||||||
| 109 | - | |||||||||||||
| 110 | if (pixelType() == BitmapType && !image.isNull()) {
| 0 | ||||||||||||
| 111 | image.setColorCount(2); | - | ||||||||||||
| 112 | image.setColor(0, QColor(Qt::color0).rgba()); | - | ||||||||||||
| 113 | image.setColor(1, QColor(Qt::color1).rgba()); | - | ||||||||||||
| 114 | } never executed: end of block | 0 | ||||||||||||
| 115 | - | |||||||||||||
| 116 | setSerialNumber(image.cacheKey() >> 32); | - | ||||||||||||
| 117 | } never executed: end of block | 0 | ||||||||||||
| 118 | - | |||||||||||||
| 119 | bool QRasterPlatformPixmap::fromData(const uchar *buffer, uint len, const char *format, | - | ||||||||||||
| 120 | Qt::ImageConversionFlags flags) | - | ||||||||||||
| 121 | { | - | ||||||||||||
| 122 | QByteArray a = QByteArray::fromRawData(reinterpret_cast<const char *>(buffer), len); | - | ||||||||||||
| 123 | QBuffer b(&a); | - | ||||||||||||
| 124 | b.open(QIODevice::ReadOnly); | - | ||||||||||||
| 125 | QImage image = QImageReader(&b, format).read(); | - | ||||||||||||
| 126 | if (image.isNull())
| 0 | ||||||||||||
| 127 | return false; never executed: return false; | 0 | ||||||||||||
| 128 | - | |||||||||||||
| 129 | createPixmapForImage(image, flags, /* inplace = */true); | - | ||||||||||||
| 130 | return !isNull(); never executed: return !isNull(); | 0 | ||||||||||||
| 131 | } | - | ||||||||||||
| 132 | - | |||||||||||||
| 133 | void QRasterPlatformPixmap::fromImage(const QImage &sourceImage, | - | ||||||||||||
| 134 | Qt::ImageConversionFlags flags) | - | ||||||||||||
| 135 | { | - | ||||||||||||
| 136 | QImage image = sourceImage; | - | ||||||||||||
| 137 | createPixmapForImage(image, flags, /* inplace = */false); | - | ||||||||||||
| 138 | } never executed: end of block | 0 | ||||||||||||
| 139 | - | |||||||||||||
| 140 | void QRasterPlatformPixmap::fromImageInPlace(QImage &sourceImage, | - | ||||||||||||
| 141 | Qt::ImageConversionFlags flags) | - | ||||||||||||
| 142 | { | - | ||||||||||||
| 143 | createPixmapForImage(sourceImage, flags, /* inplace = */true); | - | ||||||||||||
| 144 | } never executed: end of block | 0 | ||||||||||||
| 145 | - | |||||||||||||
| 146 | void QRasterPlatformPixmap::fromImageReader(QImageReader *imageReader, | - | ||||||||||||
| 147 | Qt::ImageConversionFlags flags) | - | ||||||||||||
| 148 | { | - | ||||||||||||
| 149 | Q_UNUSED(flags); | - | ||||||||||||
| 150 | QImage image = imageReader->read(); | - | ||||||||||||
| 151 | if (image.isNull())
| 0 | ||||||||||||
| 152 | return; never executed: return; | 0 | ||||||||||||
| 153 | - | |||||||||||||
| 154 | createPixmapForImage(image, flags, /* inplace = */true); | - | ||||||||||||
| 155 | } never executed: end of block | 0 | ||||||||||||
| 156 | - | |||||||||||||
| 157 | // from qbackingstore.cpp | - | ||||||||||||
| 158 | extern void qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset); | - | ||||||||||||
| 159 | - | |||||||||||||
| 160 | void QRasterPlatformPixmap::copy(const QPlatformPixmap *data, const QRect &rect) | - | ||||||||||||
| 161 | { | - | ||||||||||||
| 162 | fromImage(data->toImage(rect).copy(), Qt::NoOpaqueDetection); | - | ||||||||||||
| 163 | } never executed: end of block | 0 | ||||||||||||
| 164 | - | |||||||||||||
| 165 | bool QRasterPlatformPixmap::scroll(int dx, int dy, const QRect &rect) | - | ||||||||||||
| 166 | { | - | ||||||||||||
| 167 | if (!image.isNull())
| 0 | ||||||||||||
| 168 | qt_scrollRectInImage(image, rect, QPoint(dx, dy)); never executed: qt_scrollRectInImage(image, rect, QPoint(dx, dy)); | 0 | ||||||||||||
| 169 | return true; never executed: return true; | 0 | ||||||||||||
| 170 | } | - | ||||||||||||
| 171 | - | |||||||||||||
| 172 | void QRasterPlatformPixmap::fill(const QColor &color) | - | ||||||||||||
| 173 | { | - | ||||||||||||
| 174 | uint pixel; | - | ||||||||||||
| 175 | - | |||||||||||||
| 176 | if (image.depth() == 1) {
| 0 | ||||||||||||
| 177 | int gray = qGray(color.rgba()); | - | ||||||||||||
| 178 | // Pick the best approximate color in the image's colortable. | - | ||||||||||||
| 179 | if (qAbs(qGray(image.color(0)) - gray) < qAbs(qGray(image.color(1)) - gray))
| 0 | ||||||||||||
| 180 | pixel = 0; never executed: pixel = 0; | 0 | ||||||||||||
| 181 | else | - | ||||||||||||
| 182 | pixel = 1; never executed: pixel = 1; | 0 | ||||||||||||
| 183 | } else if (image.depth() >= 15) {
| 0 | ||||||||||||
| 184 | int alpha = color.alpha(); | - | ||||||||||||
| 185 | if (alpha != 255) {
| 0 | ||||||||||||
| 186 | if (!image.hasAlphaChannel()) {
| 0 | ||||||||||||
| 187 | QImage::Format toFormat = qt_alphaVersionForPainting(image.format()); | - | ||||||||||||
| 188 | if (!image.isNull() && qt_depthForFormat(image.format()) == qt_depthForFormat(toFormat)) {
| 0 | ||||||||||||
| 189 | image.detach(); | - | ||||||||||||
| 190 | image.d->format = toFormat; | - | ||||||||||||
| 191 | } else { never executed: end of block | 0 | ||||||||||||
| 192 | image = QImage(image.width(), image.height(), toFormat); | - | ||||||||||||
| 193 | } never executed: end of block | 0 | ||||||||||||
| 194 | } | - | ||||||||||||
| 195 | } never executed: end of block | 0 | ||||||||||||
| 196 | pixel = qPremultiply(color.rgba()); | - | ||||||||||||
| 197 | const QPixelLayout *layout = &qPixelLayouts[image.format()]; | - | ||||||||||||
| 198 | layout->convertFromARGB32PM(&pixel, &pixel, 1, layout, 0); | - | ||||||||||||
| 199 | } else if (image.format() == QImage::Format_Alpha8) { never executed: end of block
| 0 | ||||||||||||
| 200 | pixel = qAlpha(color.rgba()); | - | ||||||||||||
| 201 | } else if (image.format() == QImage::Format_Grayscale8) { never executed: end of block
| 0 | ||||||||||||
| 202 | pixel = qGray(color.rgba()); | - | ||||||||||||
| 203 | } else never executed: end of block | 0 | ||||||||||||
| 204 | { | - | ||||||||||||
| 205 | pixel = 0; | - | ||||||||||||
| 206 | // ### what about 8 bit indexed? | - | ||||||||||||
| 207 | } never executed: end of block | 0 | ||||||||||||
| 208 | - | |||||||||||||
| 209 | image.fill(pixel); | - | ||||||||||||
| 210 | } never executed: end of block | 0 | ||||||||||||
| 211 | - | |||||||||||||
| 212 | bool QRasterPlatformPixmap::hasAlphaChannel() const | - | ||||||||||||
| 213 | { | - | ||||||||||||
| 214 | return image.hasAlphaChannel(); never executed: return image.hasAlphaChannel(); | 0 | ||||||||||||
| 215 | } | - | ||||||||||||
| 216 | - | |||||||||||||
| 217 | QImage QRasterPlatformPixmap::toImage() const | - | ||||||||||||
| 218 | { | - | ||||||||||||
| 219 | if (!image.isNull()) {
| 0 | ||||||||||||
| 220 | QImageData *data = const_cast<QImage &>(image).data_ptr(); | - | ||||||||||||
| 221 | if (data->paintEngine && data->paintEngine->isActive()
| 0 | ||||||||||||
| 222 | && data->paintEngine->paintDevice() == &image)
| 0 | ||||||||||||
| 223 | { | - | ||||||||||||
| 224 | return image.copy(); never executed: return image.copy(); | 0 | ||||||||||||
| 225 | } | - | ||||||||||||
| 226 | } never executed: end of block | 0 | ||||||||||||
| 227 | - | |||||||||||||
| 228 | return image; never executed: return image; | 0 | ||||||||||||
| 229 | } | - | ||||||||||||
| 230 | - | |||||||||||||
| 231 | QImage QRasterPlatformPixmap::toImage(const QRect &rect) const | - | ||||||||||||
| 232 | { | - | ||||||||||||
| 233 | if (rect.isNull())
| 0 | ||||||||||||
| 234 | return image; never executed: return image; | 0 | ||||||||||||
| 235 | - | |||||||||||||
| 236 | QRect clipped = rect.intersected(QRect(0, 0, w, h)); | - | ||||||||||||
| 237 | const uint du = uint(d); | - | ||||||||||||
| 238 | if ((du % 8 == 0) && (((uint(clipped.x()) * du)) % 32 == 0)) {
| 0 | ||||||||||||
| 239 | QImage newImage(image.scanLine(clipped.y()) + clipped.x() * (du / 8), | - | ||||||||||||
| 240 | clipped.width(), clipped.height(), | - | ||||||||||||
| 241 | image.bytesPerLine(), image.format()); | - | ||||||||||||
| 242 | newImage.setDevicePixelRatio(image.devicePixelRatio()); | - | ||||||||||||
| 243 | return newImage; never executed: return newImage; | 0 | ||||||||||||
| 244 | } else { | - | ||||||||||||
| 245 | return image.copy(clipped); never executed: return image.copy(clipped); | 0 | ||||||||||||
| 246 | } | - | ||||||||||||
| 247 | } | - | ||||||||||||
| 248 | - | |||||||||||||
| 249 | QPaintEngine* QRasterPlatformPixmap::paintEngine() const | - | ||||||||||||
| 250 | { | - | ||||||||||||
| 251 | return image.paintEngine(); never executed: return image.paintEngine(); | 0 | ||||||||||||
| 252 | } | - | ||||||||||||
| 253 | - | |||||||||||||
| 254 | int QRasterPlatformPixmap::metric(QPaintDevice::PaintDeviceMetric metric) const | - | ||||||||||||
| 255 | { | - | ||||||||||||
| 256 | QImageData *d = image.d; | - | ||||||||||||
| 257 | if (!d)
| 0 | ||||||||||||
| 258 | return 0; never executed: return 0; | 0 | ||||||||||||
| 259 | - | |||||||||||||
| 260 | // override the image dpi with the screen dpi when rendering to a pixmap | - | ||||||||||||
| 261 | switch (metric) { | - | ||||||||||||
| 262 | case QPaintDevice::PdmWidth: never executed: case QPaintDevice::PdmWidth: | 0 | ||||||||||||
| 263 | return w; never executed: return w; | 0 | ||||||||||||
| 264 | case QPaintDevice::PdmHeight: never executed: case QPaintDevice::PdmHeight: | 0 | ||||||||||||
| 265 | return h; never executed: return h; | 0 | ||||||||||||
| 266 | case QPaintDevice::PdmWidthMM: never executed: case QPaintDevice::PdmWidthMM: | 0 | ||||||||||||
| 267 | return qRound(d->width * 25.4 / qt_defaultDpiX()); never executed: return qRound(d->width * 25.4 / qt_defaultDpiX()); | 0 | ||||||||||||
| 268 | case QPaintDevice::PdmHeightMM: never executed: case QPaintDevice::PdmHeightMM: | 0 | ||||||||||||
| 269 | return qRound(d->height * 25.4 / qt_defaultDpiY()); never executed: return qRound(d->height * 25.4 / qt_defaultDpiY()); | 0 | ||||||||||||
| 270 | case QPaintDevice::PdmNumColors: never executed: case QPaintDevice::PdmNumColors: | 0 | ||||||||||||
| 271 | return d->colortable.size(); never executed: return d->colortable.size(); | 0 | ||||||||||||
| 272 | case QPaintDevice::PdmDepth: never executed: case QPaintDevice::PdmDepth: | 0 | ||||||||||||
| 273 | return this->d; never executed: return this->d; | 0 | ||||||||||||
| 274 | case QPaintDevice::PdmDpiX: never executed: case QPaintDevice::PdmDpiX: | 0 | ||||||||||||
| 275 | return qt_defaultDpiX(); never executed: return qt_defaultDpiX(); | 0 | ||||||||||||
| 276 | case QPaintDevice::PdmPhysicalDpiX: never executed: case QPaintDevice::PdmPhysicalDpiX: | 0 | ||||||||||||
| 277 | return qt_defaultDpiX(); never executed: return qt_defaultDpiX(); | 0 | ||||||||||||
| 278 | case QPaintDevice::PdmDpiY: never executed: case QPaintDevice::PdmDpiY: | 0 | ||||||||||||
| 279 | return qt_defaultDpiX(); never executed: return qt_defaultDpiX(); | 0 | ||||||||||||
| 280 | case QPaintDevice::PdmPhysicalDpiY: never executed: case QPaintDevice::PdmPhysicalDpiY: | 0 | ||||||||||||
| 281 | return qt_defaultDpiY(); never executed: return qt_defaultDpiY(); | 0 | ||||||||||||
| 282 | case QPaintDevice::PdmDevicePixelRatio: never executed: case QPaintDevice::PdmDevicePixelRatio: | 0 | ||||||||||||
| 283 | return image.devicePixelRatio(); never executed: return image.devicePixelRatio(); | 0 | ||||||||||||
| 284 | case QPaintDevice::PdmDevicePixelRatioScaled: never executed: case QPaintDevice::PdmDevicePixelRatioScaled: | 0 | ||||||||||||
| 285 | return image.devicePixelRatio() * QPaintDevice::devicePixelRatioFScale(); never executed: return image.devicePixelRatio() * QPaintDevice::devicePixelRatioFScale(); | 0 | ||||||||||||
| 286 | - | |||||||||||||
| 287 | default: never executed: default: | 0 | ||||||||||||
| 288 | qWarning("QRasterPlatformPixmap::metric(): Unhandled metric type %d", metric); | - | ||||||||||||
| 289 | break; never executed: break; | 0 | ||||||||||||
| 290 | } | - | ||||||||||||
| 291 | - | |||||||||||||
| 292 | return 0; never executed: return 0; | 0 | ||||||||||||
| 293 | } | - | ||||||||||||
| 294 | - | |||||||||||||
| 295 | void QRasterPlatformPixmap::createPixmapForImage(QImage &sourceImage, Qt::ImageConversionFlags flags, bool inPlace) | - | ||||||||||||
| 296 | { | - | ||||||||||||
| 297 | QImage::Format format; | - | ||||||||||||
| 298 | if (flags & Qt::NoFormatConversion)
| 0 | ||||||||||||
| 299 | format = sourceImage.format(); never executed: format = sourceImage.format(); | 0 | ||||||||||||
| 300 | else | - | ||||||||||||
| 301 | if (pixelType() == BitmapType) {
| 0 | ||||||||||||
| 302 | format = QImage::Format_MonoLSB; | - | ||||||||||||
| 303 | } else { never executed: end of block | 0 | ||||||||||||
| 304 | if (sourceImage.depth() == 1) {
| 0 | ||||||||||||
| 305 | format = sourceImage.hasAlphaChannel()
| 0 | ||||||||||||
| 306 | ? QImage::Format_ARGB32_Premultiplied | - | ||||||||||||
| 307 | : QImage::Format_RGB32; | - | ||||||||||||
| 308 | } else { never executed: end of block | 0 | ||||||||||||
| 309 | QImage::Format opaqueFormat = QNativeImage::systemFormat(); | - | ||||||||||||
| 310 | QImage::Format alphaFormat = qt_alphaVersionForPainting(opaqueFormat); | - | ||||||||||||
| 311 | - | |||||||||||||
| 312 | if (!sourceImage.hasAlphaChannel()) {
| 0 | ||||||||||||
| 313 | format = opaqueFormat; | - | ||||||||||||
| 314 | } else if ((flags & Qt::NoOpaqueDetection) == 0 never executed: end of block
| 0 | ||||||||||||
| 315 | && !const_cast<QImage &>(sourceImage).data_ptr()->checkForAlphaPixels())
| 0 | ||||||||||||
| 316 | { | - | ||||||||||||
| 317 | format = opaqueFormat; | - | ||||||||||||
| 318 | } else { never executed: end of block | 0 | ||||||||||||
| 319 | format = alphaFormat; | - | ||||||||||||
| 320 | } never executed: end of block | 0 | ||||||||||||
| 321 | } | - | ||||||||||||
| 322 | } | - | ||||||||||||
| 323 | - | |||||||||||||
| 324 | // image has alpha format but is really opaque, so try to do a | - | ||||||||||||
| 325 | // more efficient conversion | - | ||||||||||||
| 326 | if (format == QImage::Format_RGB32 && (sourceImage.format() == QImage::Format_ARGB32
| 0 | ||||||||||||
| 327 | || sourceImage.format() == QImage::Format_ARGB32_Premultiplied))
| 0 | ||||||||||||
| 328 | { | - | ||||||||||||
| 329 | inPlace = inPlace && sourceImage.isDetached();
| 0 | ||||||||||||
| 330 | image = sourceImage; | - | ||||||||||||
| 331 | if (!inPlace)
| 0 | ||||||||||||
| 332 | image.detach(); never executed: image.detach(); | 0 | ||||||||||||
| 333 | if (image.d)
| 0 | ||||||||||||
| 334 | image.d->format = QImage::Format_RGB32; never executed: image.d->format = QImage::Format_RGB32; | 0 | ||||||||||||
| 335 | } else if (inPlace && sourceImage.d->convertInPlace(format, flags)) { never executed: end of block
| 0 | ||||||||||||
| 336 | image = sourceImage; | - | ||||||||||||
| 337 | } else { never executed: end of block | 0 | ||||||||||||
| 338 | image = sourceImage.convertToFormat(format); | - | ||||||||||||
| 339 | } never executed: end of block | 0 | ||||||||||||
| 340 | - | |||||||||||||
| 341 | if (image.d) {
| 0 | ||||||||||||
| 342 | w = image.d->width; | - | ||||||||||||
| 343 | h = image.d->height; | - | ||||||||||||
| 344 | d = image.d->depth; | - | ||||||||||||
| 345 | } else { never executed: end of block | 0 | ||||||||||||
| 346 | w = h = d = 0; | - | ||||||||||||
| 347 | } never executed: end of block | 0 | ||||||||||||
| 348 | is_null = (w <= 0 || h <= 0);
| 0 | ||||||||||||
| 349 | - | |||||||||||||
| 350 | if (image.d)
| 0 | ||||||||||||
| 351 | image.d->devicePixelRatio = sourceImage.devicePixelRatio(); never executed: image.d->devicePixelRatio = sourceImage.devicePixelRatio(); | 0 | ||||||||||||
| 352 | //ensure the pixmap and the image resulting from toImage() have the same cacheKey(); | - | ||||||||||||
| 353 | setSerialNumber(image.cacheKey() >> 32); | - | ||||||||||||
| 354 | if (image.d)
| 0 | ||||||||||||
| 355 | setDetachNumber(image.d->detach_no); never executed: setDetachNumber(image.d->detach_no); | 0 | ||||||||||||
| 356 | } never executed: end of block | 0 | ||||||||||||
| 357 | - | |||||||||||||
| 358 | QImage* QRasterPlatformPixmap::buffer() | - | ||||||||||||
| 359 | { | - | ||||||||||||
| 360 | return ℑ never executed: return ℑ | 0 | ||||||||||||
| 361 | } | - | ||||||||||||
| 362 | - | |||||||||||||
| 363 | qreal QRasterPlatformPixmap::devicePixelRatio() const | - | ||||||||||||
| 364 | { | - | ||||||||||||
| 365 | return image.devicePixelRatio(); never executed: return image.devicePixelRatio(); | 0 | ||||||||||||
| 366 | } | - | ||||||||||||
| 367 | - | |||||||||||||
| 368 | void QRasterPlatformPixmap::setDevicePixelRatio(qreal scaleFactor) | - | ||||||||||||
| 369 | { | - | ||||||||||||
| 370 | image.setDevicePixelRatio(scaleFactor); | - | ||||||||||||
| 371 | } never executed: end of block | 0 | ||||||||||||
| 372 | - | |||||||||||||
| 373 | QT_END_NAMESPACE | - | ||||||||||||
| Source code | Switch to Preprocessed file |