image/qpixmap.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5 -
6 -
7 -
8static bool qt_pixmap_thread_test() -
9{ -
10 if (!QCoreApplication::instance()) {
partially evaluated: !QCoreApplication::instance()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:139993
0-139993
11 QMessageLogger("image/qpixmap.cpp", 76, __PRETTY_FUNCTION__).fatal("QPixmap: Must construct a QApplication before a QPaintDevice"); -
12 return false;
never executed: return false;
0
13 } -
14 -
15 if ((static_cast<QGuiApplication *>(QCoreApplication::instance()))->thread() != QThread::currentThread()) {
partially evaluated: (static_cast<QGuiApplication *>(QCoreApplication::instance()))->thread() != QThread::currentThread()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:139993
0-139993
16 bool fail = false; -
17 if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::ThreadedPixmaps)) {
never evaluated: !QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::ThreadedPixmaps)
0
18 printf("Lighthouse plugin does not support threaded pixmaps!\n"); -
19 fail = true; -
20 }
never executed: }
0
21 if (fail) {
never evaluated: fail
0
22 QMessageLogger("image/qpixmap.cpp", 87, __PRETTY_FUNCTION__).warning("QPixmap: It is not safe to use pixmaps outside the GUI thread"); -
23 return false;
never executed: return false;
0
24 } -
25 }
never executed: }
0
26 return true;
executed: return true;
Execution Count:139993
139993
27} -
28 -
29void QPixmap::doInit(int w, int h, int type) -
30{ -
31 if ((w > 0 && h > 0) || type == QPlatformPixmap::BitmapType)
evaluated: w > 0
TRUEFALSE
yes
Evaluation Count:683
yes
Evaluation Count:107934
evaluated: h > 0
TRUEFALSE
yes
Evaluation Count:682
yes
Evaluation Count:1
evaluated: type == QPlatformPixmap::BitmapType
TRUEFALSE
yes
Evaluation Count:113
yes
Evaluation Count:107822
1-107934
32 data = QPlatformPixmap::create(w, h, (QPlatformPixmap::PixelType) type);
executed: data = QPlatformPixmap::create(w, h, (QPlatformPixmap::PixelType) type);
Execution Count:795
795
33 else -
34 data = 0;
executed: data = 0;
Execution Count:107822
107822
35} -
36 -
37 -
38 -
39 -
40 -
41 -
42 -
43QPixmap::QPixmap() -
44 : QPaintDevice() -
45{ -
46 (void) qt_pixmap_thread_test(); -
47 doInit(0, 0, QPlatformPixmap::PixmapType); -
48}
executed: }
Execution Count:104007
104007
49QPixmap::QPixmap(int w, int h) -
50 : QPaintDevice() -
51{ -
52 if (!qt_pixmap_thread_test())
partially evaluated: !qt_pixmap_thread_test()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:355
0-355
53 doInit(0, 0, QPlatformPixmap::PixmapType);
never executed: doInit(0, 0, QPlatformPixmap::PixmapType);
0
54 else -
55 doInit(w, h, QPlatformPixmap::PixmapType);
executed: doInit(w, h, QPlatformPixmap::PixmapType);
Execution Count:355
355
56} -
57QPixmap::QPixmap(const QSize &size) -
58 : QPaintDevice() -
59{ -
60 if (!qt_pixmap_thread_test())
partially evaluated: !qt_pixmap_thread_test()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:315
0-315
61 doInit(0, 0, QPlatformPixmap::PixmapType);
never executed: doInit(0, 0, QPlatformPixmap::PixmapType);
0
62 else -
63 doInit(size.width(), size.height(), QPlatformPixmap::PixmapType);
executed: doInit(size.width(), size.height(), QPlatformPixmap::PixmapType);
Execution Count:315
315
64} -
65 -
66 -
67 -
68 -
69QPixmap::QPixmap(const QSize &s, int type) -
70{ -
71 if (!qt_pixmap_thread_test())
partially evaluated: !qt_pixmap_thread_test()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:130
0-130
72 doInit(0, 0, static_cast<QPlatformPixmap::PixelType>(type));
never executed: doInit(0, 0, static_cast<QPlatformPixmap::PixelType>(type));
0
73 else -
74 doInit(s.width(), s.height(), static_cast<QPlatformPixmap::PixelType>(type));
executed: doInit(s.width(), s.height(), static_cast<QPlatformPixmap::PixelType>(type));
Execution Count:130
130
75} -
76 -
77 -
78 -
79 -
80QPixmap::QPixmap(QPlatformPixmap *d) -
81 : QPaintDevice(), data(d) -
82{ -
83}
executed: }
Execution Count:4069
4069
84QPixmap::QPixmap(const QString& fileName, const char *format, Qt::ImageConversionFlags flags) -
85 : QPaintDevice() -
86{ -
87 doInit(0, 0, QPlatformPixmap::PixmapType); -
88 if (!qt_pixmap_thread_test())
partially evaluated: !qt_pixmap_thread_test()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1753
0-1753
89 return;
never executed: return;
0
90 -
91 load(fileName, format, flags); -
92}
executed: }
Execution Count:1753
1753
93 -
94 -
95 -
96 -
97 -
98 -
99 -
100QPixmap::QPixmap(const QPixmap &pixmap) -
101 : QPaintDevice() -
102{ -
103 if (!qt_pixmap_thread_test()) {
partially evaluated: !qt_pixmap_thread_test()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:33433
0-33433
104 doInit(0, 0, QPlatformPixmap::PixmapType); -
105 return;
never executed: return;
0
106 } -
107 if (pixmap.paintingActive()) {
partially evaluated: pixmap.paintingActive()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:33433
0-33433
108 pixmap.copy().swap(*this); -
109 } else {
never executed: }
0
110 data = pixmap.data; -
111 }
executed: }
Execution Count:33433
33433
112} -
113QPixmap::QPixmap(const char * const xpm[]) -
114 : QPaintDevice() -
115{ -
116 doInit(0, 0, QPlatformPixmap::PixmapType); -
117 if (!xpm)
partially evaluated: !xpm
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2057
0-2057
118 return;
never executed: return;
0
119 -
120 QImage image(xpm); -
121 if (!image.isNull()) {
partially evaluated: !image.isNull()
TRUEFALSE
yes
Evaluation Count:2057
no
Evaluation Count:0
0-2057
122 if (data && data->pixelType() == QPlatformPixmap::BitmapType)
partially evaluated: data
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2057
never evaluated: data->pixelType() == QPlatformPixmap::BitmapType
0-2057
123 *this = QBitmap::fromImage(image);
never executed: *this = QBitmap::fromImage(image);
0
124 else -
125 *this = fromImage(image);
executed: *this = fromImage(image);
Execution Count:2057
2057
126 } -
127}
executed: }
Execution Count:2057
2057
128 -
129 -
130 -
131 -
132 -
133 -
134 -
135QPixmap::~QPixmap() -
136{ -
137 qt_noop(); -
138}
executed: }
Execution Count:145810
145810
139 -
140 -
141 -
142 -
143int QPixmap::devType() const -
144{ -
145 return QInternal::Pixmap;
executed: return QInternal::Pixmap;
Execution Count:4039
4039
146} -
147QPixmap QPixmap::copy(const QRect &rect) const -
148{ -
149 if (isNull())
evaluated: isNull()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:55
1-55
150 return QPixmap();
executed: return QPixmap();
Execution Count:1
1
151 -
152 QRect r(0, 0, width(), height()); -
153 if (!rect.isEmpty())
evaluated: !rect.isEmpty()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:51
4-51
154 r = r.intersected(rect);
executed: r = r.intersected(rect);
Execution Count:4
4
155 -
156 QPlatformPixmap *d = data->createCompatiblePlatformPixmap(); -
157 d->copy(data.data(), r); -
158 return QPixmap(d);
executed: return QPixmap(d);
Execution Count:55
55
159} -
160void QPixmap::scroll(int dx, int dy, const QRect &rect, QRegion *exposed) -
161{ -
162 if (isNull() || (dx == 0 && dy == 0))
evaluated: isNull()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:24
evaluated: dx == 0
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:14
evaluated: dy == 0
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:7
1-24
163 return;
executed: return;
Execution Count:4
4
164 QRect dest = rect & this->rect(); -
165 QRect src = dest.translated(-dx, -dy) & dest; -
166 if (src.isEmpty()) {
evaluated: src.isEmpty()
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:12
9-12
167 if (exposed)
partially evaluated: exposed
TRUEFALSE
yes
Evaluation Count:9
no
Evaluation Count:0
0-9
168 *exposed += dest;
executed: *exposed += dest;
Execution Count:9
9
169 return;
executed: return;
Execution Count:9
9
170 } -
171 -
172 detach(); -
173 -
174 if (!data->scroll(dx, dy, src)) {
partially evaluated: !data->scroll(dx, dy, src)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
0-12
175 -
176 QPixmap pix = *this; -
177 QPainter painter(&pix); -
178 painter.setCompositionMode(QPainter::CompositionMode_Source); -
179 painter.drawPixmap(src.translated(dx, dy), *this, src); -
180 painter.end(); -
181 *this = pix; -
182 }
never executed: }
0
183 -
184 if (exposed) {
partially evaluated: exposed
TRUEFALSE
yes
Evaluation Count:12
no
Evaluation Count:0
0-12
185 *exposed += dest; -
186 *exposed -= src.translated(dx, dy); -
187 }
executed: }
Execution Count:12
12
188}
executed: }
Execution Count:12
12
189QPixmap &QPixmap::operator=(const QPixmap &pixmap) -
190{ -
191 if (paintingActive()) {
partially evaluated: paintingActive()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:22606
0-22606
192 QMessageLogger("image/qpixmap.cpp", 383, __PRETTY_FUNCTION__).warning("QPixmap::operator=: Cannot assign to pixmap during painting"); -
193 return *this;
never executed: return *this;
0
194 } -
195 if (pixmap.paintingActive()) {
partially evaluated: pixmap.paintingActive()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:22606
0-22606
196 pixmap.copy().swap(*this); -
197 } else {
never executed: }
0
198 data = pixmap.data; -
199 }
executed: }
Execution Count:22606
22606
200 return *this;
executed: return *this;
Execution Count:22606
22606
201} -
202QPixmap::operator QVariant() const -
203{ -
204 return QVariant(QVariant::Pixmap, this);
executed: return QVariant(QVariant::Pixmap, this);
Execution Count:15
15
205} -
206QImage QPixmap::toImage() const -
207{ -
208 if (isNull())
evaluated: isNull()
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:2024
16-2024
209 return QImage();
executed: return QImage();
Execution Count:16
16
210 -
211 return data->toImage();
executed: return data->toImage();
Execution Count:2024
2024
212} -
213QTransform QPixmap::trueMatrix(const QTransform &m, int w, int h) -
214{ -
215 return QImage::trueMatrix(m, w, h);
never executed: return QImage::trueMatrix(m, w, h);
0
216} -
217QMatrix QPixmap::trueMatrix(const QMatrix &m, int w, int h) -
218{ -
219 return trueMatrix(QTransform(m), w, h).toAffine();
never executed: return trueMatrix(QTransform(m), w, h).toAffine();
0
220} -
221bool QPixmap::isQBitmap() const -
222{ -
223 return data->type == QPlatformPixmap::BitmapType;
executed: return data->type == QPlatformPixmap::BitmapType;
Execution Count:7
7
224} -
225bool QPixmap::isNull() const -
226{ -
227 return !data || data->isNull();
executed: return !data || data->isNull();
Execution Count:76698
76698
228} -
229int QPixmap::width() const -
230{ -
231 return data ? data->width() : 0;
executed: return data ? data->width() : 0;
Execution Count:9778
9778
232} -
233int QPixmap::height() const -
234{ -
235 return data ? data->height() : 0;
executed: return data ? data->height() : 0;
Execution Count:9870
9870
236} -
237QSize QPixmap::size() const -
238{ -
239 return data ? QSize(data->width(), data->height()) : QSize(0, 0);
executed: return data ? QSize(data->width(), data->height()) : QSize(0, 0);
Execution Count:14817
14817
240} -
241QRect QPixmap::rect() const -
242{ -
243 return data ? QRect(0, 0, data->width(), data->height()) : QRect();
executed: return data ? QRect(0, 0, data->width(), data->height()) : QRect();
Execution Count:287
287
244} -
245int QPixmap::depth() const -
246{ -
247 return data ? data->depth() : 0;
executed: return data ? data->depth() : 0;
Execution Count:2848
2848
248} -
249void QPixmap::setMask(const QBitmap &mask) -
250{ -
251 if (paintingActive()) {
partially evaluated: paintingActive()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:64
0-64
252 QMessageLogger("image/qpixmap.cpp", 585, __PRETTY_FUNCTION__).warning("QPixmap::setMask: Cannot set mask while pixmap is being painted on"); -
253 return;
never executed: return;
0
254 } -
255 -
256 if (!mask.isNull() && mask.size() != size()) {
evaluated: !mask.isNull()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:59
partially evaluated: mask.size() != size()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
0-59
257 QMessageLogger("image/qpixmap.cpp", 590, __PRETTY_FUNCTION__).warning("QPixmap::setMask() mask size differs from pixmap size"); -
258 return;
never executed: return;
0
259 } -
260 -
261 if (isNull())
evaluated: isNull()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:62
2-62
262 return;
executed: return;
Execution Count:2
2
263 -
264 if (static_cast<const QPixmap &>(mask).data == data)
partially evaluated: static_cast<const QPixmap &>(mask).data == data
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:62
0-62
265 return;
never executed: return;
0
266 -
267 detach(); -
268 -
269 QImage image = data->toImage(); -
270 if (mask.size().isEmpty()) {
evaluated: mask.size().isEmpty()
TRUEFALSE
yes
Evaluation Count:57
yes
Evaluation Count:5
5-57
271 if (image.depth() != 1) {
evaluated: image.depth() != 1
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:54
3-54
272 image = image.convertToFormat(QImage::Format_RGB32); -
273 }
executed: }
Execution Count:3
3
274 } else {
executed: }
Execution Count:57
57
275 const int w = image.width(); -
276 const int h = image.height(); -
277 -
278 switch (image.depth()) { -
279 case 1: { -
280 const QImage imageMask = mask.toImage().convertToFormat(image.format()); -
281 for (int y = 0; y < h; ++y) {
evaluated: y < h
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:1
1-3
282 const uchar *mscan = imageMask.scanLine(y); -
283 uchar *tscan = image.scanLine(y); -
284 int bytesPerLine = image.bytesPerLine(); -
285 for (int i = 0; i < bytesPerLine; ++i)
evaluated: i < bytesPerLine
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:3
3-12
286 tscan[i] &= mscan[i];
executed: tscan[i] &= mscan[i];
Execution Count:12
12
287 }
executed: }
Execution Count:3
3
288 break;
executed: break;
Execution Count:1
1
289 } -
290 default: { -
291 const QImage imageMask = mask.toImage().convertToFormat(QImage::Format_MonoLSB); -
292 image = image.convertToFormat(QImage::Format_ARGB32_Premultiplied); -
293 for (int y = 0; y < h; ++y) {
evaluated: y < h
TRUEFALSE
yes
Evaluation Count:220
yes
Evaluation Count:4
4-220
294 const uchar *mscan = imageMask.scanLine(y); -
295 QRgb *tscan = (QRgb *)image.scanLine(y); -
296 for (int x = 0; x < w; ++x) {
evaluated: x < w
TRUEFALSE
yes
Evaluation Count:20200
yes
Evaluation Count:220
220-20200
297 if (!(mscan[x>>3] & (1 << (x&7))))
evaluated: !(mscan[x>>3] & (1 << (x&7)))
TRUEFALSE
yes
Evaluation Count:20175
yes
Evaluation Count:25
25-20175
298 tscan[x] = 0;
executed: tscan[x] = 0;
Execution Count:20175
20175
299 }
executed: }
Execution Count:20200
20200
300 }
executed: }
Execution Count:220
220
301 break;
executed: break;
Execution Count:4
4
302 } -
303 } -
304 }
executed: }
Execution Count:5
5
305 data->fromImage(image, Qt::AutoColor); -
306}
executed: }
Execution Count:62
62
307qreal QPixmap::devicePixelRatio() const -
308{ -
309 if (!data)
evaluated: !data
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:5502
10-5502
310 return qreal(1.0);
executed: return qreal(1.0);
Execution Count:10
10
311 return data->devicePixelRatio();
executed: return data->devicePixelRatio();
Execution Count:5502
5502
312} -
313void QPixmap::setDevicePixelRatio(qreal scaleFactor) -
314{ -
315 detach(); -
316 data->setDevicePixelRatio(scaleFactor); -
317}
executed: }
Execution Count:8
8
318QBitmap QPixmap::createHeuristicMask(bool clipTight) const -
319{ -
320 QBitmap m = QBitmap::fromImage(toImage().createHeuristicMask(clipTight)); -
321 return m;
never executed: return m;
0
322} -
323QBitmap QPixmap::createMaskFromColor(const QColor &maskColor, Qt::MaskMode mode) const -
324{ -
325 QImage image = toImage().convertToFormat(QImage::Format_ARGB32); -
326 return QBitmap::fromImage(image.createMaskFromColor(maskColor.rgba(), mode));
executed: return QBitmap::fromImage(image.createMaskFromColor(maskColor.rgba(), mode));
Execution Count:2
2
327} -
328bool QPixmap::load(const QString &fileName, const char *format, Qt::ImageConversionFlags flags) -
329{ -
330 if (fileName.isEmpty()) {
evaluated: fileName.isEmpty()
TRUEFALSE
yes
Evaluation Count:54
yes
Evaluation Count:1711
54-1711
331 data.reset(); -
332 return false;
executed: return false;
Execution Count:54
54
333 } -
334 -
335 detach(); -
336 -
337 QFileInfo info(fileName); -
338 QString key = QLatin1String("qt_pixmap") -
339 % info.absoluteFilePath() -
340 % HexString<uint>(info.lastModified().toTime_t()) -
341 % HexString<quint64>(info.size()) -
342 % HexString<uint>(data ? data->pixelType() : QPlatformPixmap::PixmapType); -
343 -
344 -
345 -
346 if (!info.completeSuffix().isEmpty() && !info.exists()) {
evaluated: !info.completeSuffix().isEmpty()
TRUEFALSE
yes
Evaluation Count:1706
yes
Evaluation Count:5
evaluated: !info.exists()
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:1697
5-1706
347 data.reset(); -
348 return false;
executed: return false;
Execution Count:9
9
349 } -
350 -
351 if (QPixmapCache::find(key, this))
evaluated: QPixmapCache::find(key, this)
TRUEFALSE
yes
Evaluation Count:1575
yes
Evaluation Count:127
127-1575
352 return true;
executed: return true;
Execution Count:1575
1575
353 -
354 if (!data)
evaluated: !data
TRUEFALSE
yes
Evaluation Count:125
yes
Evaluation Count:2
2-125
355 data = QPlatformPixmap::create(0, 0, QPlatformPixmap::PixmapType);
executed: data = QPlatformPixmap::create(0, 0, QPlatformPixmap::PixmapType);
Execution Count:125
125
356 -
357 if (data->fromFile(fileName, format, flags)) {
evaluated: data->fromFile(fileName, format, flags)
TRUEFALSE
yes
Evaluation Count:122
yes
Evaluation Count:5
5-122
358 QPixmapCache::insert(key, *this); -
359 return true;
executed: return true;
Execution Count:122
122
360 } -
361 -
362 data.reset(); -
363 return false;
executed: return false;
Execution Count:5
5
364} -
365bool QPixmap::loadFromData(const uchar *buf, uint len, const char *format, Qt::ImageConversionFlags flags) -
366{ -
367 if (len == 0 || buf == 0) {
evaluated: len == 0
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:19
evaluated: buf == 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:18
1-19
368 data.reset(); -
369 return false;
executed: return false;
Execution Count:4
4
370 } -
371 -
372 if (!data)
partially evaluated: !data
TRUEFALSE
yes
Evaluation Count:18
no
Evaluation Count:0
0-18
373 data = QPlatformPixmap::create(0, 0, QPlatformPixmap::PixmapType);
executed: data = QPlatformPixmap::create(0, 0, QPlatformPixmap::PixmapType);
Execution Count:18
18
374 -
375 if (data->fromData(buf, len, format, flags))
partially evaluated: data->fromData(buf, len, format, flags)
TRUEFALSE
yes
Evaluation Count:18
no
Evaluation Count:0
0-18
376 return true;
executed: return true;
Execution Count:18
18
377 -
378 data.reset(); -
379 return false;
never executed: return false;
0
380} -
381bool QPixmap::save(const QString &fileName, const char *format, int quality) const -
382{ -
383 if (isNull())
never evaluated: isNull()
0
384 return false;
never executed: return false;
0
385 QImageWriter writer(fileName, format); -
386 return doImageIO(&writer, quality);
never executed: return doImageIO(&writer, quality);
0
387} -
388bool QPixmap::save(QIODevice* device, const char* format, int quality) const -
389{ -
390 if (isNull())
partially evaluated: isNull()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
391 return false;
never executed: return false;
0
392 QImageWriter writer(device, format); -
393 return doImageIO(&writer, quality);
executed: return doImageIO(&writer, quality);
Execution Count:1
1
394} -
395 -
396 -
397 -
398bool QPixmap::doImageIO(QImageWriter *writer, int quality) const -
399{ -
400 if (quality > 100 || quality < -1)
partially evaluated: quality > 100
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
partially evaluated: quality < -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
401 QMessageLogger("image/qpixmap.cpp", 887, __PRETTY_FUNCTION__).warning("QPixmap::save: quality out of range [-1,100]");
never executed: QMessageLogger("image/qpixmap.cpp", 887, __PRETTY_FUNCTION__).warning("QPixmap::save: quality out of range [-1,100]");
0
402 if (quality >= 0)
partially evaluated: quality >= 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
403 writer->setQuality(qMin(quality,100));
never executed: writer->setQuality(qMin(quality,100));
0
404 return writer->write(toImage());
executed: return writer->write(toImage());
Execution Count:1
1
405} -
406void QPixmap::fill(const QPaintDevice *device, const QPoint &p) -
407{ -
408 (void)device; -
409 (void)p; -
410 QMessageLogger("image/qpixmap.cpp", 904, __PRETTY_FUNCTION__).warning("%s is deprecated, ignored", __PRETTY_FUNCTION__); -
411}
never executed: }
0
412void QPixmap::fill(const QColor &color) -
413{ -
414 if (isNull())
evaluated: isNull()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:423
4-423
415 return;
executed: return;
Execution Count:4
4
416 -
417 -
418 -
419 if (paintingActive() && (color.alpha() != 255) && !hasAlphaChannel()) {
partially evaluated: paintingActive()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:423
never evaluated: (color.alpha() != 255)
never evaluated: !hasAlphaChannel()
0-423
420 QMessageLogger("image/qpixmap.cpp", 933, __PRETTY_FUNCTION__).warning("QPixmap::fill: Cannot fill while pixmap is being painted on"); -
421 return;
never executed: return;
0
422 } -
423 -
424 if (data->ref.load() == 1) {
evaluated: data->ref.load() == 1
TRUEFALSE
yes
Evaluation Count:413
yes
Evaluation Count:10
10-413
425 -
426 -
427 detach(); -
428 } else {
executed: }
Execution Count:413
413
429 -
430 -
431 QPlatformPixmap *d = data->createCompatiblePlatformPixmap(); -
432 d->resize(data->width(), data->height()); -
433 data = d; -
434 }
executed: }
Execution Count:10
10
435 data->fill(color); -
436}
executed: }
Execution Count:423
423
437qint64 QPixmap::cacheKey() const -
438{ -
439 if (isNull())
evaluated: isNull()
TRUEFALSE
yes
Evaluation Count:23
yes
Evaluation Count:4416
23-4416
440 return 0;
executed: return 0;
Execution Count:23
23
441 -
442 qt_noop(); -
443 return data->cacheKey();
executed: return data->cacheKey();
Execution Count:4416
4416
444} -
445QPixmap QPixmap::grabWidget(QObject *widget, const QRect &rectangle) -
446{ -
447 QPixmap pixmap; -
448 QMessageLogger("image/qpixmap.cpp", 1005, __PRETTY_FUNCTION__).warning("QPixmap::grabWidget is deprecated, use QWidget::grab() instead"); -
449 if (!widget)
never evaluated: !widget
0
450 return pixmap;
never executed: return pixmap;
0
451 QMetaObject::invokeMethod(widget, "grab", Qt::DirectConnection, -
452 QReturnArgument<QPixmap >("QPixmap", pixmap), -
453 QArgument<QRect >("QRect", rectangle)); -
454 return pixmap;
never executed: return pixmap;
0
455} -
456QDataStream &operator<<(QDataStream &stream, const QPixmap &pixmap) -
457{ -
458 return stream << pixmap.toImage();
executed: return stream << pixmap.toImage();
Execution Count:59
59
459} -
460QDataStream &operator>>(QDataStream &stream, QPixmap &pixmap) -
461{ -
462 QImage image; -
463 stream >> image; -
464 -
465 if (image.isNull()) {
evaluated: image.isNull()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:55
3-55
466 pixmap = QPixmap(); -
467 } else if (image.depth() == 1) {
evaluated: image.depth() == 1
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:42
executed: }
Execution Count:3
3-42
468 pixmap = QBitmap::fromImage(image); -
469 } else {
executed: }
Execution Count:13
13
470 pixmap = QPixmap::fromImage(image); -
471 }
executed: }
Execution Count:42
42
472 return stream;
executed: return stream;
Execution Count:58
58
473} -
474 -
475 -
476 -
477 -
478 -
479 -
480 -
481bool QPixmap::isDetached() const -
482{ -
483 return data && data->ref.load() == 1;
executed: return data && data->ref.load() == 1;
Execution Count:4
4
484} -
485bool QPixmap::convertFromImage(const QImage &image, Qt::ImageConversionFlags flags) -
486{ -
487 if (image.isNull() || !data)
never evaluated: image.isNull()
never evaluated: !data
0
488 *this = QPixmap::fromImage(image, flags);
never executed: *this = QPixmap::fromImage(image, flags);
0
489 else -
490 data->fromImage(image, flags);
never executed: data->fromImage(image, flags);
0
491 return !isNull();
never executed: return !isNull();
0
492} -
493QPixmap QPixmap::scaled(const QSize& s, Qt::AspectRatioMode aspectMode, Qt::TransformationMode mode) const -
494{ -
495 if (isNull()) {
partially evaluated: isNull()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:99
0-99
496 QMessageLogger("image/qpixmap.cpp", 1148, __PRETTY_FUNCTION__).warning("QPixmap::scaled: Pixmap is a null pixmap"); -
497 return QPixmap();
never executed: return QPixmap();
0
498 } -
499 if (s.isEmpty())
partially evaluated: s.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:99
0-99
500 return QPixmap();
never executed: return QPixmap();
0
501 -
502 QSize newSize = size(); -
503 newSize.scale(s, aspectMode); -
504 newSize.rwidth() = qMax(newSize.width(), 1); -
505 newSize.rheight() = qMax(newSize.height(), 1); -
506 if (newSize == size())
partially evaluated: newSize == size()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:99
0-99
507 return *this;
never executed: return *this;
0
508 -
509 QTransform wm = QTransform::fromScale((qreal)newSize.width() / width(), -
510 (qreal)newSize.height() / height()); -
511 QPixmap pix = transformed(wm, mode); -
512 return pix;
executed: return pix;
Execution Count:99
99
513} -
514QPixmap QPixmap::scaledToWidth(int w, Qt::TransformationMode mode) const -
515{ -
516 if (isNull()) {
never evaluated: isNull()
0
517 QMessageLogger("image/qpixmap.cpp", 1184, __PRETTY_FUNCTION__).warning("QPixmap::scaleWidth: Pixmap is a null pixmap"); -
518 return copy();
never executed: return copy();
0
519 } -
520 if (w <= 0)
never evaluated: w <= 0
0
521 return QPixmap();
never executed: return QPixmap();
0
522 -
523 qreal factor = (qreal) w / width(); -
524 QTransform wm = QTransform::fromScale(factor, factor); -
525 return transformed(wm, mode);
never executed: return transformed(wm, mode);
0
526} -
527QPixmap QPixmap::scaledToHeight(int h, Qt::TransformationMode mode) const -
528{ -
529 if (isNull()) {
never evaluated: isNull()
0
530 QMessageLogger("image/qpixmap.cpp", 1212, __PRETTY_FUNCTION__).warning("QPixmap::scaleHeight: Pixmap is a null pixmap"); -
531 return copy();
never executed: return copy();
0
532 } -
533 if (h <= 0)
never evaluated: h <= 0
0
534 return QPixmap();
never executed: return QPixmap();
0
535 -
536 qreal factor = (qreal) h / height(); -
537 QTransform wm = QTransform::fromScale(factor, factor); -
538 return transformed(wm, mode);
never executed: return transformed(wm, mode);
0
539} -
540QPixmap QPixmap::transformed(const QTransform &transform, -
541 Qt::TransformationMode mode) const -
542{ -
543 if (isNull() || transform.type() <= QTransform::TxTranslate)
partially evaluated: isNull()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:103
partially evaluated: transform.type() <= QTransform::TxTranslate
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:103
0-103
544 return *this;
never executed: return *this;
0
545 -
546 return data->transformed(transform, mode);
executed: return data->transformed(transform, mode);
Execution Count:103
103
547} -
548 -
549 -
550 -
551 -
552 -
553 -
554 -
555QPixmap QPixmap::transformed(const QMatrix &matrix, Qt::TransformationMode mode) const -
556{ -
557 return transformed(QTransform(matrix), mode);
never executed: return transformed(QTransform(matrix), mode);
0
558} -
559bool QPixmap::hasAlpha() const -
560{ -
561 return data && data->hasAlphaChannel();
executed: return data && data->hasAlphaChannel();
Execution Count:1
1
562} -
563 -
564 -
565 -
566 -
567 -
568 -
569 -
570bool QPixmap::hasAlphaChannel() const -
571{ -
572 return data && data->hasAlphaChannel();
executed: return data && data->hasAlphaChannel();
Execution Count:88
88
573} -
574 -
575 -
576 -
577 -
578int QPixmap::metric(PaintDeviceMetric metric) const -
579{ -
580 return data ? data->metric(metric) : 0;
executed: return data ? data->metric(metric) : 0;
Execution Count:1963
1963
581} -
582 -
583 -
584 -
585 -
586QPaintEngine *QPixmap::paintEngine() const -
587{ -
588 return data ? data->paintEngine() : 0;
executed: return data ? data->paintEngine() : 0;
Execution Count:2156
2156
589} -
590QBitmap QPixmap::mask() const -
591{ -
592 if (!data || !hasAlphaChannel())
evaluated: !data
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:85
evaluated: !hasAlphaChannel()
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:70
7-85
593 return QBitmap();
executed: return QBitmap();
Execution Count:22
22
594 -
595 const QImage img = toImage(); -
596 const QImage image = (img.depth() < 32 ? img.convertToFormat(QImage::Format_ARGB32_Premultiplied) : img);
partially evaluated: img.depth() < 32
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:70
0-70
597 const int w = image.width(); -
598 const int h = image.height(); -
599 -
600 QImage mask(w, h, QImage::Format_MonoLSB); -
601 if (mask.isNull())
partially evaluated: mask.isNull()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:70
0-70
602 return QBitmap();
never executed: return QBitmap();
0
603 -
604 mask.setColorCount(2); -
605 mask.setColor(0, QColor(Qt::color0).rgba()); -
606 mask.setColor(1, QColor(Qt::color1).rgba()); -
607 -
608 const int bpl = mask.bytesPerLine(); -
609 -
610 for (int y = 0; y < h; ++y) {
evaluated: y < h
TRUEFALSE
yes
Evaluation Count:1078
yes
Evaluation Count:70
70-1078
611 const QRgb *src = reinterpret_cast<const QRgb*>(image.scanLine(y)); -
612 uchar *dest = mask.scanLine(y); -
613 memset(dest, 0, bpl); -
614 for (int x = 0; x < w; ++x) {
evaluated: x < w
TRUEFALSE
yes
Evaluation Count:33928
yes
Evaluation Count:1078
1078-33928
615 if (qAlpha(*src) > 0)
evaluated: qAlpha(*src) > 0
TRUEFALSE
yes
Evaluation Count:11575
yes
Evaluation Count:22353
11575-22353
616 dest[x >> 3] |= (1 << (x & 7));
executed: dest[x >> 3] |= (1 << (x & 7));
Execution Count:11575
11575
617 ++src; -
618 }
executed: }
Execution Count:33928
33928
619 }
executed: }
Execution Count:1078
1078
620 -
621 return QBitmap::fromImage(mask);
executed: return QBitmap::fromImage(mask);
Execution Count:70
70
622} -
623int QPixmap::defaultDepth() -
624{ -
625 return QGuiApplication::primaryScreen()->depth();
executed: return QGuiApplication::primaryScreen()->depth();
Execution Count:39
39
626} -
627void QPixmap::detach() -
628{ -
629 if (!data)
evaluated: !data
TRUEFALSE
yes
Evaluation Count:1708
yes
Evaluation Count:1376
1376-1708
630 return;
executed: return;
Execution Count:1708
1708
631 -
632 -
633 -
634 QPlatformPixmap *pd = handle(); -
635 QPlatformPixmap::ClassId id = pd->classId(); -
636 if (id == QPlatformPixmap::RasterClass) {
partially evaluated: id == QPlatformPixmap::RasterClass
TRUEFALSE
yes
Evaluation Count:1376
no
Evaluation Count:0
0-1376
637 QRasterPlatformPixmap *rasterData = static_cast<QRasterPlatformPixmap*>(pd); -
638 rasterData->image.detach(); -
639 }
executed: }
Execution Count:1376
1376
640 -
641 if (data->is_cached && data->ref.load() == 1)
partially evaluated: data->is_cached
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1376
never evaluated: data->ref.load() == 1
0-1376
642 QImagePixmapCleanupHooks::executePlatformPixmapModificationHooks(data.data());
never executed: QImagePixmapCleanupHooks::executePlatformPixmapModificationHooks(data.data());
0
643 -
644 if (data->ref.load() != 1) {
evaluated: data->ref.load() != 1
TRUEFALSE
yes
Evaluation Count:51
yes
Evaluation Count:1325
51-1325
645 *this = copy(); -
646 }
executed: }
Execution Count:51
51
647 ++data->detach_no; -
648}
executed: }
Execution Count:1376
1376
649QPixmap QPixmap::fromImage(const QImage &image, Qt::ImageConversionFlags flags) -
650{ -
651 if (image.isNull())
evaluated: image.isNull()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:3844
1-3844
652 return QPixmap();
executed: return QPixmap();
Execution Count:1
1
653 -
654 QScopedPointer<QPlatformPixmap> data(QGuiApplicationPrivate::platformIntegration()->createPlatformPixmap(QPlatformPixmap::PixmapType)); -
655 data->fromImage(image, flags); -
656 return QPixmap(data.take());
executed: return QPixmap(data.take());
Execution Count:3844
3844
657} -
658QPixmap QPixmap::fromImageReader(QImageReader *imageReader, Qt::ImageConversionFlags flags) -
659{ -
660 QScopedPointer<QPlatformPixmap> data(QGuiApplicationPrivate::platformIntegration()->createPlatformPixmap(QPlatformPixmap::PixmapType)); -
661 data->fromImageReader(imageReader, flags); -
662 return QPixmap(data.take());
executed: return QPixmap(data.take());
Execution Count:15
15
663} -
664QPixmap QPixmap::grabWindow(WId window, int x, int y, int w, int h) -
665{ -
666 QMessageLogger("image/qpixmap.cpp", 1683, __PRETTY_FUNCTION__).warning("%s is deprecated, use QScreen::grabWindow() instead." -
667 " Defaulting to primary screen.", __PRETTY_FUNCTION__); -
668 return QGuiApplication::primaryScreen()->grabWindow(window, x, y, w, h);
never executed: return QGuiApplication::primaryScreen()->grabWindow(window, x, y, w, h);
0
669} -
670 -
671 -
672 -
673 -
674QPlatformPixmap* QPixmap::handle() const -
675{ -
676 return data.data();
executed: return data.data();
Execution Count:14189
14189
677} -
678 -
679 -
680QDebug operator<<(QDebug dbg, const QPixmap &r) -
681{ -
682 dbg.nospace() << "QPixmap(" << r.size() << ')'; -
683 return dbg.space();
executed: return dbg.space();
Execution Count:2
2
684} -
685 -
686 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial