Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/image/qpixmap_blitter.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||
2 | - | |||||||||||||
3 | - | |||||||||||||
4 | - | |||||||||||||
5 | - | |||||||||||||
6 | - | |||||||||||||
7 | - | |||||||||||||
8 | static int global_ser_no = 0; | - | ||||||||||||
9 | - | |||||||||||||
10 | QBlittablePlatformPixmap::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 | - | |||||||||||||
21 | QBlittablePlatformPixmap::~QBlittablePlatformPixmap() | - | ||||||||||||
22 | { | - | ||||||||||||
23 | - | |||||||||||||
24 | - | |||||||||||||
25 | - | |||||||||||||
26 | - | |||||||||||||
27 | } | - | ||||||||||||
28 | - | |||||||||||||
29 | QBlittable *QBlittablePlatformPixmap::blittable() const | - | ||||||||||||
30 | { | - | ||||||||||||
31 | if (!m_blittable
| 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: m_blittable.data();return m_blittable.data(); never executed: return m_blittable.data(); | 0 | ||||||||||||
37 | } | - | ||||||||||||
38 | - | |||||||||||||
39 | void 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 | - | |||||||||||||
45 | void 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
| 0 | ||||||||||||
53 | setSerialNumber(++global_ser_no); | - | ||||||||||||
54 | } never executed: end of block | 0 | ||||||||||||
55 | - | |||||||||||||
56 | int QBlittablePlatformPixmap::metric(QPaintDevice::PaintDeviceMetric metric) const | - | ||||||||||||
57 | { | - | ||||||||||||
58 | switch (metric) { | - | ||||||||||||
59 | case never executed: QPaintDevice::PdmWidth:case QPaintDevice::PdmWidth: never executed: case QPaintDevice::PdmWidth: | 0 | ||||||||||||
60 | return never executed: w;return w; never executed: return w; | 0 | ||||||||||||
61 | case never executed: QPaintDevice::PdmHeight:case QPaintDevice::PdmHeight: never executed: case QPaintDevice::PdmHeight: | 0 | ||||||||||||
62 | return never executed: h;return h; never executed: return h; | 0 | ||||||||||||
63 | case never executed: QPaintDevice::PdmWidthMM:case QPaintDevice::PdmWidthMM: never executed: case QPaintDevice::PdmWidthMM: | 0 | ||||||||||||
64 | return never executed: qRound(w * 25.4 / qt_defaultDpiX());return qRound(w * 25.4 / qt_defaultDpiX()); never executed: return qRound(w * 25.4 / qt_defaultDpiX()); | 0 | ||||||||||||
65 | case never executed: QPaintDevice::PdmHeightMM:case QPaintDevice::PdmHeightMM: never executed: case QPaintDevice::PdmHeightMM: | 0 | ||||||||||||
66 | return never executed: qRound(h * 25.4 / qt_defaultDpiY());return qRound(h * 25.4 / qt_defaultDpiY()); never executed: return qRound(h * 25.4 / qt_defaultDpiY()); | 0 | ||||||||||||
67 | case never executed: QPaintDevice::PdmDepth:case QPaintDevice::PdmDepth: never executed: case QPaintDevice::PdmDepth: | 0 | ||||||||||||
68 | return never executed: 32;return 32; never executed: return 32; | 0 | ||||||||||||
69 | case never executed: QPaintDevice::PdmDpiX:case QPaintDevice::PdmDpiX: never executed: case QPaintDevice::PdmDpiX: | 0 | ||||||||||||
70 | case never executed: QPaintDevice::PdmPhysicalDpiX:case QPaintDevice::PdmPhysicalDpiX: never executed: case QPaintDevice::PdmPhysicalDpiX: | 0 | ||||||||||||
71 | return never executed: qt_defaultDpiX();return qt_defaultDpiX(); never executed: return qt_defaultDpiX(); | 0 | ||||||||||||
72 | case never executed: QPaintDevice::PdmDpiY:case QPaintDevice::PdmDpiY: never executed: case QPaintDevice::PdmDpiY: | 0 | ||||||||||||
73 | case never executed: QPaintDevice::PdmPhysicalDpiY:case QPaintDevice::PdmPhysicalDpiY: never executed: case QPaintDevice::PdmPhysicalDpiY: | 0 | ||||||||||||
74 | return never executed: qt_defaultDpiY();return qt_defaultDpiY(); never executed: return qt_defaultDpiY(); | 0 | ||||||||||||
75 | case never executed: QPaintDevice::PdmDevicePixelRatio:case QPaintDevice::PdmDevicePixelRatio: never executed: case QPaintDevice::PdmDevicePixelRatio: | 0 | ||||||||||||
76 | return never executed: devicePixelRatio();return devicePixelRatio(); never executed: return devicePixelRatio(); | 0 | ||||||||||||
77 | case never executed: QPaintDevice::PdmDevicePixelRatioScaled:case QPaintDevice::PdmDevicePixelRatioScaled: never executed: case QPaintDevice::PdmDevicePixelRatioScaled: | 0 | ||||||||||||
78 | return never executed: devicePixelRatio() * QPaintDevice::devicePixelRatioFScale();return 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: 0;return 0; never executed: return 0; | 0 | ||||||||||||
85 | } | - | ||||||||||||
86 | - | |||||||||||||
87 | void QBlittablePlatformPixmap::fill(const QColor &color) | - | ||||||||||||
88 | { | - | ||||||||||||
89 | if (blittable()->capabilities() & QBlittable::AlphaFillRectCapability
| 0 | ||||||||||||
90 | blittable()->unlock(); | - | ||||||||||||
91 | blittable()->alphaFillRect(QRectF(0,0,w,h),color,QPainter::CompositionMode_Source); | - | ||||||||||||
92 | } never executed: else if (color.alpha() == 255end of block
| 0 | ||||||||||||
93 | blittable()->unlock(); | - | ||||||||||||
94 | blittable()->fillRect(QRectF(0,0,w,h),color); | - | ||||||||||||
95 | } never executed: else {end of block | 0 | ||||||||||||
96 | - | |||||||||||||
97 | - | |||||||||||||
98 | - | |||||||||||||
99 | if (color.alpha() != 255
| 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 | - | |||||||||||||
116 | QImage *QBlittablePlatformPixmap::buffer() | - | ||||||||||||
117 | { | - | ||||||||||||
118 | return never executed: blittable()->lock();return blittable()->lock(); never executed: return blittable()->lock(); | 0 | ||||||||||||
119 | } | - | ||||||||||||
120 | - | |||||||||||||
121 | QImage QBlittablePlatformPixmap::toImage() const | - | ||||||||||||
122 | { | - | ||||||||||||
123 | return never executed: blittable()->lock()->copy();return blittable()->lock()->copy(); never executed: return blittable()->lock()->copy(); | 0 | ||||||||||||
124 | } | - | ||||||||||||
125 | - | |||||||||||||
126 | bool QBlittablePlatformPixmap::hasAlphaChannel() const | - | ||||||||||||
127 | { | - | ||||||||||||
128 | return never executed: blittable()->lock()->hasAlphaChannel();return blittable()->lock()->hasAlphaChannel(); never executed: return blittable()->lock()->hasAlphaChannel(); | 0 | ||||||||||||
129 | } | - | ||||||||||||
130 | - | |||||||||||||
131 | void 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()
| 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()
| 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 | - | |||||||||||||
155 | qreal QBlittablePlatformPixmap::devicePixelRatio() const | - | ||||||||||||
156 | { | - | ||||||||||||
157 | return never executed: m_devicePixelRatio;return m_devicePixelRatio; never executed: return m_devicePixelRatio; | 0 | ||||||||||||
158 | } | - | ||||||||||||
159 | - | |||||||||||||
160 | void QBlittablePlatformPixmap::setDevicePixelRatio(qreal scaleFactor) | - | ||||||||||||
161 | { | - | ||||||||||||
162 | m_devicePixelRatio = scaleFactor; | - | ||||||||||||
163 | } never executed: end of block | 0 | ||||||||||||
164 | - | |||||||||||||
165 | QPaintEngine *QBlittablePlatformPixmap::paintEngine() const | - | ||||||||||||
166 | { | - | ||||||||||||
167 | if (!m_engine
| 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: m_engine.data();return m_engine.data(); never executed: return m_engine.data(); | 0 | ||||||||||||
172 | } | - | ||||||||||||
173 | - | |||||||||||||
Switch to Source code | Preprocessed file |