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:107063
0-107063
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:107063
0-107063
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:107063
107063
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:648
yes
Evaluation Count:81535
evaluated: h > 0
TRUEFALSE
yes
Evaluation Count:647
yes
Evaluation Count:1
evaluated: type == QPlatformPixmap::BitmapType
TRUEFALSE
yes
Evaluation Count:113
yes
Evaluation Count:81423
1-81535
32 data = QPlatformPixmap::create(w, h, (QPlatformPixmap::PixelType) type);
executed: data = QPlatformPixmap::create(w, h, (QPlatformPixmap::PixelType) type);
Execution Count:760
760
33 else -
34 data = 0;
executed: data = 0;
Execution Count:81423
81423
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:77987
77987
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:345
0-345
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:345
345
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:290
0-290
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:290
290
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:4042
4042
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:1229
0-1229
89 return;
never executed: return;
0
90 -
91 load(fileName, format, flags); -
92}
executed: }
Execution Count:1229
1229
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:27082
0-27082
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:27082
0-27082
108 pixmap.copy().swap(*this); -
109 } else {
never executed: }
0
110 data = pixmap.data; -
111 }
executed: }
Execution Count:27082
27082
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:2202
0-2202
118 return;
never executed: return;
0
119 -
120 QImage image(xpm); -
121 if (!image.isNull()) {
partially evaluated: !image.isNull()
TRUEFALSE
yes
Evaluation Count:2202
no
Evaluation Count:0
0-2202
122 if (data && data->pixelType() == QPlatformPixmap::BitmapType)
partially evaluated: data
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2202
never evaluated: data->pixelType() == QPlatformPixmap::BitmapType
0-2202
123 *this = QBitmap::fromImage(image);
never executed: *this = QBitmap::fromImage(image);
0
124 else -
125 *this = fromImage(image);
executed: *this = fromImage(image);
Execution Count:2202
2202
126 } -
127}
executed: }
Execution Count:2202
2202
128 -
129 -
130 -
131 -
132 -
133 -
134 -
135QPixmap::~QPixmap() -
136{ -
137 qt_noop(); -
138}
executed: }
Execution Count:112604
112604
139 -
140 -
141 -
142 -
143int QPixmap::devType() const -
144{ -
145 return QInternal::Pixmap;
executed: return QInternal::Pixmap;
Execution Count:3879
3879
146} -
147QPixmap QPixmap::copy(const QRect &rect) const -
148{ -
149 if (isNull())
evaluated: isNull()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:9
1-9
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:3
yes
Evaluation Count:6
3-6
154 r = r.intersected(rect);
executed: r = r.intersected(rect);
Execution Count:3
3
155 -
156 QPlatformPixmap *d = data->createCompatiblePlatformPixmap(); -
157 d->copy(data.data(), r); -
158 return QPixmap(d);
executed: return QPixmap(d);
Execution Count:9
9
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:13605
0-13605
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:13605
0-13605
196 pixmap.copy().swap(*this); -
197 } else {
never executed: }
0
198 data = pixmap.data; -
199 }
executed: }
Execution Count:13605
13605
200 return *this;
executed: return *this;
Execution Count:13605
13605
201} -
202QPixmap::operator QVariant() const -
203{ -
204 return QVariant(QVariant::Pixmap, this);
executed: return QVariant(QVariant::Pixmap, this);
Execution Count:14
14
205} -
206QImage QPixmap::toImage() const -
207{ -
208 if (isNull())
evaluated: isNull()
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:1850
12-1850
209 return QImage();
executed: return QImage();
Execution Count:12
12
210 -
211 return data->toImage();
executed: return data->toImage();
Execution Count:1850
1850
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:57918
57918
228} -
229int QPixmap::width() const -
230{ -
231 return data ? data->width() : 0;
executed: return data ? data->width() : 0;
Execution Count:7438
7438
232} -
233int QPixmap::height() const -
234{ -
235 return data ? data->height() : 0;
executed: return data ? data->height() : 0;
Execution Count:7542
7542
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:13246
13246
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:274
274
244} -
245int QPixmap::depth() const -
246{ -
247 return data ? data->depth() : 0;
executed: return data ? data->depth() : 0;
Execution Count:2787
2787
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:4370
10-4370
310 return qreal(1.0);
executed: return qreal(1.0);
Execution Count:10
10
311 return data->devicePixelRatio();
executed: return data->devicePixelRatio();
Execution Count:4370
4370
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:36
yes
Evaluation Count:1202
36-1202
331 data.reset(); -
332 return false;
executed: return false;
Execution Count:36
36
333 } -
334 -
335 QFileInfo info(fileName); -
336 QString key = QLatin1String("qt_pixmap") -
337 % info.absoluteFilePath() -
338 % HexString<uint>(info.lastModified().toTime_t()) -
339 % HexString<quint64>(info.size()) -
340 % HexString<uint>(data ? data->pixelType() : QPlatformPixmap::PixmapType); -
341 -
342 -
343 -
344 if (!info.completeSuffix().isEmpty() && !info.exists()) {
evaluated: !info.completeSuffix().isEmpty()
TRUEFALSE
yes
Evaluation Count:1197
yes
Evaluation Count:5
evaluated: !info.exists()
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:1189
5-1197
345 data.reset(); -
346 return false;
executed: return false;
Execution Count:8
8
347 } -
348 -
349 if (QPixmapCache::find(key, this))
evaluated: QPixmapCache::find(key, this)
TRUEFALSE
yes
Evaluation Count:1087
yes
Evaluation Count:107
107-1087
350 return true;
executed: return true;
Execution Count:1087
1087
351 -
352 if (!data)
evaluated: !data
TRUEFALSE
yes
Evaluation Count:106
yes
Evaluation Count:1
1-106
353 data = QPlatformPixmap::create(0, 0, QPlatformPixmap::PixmapType);
executed: data = QPlatformPixmap::create(0, 0, QPlatformPixmap::PixmapType);
Execution Count:106
106
354 -
355 if (data->fromFile(fileName, format, flags)) {
evaluated: data->fromFile(fileName, format, flags)
TRUEFALSE
yes
Evaluation Count:102
yes
Evaluation Count:5
5-102
356 QPixmapCache::insert(key, *this); -
357 return true;
executed: return true;
Execution Count:102
102
358 } -
359 -
360 data.reset(); -
361 return false;
executed: return false;
Execution Count:5
5
362} -
363bool QPixmap::loadFromData(const uchar *buf, uint len, const char *format, Qt::ImageConversionFlags flags) -
364{ -
365 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
366 data.reset(); -
367 return false;
executed: return false;
Execution Count:4
4
368 } -
369 -
370 if (!data)
partially evaluated: !data
TRUEFALSE
yes
Evaluation Count:18
no
Evaluation Count:0
0-18
371 data = QPlatformPixmap::create(0, 0, QPlatformPixmap::PixmapType);
executed: data = QPlatformPixmap::create(0, 0, QPlatformPixmap::PixmapType);
Execution Count:18
18
372 -
373 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
374 return true;
executed: return true;
Execution Count:18
18
375 -
376 data.reset(); -
377 return false;
never executed: return false;
0
378} -
379bool QPixmap::save(const QString &fileName, const char *format, int quality) const -
380{ -
381 if (isNull())
never evaluated: isNull()
0
382 return false;
never executed: return false;
0
383 QImageWriter writer(fileName, format); -
384 return doImageIO(&writer, quality);
never executed: return doImageIO(&writer, quality);
0
385} -
386bool QPixmap::save(QIODevice* device, const char* format, int quality) const -
387{ -
388 if (isNull())
partially evaluated: isNull()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
389 return false;
never executed: return false;
0
390 QImageWriter writer(device, format); -
391 return doImageIO(&writer, quality);
executed: return doImageIO(&writer, quality);
Execution Count:1
1
392} -
393 -
394 -
395 -
396bool QPixmap::doImageIO(QImageWriter *writer, int quality) const -
397{ -
398 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
399 QMessageLogger("image/qpixmap.cpp", 885, __PRETTY_FUNCTION__).warning("QPixmap::save: quality out of range [-1,100]");
never executed: QMessageLogger("image/qpixmap.cpp", 885, __PRETTY_FUNCTION__).warning("QPixmap::save: quality out of range [-1,100]");
0
400 if (quality >= 0)
partially evaluated: quality >= 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
401 writer->setQuality(qMin(quality,100));
never executed: writer->setQuality(qMin(quality,100));
0
402 return writer->write(toImage());
executed: return writer->write(toImage());
Execution Count:1
1
403} -
404void QPixmap::fill(const QPaintDevice *device, const QPoint &p) -
405{ -
406 (void)device; -
407 (void)p; -
408 QMessageLogger("image/qpixmap.cpp", 902, __PRETTY_FUNCTION__).warning("%s is deprecated, ignored", __PRETTY_FUNCTION__); -
409}
never executed: }
0
410void QPixmap::fill(const QColor &color) -
411{ -
412 if (isNull())
evaluated: isNull()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:363
4-363
413 return;
executed: return;
Execution Count:4
4
414 -
415 -
416 -
417 if (paintingActive() && (color.alpha() != 255) && !hasAlphaChannel()) {
partially evaluated: paintingActive()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:363
never evaluated: (color.alpha() != 255)
never evaluated: !hasAlphaChannel()
0-363
418 QMessageLogger("image/qpixmap.cpp", 931, __PRETTY_FUNCTION__).warning("QPixmap::fill: Cannot fill while pixmap is being painted on"); -
419 return;
never executed: return;
0
420 } -
421 -
422 if (data->ref.load() == 1) {
evaluated: data->ref.load() == 1
TRUEFALSE
yes
Evaluation Count:353
yes
Evaluation Count:10
10-353
423 -
424 -
425 detach(); -
426 } else {
executed: }
Execution Count:353
353
427 -
428 -
429 QPlatformPixmap *d = data->createCompatiblePlatformPixmap(); -
430 d->resize(data->width(), data->height()); -
431 data = d; -
432 }
executed: }
Execution Count:10
10
433 data->fill(color); -
434}
executed: }
Execution Count:363
363
435qint64 QPixmap::cacheKey() const -
436{ -
437 if (isNull())
evaluated: isNull()
TRUEFALSE
yes
Evaluation Count:23
yes
Evaluation Count:3726
23-3726
438 return 0;
executed: return 0;
Execution Count:23
23
439 -
440 qt_noop(); -
441 return data->cacheKey();
executed: return data->cacheKey();
Execution Count:3726
3726
442} -
443QPixmap QPixmap::grabWidget(QObject *widget, const QRect &rectangle) -
444{ -
445 QPixmap pixmap; -
446 QMessageLogger("image/qpixmap.cpp", 1003, __PRETTY_FUNCTION__).warning("QPixmap::grabWidget is deprecated, use QWidget::grab() instead"); -
447 if (!widget)
never evaluated: !widget
0
448 return pixmap;
never executed: return pixmap;
0
449 QMetaObject::invokeMethod(widget, "grab", Qt::DirectConnection, -
450 QReturnArgument<QPixmap >("QPixmap", pixmap), -
451 QArgument<QRect >("QRect", rectangle)); -
452 return pixmap;
never executed: return pixmap;
0
453} -
454QDataStream &operator<<(QDataStream &stream, const QPixmap &pixmap) -
455{ -
456 return stream << pixmap.toImage();
executed: return stream << pixmap.toImage();
Execution Count:59
59
457} -
458QDataStream &operator>>(QDataStream &stream, QPixmap &pixmap) -
459{ -
460 QImage image; -
461 stream >> image; -
462 -
463 if (image.isNull()) {
evaluated: image.isNull()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:55
3-55
464 pixmap = QPixmap(); -
465 } else if (image.depth() == 1) {
evaluated: image.depth() == 1
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:42
executed: }
Execution Count:3
3-42
466 pixmap = QBitmap::fromImage(image); -
467 } else {
executed: }
Execution Count:13
13
468 pixmap = QPixmap::fromImage(image); -
469 }
executed: }
Execution Count:42
42
470 return stream;
executed: return stream;
Execution Count:58
58
471} -
472 -
473 -
474 -
475 -
476 -
477 -
478 -
479bool QPixmap::isDetached() const -
480{ -
481 return data && data->ref.load() == 1;
executed: return data && data->ref.load() == 1;
Execution Count:4
4
482} -
483bool QPixmap::convertFromImage(const QImage &image, Qt::ImageConversionFlags flags) -
484{ -
485 if (image.isNull() || !data)
never evaluated: image.isNull()
never evaluated: !data
0
486 *this = QPixmap::fromImage(image, flags);
never executed: *this = QPixmap::fromImage(image, flags);
0
487 else -
488 data->fromImage(image, flags);
never executed: data->fromImage(image, flags);
0
489 return !isNull();
never executed: return !isNull();
0
490} -
491QPixmap QPixmap::scaled(const QSize& s, Qt::AspectRatioMode aspectMode, Qt::TransformationMode mode) const -
492{ -
493 if (isNull()) {
partially evaluated: isNull()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:109
0-109
494 QMessageLogger("image/qpixmap.cpp", 1146, __PRETTY_FUNCTION__).warning("QPixmap::scaled: Pixmap is a null pixmap"); -
495 return QPixmap();
never executed: return QPixmap();
0
496 } -
497 if (s.isEmpty())
partially evaluated: s.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:109
0-109
498 return QPixmap();
never executed: return QPixmap();
0
499 -
500 QSize newSize = size(); -
501 newSize.scale(s, aspectMode); -
502 newSize.rwidth() = qMax(newSize.width(), 1); -
503 newSize.rheight() = qMax(newSize.height(), 1); -
504 if (newSize == size())
partially evaluated: newSize == size()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:109
0-109
505 return *this;
never executed: return *this;
0
506 -
507 QTransform wm = QTransform::fromScale((qreal)newSize.width() / width(), -
508 (qreal)newSize.height() / height()); -
509 QPixmap pix = transformed(wm, mode); -
510 return pix;
executed: return pix;
Execution Count:109
109
511} -
512QPixmap QPixmap::scaledToWidth(int w, Qt::TransformationMode mode) const -
513{ -
514 if (isNull()) {
never evaluated: isNull()
0
515 QMessageLogger("image/qpixmap.cpp", 1182, __PRETTY_FUNCTION__).warning("QPixmap::scaleWidth: Pixmap is a null pixmap"); -
516 return copy();
never executed: return copy();
0
517 } -
518 if (w <= 0)
never evaluated: w <= 0
0
519 return QPixmap();
never executed: return QPixmap();
0
520 -
521 qreal factor = (qreal) w / width(); -
522 QTransform wm = QTransform::fromScale(factor, factor); -
523 return transformed(wm, mode);
never executed: return transformed(wm, mode);
0
524} -
525QPixmap QPixmap::scaledToHeight(int h, Qt::TransformationMode mode) const -
526{ -
527 if (isNull()) {
never evaluated: isNull()
0
528 QMessageLogger("image/qpixmap.cpp", 1210, __PRETTY_FUNCTION__).warning("QPixmap::scaleHeight: Pixmap is a null pixmap"); -
529 return copy();
never executed: return copy();
0
530 } -
531 if (h <= 0)
never evaluated: h <= 0
0
532 return QPixmap();
never executed: return QPixmap();
0
533 -
534 qreal factor = (qreal) h / height(); -
535 QTransform wm = QTransform::fromScale(factor, factor); -
536 return transformed(wm, mode);
never executed: return transformed(wm, mode);
0
537} -
538QPixmap QPixmap::transformed(const QTransform &transform, -
539 Qt::TransformationMode mode) const -
540{ -
541 if (isNull() || transform.type() <= QTransform::TxTranslate)
partially evaluated: isNull()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:113
partially evaluated: transform.type() <= QTransform::TxTranslate
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:113
0-113
542 return *this;
never executed: return *this;
0
543 -
544 return data->transformed(transform, mode);
executed: return data->transformed(transform, mode);
Execution Count:113
113
545} -
546 -
547 -
548 -
549 -
550 -
551 -
552 -
553QPixmap QPixmap::transformed(const QMatrix &matrix, Qt::TransformationMode mode) const -
554{ -
555 return transformed(QTransform(matrix), mode);
never executed: return transformed(QTransform(matrix), mode);
0
556} -
557bool QPixmap::hasAlpha() const -
558{ -
559 return data && data->hasAlphaChannel();
executed: return data && data->hasAlphaChannel();
Execution Count:1
1
560} -
561 -
562 -
563 -
564 -
565 -
566 -
567 -
568bool QPixmap::hasAlphaChannel() const -
569{ -
570 return data && data->hasAlphaChannel();
executed: return data && data->hasAlphaChannel();
Execution Count:88
88
571} -
572 -
573 -
574 -
575 -
576int QPixmap::metric(PaintDeviceMetric metric) const -
577{ -
578 return data ? data->metric(metric) : 0;
executed: return data ? data->metric(metric) : 0;
Execution Count:1916
1916
579} -
580 -
581 -
582 -
583 -
584QPaintEngine *QPixmap::paintEngine() const -
585{ -
586 return data ? data->paintEngine() : 0;
executed: return data ? data->paintEngine() : 0;
Execution Count:1900
1900
587} -
588QBitmap QPixmap::mask() const -
589{ -
590 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
591 return QBitmap();
executed: return QBitmap();
Execution Count:22
22
592 -
593 const QImage img = toImage(); -
594 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
595 const int w = image.width(); -
596 const int h = image.height(); -
597 -
598 QImage mask(w, h, QImage::Format_MonoLSB); -
599 if (mask.isNull())
partially evaluated: mask.isNull()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:70
0-70
600 return QBitmap();
never executed: return QBitmap();
0
601 -
602 mask.setColorCount(2); -
603 mask.setColor(0, QColor(Qt::color0).rgba()); -
604 mask.setColor(1, QColor(Qt::color1).rgba()); -
605 -
606 const int bpl = mask.bytesPerLine(); -
607 -
608 for (int y = 0; y < h; ++y) {
evaluated: y < h
TRUEFALSE
yes
Evaluation Count:1078
yes
Evaluation Count:70
70-1078
609 const QRgb *src = reinterpret_cast<const QRgb*>(image.scanLine(y)); -
610 uchar *dest = mask.scanLine(y); -
611 memset(dest, 0, bpl); -
612 for (int x = 0; x < w; ++x) {
evaluated: x < w
TRUEFALSE
yes
Evaluation Count:33928
yes
Evaluation Count:1078
1078-33928
613 if (qAlpha(*src) > 0)
evaluated: qAlpha(*src) > 0
TRUEFALSE
yes
Evaluation Count:11575
yes
Evaluation Count:22353
11575-22353
614 dest[x >> 3] |= (1 << (x & 7));
executed: dest[x >> 3] |= (1 << (x & 7));
Execution Count:11575
11575
615 ++src; -
616 }
executed: }
Execution Count:33928
33928
617 }
executed: }
Execution Count:1078
1078
618 -
619 return QBitmap::fromImage(mask);
executed: return QBitmap::fromImage(mask);
Execution Count:70
70
620} -
621int QPixmap::defaultDepth() -
622{ -
623 return QGuiApplication::primaryScreen()->depth();
executed: return QGuiApplication::primaryScreen()->depth();
Execution Count:33
33
624} -
625void QPixmap::detach() -
626{ -
627 if (!data)
evaluated: !data
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1235
1-1235
628 return;
executed: return;
Execution Count:1
1
629 -
630 -
631 -
632 QPlatformPixmap *pd = handle(); -
633 QPlatformPixmap::ClassId id = pd->classId(); -
634 if (id == QPlatformPixmap::RasterClass) {
partially evaluated: id == QPlatformPixmap::RasterClass
TRUEFALSE
yes
Evaluation Count:1235
no
Evaluation Count:0
0-1235
635 QRasterPlatformPixmap *rasterData = static_cast<QRasterPlatformPixmap*>(pd); -
636 rasterData->image.detach(); -
637 }
executed: }
Execution Count:1235
1235
638 -
639 if (data->is_cached && data->ref.load() == 1)
partially evaluated: data->is_cached
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1235
never evaluated: data->ref.load() == 1
0-1235
640 QImagePixmapCleanupHooks::executePlatformPixmapModificationHooks(data.data());
never executed: QImagePixmapCleanupHooks::executePlatformPixmapModificationHooks(data.data());
0
641 -
642 if (data->ref.load() != 1) {
evaluated: data->ref.load() != 1
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:1229
6-1229
643 *this = copy(); -
644 }
executed: }
Execution Count:6
6
645 ++data->detach_no; -
646}
executed: }
Execution Count:1235
1235
647QPixmap QPixmap::fromImage(const QImage &image, Qt::ImageConversionFlags flags) -
648{ -
649 if (image.isNull())
evaluated: image.isNull()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:3863
1-3863
650 return QPixmap();
executed: return QPixmap();
Execution Count:1
1
651 -
652 QScopedPointer<QPlatformPixmap> data(QGuiApplicationPrivate::platformIntegration()->createPlatformPixmap(QPlatformPixmap::PixmapType)); -
653 data->fromImage(image, flags); -
654 return QPixmap(data.take());
executed: return QPixmap(data.take());
Execution Count:3863
3863
655} -
656QPixmap QPixmap::fromImageReader(QImageReader *imageReader, Qt::ImageConversionFlags flags) -
657{ -
658 QScopedPointer<QPlatformPixmap> data(QGuiApplicationPrivate::platformIntegration()->createPlatformPixmap(QPlatformPixmap::PixmapType)); -
659 data->fromImageReader(imageReader, flags); -
660 return QPixmap(data.take());
executed: return QPixmap(data.take());
Execution Count:15
15
661} -
662QPixmap QPixmap::grabWindow(WId window, int x, int y, int w, int h) -
663{ -
664 QMessageLogger("image/qpixmap.cpp", 1681, __PRETTY_FUNCTION__).warning("%s is deprecated, use QScreen::grabWindow() instead." -
665 " Defaulting to primary screen.", __PRETTY_FUNCTION__); -
666 return QGuiApplication::primaryScreen()->grabWindow(window, x, y, w, h);
never executed: return QGuiApplication::primaryScreen()->grabWindow(window, x, y, w, h);
0
667} -
668 -
669 -
670 -
671 -
672QPlatformPixmap* QPixmap::handle() const -
673{ -
674 return data.data();
executed: return data.data();
Execution Count:8313
8313
675} -
676 -
677 -
678QDebug operator<<(QDebug dbg, const QPixmap &r) -
679{ -
680 dbg.nospace() << "QPixmap(" << r.size() << ')'; -
681 return dbg.space();
executed: return dbg.space();
Execution Count:2
2
682} -
683 -
684 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial