qpixmap_blitter.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/image/qpixmap_blitter.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8static int global_ser_no = 0;-
9-
10QBlittablePlatformPixmap::QBlittablePlatformPixmap()-
11 : QPlatformPixmap(QPlatformPixmap::PixmapType,BlitterClass)-
12 , m_alpha(false)-
13 , m_devicePixelRatio(1.0)-
14-
15-
16-
17{-
18 setSerialNumber(++global_ser_no);-
19}
never executed: end of block
0
20-
21QBlittablePlatformPixmap::~QBlittablePlatformPixmap()-
22{-
23-
24-
25-
26-
27}-
28-
29QBlittable *QBlittablePlatformPixmap::blittable() const-
30{-
31 if (!m_blittable
!m_blittableDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
32 QBlittablePlatformPixmap *that = const_cast<QBlittablePlatformPixmap *>(this);-
33 that->m_blittable.reset(this->createBlittable(QSize(w, h), m_alpha));-
34 }
never executed: end of block
0
35-
36 return
never executed: return m_blittable.data();
m_blittable.data();
never executed: return m_blittable.data();
0
37}-
38-
39void QBlittablePlatformPixmap::setBlittable(QBlittable *blittable)-
40{-
41 resize(blittable->size().width(),blittable->size().height());-
42 m_blittable.reset(blittable);-
43}
never executed: end of block
0
44-
45void QBlittablePlatformPixmap::resize(int width, int height)-
46{-
47 m_blittable.reset(0);-
48 m_engine.reset(0);-
49 d = QGuiApplication::primaryScreen()->depth();-
50 w = width;-
51 h = height;-
52 is_null = (w <= 0
w <= 0Description
TRUEnever evaluated
FALSEnever evaluated
|| h <= 0
h <= 0Description
TRUEnever evaluated
FALSEnever evaluated
);
0
53 setSerialNumber(++global_ser_no);-
54}
never executed: end of block
0
55-
56int QBlittablePlatformPixmap::metric(QPaintDevice::PaintDeviceMetric metric) const-
57{-
58 switch (metric) {-
59 case
never executed: case QPaintDevice::PdmWidth:
QPaintDevice::PdmWidth:
never executed: case QPaintDevice::PdmWidth:
0
60 return
never executed: return w;
w;
never executed: return w;
0
61 case
never executed: case QPaintDevice::PdmHeight:
QPaintDevice::PdmHeight:
never executed: case QPaintDevice::PdmHeight:
0
62 return
never executed: return h;
h;
never executed: return h;
0
63 case
never executed: case QPaintDevice::PdmWidthMM:
QPaintDevice::PdmWidthMM:
never executed: case QPaintDevice::PdmWidthMM:
0
64 return
never executed: return qRound(w * 25.4 / qt_defaultDpiX());
qRound(w * 25.4 / qt_defaultDpiX());
never executed: return qRound(w * 25.4 / qt_defaultDpiX());
0
65 case
never executed: case QPaintDevice::PdmHeightMM:
QPaintDevice::PdmHeightMM:
never executed: case QPaintDevice::PdmHeightMM:
0
66 return
never executed: return qRound(h * 25.4 / qt_defaultDpiY());
qRound(h * 25.4 / qt_defaultDpiY());
never executed: return qRound(h * 25.4 / qt_defaultDpiY());
0
67 case
never executed: case QPaintDevice::PdmDepth:
QPaintDevice::PdmDepth:
never executed: case QPaintDevice::PdmDepth:
0
68 return
never executed: return 32;
32;
never executed: return 32;
0
69 case
never executed: case QPaintDevice::PdmDpiX:
QPaintDevice::PdmDpiX:
never executed: case QPaintDevice::PdmDpiX:
0
70 case
never executed: case QPaintDevice::PdmPhysicalDpiX:
QPaintDevice::PdmPhysicalDpiX:
never executed: case QPaintDevice::PdmPhysicalDpiX:
0
71 return
never executed: return qt_defaultDpiX();
qt_defaultDpiX();
never executed: return qt_defaultDpiX();
0
72 case
never executed: case QPaintDevice::PdmDpiY:
QPaintDevice::PdmDpiY:
never executed: case QPaintDevice::PdmDpiY:
0
73 case
never executed: case QPaintDevice::PdmPhysicalDpiY:
QPaintDevice::PdmPhysicalDpiY:
never executed: case QPaintDevice::PdmPhysicalDpiY:
0
74 return
never executed: return qt_defaultDpiY();
qt_defaultDpiY();
never executed: return qt_defaultDpiY();
0
75 case
never executed: case QPaintDevice::PdmDevicePixelRatio:
QPaintDevice::PdmDevicePixelRatio:
never executed: case QPaintDevice::PdmDevicePixelRatio:
0
76 return
never executed: return devicePixelRatio();
devicePixelRatio();
never executed: return devicePixelRatio();
0
77 case
never executed: case QPaintDevice::PdmDevicePixelRatioScaled:
QPaintDevice::PdmDevicePixelRatioScaled:
never executed: case QPaintDevice::PdmDevicePixelRatioScaled:
0
78 return
never executed: return devicePixelRatio() * QPaintDevice::devicePixelRatioFScale();
devicePixelRatio() * QPaintDevice::devicePixelRatioFScale();
never executed: return devicePixelRatio() * QPaintDevice::devicePixelRatioFScale();
0
79 default
never executed: default:
:
never executed: default:
0
80 QMessageLogger(__FILE__, 127, __PRETTY_FUNCTION__).warning("QRasterPlatformPixmap::metric(): Unhandled metric type %d", metric);-
81 break;
never executed: break;
0
82 }-
83-
84 return
never executed: return 0;
0;
never executed: return 0;
0
85}-
86-
87void QBlittablePlatformPixmap::fill(const QColor &color)-
88{-
89 if (blittable()->capabilities() & QBlittable::AlphaFillRectCapability
blittable()->c...RectCapabilityDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
90 blittable()->unlock();-
91 blittable()->alphaFillRect(QRectF(0,0,w,h),color,QPainter::CompositionMode_Source);-
92 }
never executed: end of block
else if (color.alpha() == 255
color.alpha() == 255Description
TRUEnever evaluated
FALSEnever evaluated
&& blittable()->capabilities() & QBlittable::SolidRectCapability
blittable()->c...RectCapabilityDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
93 blittable()->unlock();-
94 blittable()->fillRect(QRectF(0,0,w,h),color);-
95 }
never executed: end of block
else {
0
96-
97-
98-
99 if (color.alpha() != 255
color.alpha() != 255Description
TRUEnever evaluated
FALSEnever evaluated
&& !hasAlphaChannel()
!hasAlphaChannel()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
100 m_blittable.reset(0);-
101 m_engine.reset(0);-
102 m_alpha = true;-
103 }
never executed: end of block
0
104-
105 uint pixel = qPremultiply(color.rgba());-
106 const QPixelLayout *layout = &qPixelLayouts[blittable()->lock()->format()];-
107 ((!(layout->convertFromARGB32PM)) ? qt_assert("layout->convertFromARGB32PM",__FILE__,154) : qt_noop());-
108 layout->convertFromARGB32PM(&pixel, &pixel, 1, layout, 0);-
109-
110-
111 blittable()->lock()->fill(pixel);-
112 }
never executed: end of block
0
113-
114}-
115-
116QImage *QBlittablePlatformPixmap::buffer()-
117{-
118 return
never executed: return blittable()->lock();
blittable()->lock();
never executed: return blittable()->lock();
0
119}-
120-
121QImage QBlittablePlatformPixmap::toImage() const-
122{-
123 return
never executed: return blittable()->lock()->copy();
blittable()->lock()->copy();
never executed: return blittable()->lock()->copy();
0
124}-
125-
126bool QBlittablePlatformPixmap::hasAlphaChannel() const-
127{-
128 return
never executed: return blittable()->lock()->hasAlphaChannel();
blittable()->lock()->hasAlphaChannel();
never executed: return blittable()->lock()->hasAlphaChannel();
0
129}-
130-
131void QBlittablePlatformPixmap::fromImage(const QImage &image,-
132 Qt::ImageConversionFlags flags)-
133{-
134 m_alpha = image.hasAlphaChannel();-
135 m_devicePixelRatio = image.devicePixelRatio();-
136 resize(image.width(),image.height());-
137 markRasterOverlay(QRect(0,0,w,h));-
138 QImage *thisImg = buffer();-
139-
140 QImage correctFormatPic = image;-
141 if (correctFormatPic.format() != thisImg->format()
correctFormatP...sImg->format()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
142 correctFormatPic = correctFormatPic.convertToFormat(thisImg->format(), flags);
never executed: correctFormatPic = correctFormatPic.convertToFormat(thisImg->format(), flags);
0
143-
144 uchar *mem = thisImg->bits();-
145 const uchar *bits = correctFormatPic.constBits();-
146 int bytesCopied = 0;-
147 while (bytesCopied < correctFormatPic.byteCount()
bytesCopied < ...ic.byteCount()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
148 memcpy(mem,bits,correctFormatPic.bytesPerLine());-
149 mem += thisImg->bytesPerLine();-
150 bits += correctFormatPic.bytesPerLine();-
151 bytesCopied+=correctFormatPic.bytesPerLine();-
152 }
never executed: end of block
0
153}
never executed: end of block
0
154-
155qreal QBlittablePlatformPixmap::devicePixelRatio() const-
156{-
157 return
never executed: return m_devicePixelRatio;
m_devicePixelRatio;
never executed: return m_devicePixelRatio;
0
158}-
159-
160void QBlittablePlatformPixmap::setDevicePixelRatio(qreal scaleFactor)-
161{-
162 m_devicePixelRatio = scaleFactor;-
163}
never executed: end of block
0
164-
165QPaintEngine *QBlittablePlatformPixmap::paintEngine() const-
166{-
167 if (!m_engine
!m_engineDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
168 QBlittablePlatformPixmap *that = const_cast<QBlittablePlatformPixmap *>(this);-
169 that->m_engine.reset(new QBlitterPaintEngine(that));-
170 }
never executed: end of block
0
171 return
never executed: return m_engine.data();
m_engine.data();
never executed: return m_engine.data();
0
172}-
173-
Switch to Source codePreprocessed file

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