qpixmap.cpp

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

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9