Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | extern void qt_format_text(const QFont &font, | - |
9 | const QRectF &_r, int tf, const QTextOption *option, const QString& str, QRectF *brect, | - |
10 | int tabstops, int* tabarray, int tabarraylen, | - |
11 | QPainter *painter); | - |
12 | | - |
13 | QTextItemIntCopy::QTextItemIntCopy(const QTextItem &item) | - |
14 | : m_item(static_cast<const QTextItemInt &>(item)) | - |
15 | { | - |
16 | QChar *chars = new QChar[m_item.num_chars]; | - |
17 | unsigned short *logClusters = new unsigned short[m_item.num_chars]; | - |
18 | memcpy(chars, m_item.chars, m_item.num_chars * sizeof(QChar)); | - |
19 | memcpy(logClusters, m_item.logClusters, m_item.num_chars * sizeof(unsigned short)); | - |
20 | m_item.chars = chars; | - |
21 | m_item.logClusters = logClusters; | - |
22 | | - |
23 | const int size = QGlyphLayout::spaceNeededForGlyphLayout(m_item.glyphs.numGlyphs); | - |
24 | char *glyphLayoutData = new char[size]; | - |
25 | QGlyphLayout glyphs(glyphLayoutData, m_item.glyphs.numGlyphs); | - |
26 | memcpy(glyphs.offsets, m_item.glyphs.offsets, m_item.glyphs.numGlyphs * sizeof(QFixedPoint)); | - |
27 | memcpy(glyphs.glyphs, m_item.glyphs.glyphs, m_item.glyphs.numGlyphs * sizeof(HB_Glyph)); | - |
28 | memcpy(glyphs.advances_x, m_item.glyphs.advances_x, m_item.glyphs.numGlyphs * sizeof(QFixed)); | - |
29 | memcpy(glyphs.advances_y, m_item.glyphs.advances_y, m_item.glyphs.numGlyphs * sizeof(QFixed)); | - |
30 | memcpy(glyphs.justifications, m_item.glyphs.justifications, m_item.glyphs.numGlyphs * sizeof(QGlyphJustification)); | - |
31 | memcpy(glyphs.attributes, m_item.glyphs.attributes, m_item.glyphs.numGlyphs * sizeof(HB_GlyphAttributes)); | - |
32 | m_item.glyphs = glyphs; | - |
33 | | - |
34 | m_font = *m_item.f; | - |
35 | m_item.f = &m_font; | - |
36 | | - |
37 | m_item.fontEngine->ref.ref(); | - |
38 | } | 0 |
39 | | - |
40 | QTextItemIntCopy::~QTextItemIntCopy() | - |
41 | { | - |
42 | delete m_item.chars; | - |
43 | delete m_item.logClusters; | - |
44 | delete m_item.glyphs.data(); | - |
45 | if (!m_item.fontEngine->ref.deref()) never evaluated: !m_item.fontEngine->ref.deref() | 0 |
46 | delete m_item.fontEngine; never executed: delete m_item.fontEngine; | 0 |
47 | } | 0 |
48 | | - |
49 | | - |
50 | | - |
51 | | - |
52 | | - |
53 | | - |
54 | | - |
55 | QPaintBufferPrivate::QPaintBufferPrivate() | - |
56 | : ref(1), engine(0), penWidthAdjustment(0) | - |
57 | , calculateBoundingRect(true) | - |
58 | , cache(0) | - |
59 | { | - |
60 | } | 0 |
61 | | - |
62 | QPaintBufferPrivate::~QPaintBufferPrivate() | - |
63 | { | - |
64 | for (int i = 0; i < commands.size(); ++i) { never evaluated: i < commands.size() | 0 |
65 | const QPaintBufferCommand &cmd = commands.at(i); | - |
66 | if (cmd.id == QPaintBufferPrivate::Cmd_DrawTextItem) never evaluated: cmd.id == QPaintBufferPrivate::Cmd_DrawTextItem | 0 |
67 | delete reinterpret_cast<QTextItemIntCopy *>(qvariant_cast<void *>(variants.at(cmd.offset))); never executed: delete reinterpret_cast<QTextItemIntCopy *>(qvariant_cast<void *>(variants.at(cmd.offset))); | 0 |
68 | } | 0 |
69 | } | 0 |
70 | | - |
71 | | - |
72 | inline void QPaintBufferPrivate::updateBoundingRect(const QRectF &br) | - |
73 | { | - |
74 | | - |
75 | qt_noop(); | - |
76 | QPainter *painter = engine->painter(); | - |
77 | const QTransform transform = painter->transform(); | - |
78 | QRectF devRect = transform.mapRect(br); | - |
79 | if (penWidthAdjustment > 0) { never evaluated: penWidthAdjustment > 0 | 0 |
80 | devRect = devRect.adjusted(-penWidthAdjustment, -penWidthAdjustment, | - |
81 | penWidthAdjustment, penWidthAdjustment); | - |
82 | } | 0 |
83 | | - |
84 | if (boundingRect.isEmpty()) { never evaluated: boundingRect.isEmpty() | 0 |
85 | boundingRect = devRect; | - |
86 | } else { | 0 |
87 | qreal min_x = qMin(devRect.left(), boundingRect.left()); | - |
88 | qreal min_y = qMin(devRect.top(), boundingRect.top()); | - |
89 | qreal max_x = qMax(devRect.right(), boundingRect.right()); | - |
90 | qreal max_y = qMax(devRect.bottom(), boundingRect.bottom()); | - |
91 | boundingRect = QRectF(min_x, min_y, max_x - min_x, max_y - min_y); | - |
92 | } | 0 |
93 | if (painter->hasClipping()) never evaluated: painter->hasClipping() | 0 |
94 | boundingRect &= transform.mapRect(painter->clipRegion().boundingRect()); never executed: boundingRect &= transform.mapRect(painter->clipRegion().boundingRect()); | 0 |
95 | } | 0 |
96 | QPaintBuffer::QPaintBuffer() | - |
97 | : d_ptr(new QPaintBufferPrivate) | - |
98 | { | - |
99 | } | 0 |
100 | | - |
101 | QPaintBuffer::~QPaintBuffer() | - |
102 | { | - |
103 | if (!d_ptr->ref.deref()) never evaluated: !d_ptr->ref.deref() | 0 |
104 | delete d_ptr; never executed: delete d_ptr; | 0 |
105 | } | 0 |
106 | | - |
107 | QPaintBuffer::QPaintBuffer(const QPaintBuffer &other) | - |
108 | : QPaintDevice(), d_ptr(other.d_ptr) | - |
109 | { | - |
110 | d_ptr->ref.ref(); | - |
111 | } | 0 |
112 | | - |
113 | QPaintEngine *QPaintBuffer::paintEngine() const | - |
114 | { | - |
115 | QPaintBufferPrivate *d = const_cast<QPaintBuffer *>(this)->d_ptr; | - |
116 | if (!d->engine) never evaluated: !d->engine | 0 |
117 | d->engine = new QPaintBufferEngine(d); never executed: d->engine = new QPaintBufferEngine(d); | 0 |
118 | return d->engine; never executed: return d->engine; | 0 |
119 | } | - |
120 | | - |
121 | | - |
122 | int QPaintBuffer::metric(PaintDeviceMetric metric) const | - |
123 | { | - |
124 | int val = 0; | - |
125 | switch (metric) { | - |
126 | case PdmWidth: | - |
127 | val = qCeil(d_ptr->boundingRect.width()); | - |
128 | break; | 0 |
129 | case PdmHeight: | - |
130 | val = qCeil(d_ptr->boundingRect.height()); | - |
131 | break; | 0 |
132 | case PdmDpiX: | - |
133 | case PdmPhysicalDpiX: | - |
134 | val = qt_defaultDpiX(); | - |
135 | break; | 0 |
136 | case PdmDpiY: | - |
137 | case PdmPhysicalDpiY: | - |
138 | val = qt_defaultDpiY(); | - |
139 | break; | 0 |
140 | default: | - |
141 | val = QPaintDevice::metric(metric); | - |
142 | } | 0 |
143 | | - |
144 | return val; never executed: return val; | 0 |
145 | } | - |
146 | | - |
147 | int QPaintBuffer::devType() const | - |
148 | { | - |
149 | return QInternal::PaintBuffer; never executed: return QInternal::PaintBuffer; | 0 |
150 | } | - |
151 | | - |
152 | QPaintBuffer &QPaintBuffer::operator=(const QPaintBuffer &other) | - |
153 | { | - |
154 | if (other.d_ptr != d_ptr) { never evaluated: other.d_ptr != d_ptr | 0 |
155 | QPaintBufferPrivate *data = other.d_ptr; | - |
156 | data->ref.ref(); | - |
157 | if (d_ptr->ref.deref()) never evaluated: d_ptr->ref.deref() | 0 |
158 | delete d_ptr; never executed: delete d_ptr; | 0 |
159 | d_ptr = data; | - |
160 | } | 0 |
161 | return *this; never executed: return *this; | 0 |
162 | } | - |
163 | | - |
164 | bool QPaintBuffer::isEmpty() const | - |
165 | { | - |
166 | return d_ptr->commands.isEmpty(); never executed: return d_ptr->commands.isEmpty(); | 0 |
167 | } | - |
168 | | - |
169 | | - |
170 | | - |
171 | void QPaintBuffer::draw(QPainter *painter, int frame) const | - |
172 | { | - |
173 | processCommands(painter, frameStartIndex(frame), frameEndIndex(frame)); | - |
174 | | - |
175 | | - |
176 | | - |
177 | | - |
178 | } | 0 |
179 | | - |
180 | int QPaintBuffer::frameStartIndex(int frame) const | - |
181 | { | - |
182 | return (frame == 0) ? 0 : d_ptr->frames.at(frame - 1); never executed: return (frame == 0) ? 0 : d_ptr->frames.at(frame - 1); | 0 |
183 | } | - |
184 | | - |
185 | int QPaintBuffer::frameEndIndex(int frame) const | - |
186 | { | - |
187 | return (frame == d_ptr->frames.size()) ? d_ptr->commands.size() : d_ptr->frames.at(frame); never executed: return (frame == d_ptr->frames.size()) ? d_ptr->commands.size() : d_ptr->frames.at(frame); | 0 |
188 | } | - |
189 | | - |
190 | int QPaintBuffer::processCommands(QPainter *painter, int begin, int end) const | - |
191 | { | - |
192 | if (!painter || !painter->isActive()) never evaluated: !painter never evaluated: !painter->isActive() | 0 |
193 | return 0; never executed: return 0; | 0 |
194 | | - |
195 | QPaintEngineEx *xengine = painter->paintEngine()->isExtended() never evaluated: painter->paintEngine()->isExtended() | 0 |
196 | ? (QPaintEngineEx *) painter->paintEngine() : 0; | - |
197 | if (xengine) { | 0 |
198 | QPaintEngineExReplayer player; | - |
199 | player.processCommands(*this, painter, begin, end); | - |
200 | } else { | 0 |
201 | QPainterReplayer player; | - |
202 | player.processCommands(*this, painter, begin, end); | - |
203 | } | 0 |
204 | | - |
205 | int depth = 0; | - |
206 | for (int i = begin; i < end; ++i) { | 0 |
207 | const QPaintBufferCommand &cmd = d_ptr->commands.at(i); | - |
208 | if (cmd.id == QPaintBufferPrivate::Cmd_Save) never evaluated: cmd.id == QPaintBufferPrivate::Cmd_Save | 0 |
209 | ++depth; | 0 |
210 | else if (cmd.id == QPaintBufferPrivate::Cmd_Restore) never evaluated: cmd.id == QPaintBufferPrivate::Cmd_Restore | 0 |
211 | --depth; | 0 |
212 | } | - |
213 | return depth; never executed: return depth; | 0 |
214 | } | - |
215 | | - |
216 | | - |
217 | QString QPaintBuffer::commandDescription(int command) const | - |
218 | { | - |
219 | QString desc; | - |
220 | QDebug debug(&desc); | - |
221 | | - |
222 | const QPaintBufferCommand &cmd = d_ptr->commands.at(command); | - |
223 | | - |
224 | switch (cmd.id) { | - |
225 | case QPaintBufferPrivate::Cmd_Save: { | - |
226 | debug << "Cmd_Save"; | - |
227 | break; } | 0 |
228 | | - |
229 | case QPaintBufferPrivate::Cmd_Restore: { | - |
230 | debug << "Cmd_Restore"; | - |
231 | break; } | 0 |
232 | | - |
233 | case QPaintBufferPrivate::Cmd_SetBrush: { | - |
234 | QBrush brush = qvariant_cast<QBrush>(d_ptr->variants.at(cmd.offset)); | - |
235 | debug << "Cmd_SetBrush: " << brush; | - |
236 | break; } | 0 |
237 | | - |
238 | case QPaintBufferPrivate::Cmd_SetBrushOrigin: { | - |
239 | debug << "Cmd_SetBrushOrigin: " << d_ptr->variants.at(cmd.offset).toPointF(); | - |
240 | break; } | 0 |
241 | | - |
242 | case QPaintBufferPrivate::Cmd_SetCompositionMode: { | - |
243 | QPainter::CompositionMode mode = (QPainter::CompositionMode) cmd.extra; | - |
244 | debug << "ExCmd_SetCompositionMode, mode: " << mode; | - |
245 | break; } | 0 |
246 | | - |
247 | case QPaintBufferPrivate::Cmd_SetOpacity: { | - |
248 | debug << "ExCmd_SetOpacity: " << d_ptr->variants.at(cmd.offset).toDouble(); | - |
249 | break; } | 0 |
250 | | - |
251 | case QPaintBufferPrivate::Cmd_DrawVectorPath: { | - |
252 | debug << "ExCmd_DrawVectorPath: size: " << cmd.size | - |
253 | | - |
254 | << "pts/elms:" << cmd.offset << cmd.offset2; | - |
255 | break; } | 0 |
256 | | - |
257 | case QPaintBufferPrivate::Cmd_StrokeVectorPath: { | - |
258 | QPen pen = qvariant_cast<QPen>(d_ptr->variants.at(cmd.extra)); | - |
259 | debug << "ExCmd_StrokeVectorPath: size: " << cmd.size | - |
260 | | - |
261 | << "pts/elms:" << cmd.offset << cmd.offset2 << pen; | - |
262 | break; } | 0 |
263 | | - |
264 | case QPaintBufferPrivate::Cmd_FillVectorPath: { | - |
265 | QBrush brush = qvariant_cast<QBrush>(d_ptr->variants.at(cmd.extra)); | - |
266 | debug << "ExCmd_FillVectorPath: size: " << cmd.size | - |
267 | | - |
268 | << "pts/elms:" << cmd.offset << cmd.offset2 << brush; | - |
269 | break; } | 0 |
270 | | - |
271 | case QPaintBufferPrivate::Cmd_FillRectBrush: { | - |
272 | QBrush brush = qvariant_cast<QBrush>(d_ptr->variants.at(cmd.extra)); | - |
273 | QRectF *rect = (QRectF *)(d_ptr->floats.constData() + cmd.offset); | - |
274 | debug << "ExCmd_FillRectBrush, offset: " << cmd.offset << " rect: " << *rect << " brush: " << brush; | - |
275 | break; } | 0 |
276 | | - |
277 | case QPaintBufferPrivate::Cmd_FillRectColor: { | - |
278 | QColor color = qvariant_cast<QColor>(d_ptr->variants.at(cmd.extra)); | - |
279 | QRectF *rect = (QRectF *)(d_ptr->floats.constData() + cmd.offset); | - |
280 | debug << "ExCmd_FillRectBrush, offset: " << cmd.offset << " rect: " << *rect << " color: " << color; | - |
281 | break; } | 0 |
282 | | - |
283 | case QPaintBufferPrivate::Cmd_DrawPolygonF: { | - |
284 | debug << "ExCmd_DrawPolygonF, offset: " << cmd.offset << " size: " << cmd.size | - |
285 | << " mode: " << cmd.extra | - |
286 | << d_ptr->floats.at(cmd.offset) | - |
287 | << d_ptr->floats.at(cmd.offset+1); | - |
288 | break; } | 0 |
289 | | - |
290 | case QPaintBufferPrivate::Cmd_DrawPolygonI: { | - |
291 | debug << "ExCmd_DrawPolygonI, offset: " << cmd.offset << " size: " << cmd.size | - |
292 | << " mode: " << cmd.extra | - |
293 | << d_ptr->ints.at(cmd.offset) | - |
294 | << d_ptr->ints.at(cmd.offset+1); | - |
295 | break; } | 0 |
296 | | - |
297 | case QPaintBufferPrivate::Cmd_DrawEllipseF: { | - |
298 | debug << "ExCmd_DrawEllipseF, offset: " << cmd.offset; | - |
299 | break; } | 0 |
300 | | - |
301 | case QPaintBufferPrivate::Cmd_DrawLineF: { | - |
302 | debug << "ExCmd_DrawLineF, offset: " << cmd.offset << " size: " << cmd.size; | - |
303 | break; } | 0 |
304 | | - |
305 | case QPaintBufferPrivate::Cmd_DrawLineI: { | - |
306 | debug << "ExCmd_DrawLineI, offset: " << cmd.offset << " size: " << cmd.size; | - |
307 | break; } | 0 |
308 | | - |
309 | case QPaintBufferPrivate::Cmd_DrawPointsF: { | - |
310 | debug << "ExCmd_DrawPointsF, offset: " << cmd.offset << " size: " << cmd.size; | - |
311 | break; } | 0 |
312 | | - |
313 | case QPaintBufferPrivate::Cmd_DrawPointsI: { | - |
314 | debug << "ExCmd_DrawPointsI, offset: " << cmd.offset << " size: " << cmd.size; | - |
315 | break; } | 0 |
316 | | - |
317 | case QPaintBufferPrivate::Cmd_DrawPolylineF: { | - |
318 | debug << "ExCmd_DrawPolylineF, offset: " << cmd.offset << " size: " << cmd.size; | - |
319 | break; } | 0 |
320 | | - |
321 | case QPaintBufferPrivate::Cmd_DrawPolylineI: { | - |
322 | debug << "ExCmd_DrawPolylineI, offset: " << cmd.offset << " size: " << cmd.size; | - |
323 | break; } | 0 |
324 | | - |
325 | case QPaintBufferPrivate::Cmd_DrawRectF: { | - |
326 | debug << "ExCmd_DrawRectF, offset: " << cmd.offset << " size: " << cmd.size; | - |
327 | break; } | 0 |
328 | | - |
329 | case QPaintBufferPrivate::Cmd_DrawRectI: { | - |
330 | debug << "ExCmd_DrawRectI, offset: " << cmd.offset << " size: " << cmd.size; | - |
331 | break; } | 0 |
332 | | - |
333 | case QPaintBufferPrivate::Cmd_SetClipEnabled: { | - |
334 | bool clipEnabled = d_ptr->variants.at(cmd.offset).toBool(); | - |
335 | debug << "ExCmd_SetClipEnabled:" << clipEnabled; | - |
336 | break; } | 0 |
337 | | - |
338 | case QPaintBufferPrivate::Cmd_ClipVectorPath: { | - |
339 | QVectorPathCmd path(d_ptr, cmd); | - |
340 | debug << "ExCmd_ClipVectorPath:" << path().elementCount(); | - |
341 | break; } | 0 |
342 | | - |
343 | case QPaintBufferPrivate::Cmd_ClipRect: { | - |
344 | QRect rect(QPoint(d_ptr->ints.at(cmd.offset), d_ptr->ints.at(cmd.offset + 1)), | - |
345 | QPoint(d_ptr->ints.at(cmd.offset + 2), d_ptr->ints.at(cmd.offset + 3))); | - |
346 | debug << "ExCmd_ClipRect:" << rect << cmd.extra; | - |
347 | break; } | 0 |
348 | | - |
349 | case QPaintBufferPrivate::Cmd_ClipRegion: { | - |
350 | QRegion region(d_ptr->variants.at(cmd.offset).value<QRegion>()); | - |
351 | debug << "ExCmd_ClipRegion:" << region.boundingRect() << cmd.extra; | - |
352 | break; } | 0 |
353 | | - |
354 | case QPaintBufferPrivate::Cmd_SetPen: { | - |
355 | QPen pen = qvariant_cast<QPen>(d_ptr->variants.at(cmd.offset)); | - |
356 | debug << "Cmd_SetPen: " << pen; | - |
357 | break; } | 0 |
358 | | - |
359 | case QPaintBufferPrivate::Cmd_SetTransform: { | - |
360 | QTransform xform = qvariant_cast<QTransform>(d_ptr->variants.at(cmd.offset)); | - |
361 | debug << "Cmd_SetTransform, offset: " << cmd.offset << xform; | - |
362 | break; } | 0 |
363 | | - |
364 | case QPaintBufferPrivate::Cmd_SetRenderHints: { | - |
365 | debug << "Cmd_SetRenderHints, hints: " << cmd.extra; | - |
366 | break; } | 0 |
367 | | - |
368 | case QPaintBufferPrivate::Cmd_SetBackgroundMode: { | - |
369 | debug << "Cmd_SetBackgroundMode: " << cmd.extra; | - |
370 | break; } | 0 |
371 | | - |
372 | case QPaintBufferPrivate::Cmd_DrawConvexPolygonF: { | - |
373 | debug << "Cmd_DrawConvexPolygonF, offset: " << cmd.offset << " size: " << cmd.size; | - |
374 | break; } | 0 |
375 | | - |
376 | case QPaintBufferPrivate::Cmd_DrawConvexPolygonI: { | - |
377 | debug << "Cmd_DrawConvexPolygonI, offset: " << cmd.offset << " size: " << cmd.size; | - |
378 | break; } | 0 |
379 | | - |
380 | case QPaintBufferPrivate::Cmd_DrawEllipseI: { | - |
381 | debug << "Cmd_DrawEllipseI, offset: " << cmd.offset; | - |
382 | break; } | 0 |
383 | | - |
384 | case QPaintBufferPrivate::Cmd_DrawPixmapRect: { | - |
385 | QPixmap pm(d_ptr->variants.at(cmd.offset).value<QPixmap>()); | - |
386 | QRectF r(d_ptr->floats.at(cmd.extra), d_ptr->floats.at(cmd.extra+1), | - |
387 | d_ptr->floats.at(cmd.extra+2), d_ptr->floats.at(cmd.extra+3)); | - |
388 | | - |
389 | QRectF sr(d_ptr->floats.at(cmd.extra+4), d_ptr->floats.at(cmd.extra+5), | - |
390 | d_ptr->floats.at(cmd.extra+6), d_ptr->floats.at(cmd.extra+7)); | - |
391 | debug << "Cmd_DrawPixmapRect:" << r << sr << pm.size(); | - |
392 | break; } | 0 |
393 | | - |
394 | case QPaintBufferPrivate::Cmd_DrawPixmapPos: { | - |
395 | QPixmap pm(d_ptr->variants.at(cmd.offset).value<QPixmap>()); | - |
396 | QPointF pos(d_ptr->floats.at(cmd.extra), d_ptr->floats.at(cmd.extra+1)); | - |
397 | debug << "Cmd_DrawPixmapPos:" << pos << pm.size(); | - |
398 | break; } | 0 |
399 | | - |
400 | case QPaintBufferPrivate::Cmd_DrawTiledPixmap: { | - |
401 | QPixmap pm(d_ptr->variants.at(cmd.offset).value<QPixmap>()); | - |
402 | QRectF r(d_ptr->floats.at(cmd.extra), d_ptr->floats.at(cmd.extra+1), | - |
403 | d_ptr->floats.at(cmd.extra+2), d_ptr->floats.at(cmd.extra+3)); | - |
404 | | - |
405 | QPointF offset(d_ptr->floats.at(cmd.extra+4), d_ptr->floats.at(cmd.extra+5)); | - |
406 | debug << "Cmd_DrawTiledPixmap:" << r << offset << pm.size(); | - |
407 | break; } | 0 |
408 | | - |
409 | case QPaintBufferPrivate::Cmd_DrawImageRect: { | - |
410 | QImage image(d_ptr->variants.at(cmd.offset).value<QImage>()); | - |
411 | QRectF r(d_ptr->floats.at(cmd.extra), d_ptr->floats.at(cmd.extra+1), | - |
412 | d_ptr->floats.at(cmd.extra+2), d_ptr->floats.at(cmd.extra+3)); | - |
413 | QRectF sr(d_ptr->floats.at(cmd.extra+4), d_ptr->floats.at(cmd.extra+5), | - |
414 | d_ptr->floats.at(cmd.extra+6), d_ptr->floats.at(cmd.extra+7)); | - |
415 | debug << "Cmd_DrawImageRect:" << r << sr << image.size(); | - |
416 | break; } | 0 |
417 | | - |
418 | case QPaintBufferPrivate::Cmd_DrawImagePos: { | - |
419 | QImage image(d_ptr->variants.at(cmd.offset).value<QImage>()); | - |
420 | QPointF pos(d_ptr->floats.at(cmd.extra), d_ptr->floats.at(cmd.extra+1)); | - |
421 | debug << "Cmd_DrawImagePos:" << pos << image.size(); | - |
422 | break; } | 0 |
423 | | - |
424 | case QPaintBufferPrivate::Cmd_DrawText: { | - |
425 | QPointF pos(d_ptr->floats.at(cmd.extra), d_ptr->floats.at(cmd.extra+1)); | - |
426 | QList<QVariant> variants(d_ptr->variants.at(cmd.offset).value<QList<QVariant> >()); | - |
427 | | - |
428 | QFont font(variants.at(0).value<QFont>()); | - |
429 | QString text(variants.at(1).value<QString>()); | - |
430 | | - |
431 | debug << "Cmd_DrawText:" << pos << text << font.family(); | - |
432 | break; } | 0 |
433 | | - |
434 | case QPaintBufferPrivate::Cmd_DrawTextItem: { | - |
435 | QPointF pos(d_ptr->floats.at(cmd.extra), d_ptr->floats.at(cmd.extra+1)); | - |
436 | QTextItemIntCopy *tiCopy = reinterpret_cast<QTextItemIntCopy *>(qvariant_cast<void *>(d_ptr->variants.at(cmd.offset))); | - |
437 | QTextItemInt &ti = (*tiCopy)(); | - |
438 | QString text(ti.text()); | - |
439 | | - |
440 | debug << "Cmd_DrawTextItem:" << pos << " " << text; | - |
441 | break; } | 0 |
442 | case QPaintBufferPrivate::Cmd_SystemStateChanged: { | - |
443 | QRegion systemClip(d_ptr->variants.at(cmd.offset).value<QRegion>()); | - |
444 | | - |
445 | debug << "Cmd_SystemStateChanged:" << systemClip; | - |
446 | break; } | 0 |
447 | case QPaintBufferPrivate::Cmd_Translate: { | - |
448 | QPointF delta(d_ptr->floats.at(cmd.extra), d_ptr->floats.at(cmd.extra+1)); | - |
449 | debug << "Cmd_Translate:" << delta; | - |
450 | break; } | 0 |
451 | case QPaintBufferPrivate::Cmd_DrawStaticText: { | - |
452 | debug << "Cmd_DrawStaticText"; | - |
453 | break; } | 0 |
454 | } | - |
455 | | - |
456 | return desc; never executed: return desc; | 0 |
457 | } | - |
458 | | - |
459 | | - |
460 | QRectF QPaintBuffer::boundingRect() const | - |
461 | { | - |
462 | return d_ptr->boundingRect; never executed: return d_ptr->boundingRect; | 0 |
463 | } | - |
464 | | - |
465 | void QPaintBuffer::setBoundingRect(const QRectF &rect) | - |
466 | { | - |
467 | d_ptr->boundingRect = rect; | - |
468 | d_ptr->calculateBoundingRect = false; | - |
469 | } | 0 |
470 | | - |
471 | | - |
472 | class QPaintBufferEnginePrivate : public QPaintEngineExPrivate | - |
473 | { | - |
474 | inline QPaintBufferEngine* q_func() { return static_cast<QPaintBufferEngine *>(q_ptr); } inline const QPaintBufferEngine* q_func() const { return static_cast<const QPaintBufferEngine *>(q_ptr); } friend class QPaintBufferEngine; | - |
475 | public: | - |
476 | void systemStateChanged() { | - |
477 | QPaintBufferEngine * const q = q_func(); | - |
478 | q->buffer->addCommand(QPaintBufferPrivate::Cmd_SystemStateChanged, QVariant(systemClip)); | - |
479 | } | 0 |
480 | | - |
481 | QTransform last; | - |
482 | }; | - |
483 | QPaintBufferEngine::QPaintBufferEngine(QPaintBufferPrivate *b) | - |
484 | : QPaintEngineEx(*(new QPaintBufferEnginePrivate)) | - |
485 | , buffer(b) | - |
486 | , m_begin_detected(false) | - |
487 | , m_save_detected(false) | - |
488 | , m_stream_raw_text_items(false) | - |
489 | { | - |
490 | } | 0 |
491 | | - |
492 | bool QPaintBufferEngine::begin(QPaintDevice *) | - |
493 | { | - |
494 | QPaintBufferEnginePrivate * const d = d_func(); | - |
495 | painter()->save(); | - |
496 | d->systemStateChanged(); | - |
497 | return true; never executed: return true; | 0 |
498 | } | - |
499 | | - |
500 | bool QPaintBufferEngine::end() | - |
501 | { | - |
502 | painter()->restore(); | - |
503 | m_created_state = 0; | - |
504 | return true; never executed: return true; | 0 |
505 | } | - |
506 | | - |
507 | QPainterState *QPaintBufferEngine::createState(QPainterState *orig) const | - |
508 | { | - |
509 | | - |
510 | | - |
511 | | - |
512 | | - |
513 | qt_noop(); | - |
514 | qt_noop(); | - |
515 | | - |
516 | if (orig == 0) { never evaluated: orig == 0 | 0 |
517 | m_begin_detected = true; | - |
518 | return new QPainterState(); never executed: return new QPainterState(); | 0 |
519 | } else { | - |
520 | m_save_detected = true; | - |
521 | return new QPainterState(orig); never executed: return new QPainterState(orig); | 0 |
522 | } | - |
523 | } | - |
524 | | - |
525 | void QPaintBufferEngine::clip(const QVectorPath &path, Qt::ClipOperation op) | - |
526 | { | - |
527 | | - |
528 | | - |
529 | | - |
530 | QPaintBufferCommand *cmd = | - |
531 | buffer->addCommand(QPaintBufferPrivate::Cmd_ClipVectorPath, path); | - |
532 | cmd->extra = op; | - |
533 | } | 0 |
534 | | - |
535 | void QPaintBufferEngine::clip(const QRect &rect, Qt::ClipOperation op) | - |
536 | { | - |
537 | | - |
538 | | - |
539 | | - |
540 | QPaintBufferCommand *cmd = | - |
541 | buffer->addCommand(QPaintBufferPrivate::Cmd_ClipRect, (int *) &rect, 4, 1); | - |
542 | cmd->extra = op; | - |
543 | } | 0 |
544 | | - |
545 | void QPaintBufferEngine::clip(const QRegion ®ion, Qt::ClipOperation op) | - |
546 | { | - |
547 | | - |
548 | | - |
549 | | - |
550 | QPaintBufferCommand *cmd = | - |
551 | buffer->addCommand(QPaintBufferPrivate::Cmd_ClipRegion, QVariant(region)); | - |
552 | cmd->extra = op; | - |
553 | } | 0 |
554 | | - |
555 | void QPaintBufferEngine::clip(const QPainterPath &path, Qt::ClipOperation op) | - |
556 | { | - |
557 | | - |
558 | | - |
559 | | - |
560 | | - |
561 | QPaintEngineEx::clip(path, op); | - |
562 | } | 0 |
563 | | - |
564 | void QPaintBufferEngine::clipEnabledChanged() | - |
565 | { | - |
566 | | - |
567 | | - |
568 | | - |
569 | | - |
570 | buffer->addCommand(QPaintBufferPrivate::Cmd_SetClipEnabled, state()->clipEnabled); | - |
571 | } | 0 |
572 | | - |
573 | void QPaintBufferEngine::penChanged() | - |
574 | { | - |
575 | const QPen &pen = state()->pen; | - |
576 | | - |
577 | if (!buffer->commands.isEmpty() never evaluated: !buffer->commands.isEmpty() | 0 |
578 | && buffer->commands.last().id == QPaintBufferPrivate::Cmd_SetPen) { never evaluated: buffer->commands.last().id == QPaintBufferPrivate::Cmd_SetPen | 0 |
579 | | - |
580 | | - |
581 | | - |
582 | buffer->variants[buffer->commands.last().offset] = pen; | - |
583 | return; | 0 |
584 | } | - |
585 | | - |
586 | if (buffer->calculateBoundingRect) { never evaluated: buffer->calculateBoundingRect | 0 |
587 | if (pen.style() == Qt::NoPen) { never evaluated: pen.style() == Qt::NoPen | 0 |
588 | buffer->penWidthAdjustment = 0; | - |
589 | } else { | 0 |
590 | qreal penWidth = (pen.widthF() == 0) ? 1 : pen.widthF(); never evaluated: (pen.widthF() == 0) | 0 |
591 | QPointF transformedWidth(penWidth, penWidth); | - |
592 | if (!qt_pen_is_cosmetic(pen, state()->renderHints)) never evaluated: !qt_pen_is_cosmetic(pen, state()->renderHints) | 0 |
593 | transformedWidth = painter()->transform().map(transformedWidth); never executed: transformedWidth = painter()->transform().map(transformedWidth); | 0 |
594 | buffer->penWidthAdjustment = transformedWidth.x() / 2.0; | - |
595 | } | 0 |
596 | } | - |
597 | | - |
598 | | - |
599 | | - |
600 | buffer->addCommand(QPaintBufferPrivate::Cmd_SetPen, pen); | - |
601 | } | 0 |
602 | | - |
603 | void QPaintBufferEngine::brushChanged() | - |
604 | { | - |
605 | const QBrush &brush = state()->brush; | - |
606 | | - |
607 | if (!buffer->commands.isEmpty() never evaluated: !buffer->commands.isEmpty() | 0 |
608 | && buffer->commands.last().id == QPaintBufferPrivate::Cmd_SetBrush) { never evaluated: buffer->commands.last().id == QPaintBufferPrivate::Cmd_SetBrush | 0 |
609 | | - |
610 | | - |
611 | | - |
612 | buffer->variants[buffer->commands.last().offset] = brush; | - |
613 | return; | 0 |
614 | } | - |
615 | | - |
616 | | - |
617 | | - |
618 | | - |
619 | buffer->addCommand(QPaintBufferPrivate::Cmd_SetBrush, brush); | - |
620 | } | 0 |
621 | | - |
622 | void QPaintBufferEngine::brushOriginChanged() | - |
623 | { | - |
624 | | - |
625 | | - |
626 | | - |
627 | buffer->addCommand(QPaintBufferPrivate::Cmd_SetBrushOrigin, state()->brushOrigin); | - |
628 | } | 0 |
629 | | - |
630 | void QPaintBufferEngine::opacityChanged() | - |
631 | { | - |
632 | | - |
633 | | - |
634 | | - |
635 | buffer->addCommand(QPaintBufferPrivate::Cmd_SetOpacity, state()->opacity); | - |
636 | } | 0 |
637 | | - |
638 | void QPaintBufferEngine::compositionModeChanged() | - |
639 | { | - |
640 | | - |
641 | | - |
642 | | - |
643 | QPaintBufferCommand *cmd = | - |
644 | buffer->addCommand(QPaintBufferPrivate::Cmd_SetCompositionMode); | - |
645 | cmd->extra = state()->composition_mode; | - |
646 | } | 0 |
647 | | - |
648 | void QPaintBufferEngine::renderHintsChanged() | - |
649 | { | - |
650 | | - |
651 | | - |
652 | | - |
653 | QPaintBufferCommand *cmd = | - |
654 | buffer->addCommand(QPaintBufferPrivate::Cmd_SetRenderHints); | - |
655 | cmd->extra = state()->renderHints; | - |
656 | } | 0 |
657 | | - |
658 | void QPaintBufferEngine::transformChanged() | - |
659 | { | - |
660 | QPaintBufferEnginePrivate * const d = d_func(); | - |
661 | const QTransform &transform = state()->matrix; | - |
662 | | - |
663 | QTransform delta; | - |
664 | | - |
665 | bool invertible = false; | - |
666 | if (transform.type() <= QTransform::TxScale && transform.type() == d->last.type()) never evaluated: transform.type() <= QTransform::TxScale never evaluated: transform.type() == d->last.type() | 0 |
667 | delta = transform * d->last.inverted(&invertible); never executed: delta = transform * d->last.inverted(&invertible); | 0 |
668 | | - |
669 | d->last = transform; | - |
670 | | - |
671 | if (invertible && delta.type() == QTransform::TxNone) never evaluated: invertible never evaluated: delta.type() == QTransform::TxNone | 0 |
672 | return; | 0 |
673 | | - |
674 | if (invertible && delta.type() == QTransform::TxTranslate) { never evaluated: invertible never evaluated: delta.type() == QTransform::TxTranslate | 0 |
675 | | - |
676 | | - |
677 | | - |
678 | QPaintBufferCommand *cmd = | - |
679 | buffer->addCommand(QPaintBufferPrivate::Cmd_Translate); | - |
680 | | - |
681 | qreal data[] = { delta.dx(), delta.dy() }; | - |
682 | cmd->extra = buffer->addData((qreal *) data, 2); | - |
683 | return; | 0 |
684 | } | - |
685 | | - |
686 | | - |
687 | if (!buffer->commands.isEmpty() never evaluated: !buffer->commands.isEmpty() | 0 |
688 | && buffer->commands.last().id == QPaintBufferPrivate::Cmd_SetTransform) { never evaluated: buffer->commands.last().id == QPaintBufferPrivate::Cmd_SetTransform | 0 |
689 | | - |
690 | | - |
691 | | - |
692 | buffer->variants[buffer->commands.last().offset] = state()->matrix; | - |
693 | return; | 0 |
694 | } | - |
695 | | - |
696 | | - |
697 | | - |
698 | | - |
699 | buffer->addCommand(QPaintBufferPrivate::Cmd_SetTransform, state()->matrix); | - |
700 | } | 0 |
701 | | - |
702 | void QPaintBufferEngine::backgroundModeChanged() | - |
703 | { | - |
704 | | - |
705 | | - |
706 | | - |
707 | QPaintBufferCommand *cmd = buffer->addCommand(QPaintBufferPrivate::Cmd_SetBackgroundMode); | - |
708 | cmd->extra = state()->bgMode; | - |
709 | } | 0 |
710 | | - |
711 | void QPaintBufferEngine::draw(const QVectorPath &path) | - |
712 | { | - |
713 | | - |
714 | | - |
715 | | - |
716 | | - |
717 | bool hasBrush = qbrush_style(state()->brush) != Qt::NoBrush; | - |
718 | bool hasPen = qpen_style(state()->pen) != Qt::NoPen never evaluated: qpen_style(state()->pen) != Qt::NoPen | 0 |
719 | && qbrush_style(qpen_brush(state()->pen)) != Qt::NoBrush; never evaluated: qbrush_style(qpen_brush(state()->pen)) != Qt::NoBrush | 0 |
720 | | - |
721 | if (hasPen || hasBrush) never evaluated: hasBrush | 0 |
722 | buffer->addCommand(QPaintBufferPrivate::Cmd_DrawVectorPath, path); never executed: buffer->addCommand(QPaintBufferPrivate::Cmd_DrawVectorPath, path); | 0 |
723 | } | 0 |
724 | | - |
725 | void QPaintBufferEngine::fill(const QVectorPath &path, const QBrush &brush) | - |
726 | { | - |
727 | | - |
728 | | - |
729 | | - |
730 | QPaintBufferCommand *cmd = | - |
731 | buffer->addCommand(QPaintBufferPrivate::Cmd_FillVectorPath, path); | - |
732 | cmd->extra = buffer->addData(QVariant(brush)); | - |
733 | | - |
734 | | - |
735 | | - |
736 | | - |
737 | } | 0 |
738 | | - |
739 | void QPaintBufferEngine::stroke(const QVectorPath &path, const QPen &pen) | - |
740 | { | - |
741 | | - |
742 | | - |
743 | | - |
744 | QPaintBufferCommand *cmd = | - |
745 | buffer->addCommand(QPaintBufferPrivate::Cmd_StrokeVectorPath, path); | - |
746 | cmd->extra = buffer->addData(QVariant(pen)); | - |
747 | | - |
748 | | - |
749 | | - |
750 | | - |
751 | } | 0 |
752 | | - |
753 | void QPaintBufferEngine::fillRect(const QRectF &rect, const QBrush &brush) | - |
754 | { | - |
755 | | - |
756 | | - |
757 | | - |
758 | QPaintBufferCommand *cmd = | - |
759 | buffer->addCommand(QPaintBufferPrivate::Cmd_FillRectBrush, (qreal *) &rect, 4, 1); | - |
760 | cmd->extra = buffer->addData(brush); | - |
761 | if (buffer->calculateBoundingRect) never evaluated: buffer->calculateBoundingRect | 0 |
762 | buffer->updateBoundingRect(rect); never executed: buffer->updateBoundingRect(rect); | 0 |
763 | } | 0 |
764 | | - |
765 | void QPaintBufferEngine::fillRect(const QRectF &rect, const QColor &color) | - |
766 | { | - |
767 | | - |
768 | | - |
769 | | - |
770 | QPaintBufferCommand *cmd = | - |
771 | buffer->addCommand(QPaintBufferPrivate::Cmd_FillRectColor, (qreal *) &rect, 4, 1); | - |
772 | cmd->extra = buffer->addData(color); | - |
773 | if (buffer->calculateBoundingRect) never evaluated: buffer->calculateBoundingRect | 0 |
774 | buffer->updateBoundingRect(rect); never executed: buffer->updateBoundingRect(rect); | 0 |
775 | } | 0 |
776 | | - |
777 | void QPaintBufferEngine::drawRects(const QRect *rects, int rectCount) | - |
778 | { | - |
779 | | - |
780 | | - |
781 | | - |
782 | QPaintBufferCommand *cmd = | - |
783 | buffer->addCommand(QPaintBufferPrivate::Cmd_DrawRectI, (int *) rects, 4 * rectCount, rectCount); | - |
784 | cmd->extra = rectCount; | - |
785 | | - |
786 | if (buffer->calculateBoundingRect) { never evaluated: buffer->calculateBoundingRect | 0 |
787 | if (rectCount == 1) { never evaluated: rectCount == 1 | 0 |
788 | buffer->updateBoundingRect(rects[0]); | - |
789 | } else { | 0 |
790 | int min_x = rects[0].left(); | - |
791 | int min_y = rects[0].top(); | - |
792 | int max_x = rects[0].left() + rects[0].width(); | - |
793 | int max_y = rects[0].top() + rects[0].height(); | - |
794 | for (int i=1; i< rectCount; ++i) { never evaluated: i< rectCount | 0 |
795 | if (rects[i].left() < min_x) never evaluated: rects[i].left() < min_x | 0 |
796 | min_x = rects[i].left(); never executed: min_x = rects[i].left(); | 0 |
797 | if (rects[i].top() < min_y) never evaluated: rects[i].top() < min_y | 0 |
798 | min_y = rects[i].top(); never executed: min_y = rects[i].top(); | 0 |
799 | if (rects[i].right() > max_x) never evaluated: rects[i].right() > max_x | 0 |
800 | max_x = rects[i].left() + rects[i].width(); never executed: max_x = rects[i].left() + rects[i].width(); | 0 |
801 | if (rects[i].bottom() > max_y) never evaluated: rects[i].bottom() > max_y | 0 |
802 | max_y = rects[i].top() + rects[i].height(); never executed: max_y = rects[i].top() + rects[i].height(); | 0 |
803 | | - |
804 | } | 0 |
805 | buffer->updateBoundingRect(QRectF(min_x, min_y, max_x - min_x, max_y - min_y)); | - |
806 | } | 0 |
807 | } | - |
808 | } | 0 |
809 | | - |
810 | void QPaintBufferEngine::drawRects(const QRectF *rects, int rectCount) | - |
811 | { | - |
812 | | - |
813 | | - |
814 | | - |
815 | QPaintBufferCommand *cmd = | - |
816 | buffer->addCommand(QPaintBufferPrivate::Cmd_DrawRectF, (qreal *) rects, 4 * rectCount, rectCount); | - |
817 | cmd->extra = rectCount; | - |
818 | | - |
819 | if (buffer->calculateBoundingRect) { never evaluated: buffer->calculateBoundingRect | 0 |
820 | if (rectCount == 1) { never evaluated: rectCount == 1 | 0 |
821 | buffer->updateBoundingRect(rects[0]); | - |
822 | } else { | 0 |
823 | qreal min_x = rects[0].left(); | - |
824 | qreal min_y = rects[0].top(); | - |
825 | qreal max_x = rects[0].right(); | - |
826 | qreal max_y = rects[0].bottom(); | - |
827 | for (int i=1; i< rectCount; ++i) { never evaluated: i< rectCount | 0 |
828 | if (rects[i].left() < min_x) never evaluated: rects[i].left() < min_x | 0 |
829 | min_x = rects[i].left(); never executed: min_x = rects[i].left(); | 0 |
830 | if (rects[i].top() < min_y) never evaluated: rects[i].top() < min_y | 0 |
831 | min_y = rects[i].top(); never executed: min_y = rects[i].top(); | 0 |
832 | if (rects[i].right() > max_x) never evaluated: rects[i].right() > max_x | 0 |
833 | max_x = rects[i].right(); never executed: max_x = rects[i].right(); | 0 |
834 | if (rects[i].bottom() > max_y) never evaluated: rects[i].bottom() > max_y | 0 |
835 | max_y = rects[i].bottom(); never executed: max_y = rects[i].bottom(); | 0 |
836 | | - |
837 | } | 0 |
838 | buffer->updateBoundingRect(QRectF(min_x, min_y, max_x - min_x, max_y - min_y)); | - |
839 | } | 0 |
840 | } | - |
841 | } | 0 |
842 | | - |
843 | void QPaintBufferEngine::drawLines(const QLine *lines, int lineCount) | - |
844 | { | - |
845 | | - |
846 | | - |
847 | | - |
848 | QPaintBufferCommand *cmd = | - |
849 | buffer->addCommand(QPaintBufferPrivate::Cmd_DrawLineI, (int *) lines, 4 * lineCount, lineCount); | - |
850 | cmd->extra = lineCount; | - |
851 | | - |
852 | if (buffer->calculateBoundingRect) { never evaluated: buffer->calculateBoundingRect | 0 |
853 | int min_x = lines[0].p1().x(); | - |
854 | int min_y = lines[0].p1().y(); | - |
855 | int max_x = lines[0].p2().x(); | - |
856 | int max_y = lines[0].p2().y(); | - |
857 | if (min_x > max_x) never evaluated: min_x > max_x | 0 |
858 | qSwap(min_x, max_x); never executed: qSwap(min_x, max_x); | 0 |
859 | if (min_y > max_y) never evaluated: min_y > max_y | 0 |
860 | qSwap(min_y, max_y); never executed: qSwap(min_y, max_y); | 0 |
861 | for (int i=1; i < lineCount; ++i) { never evaluated: i < lineCount | 0 |
862 | int p1_x = lines[i].p1().x(); | - |
863 | int p1_y = lines[i].p1().y(); | - |
864 | int p2_x = lines[i].p2().x(); | - |
865 | int p2_y = lines[i].p2().y(); | - |
866 | if (p1_x > p2_x) { never evaluated: p1_x > p2_x | 0 |
867 | min_x = qMin(p2_x, min_x); | - |
868 | max_x = qMax(p1_x, max_x); | - |
869 | } else { | 0 |
870 | min_x = qMin(p1_x, min_x); | - |
871 | max_x = qMax(p2_x, max_x); | - |
872 | } | 0 |
873 | if (p1_y > p2_y) { never evaluated: p1_y > p2_y | 0 |
874 | min_y = qMin(p2_y, min_y); | - |
875 | max_y = qMax(p1_y, max_y); | - |
876 | } else { | 0 |
877 | min_y = qMin(p1_y, min_y); | - |
878 | max_y = qMax(p2_y, max_y); | - |
879 | } | 0 |
880 | } | - |
881 | buffer->updateBoundingRect(QRectF(min_x, min_y, max_x - min_x, max_y - min_y)); | - |
882 | } | 0 |
883 | } | 0 |
884 | | - |
885 | void QPaintBufferEngine::drawLines(const QLineF *lines, int lineCount) | - |
886 | { | - |
887 | | - |
888 | | - |
889 | | - |
890 | QPaintBufferCommand *cmd = | - |
891 | buffer->addCommand(QPaintBufferPrivate::Cmd_DrawLineF, (qreal *) lines, 4 * lineCount, lineCount); | - |
892 | cmd->extra = lineCount; | - |
893 | | - |
894 | if (buffer->calculateBoundingRect) { never evaluated: buffer->calculateBoundingRect | 0 |
895 | qreal min_x = lines[0].p1().x(); | - |
896 | qreal min_y = lines[0].p1().y(); | - |
897 | qreal max_x = lines[0].p2().x(); | - |
898 | qreal max_y = lines[0].p2().y(); | - |
899 | if (min_x > max_x) never evaluated: min_x > max_x | 0 |
900 | qSwap(min_x, max_x); never executed: qSwap(min_x, max_x); | 0 |
901 | if (min_y > max_y) never evaluated: min_y > max_y | 0 |
902 | qSwap(min_y, max_y); never executed: qSwap(min_y, max_y); | 0 |
903 | for (int i=1; i < lineCount; ++i) { never evaluated: i < lineCount | 0 |
904 | qreal p1_x = lines[i].p1().x(); | - |
905 | qreal p1_y = lines[i].p1().y(); | - |
906 | qreal p2_x = lines[i].p2().x(); | - |
907 | qreal p2_y = lines[i].p2().y(); | - |
908 | if (p1_x > p2_x) { never evaluated: p1_x > p2_x | 0 |
909 | min_x = qMin(p2_x, min_x); | - |
910 | max_x = qMax(p1_x, max_x); | - |
911 | } else { | 0 |
912 | min_x = qMin(p1_x, min_x); | - |
913 | max_x = qMax(p2_x, max_x); | - |
914 | } | 0 |
915 | if (p1_y > p2_y) { never evaluated: p1_y > p2_y | 0 |
916 | min_y = qMin(p2_y, min_y); | - |
917 | max_y = qMax(p1_y, max_y); | - |
918 | } else { | 0 |
919 | min_y = qMin(p1_y, min_y); | - |
920 | max_y = qMax(p2_y, max_y); | - |
921 | } | 0 |
922 | } | - |
923 | buffer->updateBoundingRect(QRectF(min_x, min_y, max_x - min_x, max_y - min_y)); | - |
924 | } | 0 |
925 | } | 0 |
926 | | - |
927 | void QPaintBufferEngine::drawEllipse(const QRectF &r) | - |
928 | { | - |
929 | | - |
930 | | - |
931 | | - |
932 | buffer->addCommand(QPaintBufferPrivate::Cmd_DrawEllipseF, (qreal *) &r, 4, 1); | - |
933 | if (buffer->calculateBoundingRect) never evaluated: buffer->calculateBoundingRect | 0 |
934 | buffer->updateBoundingRect(r); never executed: buffer->updateBoundingRect(r); | 0 |
935 | } | 0 |
936 | | - |
937 | void QPaintBufferEngine::drawEllipse(const QRect &r) | - |
938 | { | - |
939 | | - |
940 | | - |
941 | | - |
942 | buffer->addCommand(QPaintBufferPrivate::Cmd_DrawEllipseI, (int *) &r, 4, 1); | - |
943 | if (buffer->calculateBoundingRect) never evaluated: buffer->calculateBoundingRect | 0 |
944 | buffer->updateBoundingRect(r); never executed: buffer->updateBoundingRect(r); | 0 |
945 | } | 0 |
946 | | - |
947 | void QPaintBufferEngine::drawPath(const QPainterPath &path) | - |
948 | { | - |
949 | | - |
950 | | - |
951 | | - |
952 | | - |
953 | | - |
954 | QPaintEngineEx::drawPath(path); | - |
955 | | - |
956 | | - |
957 | | - |
958 | } | 0 |
959 | | - |
960 | void QPaintBufferEngine::drawPoints(const QPoint *points, int pointCount) | - |
961 | { | - |
962 | | - |
963 | | - |
964 | | - |
965 | buffer->addCommand(QPaintBufferPrivate::Cmd_DrawPointsI, (int *) points, 2 * pointCount, pointCount); | - |
966 | | - |
967 | if (buffer->calculateBoundingRect) { never evaluated: buffer->calculateBoundingRect | 0 |
968 | int min_x = points[0].x(); | - |
969 | int min_y = points[0].y(); | - |
970 | int max_x = points[0].x()+1; | - |
971 | int max_y = points[0].y()+1; | - |
972 | for (int i=1; i<pointCount; ++i) { never evaluated: i<pointCount | 0 |
973 | int x = points[i].x(); | - |
974 | int y = points[i].y(); | - |
975 | min_x = qMin(min_x, x); | - |
976 | min_y = qMin(min_y, y); | - |
977 | max_x = qMax(max_x, x+1); | - |
978 | max_y = qMax(max_y, y+1); | - |
979 | } | 0 |
980 | buffer->updateBoundingRect(QRectF(min_x, min_y, max_x - min_x, max_y - min_y)); | - |
981 | } | 0 |
982 | } | 0 |
983 | | - |
984 | void QPaintBufferEngine::drawPoints(const QPointF *points, int pointCount) | - |
985 | { | - |
986 | | - |
987 | | - |
988 | | - |
989 | buffer->addCommand(QPaintBufferPrivate::Cmd_DrawPointsF, (qreal *) points, 2 * pointCount, pointCount); | - |
990 | | - |
991 | if (buffer->calculateBoundingRect) { never evaluated: buffer->calculateBoundingRect | 0 |
992 | qreal min_x = points[0].x(); | - |
993 | qreal min_y = points[0].y(); | - |
994 | qreal max_x = points[0].x()+1; | - |
995 | qreal max_y = points[0].y()+1; | - |
996 | for (int i=1; i<pointCount; ++i) { never evaluated: i<pointCount | 0 |
997 | qreal x = points[i].x(); | - |
998 | qreal y = points[i].y(); | - |
999 | min_x = qMin(min_x, x); | - |
1000 | min_y = qMin(min_y, y); | - |
1001 | max_x = qMax(max_x, x+1); | - |
1002 | max_y = qMax(max_y, y+1); | - |
1003 | } | 0 |
1004 | buffer->updateBoundingRect(QRectF(min_x, min_y, max_x - min_x, max_y - min_y)); | - |
1005 | } | 0 |
1006 | } | 0 |
1007 | | - |
1008 | void QPaintBufferEngine::drawPolygon(const QPoint *pts, int count, PolygonDrawMode mode) | - |
1009 | { | - |
1010 | | - |
1011 | | - |
1012 | | - |
1013 | if (mode == QPaintEngine::OddEvenMode || mode == QPaintEngine::WindingMode) { never evaluated: mode == QPaintEngine::OddEvenMode never evaluated: mode == QPaintEngine::WindingMode | 0 |
1014 | QPaintBufferCommand *cmd = buffer->addCommand(QPaintBufferPrivate::Cmd_DrawPolygonI, | - |
1015 | (int *) pts, 2 * count, count); | - |
1016 | cmd->extra = mode; | - |
1017 | } else if (mode == QPaintEngine::PolylineMode) { never evaluated: mode == QPaintEngine::PolylineMode | 0 |
1018 | buffer->addCommand(QPaintBufferPrivate::Cmd_DrawPolylineI, (int *) pts, 2 * count, count); | - |
1019 | } else { | 0 |
1020 | buffer->addCommand(QPaintBufferPrivate::Cmd_DrawConvexPolygonI, (int *) pts, 2 * count, count); | - |
1021 | } | 0 |
1022 | | - |
1023 | if (buffer->calculateBoundingRect) { never evaluated: buffer->calculateBoundingRect | 0 |
1024 | int min_x = pts[0].x(); | - |
1025 | int min_y = pts[0].y(); | - |
1026 | int max_x = pts[0].x(); | - |
1027 | int max_y = pts[0].y(); | - |
1028 | for (int i=1; i<count; ++i) { | 0 |
1029 | int x = pts[i].x(); | - |
1030 | int y = pts[i].y(); | - |
1031 | min_x = qMin(min_x, x); | - |
1032 | min_y = qMin(min_y, y); | - |
1033 | max_x = qMax(max_x, x); | - |
1034 | max_y = qMax(max_y, y); | - |
1035 | } | 0 |
1036 | buffer->updateBoundingRect(QRectF(min_x, min_y, max_x - min_x, max_y - min_y)); | - |
1037 | } | 0 |
1038 | } | 0 |
1039 | | - |
1040 | void QPaintBufferEngine::drawPolygon(const QPointF *pts, int count, PolygonDrawMode mode) | - |
1041 | { | - |
1042 | | - |
1043 | | - |
1044 | | - |
1045 | if (mode == QPaintEngine::OddEvenMode || mode == QPaintEngine::WindingMode) { never evaluated: mode == QPaintEngine::OddEvenMode never evaluated: mode == QPaintEngine::WindingMode | 0 |
1046 | QPaintBufferCommand *cmd = buffer->addCommand(QPaintBufferPrivate::Cmd_DrawPolygonF, | - |
1047 | (qreal *) pts, 2 * count, count); | - |
1048 | cmd->extra = mode; | - |
1049 | } else if (mode == QPaintEngine::PolylineMode) { never evaluated: mode == QPaintEngine::PolylineMode | 0 |
1050 | buffer->addCommand(QPaintBufferPrivate::Cmd_DrawPolylineF, (qreal *) pts, 2 * count, count); | - |
1051 | } else { | 0 |
1052 | buffer->addCommand(QPaintBufferPrivate::Cmd_DrawConvexPolygonF, (qreal *) pts, 2 * count, count); | - |
1053 | } | 0 |
1054 | | - |
1055 | if (buffer->calculateBoundingRect) { never evaluated: buffer->calculateBoundingRect | 0 |
1056 | qreal min_x = pts[0].x(); | - |
1057 | qreal min_y = pts[0].y(); | - |
1058 | qreal max_x = pts[0].x(); | - |
1059 | qreal max_y = pts[0].y(); | - |
1060 | for (int i=1; i<count; ++i) { | 0 |
1061 | qreal x = pts[i].x(); | - |
1062 | qreal y = pts[i].y(); | - |
1063 | min_x = qMin(min_x, x); | - |
1064 | min_y = qMin(min_y, y); | - |
1065 | max_x = qMax(max_x, x); | - |
1066 | max_y = qMax(max_y, y); | - |
1067 | } | 0 |
1068 | buffer->updateBoundingRect(QRectF(min_x, min_y, max_x - min_x, max_y - min_y)); | - |
1069 | } | 0 |
1070 | } | 0 |
1071 | | - |
1072 | void QPaintBufferEngine::drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) | - |
1073 | { | - |
1074 | | - |
1075 | | - |
1076 | | - |
1077 | QPaintBufferCommand *cmd = | - |
1078 | buffer->addCommand(QPaintBufferPrivate::Cmd_DrawPixmapRect, QVariant(pm)); | - |
1079 | cmd->extra = buffer->addData((qreal *) &r, 4); | - |
1080 | buffer->addData((qreal *) &sr, 4); | - |
1081 | if (buffer->calculateBoundingRect) never evaluated: buffer->calculateBoundingRect | 0 |
1082 | buffer->updateBoundingRect(r); never executed: buffer->updateBoundingRect(r); | 0 |
1083 | } | 0 |
1084 | | - |
1085 | void QPaintBufferEngine::drawPixmap(const QPointF &pos, const QPixmap &pm) | - |
1086 | { | - |
1087 | | - |
1088 | | - |
1089 | | - |
1090 | QPaintBufferCommand *cmd = | - |
1091 | buffer->addCommand(QPaintBufferPrivate::Cmd_DrawPixmapPos, QVariant(pm)); | - |
1092 | cmd->extra = buffer->addData((qreal *) &pos, 2); | - |
1093 | if (buffer->calculateBoundingRect) never evaluated: buffer->calculateBoundingRect | 0 |
1094 | buffer->updateBoundingRect(QRectF(pos, pm.size())); never executed: buffer->updateBoundingRect(QRectF(pos, pm.size())); | 0 |
1095 | } | 0 |
1096 | | - |
1097 | static inline QImage qpaintbuffer_storable_image(const QImage &src) | - |
1098 | { | - |
1099 | QImageData *d = const_cast<QImage &>(src).data_ptr(); | - |
1100 | return d->own_data ? src : src.copy(); never executed: return d->own_data ? src : src.copy(); | 0 |
1101 | } | - |
1102 | | - |
1103 | void QPaintBufferEngine::drawImage(const QRectF &r, const QImage &image, const QRectF &sr, | - |
1104 | Qt::ImageConversionFlags ) | - |
1105 | { | - |
1106 | | - |
1107 | | - |
1108 | | - |
1109 | QPaintBufferCommand *cmd = | - |
1110 | buffer->addCommand(QPaintBufferPrivate::Cmd_DrawImageRect, | - |
1111 | QVariant(qpaintbuffer_storable_image(image))); | - |
1112 | cmd->extra = buffer->addData((qreal *) &r, 4); | - |
1113 | buffer->addData((qreal *) &sr, 4); | - |
1114 | | - |
1115 | if (buffer->calculateBoundingRect) never evaluated: buffer->calculateBoundingRect | 0 |
1116 | buffer->updateBoundingRect(r); never executed: buffer->updateBoundingRect(r); | 0 |
1117 | } | 0 |
1118 | | - |
1119 | void QPaintBufferEngine::drawImage(const QPointF &pos, const QImage &image) | - |
1120 | { | - |
1121 | | - |
1122 | | - |
1123 | | - |
1124 | QPaintBufferCommand *cmd = | - |
1125 | buffer->addCommand(QPaintBufferPrivate::Cmd_DrawImagePos, | - |
1126 | QVariant(qpaintbuffer_storable_image(image))); | - |
1127 | cmd->extra = buffer->addData((qreal *) &pos, 2); | - |
1128 | if (buffer->calculateBoundingRect) never evaluated: buffer->calculateBoundingRect | 0 |
1129 | buffer->updateBoundingRect(QRectF(pos, image.size())); never executed: buffer->updateBoundingRect(QRectF(pos, image.size())); | 0 |
1130 | } | 0 |
1131 | | - |
1132 | void QPaintBufferEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pm, const QPointF &s) | - |
1133 | { | - |
1134 | | - |
1135 | | - |
1136 | | - |
1137 | QPaintBufferCommand *cmd = | - |
1138 | buffer->addCommand(QPaintBufferPrivate::Cmd_DrawTiledPixmap, QVariant(pm)); | - |
1139 | cmd->extra = buffer->addData((qreal *) &r, 4); | - |
1140 | buffer->addData((qreal *) &s, 2); | - |
1141 | if (buffer->calculateBoundingRect) never evaluated: buffer->calculateBoundingRect | 0 |
1142 | buffer->updateBoundingRect(r); never executed: buffer->updateBoundingRect(r); | 0 |
1143 | } | 0 |
1144 | | - |
1145 | void QPaintBufferEngine::drawStaticTextItem(QStaticTextItem *staticTextItem) | - |
1146 | { | - |
1147 | QVariantList variants; | - |
1148 | | - |
1149 | variants << QVariant(staticTextItem->font); | - |
1150 | for (int i=0; i<staticTextItem->numGlyphs; ++i) { never evaluated: i<staticTextItem->numGlyphs | 0 |
1151 | variants.append(staticTextItem->glyphs[i]); | - |
1152 | variants.append(staticTextItem->glyphPositions[i].toPointF()); | - |
1153 | } | 0 |
1154 | | - |
1155 | buffer->addCommand(QPaintBufferPrivate::Cmd_DrawStaticText, QVariant(variants)); | - |
1156 | } | 0 |
1157 | | - |
1158 | void QPaintBufferEngine::drawTextItem(const QPointF &pos, const QTextItem &ti) | - |
1159 | { | - |
1160 | | - |
1161 | | - |
1162 | | - |
1163 | if (m_stream_raw_text_items) { never evaluated: m_stream_raw_text_items | 0 |
1164 | QPaintBufferCommand *cmd = buffer->addCommand(QPaintBufferPrivate::Cmd_DrawTextItem, QVariant::fromValue<void *>(new QTextItemIntCopy(ti))); | - |
1165 | | - |
1166 | QFont font(ti.font()); | - |
1167 | font.setUnderline(false); | - |
1168 | font.setStrikeOut(false); | - |
1169 | font.setOverline(false); | - |
1170 | | - |
1171 | const QTextItemInt &si = static_cast<const QTextItemInt &>(ti); | - |
1172 | qreal justificationWidth = 0; | - |
1173 | if (si.justified) never evaluated: si.justified | 0 |
1174 | justificationWidth = si.width.toReal(); never executed: justificationWidth = si.width.toReal(); | 0 |
1175 | int renderFlags = ti.renderFlags(); | - |
1176 | qreal scaleFactor = font.d->dpi/qreal(qt_defaultDpiY()); | - |
1177 | | - |
1178 | buffer->addData(QVariant(font)); | - |
1179 | cmd->extra = buffer->addData((qreal *) &pos, 2); | - |
1180 | buffer->addData((qreal *) &justificationWidth, 1); | - |
1181 | buffer->addData((qreal *) &scaleFactor, 1); | - |
1182 | cmd->offset2 = buffer->addData((int *) &renderFlags, 1); | - |
1183 | } else { | 0 |
1184 | QList<QVariant> variants; | - |
1185 | variants << QVariant(ti.font()) << QVariant(ti.text()); | - |
1186 | QPaintBufferCommand *cmd = buffer->addCommand(QPaintBufferPrivate::Cmd_DrawText, QVariant(variants)); | - |
1187 | cmd->extra = buffer->addData((qreal *) &pos, 2); | - |
1188 | } | 0 |
1189 | | - |
1190 | if (buffer->calculateBoundingRect) never evaluated: buffer->calculateBoundingRect | 0 |
1191 | buffer->updateBoundingRect(QRectF(pos, QSize(ti.width(), ti.ascent() + ti.descent() + 1))); never executed: buffer->updateBoundingRect(QRectF(pos, QSize(ti.width(), ti.ascent() + ti.descent() + 1))); | 0 |
1192 | } | 0 |
1193 | | - |
1194 | | - |
1195 | void QPaintBufferEngine::setState(QPainterState *s) | - |
1196 | { | - |
1197 | QPaintBufferEnginePrivate * const d = d_func(); | - |
1198 | if (m_begin_detected) { never evaluated: m_begin_detected | 0 |
1199 | | - |
1200 | | - |
1201 | | - |
1202 | m_begin_detected = false; | - |
1203 | } else if (m_save_detected) { never evaluated: m_save_detected | 0 |
1204 | | - |
1205 | | - |
1206 | | - |
1207 | m_save_detected = false; | - |
1208 | buffer->addCommand(QPaintBufferPrivate::Cmd_Save); | - |
1209 | } else { | 0 |
1210 | | - |
1211 | | - |
1212 | | - |
1213 | buffer->addCommand(QPaintBufferPrivate::Cmd_Restore); | - |
1214 | } | 0 |
1215 | | - |
1216 | d->last = s->matrix; | - |
1217 | | - |
1218 | QPaintEngineEx::setState(s); | - |
1219 | } | 0 |
1220 | class QFakeDevice : public QPaintDevice | - |
1221 | { | - |
1222 | public: | - |
1223 | QFakeDevice() { dpi_x = qt_defaultDpiX(); dpi_y = qt_defaultDpiY(); } | 0 |
1224 | void setDpiX(int dpi) { dpi_x = dpi; } | 0 |
1225 | void setDpiY(int dpi) { dpi_y = dpi; } | 0 |
1226 | QPaintEngine *paintEngine() const { return 0; } never executed: return 0; | 0 |
1227 | int metric(PaintDeviceMetric m) const | - |
1228 | { | - |
1229 | switch(m) { | - |
1230 | case PdmPhysicalDpiX: | - |
1231 | case PdmDpiX: | - |
1232 | return dpi_x; never executed: return dpi_x; | 0 |
1233 | case PdmPhysicalDpiY: | - |
1234 | case PdmDpiY: | - |
1235 | return dpi_y; never executed: return dpi_y; | 0 |
1236 | default: | - |
1237 | return QPaintDevice::metric(m); never executed: return QPaintDevice::metric(m); | 0 |
1238 | } | - |
1239 | } | 0 |
1240 | | - |
1241 | private: | - |
1242 | int dpi_x; | - |
1243 | int dpi_y; | - |
1244 | }; | - |
1245 | | - |
1246 | | - |
1247 | void QPainterReplayer::setupTransform(QPainter *_painter) | - |
1248 | { | - |
1249 | painter = _painter; | - |
1250 | m_world_matrix = painter->transform(); | - |
1251 | m_world_matrix.scale(qreal(painter->device()->logicalDpiX()) / qreal(qt_defaultDpiX()), | - |
1252 | qreal(painter->device()->logicalDpiY()) / qreal(qt_defaultDpiY())); | - |
1253 | painter->setTransform(m_world_matrix); | - |
1254 | } | 0 |
1255 | | - |
1256 | void QPainterReplayer::processCommands(const QPaintBuffer &buffer, QPainter *p, int begin, int end) | - |
1257 | { | - |
1258 | d = buffer.d_ptr; | - |
1259 | painter = p; | - |
1260 | | - |
1261 | for (int cmdIndex = begin; cmdIndex < end; ++cmdIndex) { never evaluated: cmdIndex < end | 0 |
1262 | const QPaintBufferCommand &cmd = d->commands.at(cmdIndex); | - |
1263 | process(cmd); | - |
1264 | } | 0 |
1265 | } | 0 |
1266 | | - |
1267 | void QPaintBuffer::beginNewFrame() | - |
1268 | { | - |
1269 | if (!d_ptr->commands.isEmpty()) never evaluated: !d_ptr->commands.isEmpty() | 0 |
1270 | d_ptr->frames << d_ptr->commands.size(); never executed: d_ptr->frames << d_ptr->commands.size(); | 0 |
1271 | } | 0 |
1272 | | - |
1273 | int QPaintBuffer::numFrames() const | - |
1274 | { | - |
1275 | return d_ptr->frames.size() + 1; never executed: return d_ptr->frames.size() + 1; | 0 |
1276 | } | - |
1277 | | - |
1278 | void QPainterReplayer::process(const QPaintBufferCommand &cmd) | - |
1279 | { | - |
1280 | switch (cmd.id) { | - |
1281 | case QPaintBufferPrivate::Cmd_Save: { | - |
1282 | | - |
1283 | | - |
1284 | | - |
1285 | painter->save(); | - |
1286 | break; } | 0 |
1287 | | - |
1288 | case QPaintBufferPrivate::Cmd_Restore: { | - |
1289 | | - |
1290 | | - |
1291 | | - |
1292 | painter->restore(); | - |
1293 | break; } | 0 |
1294 | | - |
1295 | case QPaintBufferPrivate::Cmd_SetPen: { | - |
1296 | QPen pen = qvariant_cast<QPen>(d->variants.at(cmd.offset)); | - |
1297 | | - |
1298 | | - |
1299 | | - |
1300 | painter->setPen(pen); | - |
1301 | break; } | 0 |
1302 | | - |
1303 | case QPaintBufferPrivate::Cmd_SetBrush: { | - |
1304 | QBrush brush = qvariant_cast<QBrush>(d->variants.at(cmd.offset)); | - |
1305 | | - |
1306 | | - |
1307 | | - |
1308 | painter->setBrush(brush); | - |
1309 | break; } | 0 |
1310 | | - |
1311 | case QPaintBufferPrivate::Cmd_SetBrushOrigin: { | - |
1312 | | - |
1313 | | - |
1314 | | - |
1315 | painter->setBrushOrigin(d->variants.at(cmd.offset).toPointF()); | - |
1316 | break; } | 0 |
1317 | | - |
1318 | case QPaintBufferPrivate::Cmd_SetTransform: { | - |
1319 | QTransform xform = qvariant_cast<QTransform>(d->variants.at(cmd.offset)); | - |
1320 | | - |
1321 | | - |
1322 | | - |
1323 | painter->setTransform(xform * m_world_matrix); | - |
1324 | break; } | 0 |
1325 | | - |
1326 | case QPaintBufferPrivate::Cmd_Translate: { | - |
1327 | QPointF delta(d->floats.at(cmd.extra), d->floats.at(cmd.extra+1)); | - |
1328 | | - |
1329 | | - |
1330 | | - |
1331 | painter->translate(delta.x(), delta.y()); | - |
1332 | return; | 0 |
1333 | } | - |
1334 | | - |
1335 | case QPaintBufferPrivate::Cmd_SetCompositionMode: { | - |
1336 | QPainter::CompositionMode mode = (QPainter::CompositionMode) cmd.extra; | - |
1337 | | - |
1338 | | - |
1339 | | - |
1340 | painter->setCompositionMode(mode); | - |
1341 | break; } | 0 |
1342 | | - |
1343 | case QPaintBufferPrivate::Cmd_SetRenderHints: { | - |
1344 | | - |
1345 | | - |
1346 | | - |
1347 | QPainter::RenderHints ph = painter->renderHints(); | - |
1348 | QPainter::RenderHints nh = (QPainter::RenderHints) cmd.extra; | - |
1349 | QPainter::RenderHints xored = ph ^ nh; | - |
1350 | if (xored & QPainter::Antialiasing) never evaluated: xored & QPainter::Antialiasing | 0 |
1351 | painter->setRenderHint(QPainter::Antialiasing, nh & QPainter::Antialiasing); never executed: painter->setRenderHint(QPainter::Antialiasing, nh & QPainter::Antialiasing); | 0 |
1352 | if (xored & QPainter::HighQualityAntialiasing) never evaluated: xored & QPainter::HighQualityAntialiasing | 0 |
1353 | painter->setRenderHint(QPainter::HighQualityAntialiasing, nh & QPainter::HighQualityAntialiasing); never executed: painter->setRenderHint(QPainter::HighQualityAntialiasing, nh & QPainter::HighQualityAntialiasing); | 0 |
1354 | if (xored & QPainter::TextAntialiasing) never evaluated: xored & QPainter::TextAntialiasing | 0 |
1355 | painter->setRenderHint(QPainter::TextAntialiasing, nh & QPainter::TextAntialiasing); never executed: painter->setRenderHint(QPainter::TextAntialiasing, nh & QPainter::TextAntialiasing); | 0 |
1356 | if (xored & QPainter::SmoothPixmapTransform) never evaluated: xored & QPainter::SmoothPixmapTransform | 0 |
1357 | painter->setRenderHint(QPainter::SmoothPixmapTransform, nh & QPainter::SmoothPixmapTransform); never executed: painter->setRenderHint(QPainter::SmoothPixmapTransform, nh & QPainter::SmoothPixmapTransform); | 0 |
1358 | if (xored & QPainter::NonCosmeticDefaultPen) never evaluated: xored & QPainter::NonCosmeticDefaultPen | 0 |
1359 | painter->setRenderHint(QPainter::NonCosmeticDefaultPen, nh & QPainter::NonCosmeticDefaultPen); never executed: painter->setRenderHint(QPainter::NonCosmeticDefaultPen, nh & QPainter::NonCosmeticDefaultPen); | 0 |
1360 | if (xored & QPainter::Qt4CompatiblePainting) never evaluated: xored & QPainter::Qt4CompatiblePainting | 0 |
1361 | painter->setRenderHint(QPainter::Qt4CompatiblePainting, nh & QPainter::Qt4CompatiblePainting); never executed: painter->setRenderHint(QPainter::Qt4CompatiblePainting, nh & QPainter::Qt4CompatiblePainting); | 0 |
1362 | break; } | 0 |
1363 | | - |
1364 | case QPaintBufferPrivate::Cmd_SetOpacity: { | - |
1365 | | - |
1366 | | - |
1367 | | - |
1368 | painter->setOpacity(d->variants.at(cmd.offset).toDouble()); | - |
1369 | break; } | 0 |
1370 | | - |
1371 | case QPaintBufferPrivate::Cmd_SetBackgroundMode: { | - |
1372 | | - |
1373 | | - |
1374 | | - |
1375 | painter->setBackgroundMode((Qt::BGMode)cmd.extra); | - |
1376 | break; } | 0 |
1377 | | - |
1378 | case QPaintBufferPrivate::Cmd_DrawVectorPath: { | - |
1379 | | - |
1380 | | - |
1381 | | - |
1382 | | - |
1383 | | - |
1384 | QVectorPathCmd path(d, cmd); | - |
1385 | painter->drawPath(path().convertToPainterPath()); | - |
1386 | break; } | 0 |
1387 | | - |
1388 | case QPaintBufferPrivate::Cmd_StrokeVectorPath: { | - |
1389 | QPen pen = qvariant_cast<QPen>(d->variants.at(cmd.extra)); | - |
1390 | | - |
1391 | | - |
1392 | | - |
1393 | | - |
1394 | | - |
1395 | QVectorPathCmd path(d, cmd); | - |
1396 | painter->strokePath(path().convertToPainterPath(), pen); | - |
1397 | break; } | 0 |
1398 | | - |
1399 | case QPaintBufferPrivate::Cmd_FillVectorPath: { | - |
1400 | QBrush brush = qvariant_cast<QBrush>(d->variants.at(cmd.extra)); | - |
1401 | | - |
1402 | | - |
1403 | | - |
1404 | | - |
1405 | | - |
1406 | QVectorPathCmd path(d, cmd); | - |
1407 | painter->fillPath(path().convertToPainterPath(), brush); | - |
1408 | break; } | 0 |
1409 | | - |
1410 | case QPaintBufferPrivate::Cmd_DrawPolygonF: { | - |
1411 | | - |
1412 | | - |
1413 | | - |
1414 | | - |
1415 | | - |
1416 | | - |
1417 | Qt::FillRule fill = (QPaintEngine::PolygonDrawMode) cmd.extra == QPaintEngine::OddEvenMode never evaluated: (QPaintEngine::PolygonDrawMode) cmd.extra == QPaintEngine::OddEvenMode | 0 |
1418 | ? Qt::OddEvenFill : Qt::WindingFill; | - |
1419 | painter->drawPolygon((QPointF *) (d->floats.constData() + cmd.offset), cmd.size, fill); | - |
1420 | break; } | 0 |
1421 | | - |
1422 | case QPaintBufferPrivate::Cmd_DrawPolygonI: { | - |
1423 | | - |
1424 | | - |
1425 | | - |
1426 | | - |
1427 | | - |
1428 | | - |
1429 | Qt::FillRule fill = (QPaintEngine::PolygonDrawMode) cmd.extra == QPaintEngine::OddEvenMode never evaluated: (QPaintEngine::PolygonDrawMode) cmd.extra == QPaintEngine::OddEvenMode | 0 |
1430 | ? Qt::OddEvenFill : Qt::WindingFill; | - |
1431 | painter->drawPolygon((QPoint *) (d->ints.constData() + cmd.offset), cmd.size, fill); | - |
1432 | break; } | 0 |
1433 | | - |
1434 | case QPaintBufferPrivate::Cmd_DrawPolylineF: { | - |
1435 | | - |
1436 | | - |
1437 | | - |
1438 | painter->drawPolyline((QPointF *) (d->floats.constData() + cmd.offset), cmd.size); | - |
1439 | break; } | 0 |
1440 | | - |
1441 | case QPaintBufferPrivate::Cmd_DrawPolylineI: { | - |
1442 | | - |
1443 | | - |
1444 | | - |
1445 | painter->drawPolyline((QPoint *) (d->ints.constData() + cmd.offset), cmd.size); | - |
1446 | break; } | 0 |
1447 | | - |
1448 | case QPaintBufferPrivate::Cmd_DrawConvexPolygonF: { | - |
1449 | | - |
1450 | | - |
1451 | | - |
1452 | painter->drawConvexPolygon((QPointF *) (d->floats.constData() + cmd.offset), cmd.size); | - |
1453 | break; } | 0 |
1454 | | - |
1455 | case QPaintBufferPrivate::Cmd_DrawConvexPolygonI: { | - |
1456 | | - |
1457 | | - |
1458 | | - |
1459 | painter->drawConvexPolygon((QPoint *) (d->ints.constData() + cmd.offset), cmd.size); | - |
1460 | break; } | 0 |
1461 | | - |
1462 | case QPaintBufferPrivate::Cmd_DrawEllipseF: { | - |
1463 | | - |
1464 | | - |
1465 | | - |
1466 | painter->drawEllipse(*(QRectF *)(d->floats.constData() + cmd.offset)); | - |
1467 | break; } | 0 |
1468 | | - |
1469 | case QPaintBufferPrivate::Cmd_DrawEllipseI: { | - |
1470 | | - |
1471 | | - |
1472 | | - |
1473 | painter->drawEllipse(*(QRect *)(d->ints.constData() + cmd.offset)); | - |
1474 | break; } | 0 |
1475 | | - |
1476 | case QPaintBufferPrivate::Cmd_DrawLineF: { | - |
1477 | | - |
1478 | | - |
1479 | | - |
1480 | painter->drawLines((QLineF *)(d->floats.constData() + cmd.offset), cmd.size); | - |
1481 | break; } | 0 |
1482 | | - |
1483 | case QPaintBufferPrivate::Cmd_DrawLineI: { | - |
1484 | | - |
1485 | | - |
1486 | | - |
1487 | painter->drawLines((QLine *)(d->ints.constData() + cmd.offset), cmd.size); | - |
1488 | break; } | 0 |
1489 | | - |
1490 | case QPaintBufferPrivate::Cmd_DrawPointsF: { | - |
1491 | | - |
1492 | | - |
1493 | | - |
1494 | painter->drawPoints((QPointF *)(d->floats.constData() + cmd.offset), cmd.size); | - |
1495 | break; } | 0 |
1496 | | - |
1497 | case QPaintBufferPrivate::Cmd_DrawPointsI: { | - |
1498 | | - |
1499 | | - |
1500 | | - |
1501 | painter->drawPoints((QPoint *)(d->ints.constData() + cmd.offset), cmd.size); | - |
1502 | break; } | 0 |
1503 | | - |
1504 | case QPaintBufferPrivate::Cmd_DrawPixmapRect: { | - |
1505 | QPixmap pm(d->variants.at(cmd.offset).value<QPixmap>()); | - |
1506 | QRectF r(d->floats.at(cmd.extra), d->floats.at(cmd.extra+1), | - |
1507 | d->floats.at(cmd.extra+2), d->floats.at(cmd.extra+3)); | - |
1508 | | - |
1509 | QRectF sr(d->floats.at(cmd.extra+4), d->floats.at(cmd.extra+5), | - |
1510 | d->floats.at(cmd.extra+6), d->floats.at(cmd.extra+7)); | - |
1511 | | - |
1512 | | - |
1513 | | - |
1514 | painter->drawPixmap(r, pm, sr); | - |
1515 | break; } | 0 |
1516 | | - |
1517 | case QPaintBufferPrivate::Cmd_DrawPixmapPos: { | - |
1518 | QPixmap pm(d->variants.at(cmd.offset).value<QPixmap>()); | - |
1519 | QPointF pos(d->floats.at(cmd.extra), d->floats.at(cmd.extra+1)); | - |
1520 | | - |
1521 | | - |
1522 | | - |
1523 | painter->drawPixmap(pos, pm); | - |
1524 | break; } | 0 |
1525 | | - |
1526 | case QPaintBufferPrivate::Cmd_DrawTiledPixmap: { | - |
1527 | QPixmap pm(d->variants.at(cmd.offset).value<QPixmap>()); | - |
1528 | QRectF r(d->floats.at(cmd.extra), d->floats.at(cmd.extra+1), | - |
1529 | d->floats.at(cmd.extra+2), d->floats.at(cmd.extra+3)); | - |
1530 | | - |
1531 | QPointF offset(d->floats.at(cmd.extra+4), d->floats.at(cmd.extra+5)); | - |
1532 | | - |
1533 | | - |
1534 | | - |
1535 | painter->drawTiledPixmap(r, pm, offset); | - |
1536 | break; } | 0 |
1537 | | - |
1538 | case QPaintBufferPrivate::Cmd_DrawImageRect: { | - |
1539 | QImage image(d->variants.at(cmd.offset).value<QImage>()); | - |
1540 | QRectF r(d->floats.at(cmd.extra), d->floats.at(cmd.extra+1), | - |
1541 | d->floats.at(cmd.extra+2), d->floats.at(cmd.extra+3)); | - |
1542 | QRectF sr(d->floats.at(cmd.extra+4), d->floats.at(cmd.extra+5), | - |
1543 | d->floats.at(cmd.extra+6), d->floats.at(cmd.extra+7)); | - |
1544 | | - |
1545 | | - |
1546 | | - |
1547 | painter->drawImage(r, image, sr); | - |
1548 | break; } | 0 |
1549 | | - |
1550 | case QPaintBufferPrivate::Cmd_DrawImagePos: { | - |
1551 | QImage image(d->variants.at(cmd.offset).value<QImage>()); | - |
1552 | QPointF pos(d->floats.at(cmd.extra), d->floats.at(cmd.extra+1)); | - |
1553 | | - |
1554 | | - |
1555 | | - |
1556 | painter->drawImage(pos, image); | - |
1557 | break; } | 0 |
1558 | | - |
1559 | case QPaintBufferPrivate::Cmd_DrawRectF: { | - |
1560 | | - |
1561 | | - |
1562 | | - |
1563 | painter->drawRects((QRectF *)(d->floats.constData() + cmd.offset), cmd.size); | - |
1564 | break; } | 0 |
1565 | | - |
1566 | case QPaintBufferPrivate::Cmd_DrawRectI: { | - |
1567 | | - |
1568 | | - |
1569 | | - |
1570 | painter->drawRects((QRect *)(d->ints.constData() + cmd.offset), cmd.size); | - |
1571 | break; } | 0 |
1572 | | - |
1573 | case QPaintBufferPrivate::Cmd_FillRectBrush: { | - |
1574 | QBrush brush = qvariant_cast<QBrush>(d->variants.at(cmd.extra)); | - |
1575 | QRectF *rect = (QRectF *)(d->floats.constData() + cmd.offset); | - |
1576 | | - |
1577 | | - |
1578 | | - |
1579 | painter->fillRect(*rect, brush); | - |
1580 | break; } | 0 |
1581 | | - |
1582 | case QPaintBufferPrivate::Cmd_FillRectColor: { | - |
1583 | QColor color = qvariant_cast<QColor>(d->variants.at(cmd.extra)); | - |
1584 | QRectF *rect = (QRectF *)(d->floats.constData() + cmd.offset); | - |
1585 | | - |
1586 | | - |
1587 | | - |
1588 | painter->fillRect(*rect, color); | - |
1589 | break; } | 0 |
1590 | | - |
1591 | case QPaintBufferPrivate::Cmd_SetClipEnabled: { | - |
1592 | bool clipEnabled = d->variants.at(cmd.offset).toBool(); | - |
1593 | | - |
1594 | | - |
1595 | | - |
1596 | painter->setClipping(clipEnabled); | - |
1597 | break; } | 0 |
1598 | | - |
1599 | case QPaintBufferPrivate::Cmd_ClipVectorPath: { | - |
1600 | QVectorPathCmd path(d, cmd); | - |
1601 | | - |
1602 | | - |
1603 | | - |
1604 | painter->setClipPath(path().convertToPainterPath(), Qt::ClipOperation(cmd.extra)); | - |
1605 | break; } | 0 |
1606 | | - |
1607 | | - |
1608 | case QPaintBufferPrivate::Cmd_ClipRect: { | - |
1609 | QRect rect(QPoint(d->ints.at(cmd.offset), d->ints.at(cmd.offset + 1)), | - |
1610 | QPoint(d->ints.at(cmd.offset + 2), d->ints.at(cmd.offset + 3))); | - |
1611 | | - |
1612 | | - |
1613 | | - |
1614 | painter->setClipRect(rect, Qt::ClipOperation(cmd.extra)); | - |
1615 | break; } | 0 |
1616 | | - |
1617 | case QPaintBufferPrivate::Cmd_ClipRegion: { | - |
1618 | QRegion region(d->variants.at(cmd.offset).value<QRegion>()); | - |
1619 | | - |
1620 | | - |
1621 | | - |
1622 | painter->setClipRegion(region, Qt::ClipOperation(cmd.extra)); | - |
1623 | break; } | 0 |
1624 | | - |
1625 | | - |
1626 | case QPaintBufferPrivate::Cmd_DrawStaticText: { | - |
1627 | | - |
1628 | QVariantList variants(d->variants.at(cmd.offset).value<QVariantList>()); | - |
1629 | | - |
1630 | QFont font = variants.at(0).value<QFont>(); | - |
1631 | | - |
1632 | QVector<quint32> glyphIndexes; | - |
1633 | QVector<QPointF> positions; | - |
1634 | | - |
1635 | for (int i=0; i<(variants.size() - 1) / 2; ++i) { never evaluated: i<(variants.size() - 1) / 2 | 0 |
1636 | glyphIndexes.append(variants.at(i*2 + 1).toUInt()); | - |
1637 | positions.append(variants.at(i*2 + 2).toPointF()); | - |
1638 | } | 0 |
1639 | | - |
1640 | painter->setFont(font); | - |
1641 | | - |
1642 | QRawFont rawFont; | - |
1643 | QRawFontPrivate *rawFontD = QRawFontPrivate::get(rawFont); | - |
1644 | QFontPrivate *fontD = QFontPrivate::get(font); | - |
1645 | rawFontD->fontEngine = fontD->engineForScript(QUnicodeTables::Common); | - |
1646 | rawFontD->fontEngine->ref.ref(); | - |
1647 | | - |
1648 | QGlyphRun glyphs; | - |
1649 | glyphs.setRawFont(rawFont); | - |
1650 | glyphs.setGlyphIndexes(glyphIndexes); | - |
1651 | glyphs.setPositions(positions); | - |
1652 | | - |
1653 | painter->drawGlyphRun(QPointF(), glyphs); | - |
1654 | break; | 0 |
1655 | } | - |
1656 | | - |
1657 | | - |
1658 | case QPaintBufferPrivate::Cmd_DrawText: { | - |
1659 | QPointF pos(d->floats.at(cmd.extra), d->floats.at(cmd.extra+1)); | - |
1660 | QList<QVariant> variants(d->variants.at(cmd.offset).value<QList<QVariant> >()); | - |
1661 | | - |
1662 | QFont font(variants.at(0).value<QFont>()); | - |
1663 | QString text(variants.at(1).value<QString>()); | - |
1664 | | - |
1665 | painter->setFont(font); | - |
1666 | painter->drawText(pos, text); | - |
1667 | break; } | 0 |
1668 | | - |
1669 | case QPaintBufferPrivate::Cmd_DrawTextItem: { | - |
1670 | QPointF pos(d->floats.at(cmd.extra), d->floats.at(cmd.extra+1)); | - |
1671 | QTextItemIntCopy *tiCopy = reinterpret_cast<QTextItemIntCopy *>(qvariant_cast<void *>(d->variants.at(cmd.offset))); | - |
1672 | QTextItemInt &ti = (*tiCopy)(); | - |
1673 | QString text(ti.text()); | - |
1674 | | - |
1675 | QFont font(ti.font()); | - |
1676 | font.setUnderline(false); | - |
1677 | font.setStrikeOut(false); | - |
1678 | font.setOverline(false); | - |
1679 | | - |
1680 | const QTextItemInt &si = static_cast<const QTextItemInt &>(ti); | - |
1681 | qreal justificationWidth = 0; | - |
1682 | if (si.justified) never evaluated: si.justified | 0 |
1683 | justificationWidth = si.width.toReal(); never executed: justificationWidth = si.width.toReal(); | 0 |
1684 | qreal scaleFactor = font.d->dpi/qreal(qt_defaultDpiY()); | - |
1685 | | - |
1686 | | - |
1687 | | - |
1688 | | - |
1689 | | - |
1690 | if (scaleFactor != 1.0) { never evaluated: scaleFactor != 1.0 | 0 |
1691 | QFont fnt(font); | - |
1692 | QFakeDevice fake; | - |
1693 | fake.setDpiX(qRound(scaleFactor*qt_defaultDpiX())); | - |
1694 | fake.setDpiY(qRound(scaleFactor*qt_defaultDpiY())); | - |
1695 | font = QFont(fnt, &fake); | - |
1696 | } | 0 |
1697 | | - |
1698 | int flags = Qt::TextSingleLine | Qt::TextDontClip | Qt::TextForceLeftToRight; | - |
1699 | QSizeF size(1, 1); | - |
1700 | if (justificationWidth > 0) { never evaluated: justificationWidth > 0 | 0 |
1701 | size.setWidth(justificationWidth); | - |
1702 | flags |= Qt::TextJustificationForced; | - |
1703 | flags |= Qt::AlignJustify; | - |
1704 | } | 0 |
1705 | | - |
1706 | QFontMetrics fm(font); | - |
1707 | QPointF pt(pos.x(), pos.y() - fm.ascent()); | - |
1708 | qt_format_text(font, QRectF(pt, size), flags, 0, | - |
1709 | text, 0, 0, 0, 0, painter); | - |
1710 | break; } | 0 |
1711 | case QPaintBufferPrivate::Cmd_SystemStateChanged: { | - |
1712 | QRegion systemClip(d->variants.at(cmd.offset).value<QRegion>()); | - |
1713 | | - |
1714 | | - |
1715 | | - |
1716 | | - |
1717 | | - |
1718 | painter->paintEngine()->setSystemClip(systemClip); | - |
1719 | painter->paintEngine()->d_ptr->systemStateChanged(); | - |
1720 | break; } | 0 |
1721 | } | - |
1722 | } | 0 |
1723 | | - |
1724 | void QPaintEngineExReplayer::process(const QPaintBufferCommand &cmd) | - |
1725 | { | - |
1726 | qt_noop(); | - |
1727 | QPaintEngineEx *xengine = static_cast<QPaintEngineEx *>(painter->paintEngine()); | - |
1728 | | - |
1729 | switch (cmd.id) { | - |
1730 | case QPaintBufferPrivate::Cmd_SetBrushOrigin: { | - |
1731 | | - |
1732 | | - |
1733 | | - |
1734 | xengine->state()->brushOrigin = d->variants.at(cmd.offset).toPointF(); | - |
1735 | xengine->brushOriginChanged(); | - |
1736 | break; } | 0 |
1737 | | - |
1738 | case QPaintBufferPrivate::Cmd_SetCompositionMode: { | - |
1739 | QPainter::CompositionMode mode = (QPainter::CompositionMode) cmd.extra; | - |
1740 | | - |
1741 | | - |
1742 | | - |
1743 | xengine->state()->composition_mode = mode; | - |
1744 | xengine->compositionModeChanged(); | - |
1745 | break; } | 0 |
1746 | | - |
1747 | case QPaintBufferPrivate::Cmd_SetOpacity: { | - |
1748 | | - |
1749 | | - |
1750 | | - |
1751 | xengine->state()->opacity = d->variants.at(cmd.offset).toDouble(); | - |
1752 | xengine->opacityChanged(); | - |
1753 | break; } | 0 |
1754 | | - |
1755 | case QPaintBufferPrivate::Cmd_DrawVectorPath: { | - |
1756 | | - |
1757 | | - |
1758 | | - |
1759 | | - |
1760 | | - |
1761 | QVectorPathCmd path(d, cmd); | - |
1762 | xengine->draw(path()); | - |
1763 | break; } | 0 |
1764 | | - |
1765 | case QPaintBufferPrivate::Cmd_StrokeVectorPath: { | - |
1766 | QPen pen = qvariant_cast<QPen>(d->variants.at(cmd.extra)); | - |
1767 | | - |
1768 | | - |
1769 | | - |
1770 | | - |
1771 | | - |
1772 | QVectorPathCmd path(d, cmd); | - |
1773 | xengine->stroke(path(), pen); | - |
1774 | break; } | 0 |
1775 | | - |
1776 | case QPaintBufferPrivate::Cmd_FillVectorPath: { | - |
1777 | QBrush brush = qvariant_cast<QBrush>(d->variants.at(cmd.extra)); | - |
1778 | | - |
1779 | | - |
1780 | | - |
1781 | | - |
1782 | | - |
1783 | QVectorPathCmd path(d, cmd); | - |
1784 | xengine->fill(path(), brush); | - |
1785 | break; } | 0 |
1786 | | - |
1787 | case QPaintBufferPrivate::Cmd_FillRectBrush: { | - |
1788 | QBrush brush = qvariant_cast<QBrush>(d->variants.at(cmd.extra)); | - |
1789 | QRectF *rect = (QRectF *)(d->floats.constData() + cmd.offset); | - |
1790 | | - |
1791 | | - |
1792 | | - |
1793 | xengine->fillRect(*rect, brush); | - |
1794 | break; } | 0 |
1795 | | - |
1796 | case QPaintBufferPrivate::Cmd_FillRectColor: { | - |
1797 | QColor color = qvariant_cast<QColor>(d->variants.at(cmd.extra)); | - |
1798 | QRectF *rect = (QRectF *)(d->floats.constData() + cmd.offset); | - |
1799 | | - |
1800 | | - |
1801 | | - |
1802 | xengine->fillRect(*rect, color); | - |
1803 | break; } | 0 |
1804 | | - |
1805 | case QPaintBufferPrivate::Cmd_DrawPolygonF: { | - |
1806 | | - |
1807 | | - |
1808 | | - |
1809 | | - |
1810 | | - |
1811 | | - |
1812 | xengine->drawPolygon((QPointF *) (d->floats.constData() + cmd.offset), cmd.size, | - |
1813 | (QPaintEngine::PolygonDrawMode) cmd.extra); | - |
1814 | break; } | 0 |
1815 | | - |
1816 | case QPaintBufferPrivate::Cmd_DrawPolygonI: { | - |
1817 | | - |
1818 | | - |
1819 | | - |
1820 | | - |
1821 | | - |
1822 | | - |
1823 | xengine->drawPolygon((QPoint *) (d->ints.constData() + cmd.offset), cmd.size, | - |
1824 | (QPaintEngine::PolygonDrawMode) cmd.extra); | - |
1825 | break; } | 0 |
1826 | | - |
1827 | case QPaintBufferPrivate::Cmd_DrawEllipseF: { | - |
1828 | | - |
1829 | | - |
1830 | | - |
1831 | xengine->drawEllipse(*(QRectF *)(d->floats.constData() + cmd.offset)); | - |
1832 | break; } | 0 |
1833 | | - |
1834 | case QPaintBufferPrivate::Cmd_DrawEllipseI: { | - |
1835 | | - |
1836 | | - |
1837 | | - |
1838 | xengine->drawEllipse(*(QRect *)(d->ints.constData() + cmd.offset)); | - |
1839 | break; } | 0 |
1840 | | - |
1841 | case QPaintBufferPrivate::Cmd_DrawLineF: { | - |
1842 | | - |
1843 | | - |
1844 | | - |
1845 | xengine->drawLines((QLineF *)(d->floats.constData() + cmd.offset), cmd.size); | - |
1846 | break; } | 0 |
1847 | | - |
1848 | case QPaintBufferPrivate::Cmd_DrawLineI: { | - |
1849 | | - |
1850 | | - |
1851 | | - |
1852 | xengine->drawLines((QLine *)(d->ints.constData() + cmd.offset), cmd.size); | - |
1853 | break; } | 0 |
1854 | | - |
1855 | case QPaintBufferPrivate::Cmd_DrawPointsF: { | - |
1856 | | - |
1857 | | - |
1858 | | - |
1859 | xengine->drawPoints((QPointF *)(d->floats.constData() + cmd.offset), cmd.size); | - |
1860 | break; } | 0 |
1861 | | - |
1862 | case QPaintBufferPrivate::Cmd_DrawPointsI: { | - |
1863 | | - |
1864 | | - |
1865 | | - |
1866 | xengine->drawPoints((QPoint *)(d->ints.constData() + cmd.offset), cmd.size); | - |
1867 | break; } | 0 |
1868 | | - |
1869 | case QPaintBufferPrivate::Cmd_DrawPolylineF: { | - |
1870 | | - |
1871 | | - |
1872 | | - |
1873 | xengine->drawPolygon((QPointF *) (d->floats.constData() + cmd.offset), cmd.size, QPaintEngine::PolylineMode); | - |
1874 | break; } | 0 |
1875 | | - |
1876 | case QPaintBufferPrivate::Cmd_DrawPolylineI: { | - |
1877 | | - |
1878 | | - |
1879 | | - |
1880 | xengine->drawPolygon((QPoint *) (d->ints.constData() + cmd.offset), cmd.size, QPaintEngine::PolylineMode); | - |
1881 | break; } | 0 |
1882 | | - |
1883 | case QPaintBufferPrivate::Cmd_DrawRectF: { | - |
1884 | | - |
1885 | | - |
1886 | | - |
1887 | xengine->drawRects((QRectF *) (d->floats.constData() + cmd.offset), cmd.size); | - |
1888 | break; } | 0 |
1889 | | - |
1890 | case QPaintBufferPrivate::Cmd_DrawRectI: { | - |
1891 | | - |
1892 | | - |
1893 | | - |
1894 | xengine->drawRects((QRect *) (d->ints.constData() + cmd.offset), cmd.size); | - |
1895 | break; } | 0 |
1896 | | - |
1897 | case QPaintBufferPrivate::Cmd_SetClipEnabled: { | - |
1898 | bool clipEnabled = d->variants.at(cmd.offset).toBool(); | - |
1899 | | - |
1900 | | - |
1901 | | - |
1902 | xengine->state()->clipEnabled = clipEnabled; | - |
1903 | xengine->clipEnabledChanged(); | - |
1904 | break; } | 0 |
1905 | | - |
1906 | case QPaintBufferPrivate::Cmd_ClipVectorPath: { | - |
1907 | QVectorPathCmd path(d, cmd); | - |
1908 | | - |
1909 | | - |
1910 | | - |
1911 | xengine->clip(path(), Qt::ClipOperation(cmd.extra)); | - |
1912 | break; } | 0 |
1913 | | - |
1914 | | - |
1915 | case QPaintBufferPrivate::Cmd_ClipRect: { | - |
1916 | QRect rect(QPoint(d->ints.at(cmd.offset), d->ints.at(cmd.offset + 1)), | - |
1917 | QPoint(d->ints.at(cmd.offset + 2), d->ints.at(cmd.offset + 3))); | - |
1918 | | - |
1919 | | - |
1920 | | - |
1921 | xengine->clip(rect, Qt::ClipOperation(cmd.extra)); | - |
1922 | break; } | 0 |
1923 | | - |
1924 | case QPaintBufferPrivate::Cmd_ClipRegion: { | - |
1925 | QRegion region(d->variants.at(cmd.offset).value<QRegion>()); | - |
1926 | | - |
1927 | | - |
1928 | | - |
1929 | xengine->clip(region, Qt::ClipOperation(cmd.extra)); | - |
1930 | break; } | 0 |
1931 | | - |
1932 | default: | - |
1933 | QPainterReplayer::process(cmd); | - |
1934 | break; | 0 |
1935 | } | - |
1936 | } | 0 |
1937 | | - |
1938 | QDataStream &operator<<(QDataStream &stream, const QPaintBufferCommand &command) | - |
1939 | { | - |
1940 | quint32 id = command.id; | - |
1941 | quint32 size = command.size; | - |
1942 | stream << id << size; | - |
1943 | stream << command.offset << command.offset2 << command.extra; | - |
1944 | return stream; never executed: return stream; | 0 |
1945 | } | - |
1946 | | - |
1947 | QDataStream &operator>>(QDataStream &stream, QPaintBufferCommand &command) | - |
1948 | { | - |
1949 | quint32 id; | - |
1950 | quint32 size; | - |
1951 | stream >> id >> size; | - |
1952 | stream >> command.offset >> command.offset2 >> command.extra; | - |
1953 | command.id = id; | - |
1954 | command.size = size; | - |
1955 | return stream; never executed: return stream; | 0 |
1956 | } | - |
1957 | | - |
1958 | struct QPaintBufferCacheEntry | - |
1959 | { | - |
1960 | QVariant::Type type; | - |
1961 | quint64 cacheKey; | - |
1962 | }; | - |
1963 | | - |
1964 | struct QPaintBufferCacheEntryV2 | - |
1965 | { | - |
1966 | enum Type { | - |
1967 | ImageKey, | - |
1968 | PixmapKey | - |
1969 | }; | - |
1970 | | - |
1971 | struct Flags { | - |
1972 | uint type : 8; | - |
1973 | uint key : 24; | - |
1974 | }; | - |
1975 | | - |
1976 | union { | - |
1977 | Flags flags; | - |
1978 | uint bits; | - |
1979 | }; | - |
1980 | }; | - |
1981 | | - |
1982 | | - |
1983 | template <> struct QMetaTypeId< QPaintBufferCacheEntry > { enum { Defined = 1 }; static int qt_metatype_id() { static QBasicAtomicInt metatype_id = { (0) }; if (const int id = metatype_id.loadAcquire()) return id; const int newId = qRegisterMetaType< QPaintBufferCacheEntry >("QPaintBufferCacheEntry", reinterpret_cast< QPaintBufferCacheEntry *>(quintptr(-1))); metatype_id.storeRelease(newId); return newId; } }; | - |
1984 | template <> struct QMetaTypeId< QPaintBufferCacheEntryV2 > { enum { Defined = 1 }; static int qt_metatype_id() { static QBasicAtomicInt metatype_id = { (0) }; if (const int id = metatype_id.loadAcquire()) return id; const int newId = qRegisterMetaType< QPaintBufferCacheEntryV2 >("QPaintBufferCacheEntryV2", reinterpret_cast< QPaintBufferCacheEntryV2 *>(quintptr(-1))); metatype_id.storeRelease(newId); return newId; } }; | - |
1985 | | - |
1986 | | - |
1987 | QDataStream &operator<<(QDataStream &stream, const QPaintBufferCacheEntry &entry) | - |
1988 | { | - |
1989 | return stream << entry.type << entry.cacheKey; never executed: return stream << entry.type << entry.cacheKey; | 0 |
1990 | } | - |
1991 | | - |
1992 | QDataStream &operator>>(QDataStream &stream, QPaintBufferCacheEntry &entry) | - |
1993 | { | - |
1994 | return stream >> entry.type >> entry.cacheKey; never executed: return stream >> entry.type >> entry.cacheKey; | 0 |
1995 | } | - |
1996 | | - |
1997 | QDataStream &operator<<(QDataStream &stream, const QPaintBufferCacheEntryV2 &entry) | - |
1998 | { | - |
1999 | return stream << entry.bits; never executed: return stream << entry.bits; | 0 |
2000 | } | - |
2001 | | - |
2002 | QDataStream &operator>>(QDataStream &stream, QPaintBufferCacheEntryV2 &entry) | - |
2003 | { | - |
2004 | return stream >> entry.bits; never executed: return stream >> entry.bits; | 0 |
2005 | } | - |
2006 | | - |
2007 | static void qRegisterPaintBufferMetaTypes() | - |
2008 | { | - |
2009 | qRegisterMetaTypeStreamOperators<QPaintBufferCacheEntry>(); | - |
2010 | qRegisterMetaTypeStreamOperators<QPaintBufferCacheEntryV2>(); | - |
2011 | } executed: } Execution Count:200 | 200 |
2012 | | - |
2013 | namespace { static const struct qRegisterPaintBufferMetaTypes_ctor_class_ { inline qRegisterPaintBufferMetaTypes_ctor_class_() { qRegisterPaintBufferMetaTypes(); } } qRegisterPaintBufferMetaTypes_ctor_instance_; } executed: } Execution Count:200 | 200 |
2014 | | - |
2015 | QDataStream &operator<<(QDataStream &stream, const QPaintBuffer &buffer) | - |
2016 | { | - |
2017 | QHash<qint64, uint> pixmapKeys; | - |
2018 | QHash<qint64, uint> imageKeys; | - |
2019 | | - |
2020 | QHash<qint64, QPixmap> pixmaps; | - |
2021 | QHash<qint64, QImage> images; | - |
2022 | | - |
2023 | QVector<QVariant> variants = buffer.d_ptr->variants; | - |
2024 | for (int i = 0; i < variants.size(); ++i) { never evaluated: i < variants.size() | 0 |
2025 | const QVariant &v = variants.at(i); | - |
2026 | if (v.type() == QVariant::Image) { never evaluated: v.type() == QVariant::Image | 0 |
2027 | const QImage image(v.value<QImage>()); | - |
2028 | | - |
2029 | QPaintBufferCacheEntryV2 entry; | - |
2030 | entry.flags.type = QPaintBufferCacheEntryV2::ImageKey; | - |
2031 | | - |
2032 | QHash<qint64, uint>::iterator it = imageKeys.find(image.cacheKey()); | - |
2033 | if (it != imageKeys.end()) { never evaluated: it != imageKeys.end() | 0 |
2034 | entry.flags.key = *it; | - |
2035 | } else { | 0 |
2036 | imageKeys[image.cacheKey()] = entry.flags.key = images.size(); | - |
2037 | images[images.size()] = image; | - |
2038 | } | 0 |
2039 | | - |
2040 | variants[i] = QVariant::fromValue(entry); | - |
2041 | } else if (v.type() == QVariant::Pixmap) { never evaluated: v.type() == QVariant::Pixmap | 0 |
2042 | const QPixmap pixmap(v.value<QPixmap>()); | - |
2043 | | - |
2044 | QPaintBufferCacheEntryV2 entry; | - |
2045 | entry.flags.type = QPaintBufferCacheEntryV2::PixmapKey; | - |
2046 | | - |
2047 | QHash<qint64, uint>::iterator it = pixmapKeys.find(pixmap.cacheKey()); | - |
2048 | if (it != pixmapKeys.end()) { never evaluated: it != pixmapKeys.end() | 0 |
2049 | entry.flags.key = *it; | - |
2050 | } else { | 0 |
2051 | pixmapKeys[pixmap.cacheKey()] = entry.flags.key = pixmaps.size(); | - |
2052 | pixmaps[pixmaps.size()] = pixmap; | - |
2053 | } | 0 |
2054 | | - |
2055 | variants[i] = QVariant::fromValue(entry); | - |
2056 | } | 0 |
2057 | } | - |
2058 | | - |
2059 | stream << pixmaps; | - |
2060 | stream << images; | - |
2061 | | - |
2062 | stream << buffer.d_ptr->ints; | - |
2063 | stream << buffer.d_ptr->floats; | - |
2064 | stream << variants; | - |
2065 | stream << buffer.d_ptr->commands; | - |
2066 | stream << buffer.d_ptr->boundingRect; | - |
2067 | stream << buffer.d_ptr->frames; | - |
2068 | | - |
2069 | return stream; never executed: return stream; | 0 |
2070 | } | - |
2071 | | - |
2072 | QDataStream &operator>>(QDataStream &stream, QPaintBuffer &buffer) | - |
2073 | { | - |
2074 | QHash<qint64, QPixmap> pixmaps; | - |
2075 | QHash<qint64, QImage> images; | - |
2076 | | - |
2077 | stream >> pixmaps; | - |
2078 | stream >> images; | - |
2079 | | - |
2080 | stream >> buffer.d_ptr->ints; | - |
2081 | stream >> buffer.d_ptr->floats; | - |
2082 | stream >> buffer.d_ptr->variants; | - |
2083 | stream >> buffer.d_ptr->commands; | - |
2084 | stream >> buffer.d_ptr->boundingRect; | - |
2085 | stream >> buffer.d_ptr->frames; | - |
2086 | | - |
2087 | QVector<QVariant> &variants = buffer.d_ptr->variants; | - |
2088 | for (int i = 0; i < variants.size(); ++i) { never evaluated: i < variants.size() | 0 |
2089 | const QVariant &v = variants.at(i); | - |
2090 | if (v.canConvert<QPaintBufferCacheEntry>()) { never evaluated: v.canConvert<QPaintBufferCacheEntry>() | 0 |
2091 | QPaintBufferCacheEntry entry = v.value<QPaintBufferCacheEntry>(); | - |
2092 | if (entry.type == QVariant::Image) never evaluated: entry.type == QVariant::Image | 0 |
2093 | variants[i] = QVariant(images.value(entry.cacheKey)); never executed: variants[i] = QVariant(images.value(entry.cacheKey)); | 0 |
2094 | else | - |
2095 | variants[i] = QVariant(pixmaps.value(entry.cacheKey)); never executed: variants[i] = QVariant(pixmaps.value(entry.cacheKey)); | 0 |
2096 | } else if (v.canConvert<QPaintBufferCacheEntryV2>()) { never evaluated: v.canConvert<QPaintBufferCacheEntryV2>() | 0 |
2097 | QPaintBufferCacheEntryV2 entry = v.value<QPaintBufferCacheEntryV2>(); | - |
2098 | | - |
2099 | if (entry.flags.type == QPaintBufferCacheEntryV2::ImageKey) never evaluated: entry.flags.type == QPaintBufferCacheEntryV2::ImageKey | 0 |
2100 | variants[i] = QVariant(images.value(entry.flags.key)); never executed: variants[i] = QVariant(images.value(entry.flags.key)); | 0 |
2101 | else if (entry.flags.type == QPaintBufferCacheEntryV2::PixmapKey) never evaluated: entry.flags.type == QPaintBufferCacheEntryV2::PixmapKey | 0 |
2102 | variants[i] = QVariant(pixmaps.value(entry.flags.key)); never executed: variants[i] = QVariant(pixmaps.value(entry.flags.key)); | 0 |
2103 | else | - |
2104 | QMessageLogger("painting/qpaintbuffer.cpp", 2214, __PRETTY_FUNCTION__).warning() << "operator<<(QDataStream &stream, QPaintBuffer &buffer): unrecognized cache entry type:" << entry.flags.type; never executed: QMessageLogger("painting/qpaintbuffer.cpp", 2214, __PRETTY_FUNCTION__).warning() << "operator<<(QDataStream &stream, QPaintBuffer &buffer): unrecognized cache entry type:" << entry.flags.type; | 0 |
2105 | } | - |
2106 | } | - |
2107 | | - |
2108 | return stream; never executed: return stream; | 0 |
2109 | } | - |
2110 | | - |
2111 | | - |
2112 | | - |
| | |