Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/image/qpaintengine_pic.cpp |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||||||||
2 | ** | - | ||||||||||||
3 | ** Copyright (C) 2015 The Qt Company Ltd. | - | ||||||||||||
4 | ** Contact: http://www.qt.io/licensing/ | - | ||||||||||||
5 | ** | - | ||||||||||||
6 | ** This file is part of the QtGui module of the Qt Toolkit. | - | ||||||||||||
7 | ** | - | ||||||||||||
8 | ** $QT_BEGIN_LICENSE:LGPL21$ | - | ||||||||||||
9 | ** Commercial License Usage | - | ||||||||||||
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||
11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||
12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||
13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||
14 | ** and conditions see http://www.qt.io/terms-conditions. For further | - | ||||||||||||
15 | ** information use the contact form at http://www.qt.io/contact-us. | - | ||||||||||||
16 | ** | - | ||||||||||||
17 | ** GNU Lesser General Public License Usage | - | ||||||||||||
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||
19 | ** General Public License version 2.1 or version 3 as published by the Free | - | ||||||||||||
20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - | ||||||||||||
21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - | ||||||||||||
22 | ** following information to ensure the GNU Lesser General Public License | - | ||||||||||||
23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - | ||||||||||||
24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - | ||||||||||||
25 | ** | - | ||||||||||||
26 | ** As a special exception, The Qt Company gives you certain additional | - | ||||||||||||
27 | ** rights. These rights are described in The Qt Company LGPL Exception | - | ||||||||||||
28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - | ||||||||||||
29 | ** | - | ||||||||||||
30 | ** $QT_END_LICENSE$ | - | ||||||||||||
31 | ** | - | ||||||||||||
32 | ****************************************************************************/ | - | ||||||||||||
33 | - | |||||||||||||
34 | #include "private/qpaintengine_p.h" | - | ||||||||||||
35 | #include "private/qpainter_p.h" | - | ||||||||||||
36 | #include "private/qpicture_p.h" | - | ||||||||||||
37 | #include "private/qfont_p.h" | - | ||||||||||||
38 | - | |||||||||||||
39 | #ifndef QT_NO_PICTURE | - | ||||||||||||
40 | - | |||||||||||||
41 | #include "qbuffer.h" | - | ||||||||||||
42 | #include "qbytearray.h" | - | ||||||||||||
43 | #include "qdatastream.h" | - | ||||||||||||
44 | #include "qmath.h" | - | ||||||||||||
45 | #include "qpaintengine_pic_p.h" | - | ||||||||||||
46 | #include "qpicture.h" | - | ||||||||||||
47 | #include "qpolygon.h" | - | ||||||||||||
48 | #include "qrect.h" | - | ||||||||||||
49 | #include <private/qtextengine_p.h> | - | ||||||||||||
50 | - | |||||||||||||
51 | //#define QT_PICTURE_DEBUG | - | ||||||||||||
52 | #include <qdebug.h> | - | ||||||||||||
53 | - | |||||||||||||
54 | - | |||||||||||||
55 | QT_BEGIN_NAMESPACE | - | ||||||||||||
56 | - | |||||||||||||
57 | class QPicturePaintEnginePrivate : public QPaintEnginePrivate | - | ||||||||||||
58 | { | - | ||||||||||||
59 | Q_DECLARE_PUBLIC(QPicturePaintEngine) | - | ||||||||||||
60 | public: | - | ||||||||||||
61 | QDataStream s; | - | ||||||||||||
62 | QPainter *pt; | - | ||||||||||||
63 | QPicturePrivate *pic_d; | - | ||||||||||||
64 | }; | - | ||||||||||||
65 | - | |||||||||||||
66 | QPicturePaintEngine::QPicturePaintEngine() | - | ||||||||||||
67 | : QPaintEngine(*(new QPicturePaintEnginePrivate), AllFeatures) | - | ||||||||||||
68 | { | - | ||||||||||||
69 | Q_D(QPicturePaintEngine); | - | ||||||||||||
70 | d->pt = 0; | - | ||||||||||||
71 | } never executed: end of block | 0 | ||||||||||||
72 | - | |||||||||||||
73 | QPicturePaintEngine::QPicturePaintEngine(QPaintEnginePrivate &dptr) | - | ||||||||||||
74 | : QPaintEngine(dptr, AllFeatures) | - | ||||||||||||
75 | { | - | ||||||||||||
76 | Q_D(QPicturePaintEngine); | - | ||||||||||||
77 | d->pt = 0; | - | ||||||||||||
78 | } never executed: end of block | 0 | ||||||||||||
79 | - | |||||||||||||
80 | QPicturePaintEngine::~QPicturePaintEngine() | - | ||||||||||||
81 | { | - | ||||||||||||
82 | } | - | ||||||||||||
83 | - | |||||||||||||
84 | bool QPicturePaintEngine::begin(QPaintDevice *pd) | - | ||||||||||||
85 | { | - | ||||||||||||
86 | Q_D(QPicturePaintEngine); | - | ||||||||||||
87 | #ifdef QT_PICTURE_DEBUG | - | ||||||||||||
88 | qDebug() << "QPicturePaintEngine::begin()"; | - | ||||||||||||
89 | #endif | - | ||||||||||||
90 | Q_ASSERT(pd); | - | ||||||||||||
91 | QPicture *pic = static_cast<QPicture *>(pd); | - | ||||||||||||
92 | - | |||||||||||||
93 | d->pdev = pd; | - | ||||||||||||
94 | d->pic_d = pic->d_func(); | - | ||||||||||||
95 | Q_ASSERT(d->pic_d); | - | ||||||||||||
96 | - | |||||||||||||
97 | d->s.setDevice(&d->pic_d->pictb); | - | ||||||||||||
98 | d->s.setVersion(d->pic_d->formatMajor); | - | ||||||||||||
99 | - | |||||||||||||
100 | d->pic_d->pictb.open(QIODevice::WriteOnly | QIODevice::Truncate); | - | ||||||||||||
101 | d->s.writeRawData(qt_mfhdr_tag, 4); | - | ||||||||||||
102 | d->s << (quint16) 0 << (quint16) d->pic_d->formatMajor << (quint16) d->pic_d->formatMinor; | - | ||||||||||||
103 | d->s << (quint8) QPicturePrivate::PdcBegin << (quint8) sizeof(qint32); | - | ||||||||||||
104 | d->pic_d->brect = QRect(); | - | ||||||||||||
105 | if (d->pic_d->formatMajor >= 4) {
| 0 | ||||||||||||
106 | QRect r = pic->boundingRect(); | - | ||||||||||||
107 | d->s << (qint32) r.left() << (qint32) r.top() << (qint32) r.width() | - | ||||||||||||
108 | << (qint32) r.height(); | - | ||||||||||||
109 | } never executed: end of block | 0 | ||||||||||||
110 | d->pic_d->trecs = 0; | - | ||||||||||||
111 | d->s << (quint32)d->pic_d->trecs; // total number of records | - | ||||||||||||
112 | d->pic_d->formatOk = false; | - | ||||||||||||
113 | setActive(true); | - | ||||||||||||
114 | return true; never executed: return true; | 0 | ||||||||||||
115 | } | - | ||||||||||||
116 | - | |||||||||||||
117 | bool QPicturePaintEngine::end() | - | ||||||||||||
118 | { | - | ||||||||||||
119 | Q_D(QPicturePaintEngine); | - | ||||||||||||
120 | #ifdef QT_PICTURE_DEBUG | - | ||||||||||||
121 | qDebug() << "QPicturePaintEngine::end()"; | - | ||||||||||||
122 | #endif | - | ||||||||||||
123 | d->pic_d->trecs++; | - | ||||||||||||
124 | d->s << (quint8) QPicturePrivate::PdcEnd << (quint8) 0; | - | ||||||||||||
125 | int cs_start = sizeof(quint32); // pos of checksum word | - | ||||||||||||
126 | int data_start = cs_start + sizeof(quint16); | - | ||||||||||||
127 | int brect_start = data_start + 2*sizeof(qint16) + 2*sizeof(quint8); | - | ||||||||||||
128 | int pos = d->pic_d->pictb.pos(); | - | ||||||||||||
129 | d->pic_d->pictb.seek(brect_start); | - | ||||||||||||
130 | if (d->pic_d->formatMajor >= 4) { // bounding rectangle
| 0 | ||||||||||||
131 | QRect r = static_cast<QPicture *>(d->pdev)->boundingRect(); | - | ||||||||||||
132 | d->s << (qint32) r.left() << (qint32) r.top() << (qint32) r.width() | - | ||||||||||||
133 | << (qint32) r.height(); | - | ||||||||||||
134 | } never executed: end of block | 0 | ||||||||||||
135 | d->s << (quint32) d->pic_d->trecs; // write number of records | - | ||||||||||||
136 | d->pic_d->pictb.seek(cs_start); | - | ||||||||||||
137 | QByteArray buf = d->pic_d->pictb.buffer(); | - | ||||||||||||
138 | quint16 cs = (quint16) qChecksum(buf.constData() + data_start, pos - data_start); | - | ||||||||||||
139 | d->s << cs; // write checksum | - | ||||||||||||
140 | d->pic_d->pictb.close(); | - | ||||||||||||
141 | setActive(false); | - | ||||||||||||
142 | return true; never executed: return true; | 0 | ||||||||||||
143 | } | - | ||||||||||||
144 | - | |||||||||||||
145 | #define SERIALIZE_CMD(c) \ | - | ||||||||||||
146 | d->pic_d->trecs++; \ | - | ||||||||||||
147 | d->s << (quint8) c; \ | - | ||||||||||||
148 | d->s << (quint8) 0; \ | - | ||||||||||||
149 | pos = d->pic_d->pictb.pos() | - | ||||||||||||
150 | - | |||||||||||||
151 | void QPicturePaintEngine::updatePen(const QPen &pen) | - | ||||||||||||
152 | { | - | ||||||||||||
153 | Q_D(QPicturePaintEngine); | - | ||||||||||||
154 | #ifdef QT_PICTURE_DEBUG | - | ||||||||||||
155 | qDebug() << " -> updatePen(): width:" << pen.width() << "style:" | - | ||||||||||||
156 | << pen.style() << "color:" << pen.color(); | - | ||||||||||||
157 | #endif | - | ||||||||||||
158 | int pos; | - | ||||||||||||
159 | SERIALIZE_CMD(QPicturePrivate::PdcSetPen); | - | ||||||||||||
160 | if (d->pic_d->in_memory_only) {
| 0 | ||||||||||||
161 | int index = d->pic_d->pen_list.size(); | - | ||||||||||||
162 | d->pic_d->pen_list.append(pen); | - | ||||||||||||
163 | d->s << index; | - | ||||||||||||
164 | } else { never executed: end of block | 0 | ||||||||||||
165 | d->s << pen; | - | ||||||||||||
166 | } never executed: end of block | 0 | ||||||||||||
167 | writeCmdLength(pos, QRect(), false); | - | ||||||||||||
168 | } never executed: end of block | 0 | ||||||||||||
169 | - | |||||||||||||
170 | void QPicturePaintEngine::updateCompositionMode(QPainter::CompositionMode cmode) | - | ||||||||||||
171 | { | - | ||||||||||||
172 | Q_D(QPicturePaintEngine); | - | ||||||||||||
173 | #ifdef QT_PICTURE_DEBUG | - | ||||||||||||
174 | qDebug() << " -> updateCompositionMode():" << cmode; | - | ||||||||||||
175 | #endif | - | ||||||||||||
176 | int pos; | - | ||||||||||||
177 | SERIALIZE_CMD(QPicturePrivate::PdcSetCompositionMode); | - | ||||||||||||
178 | d->s << (qint32)cmode; | - | ||||||||||||
179 | writeCmdLength(pos, QRectF(), false); | - | ||||||||||||
180 | } never executed: end of block | 0 | ||||||||||||
181 | - | |||||||||||||
182 | void QPicturePaintEngine::updateClipEnabled(bool enabled) | - | ||||||||||||
183 | { | - | ||||||||||||
184 | Q_D(QPicturePaintEngine); | - | ||||||||||||
185 | #ifdef QT_PICTURE_DEBUG | - | ||||||||||||
186 | qDebug() << " -> updateClipEnabled():" << enabled; | - | ||||||||||||
187 | #endif | - | ||||||||||||
188 | int pos; | - | ||||||||||||
189 | SERIALIZE_CMD(QPicturePrivate::PdcSetClipEnabled); | - | ||||||||||||
190 | d->s << enabled; | - | ||||||||||||
191 | writeCmdLength(pos, QRectF(), false); | - | ||||||||||||
192 | } never executed: end of block | 0 | ||||||||||||
193 | - | |||||||||||||
194 | void QPicturePaintEngine::updateOpacity(qreal opacity) | - | ||||||||||||
195 | { | - | ||||||||||||
196 | Q_D(QPicturePaintEngine); | - | ||||||||||||
197 | #ifdef QT_PICTURE_DEBUG | - | ||||||||||||
198 | qDebug() << " -> updateOpacity():" << opacity; | - | ||||||||||||
199 | #endif | - | ||||||||||||
200 | int pos; | - | ||||||||||||
201 | SERIALIZE_CMD(QPicturePrivate::PdcSetOpacity); | - | ||||||||||||
202 | d->s << double(opacity); | - | ||||||||||||
203 | writeCmdLength(pos, QRectF(), false); | - | ||||||||||||
204 | } never executed: end of block | 0 | ||||||||||||
205 | - | |||||||||||||
206 | void QPicturePaintEngine::updateBrush(const QBrush &brush) | - | ||||||||||||
207 | { | - | ||||||||||||
208 | Q_D(QPicturePaintEngine); | - | ||||||||||||
209 | #ifdef QT_PICTURE_DEBUG | - | ||||||||||||
210 | qDebug() << " -> updateBrush(): style:" << brush.style(); | - | ||||||||||||
211 | #endif | - | ||||||||||||
212 | int pos; | - | ||||||||||||
213 | SERIALIZE_CMD(QPicturePrivate::PdcSetBrush); | - | ||||||||||||
214 | if (d->pic_d->in_memory_only) {
| 0 | ||||||||||||
215 | int index = d->pic_d->brush_list.size(); | - | ||||||||||||
216 | d->pic_d->brush_list.append(brush); | - | ||||||||||||
217 | d->s << index; | - | ||||||||||||
218 | } else { never executed: end of block | 0 | ||||||||||||
219 | d->s << brush; | - | ||||||||||||
220 | } never executed: end of block | 0 | ||||||||||||
221 | writeCmdLength(pos, QRect(), false); | - | ||||||||||||
222 | } never executed: end of block | 0 | ||||||||||||
223 | - | |||||||||||||
224 | void QPicturePaintEngine::updateBrushOrigin(const QPointF &p) | - | ||||||||||||
225 | { | - | ||||||||||||
226 | Q_D(QPicturePaintEngine); | - | ||||||||||||
227 | #ifdef QT_PICTURE_DEBUG | - | ||||||||||||
228 | qDebug() << " -> updateBrushOrigin(): " << p; | - | ||||||||||||
229 | #endif | - | ||||||||||||
230 | int pos; | - | ||||||||||||
231 | SERIALIZE_CMD(QPicturePrivate::PdcSetBrushOrigin); | - | ||||||||||||
232 | d->s << p; | - | ||||||||||||
233 | writeCmdLength(pos, QRect(), false); | - | ||||||||||||
234 | } never executed: end of block | 0 | ||||||||||||
235 | - | |||||||||||||
236 | void QPicturePaintEngine::updateFont(const QFont &font) | - | ||||||||||||
237 | { | - | ||||||||||||
238 | Q_D(QPicturePaintEngine); | - | ||||||||||||
239 | #ifdef QT_PICTURE_DEBUG | - | ||||||||||||
240 | qDebug() << " -> updateFont(): pt sz:" << font.pointSize(); | - | ||||||||||||
241 | #endif | - | ||||||||||||
242 | int pos; | - | ||||||||||||
243 | SERIALIZE_CMD(QPicturePrivate::PdcSetFont); | - | ||||||||||||
244 | QFont fnt = font; | - | ||||||||||||
245 | d->s << fnt; | - | ||||||||||||
246 | writeCmdLength(pos, QRectF(), false); | - | ||||||||||||
247 | } never executed: end of block | 0 | ||||||||||||
248 | - | |||||||||||||
249 | void QPicturePaintEngine::updateBackground(Qt::BGMode bgMode, const QBrush &bgBrush) | - | ||||||||||||
250 | { | - | ||||||||||||
251 | Q_D(QPicturePaintEngine); | - | ||||||||||||
252 | #ifdef QT_PICTURE_DEBUG | - | ||||||||||||
253 | qDebug() << " -> updateBackground(): mode:" << bgMode << "style:" << bgBrush.style(); | - | ||||||||||||
254 | #endif | - | ||||||||||||
255 | int pos; | - | ||||||||||||
256 | SERIALIZE_CMD(QPicturePrivate::PdcSetBkColor); | - | ||||||||||||
257 | d->s << bgBrush.color(); | - | ||||||||||||
258 | writeCmdLength(pos, QRect(), false); | - | ||||||||||||
259 | - | |||||||||||||
260 | SERIALIZE_CMD(QPicturePrivate::PdcSetBkMode); | - | ||||||||||||
261 | d->s << (qint8) bgMode; | - | ||||||||||||
262 | writeCmdLength(pos, QRectF(), false); | - | ||||||||||||
263 | } never executed: end of block | 0 | ||||||||||||
264 | - | |||||||||||||
265 | void QPicturePaintEngine::updateMatrix(const QTransform &matrix) | - | ||||||||||||
266 | { | - | ||||||||||||
267 | Q_D(QPicturePaintEngine); | - | ||||||||||||
268 | #ifdef QT_PICTURE_DEBUG | - | ||||||||||||
269 | qDebug() << " -> updateMatrix():" << matrix; | - | ||||||||||||
270 | #endif | - | ||||||||||||
271 | int pos; | - | ||||||||||||
272 | SERIALIZE_CMD(QPicturePrivate::PdcSetWMatrix); | - | ||||||||||||
273 | d->s << matrix << (qint8) false; | - | ||||||||||||
274 | writeCmdLength(pos, QRectF(), false); | - | ||||||||||||
275 | } never executed: end of block | 0 | ||||||||||||
276 | - | |||||||||||||
277 | void QPicturePaintEngine::updateClipRegion(const QRegion ®ion, Qt::ClipOperation op) | - | ||||||||||||
278 | { | - | ||||||||||||
279 | Q_D(QPicturePaintEngine); | - | ||||||||||||
280 | #ifdef QT_PICTURE_DEBUG | - | ||||||||||||
281 | qDebug() << " -> updateClipRegion(): op:" << op | - | ||||||||||||
282 | << "bounding rect:" << region.boundingRect(); | - | ||||||||||||
283 | #endif | - | ||||||||||||
284 | int pos; | - | ||||||||||||
285 | SERIALIZE_CMD(QPicturePrivate::PdcSetClipRegion); | - | ||||||||||||
286 | d->s << region << qint8(op); | - | ||||||||||||
287 | writeCmdLength(pos, QRectF(), false); | - | ||||||||||||
288 | } never executed: end of block | 0 | ||||||||||||
289 | - | |||||||||||||
290 | void QPicturePaintEngine::updateClipPath(const QPainterPath &path, Qt::ClipOperation op) | - | ||||||||||||
291 | { | - | ||||||||||||
292 | Q_D(QPicturePaintEngine); | - | ||||||||||||
293 | #ifdef QT_PICTURE_DEBUG | - | ||||||||||||
294 | qDebug() << " -> updateClipPath(): op:" << op | - | ||||||||||||
295 | << "bounding rect:" << path.boundingRect(); | - | ||||||||||||
296 | #endif | - | ||||||||||||
297 | int pos; | - | ||||||||||||
298 | - | |||||||||||||
299 | SERIALIZE_CMD(QPicturePrivate::PdcSetClipPath); | - | ||||||||||||
300 | d->s << path << qint8(op); | - | ||||||||||||
301 | writeCmdLength(pos, QRectF(), false); | - | ||||||||||||
302 | } never executed: end of block | 0 | ||||||||||||
303 | - | |||||||||||||
304 | void QPicturePaintEngine::updateRenderHints(QPainter::RenderHints hints) | - | ||||||||||||
305 | { | - | ||||||||||||
306 | Q_D(QPicturePaintEngine); | - | ||||||||||||
307 | #ifdef QT_PICTURE_DEBUG | - | ||||||||||||
308 | qDebug() << " -> updateRenderHints(): " << hints; | - | ||||||||||||
309 | #endif | - | ||||||||||||
310 | int pos; | - | ||||||||||||
311 | SERIALIZE_CMD(QPicturePrivate::PdcSetRenderHint); | - | ||||||||||||
312 | d->s << (quint32) hints; | - | ||||||||||||
313 | writeCmdLength(pos, QRect(), false); | - | ||||||||||||
314 | } never executed: end of block | 0 | ||||||||||||
315 | - | |||||||||||||
316 | void QPicturePaintEngine::writeCmdLength(int pos, const QRectF &r, bool corr) | - | ||||||||||||
317 | { | - | ||||||||||||
318 | Q_D(QPicturePaintEngine); | - | ||||||||||||
319 | int newpos = d->pic_d->pictb.pos(); // new position | - | ||||||||||||
320 | int length = newpos - pos; | - | ||||||||||||
321 | QRectF br(r); | - | ||||||||||||
322 | - | |||||||||||||
323 | if (length < 255) { // write 8-bit length
| 0 | ||||||||||||
324 | d->pic_d->pictb.seek(pos - 1); // position to right index | - | ||||||||||||
325 | d->s << (quint8)length; | - | ||||||||||||
326 | } else { // write 32-bit length never executed: end of block | 0 | ||||||||||||
327 | d->s << (quint32)0; // extend the buffer | - | ||||||||||||
328 | d->pic_d->pictb.seek(pos - 1); // position to right index | - | ||||||||||||
329 | d->s << (quint8)255; // indicate 32-bit length | - | ||||||||||||
330 | char *p = d->pic_d->pictb.buffer().data(); | - | ||||||||||||
331 | memmove(p+pos+4, p+pos, length); // make room for 4 byte | - | ||||||||||||
332 | d->s << (quint32)length; | - | ||||||||||||
333 | newpos += 4; | - | ||||||||||||
334 | } never executed: end of block | 0 | ||||||||||||
335 | d->pic_d->pictb.seek(newpos); // set to new position | - | ||||||||||||
336 | - | |||||||||||||
337 | if (br.width() > 0.0 || br.height() > 0.0) {
| 0 | ||||||||||||
338 | if (corr) { // widen bounding rect
| 0 | ||||||||||||
339 | int w2 = painter()->pen().width() / 2; | - | ||||||||||||
340 | br.setCoords(br.left() - w2, br.top() - w2, | - | ||||||||||||
341 | br.right() + w2, br.bottom() + w2); | - | ||||||||||||
342 | } never executed: end of block | 0 | ||||||||||||
343 | br = painter()->transform().mapRect(br); | - | ||||||||||||
344 | if (painter()->hasClipping()) {
| 0 | ||||||||||||
345 | QRectF cr = painter()->clipBoundingRect(); | - | ||||||||||||
346 | br &= cr; | - | ||||||||||||
347 | } never executed: end of block | 0 | ||||||||||||
348 | - | |||||||||||||
349 | if (br.width() > 0.0 || br.height() > 0.0) {
| 0 | ||||||||||||
350 | int minx = qFloor(br.left()); | - | ||||||||||||
351 | int miny = qFloor(br.top()); | - | ||||||||||||
352 | int maxx = qCeil(br.right()); | - | ||||||||||||
353 | int maxy = qCeil(br.bottom()); | - | ||||||||||||
354 | - | |||||||||||||
355 | if (d->pic_d->brect.width() > 0 || d->pic_d->brect.height() > 0) {
| 0 | ||||||||||||
356 | minx = qMin(minx, d->pic_d->brect.left()); | - | ||||||||||||
357 | miny = qMin(miny, d->pic_d->brect.top()); | - | ||||||||||||
358 | maxx = qMax(maxx, d->pic_d->brect.x() + d->pic_d->brect.width()); | - | ||||||||||||
359 | maxy = qMax(maxy, d->pic_d->brect.y() + d->pic_d->brect.height()); | - | ||||||||||||
360 | d->pic_d->brect = QRect(minx, miny, maxx - minx, maxy - miny); | - | ||||||||||||
361 | } else { never executed: end of block | 0 | ||||||||||||
362 | d->pic_d->brect = QRect(minx, miny, maxx - minx, maxy - miny); | - | ||||||||||||
363 | } never executed: end of block | 0 | ||||||||||||
364 | } | - | ||||||||||||
365 | } never executed: end of block | 0 | ||||||||||||
366 | } never executed: end of block | 0 | ||||||||||||
367 | - | |||||||||||||
368 | void QPicturePaintEngine::drawEllipse(const QRectF &rect) | - | ||||||||||||
369 | { | - | ||||||||||||
370 | Q_D(QPicturePaintEngine); | - | ||||||||||||
371 | #ifdef QT_PICTURE_DEBUG | - | ||||||||||||
372 | qDebug() << " -> drawEllipse():" << rect; | - | ||||||||||||
373 | #endif | - | ||||||||||||
374 | int pos; | - | ||||||||||||
375 | SERIALIZE_CMD(QPicturePrivate::PdcDrawEllipse); | - | ||||||||||||
376 | d->s << rect; | - | ||||||||||||
377 | writeCmdLength(pos, rect, true); | - | ||||||||||||
378 | } never executed: end of block | 0 | ||||||||||||
379 | - | |||||||||||||
380 | void QPicturePaintEngine::drawPath(const QPainterPath &path) | - | ||||||||||||
381 | { | - | ||||||||||||
382 | Q_D(QPicturePaintEngine); | - | ||||||||||||
383 | #ifdef QT_PICTURE_DEBUG | - | ||||||||||||
384 | qDebug() << " -> drawPath():" << path.boundingRect(); | - | ||||||||||||
385 | #endif | - | ||||||||||||
386 | int pos; | - | ||||||||||||
387 | SERIALIZE_CMD(QPicturePrivate::PdcDrawPath); | - | ||||||||||||
388 | d->s << path; | - | ||||||||||||
389 | writeCmdLength(pos, path.boundingRect(), true); | - | ||||||||||||
390 | } never executed: end of block | 0 | ||||||||||||
391 | - | |||||||||||||
392 | void QPicturePaintEngine::drawPolygon(const QPointF *points, int numPoints, PolygonDrawMode mode) | - | ||||||||||||
393 | { | - | ||||||||||||
394 | Q_D(QPicturePaintEngine); | - | ||||||||||||
395 | #ifdef QT_PICTURE_DEBUG | - | ||||||||||||
396 | qDebug() << " -> drawPolygon(): size=" << numPoints; | - | ||||||||||||
397 | #endif | - | ||||||||||||
398 | int pos; | - | ||||||||||||
399 | - | |||||||||||||
400 | QPolygonF polygon; | - | ||||||||||||
401 | polygon.reserve(numPoints); | - | ||||||||||||
402 | for (int i=0; i<numPoints; ++i)
| 0 | ||||||||||||
403 | polygon << points[i]; never executed: polygon << points[i]; | 0 | ||||||||||||
404 | - | |||||||||||||
405 | if (mode == PolylineMode) {
| 0 | ||||||||||||
406 | SERIALIZE_CMD(QPicturePrivate::PdcDrawPolyline); | - | ||||||||||||
407 | d->s << polygon; | - | ||||||||||||
408 | } else { never executed: end of block | 0 | ||||||||||||
409 | SERIALIZE_CMD(QPicturePrivate::PdcDrawPolygon); | - | ||||||||||||
410 | d->s << polygon; | - | ||||||||||||
411 | d->s << (qint8)(mode == OddEvenMode ? 0 : 1); | - | ||||||||||||
412 | } never executed: end of block | 0 | ||||||||||||
413 | - | |||||||||||||
414 | writeCmdLength(pos, polygon.boundingRect(), true); | - | ||||||||||||
415 | } never executed: end of block | 0 | ||||||||||||
416 | - | |||||||||||||
417 | void QPicturePaintEngine::drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) | - | ||||||||||||
418 | { | - | ||||||||||||
419 | Q_D(QPicturePaintEngine); | - | ||||||||||||
420 | #ifdef QT_PICTURE_DEBUG | - | ||||||||||||
421 | qDebug() << " -> drawPixmap():" << r; | - | ||||||||||||
422 | #endif | - | ||||||||||||
423 | int pos; | - | ||||||||||||
424 | SERIALIZE_CMD(QPicturePrivate::PdcDrawPixmap); | - | ||||||||||||
425 | - | |||||||||||||
426 | if (d->pic_d->in_memory_only) {
| 0 | ||||||||||||
427 | int index = d->pic_d->pixmap_list.size(); | - | ||||||||||||
428 | d->pic_d->pixmap_list.append(pm); | - | ||||||||||||
429 | d->s << r << index << sr; | - | ||||||||||||
430 | } else { never executed: end of block | 0 | ||||||||||||
431 | d->s << r << pm << sr; | - | ||||||||||||
432 | } never executed: end of block | 0 | ||||||||||||
433 | writeCmdLength(pos, r, false); | - | ||||||||||||
434 | } never executed: end of block | 0 | ||||||||||||
435 | - | |||||||||||||
436 | void QPicturePaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s) | - | ||||||||||||
437 | { | - | ||||||||||||
438 | Q_D(QPicturePaintEngine); | - | ||||||||||||
439 | #ifdef QT_PICTURE_DEBUG | - | ||||||||||||
440 | qDebug() << " -> drawTiledPixmap():" << r << s; | - | ||||||||||||
441 | #endif | - | ||||||||||||
442 | int pos; | - | ||||||||||||
443 | SERIALIZE_CMD(QPicturePrivate::PdcDrawTiledPixmap); | - | ||||||||||||
444 | if (d->pic_d->in_memory_only) {
| 0 | ||||||||||||
445 | int index = d->pic_d->pixmap_list.size(); | - | ||||||||||||
446 | d->pic_d->pixmap_list.append(pixmap); | - | ||||||||||||
447 | d->s << r << index << s; | - | ||||||||||||
448 | } else { never executed: end of block | 0 | ||||||||||||
449 | d->s << r << pixmap << s; | - | ||||||||||||
450 | } never executed: end of block | 0 | ||||||||||||
451 | writeCmdLength(pos, r, false); | - | ||||||||||||
452 | } never executed: end of block | 0 | ||||||||||||
453 | - | |||||||||||||
454 | void QPicturePaintEngine::drawImage(const QRectF &r, const QImage &image, const QRectF &sr, | - | ||||||||||||
455 | Qt::ImageConversionFlags flags) | - | ||||||||||||
456 | { | - | ||||||||||||
457 | Q_D(QPicturePaintEngine); | - | ||||||||||||
458 | #ifdef QT_PICTURE_DEBUG | - | ||||||||||||
459 | qDebug() << " -> drawImage():" << r << sr; | - | ||||||||||||
460 | #endif | - | ||||||||||||
461 | int pos; | - | ||||||||||||
462 | SERIALIZE_CMD(QPicturePrivate::PdcDrawImage); | - | ||||||||||||
463 | if (d->pic_d->in_memory_only) {
| 0 | ||||||||||||
464 | int index = d->pic_d->image_list.size(); | - | ||||||||||||
465 | d->pic_d->image_list.append(image); | - | ||||||||||||
466 | d->s << r << index << sr << (quint32) flags; | - | ||||||||||||
467 | } else { never executed: end of block | 0 | ||||||||||||
468 | d->s << r << image << sr << (quint32) flags; | - | ||||||||||||
469 | } never executed: end of block | 0 | ||||||||||||
470 | writeCmdLength(pos, r, false); | - | ||||||||||||
471 | } never executed: end of block | 0 | ||||||||||||
472 | - | |||||||||||||
473 | void QPicturePaintEngine::drawTextItem(const QPointF &p , const QTextItem &ti) | - | ||||||||||||
474 | { | - | ||||||||||||
475 | Q_D(QPicturePaintEngine); | - | ||||||||||||
476 | #ifdef QT_PICTURE_DEBUG | - | ||||||||||||
477 | qDebug() << " -> drawTextItem():" << p << ti.text(); | - | ||||||||||||
478 | #endif | - | ||||||||||||
479 | - | |||||||||||||
480 | const QTextItemInt &si = static_cast<const QTextItemInt &>(ti); | - | ||||||||||||
481 | if (si.chars == 0)
| 0 | ||||||||||||
482 | QPaintEngine::drawTextItem(p, ti); // Draw as path never executed: QPaintEngine::drawTextItem(p, ti); | 0 | ||||||||||||
483 | - | |||||||||||||
484 | if (d->pic_d->formatMajor >= 9) {
| 0 | ||||||||||||
485 | int pos; | - | ||||||||||||
486 | SERIALIZE_CMD(QPicturePrivate::PdcDrawTextItem); | - | ||||||||||||
487 | QFont fnt = ti.font(); | - | ||||||||||||
488 | fnt.setUnderline(false); | - | ||||||||||||
489 | fnt.setStrikeOut(false); | - | ||||||||||||
490 | fnt.setOverline(false); | - | ||||||||||||
491 | - | |||||||||||||
492 | qreal justificationWidth = 0; | - | ||||||||||||
493 | if (si.justified)
| 0 | ||||||||||||
494 | justificationWidth = si.width.toReal(); never executed: justificationWidth = si.width.toReal(); | 0 | ||||||||||||
495 | - | |||||||||||||
496 | d->s << p << ti.text() << fnt << ti.renderFlags() << double(fnt.d->dpi)/qt_defaultDpi() << justificationWidth; | - | ||||||||||||
497 | writeCmdLength(pos, /*brect=*/QRectF(), /*corr=*/false); | - | ||||||||||||
498 | } else if (d->pic_d->formatMajor >= 8) { never executed: end of block
| 0 | ||||||||||||
499 | // old old (buggy) format | - | ||||||||||||
500 | int pos; | - | ||||||||||||
501 | SERIALIZE_CMD(QPicturePrivate::PdcDrawTextItem); | - | ||||||||||||
502 | d->s << QPointF(p.x(), p.y() - ti.ascent()) << ti.text() << ti.font() << ti.renderFlags(); | - | ||||||||||||
503 | writeCmdLength(pos, /*brect=*/QRectF(), /*corr=*/false); | - | ||||||||||||
504 | } else { never executed: end of block | 0 | ||||||||||||
505 | // old (buggy) format | - | ||||||||||||
506 | int pos; | - | ||||||||||||
507 | SERIALIZE_CMD(QPicturePrivate::PdcDrawText2); | - | ||||||||||||
508 | d->s << p << ti.text(); | - | ||||||||||||
509 | writeCmdLength(pos, QRectF(p, QSizeF(1,1)), true); | - | ||||||||||||
510 | } never executed: end of block | 0 | ||||||||||||
511 | } | - | ||||||||||||
512 | - | |||||||||||||
513 | void QPicturePaintEngine::updateState(const QPaintEngineState &state) | - | ||||||||||||
514 | { | - | ||||||||||||
515 | QPaintEngine::DirtyFlags flags = state.state(); | - | ||||||||||||
516 | if (flags & DirtyPen) updatePen(state.pen()); never executed: updatePen(state.pen());
| 0 | ||||||||||||
517 | if (flags & DirtyBrush) updateBrush(state.brush()); never executed: updateBrush(state.brush());
| 0 | ||||||||||||
518 | if (flags & DirtyBrushOrigin) updateBrushOrigin(state.brushOrigin()); never executed: updateBrushOrigin(state.brushOrigin());
| 0 | ||||||||||||
519 | if (flags & DirtyFont) updateFont(state.font()); never executed: updateFont(state.font());
| 0 | ||||||||||||
520 | if (flags & DirtyBackground) updateBackground(state.backgroundMode(), state.backgroundBrush()); never executed: updateBackground(state.backgroundMode(), state.backgroundBrush());
| 0 | ||||||||||||
521 | if (flags & DirtyTransform) updateMatrix(state.transform()); never executed: updateMatrix(state.transform());
| 0 | ||||||||||||
522 | if (flags & DirtyClipEnabled) updateClipEnabled(state.isClipEnabled()); never executed: updateClipEnabled(state.isClipEnabled());
| 0 | ||||||||||||
523 | if (flags & DirtyClipRegion) updateClipRegion(state.clipRegion(), state.clipOperation()); never executed: updateClipRegion(state.clipRegion(), state.clipOperation());
| 0 | ||||||||||||
524 | if (flags & DirtyClipPath) updateClipPath(state.clipPath(), state.clipOperation()); never executed: updateClipPath(state.clipPath(), state.clipOperation());
| 0 | ||||||||||||
525 | if (flags & DirtyHints) updateRenderHints(state.renderHints()); never executed: updateRenderHints(state.renderHints());
| 0 | ||||||||||||
526 | if (flags & DirtyCompositionMode) updateCompositionMode(state.compositionMode()); never executed: updateCompositionMode(state.compositionMode());
| 0 | ||||||||||||
527 | if (flags & DirtyOpacity) updateOpacity(state.opacity()); never executed: updateOpacity(state.opacity());
| 0 | ||||||||||||
528 | } never executed: end of block | 0 | ||||||||||||
529 | - | |||||||||||||
530 | QT_END_NAMESPACE | - | ||||||||||||
531 | - | |||||||||||||
532 | #endif // QT_NO_PICTURE | - | ||||||||||||
Source code | Switch to Preprocessed file |