Qt 4.8
qpaintbuffer.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
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 Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/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 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 #include <qmath.h>
42 #include <private/qpainterpath_p.h>
43 #include <private/qpaintbuffer_p.h>
44 //#include <private/qtextengine_p.h>
45 #include <private/qfontengine_p.h>
46 #include <private/qemulationpaintengine_p.h>
47 #include <private/qimage_p.h>
48 #include <qstatictext.h>
49 #include <private/qstatictext_p.h>
50 #include <private/qrawfont_p.h>
51 
52 #include <QDebug>
53 
54 // #define QPAINTBUFFER_DEBUG_DRAW
55 
57 
58 extern void qt_format_text(const QFont &font,
59  const QRectF &_r, int tf, const QTextOption *option, const QString& str, QRectF *brect,
60  int tabstops, int* tabarray, int tabarraylen,
61  QPainter *painter);
62 
64  : m_item(static_cast<const QTextItemInt &>(item))
65 {
66  QChar *chars = new QChar[m_item.num_chars];
67  unsigned short *logClusters = new unsigned short[m_item.num_chars];
68  memcpy(chars, m_item.chars, m_item.num_chars * sizeof(QChar));
69  memcpy(logClusters, m_item.logClusters, m_item.num_chars * sizeof(unsigned short));
70  m_item.chars = chars;
71  m_item.logClusters = logClusters;
72 
74  char *glyphLayoutData = new char[size];
75  QGlyphLayout glyphs(glyphLayoutData, m_item.glyphs.numGlyphs);
76  memcpy(glyphs.offsets, m_item.glyphs.offsets, m_item.glyphs.numGlyphs * sizeof(QFixedPoint));
77  memcpy(glyphs.glyphs, m_item.glyphs.glyphs, m_item.glyphs.numGlyphs * sizeof(HB_Glyph));
78  memcpy(glyphs.advances_x, m_item.glyphs.advances_x, m_item.glyphs.numGlyphs * sizeof(QFixed));
79  memcpy(glyphs.advances_y, m_item.glyphs.advances_y, m_item.glyphs.numGlyphs * sizeof(QFixed));
81  memcpy(glyphs.attributes, m_item.glyphs.attributes, m_item.glyphs.numGlyphs * sizeof(HB_GlyphAttributes));
82  m_item.glyphs = glyphs;
83 
84  m_font = *m_item.f;
85  m_item.f = &m_font;
86 
87  m_item.fontEngine->ref.ref(); // Increment reference count.
88 }
89 
91 {
92  delete m_item.chars;
93  delete m_item.logClusters;
94  delete m_item.glyphs.data();
95  if (!m_item.fontEngine->ref.deref())
96  delete m_item.fontEngine;
97 }
98 
99 /************************************************************************
100  *
101  * QPaintBufferSignalProxy
102  *
103  ************************************************************************/
104 
106 
108 {
109  return theSignalProxy();
110 }
111 
112 /************************************************************************
113  *
114  * QPaintBufferPrivate
115  *
116  ************************************************************************/
117 
119  : ref(1), engine(0), penWidthAdjustment(0)
120  , calculateBoundingRect(true)
121  , cache(0)
122 {
123 }
124 
126 {
128 
129  for (int i = 0; i < commands.size(); ++i) {
130  const QPaintBufferCommand &cmd = commands.at(i);
132  delete reinterpret_cast<QTextItemIntCopy *>(qvariant_cast<void *>(variants.at(cmd.offset)));
133  }
134 }
135 
136 
138 {
139  // transform to device coords and adjust for pen width
140  Q_ASSERT(engine && engine->painter());
141  QPainter *painter = engine->painter();
142  const QTransform transform = painter->transform();
143  QRectF devRect = transform.mapRect(br);
144  if (penWidthAdjustment > 0) {
145  devRect = devRect.adjusted(-penWidthAdjustment, -penWidthAdjustment,
147  }
148 
149  if (boundingRect.isEmpty()) {
150  boundingRect = devRect;
151  } else {
152  qreal min_x = qMin(devRect.left(), boundingRect.left());
153  qreal min_y = qMin(devRect.top(), boundingRect.top());
154  qreal max_x = qMax(devRect.right(), boundingRect.right());
155  qreal max_y = qMax(devRect.bottom(), boundingRect.bottom());
156  boundingRect = QRectF(min_x, min_y, max_x - min_x, max_y - min_y);
157  }
158  if (painter->hasClipping())
159  boundingRect &= transform.mapRect(painter->clipRegion().boundingRect());
160 }
161 
162 
163 /************************************************************************
164  *
165  * QPaintBuffer
166  *
167  ************************************************************************/
168 
169 
170 
172  : d_ptr(new QPaintBufferPrivate)
173 {
174 }
175 
177 {
178  if (!d_ptr->ref.deref())
179  delete d_ptr;
180 }
181 
183  : QPaintDevice(), d_ptr(other.d_ptr)
184 {
185  d_ptr->ref.ref();
186 }
187 
189 {
190  QPaintBufferPrivate *d = const_cast<QPaintBuffer *>(this)->d_ptr;
191  if (!d->engine)
192  d->engine = new QPaintBufferEngine(d);
193  return d->engine;
194 }
195 
196 
198 {
199  int val = 0;
200  switch (metric) {
201  case PdmWidth:
202  val = qCeil(d_ptr->boundingRect.width());
203  break;
204  case PdmHeight:
205  val = qCeil(d_ptr->boundingRect.height());
206  break;
207  case PdmDpiX:
208  case PdmPhysicalDpiX:
209  val = qt_defaultDpiX();
210  break;
211  case PdmDpiY:
212  case PdmPhysicalDpiY:
213  val = qt_defaultDpiY();
214  break;
215  default:
216  val = QPaintDevice::metric(metric);
217  }
218 
219  return val;
220 }
221 
223 {
224  return QInternal::PaintBuffer;
225 }
226 
228 {
229  if (other.d_ptr != d_ptr) {
230  QPaintBufferPrivate *data = other.d_ptr;
231  data->ref.ref();
232  if (d_ptr->ref.deref())
233  delete d_ptr;
234  d_ptr = data;
235  }
236  return *this;
237 }
238 
240 {
241  return d_ptr->commands.isEmpty();
242 }
243 
244 
245 
246 void QPaintBuffer::draw(QPainter *painter, int frame) const
247 {
248 #ifdef QPAINTBUFFER_DEBUG_DRAW
249  qDebug() << "QPaintBuffer::draw() --------------------------------";
250 
251  Q_D(const QPaintBuffer);
252  printf("Float buffer:");
253  for (int i=0; i<d->floats.size(); i++) {
254  if ((i % 10) == 0) {
255  printf("\n%4d-%4d: ", i, i+9);
256  }
257  printf("%4.2f ", d->floats[i]);
258  }
259  printf("\n");
260 
261  printf("Int Buffer:");
262  for (int i=0; i<d->ints.size(); i++) {
263  if ((i % 10) == 0) {
264  printf("\n%4d-%4d: ", i, i+10);
265  }
266  printf("%5d", d->ints[i]);
267  }
268  printf("\n");
269 #endif
270 
271  processCommands(painter, frameStartIndex(frame), frameEndIndex(frame));
272 
273 #ifdef QPAINTBUFFER_DEBUG_DRAW
274  qDebug() << "QPaintBuffer::draw() -------------------------------- DONE!";
275 #endif
276 }
277 
278 int QPaintBuffer::frameStartIndex(int frame) const
279 {
280  return (frame == 0) ? 0 : d_ptr->frames.at(frame - 1);
281 }
282 
283 int QPaintBuffer::frameEndIndex(int frame) const
284 {
285  return (frame == d_ptr->frames.size()) ? d_ptr->commands.size() : d_ptr->frames.at(frame);
286 }
287 
288 int QPaintBuffer::processCommands(QPainter *painter, int begin, int end) const
289 {
290  if (!painter || !painter->isActive())
291  return 0;
292 
293  QPaintEngineEx *xengine = painter->paintEngine()->isExtended()
294  ? (QPaintEngineEx *) painter->paintEngine() : 0;
295  if (xengine) {
296  QPaintEngineExReplayer player;
297  player.processCommands(*this, painter, begin, end);
298  } else {
299  QPainterReplayer player;
300  player.processCommands(*this, painter, begin, end);
301  }
302 
303  int depth = 0;
304  for (int i = begin; i < end; ++i) {
305  const QPaintBufferCommand &cmd = d_ptr->commands.at(i);
307  ++depth;
308  else if (cmd.id == QPaintBufferPrivate::Cmd_Restore)
309  --depth;
310  }
311  return depth;
312 }
313 
314 #ifndef QT_NO_DEBUG_STREAM
316 {
317  QString desc;
318  QDebug debug(&desc);
319 
320  const QPaintBufferCommand &cmd = d_ptr->commands.at(command);
321 
322  switch (cmd.id) {
324  debug << "Cmd_Save";
325  break; }
326 
328  debug << "Cmd_Restore";
329  break; }
330 
333  debug << "Cmd_SetBrush: " << brush;
334  break; }
335 
337  debug << "Cmd_SetBrushOrigin: " << d_ptr->variants.at(cmd.offset).toPointF();
338  break; }
339 
342  debug << "ExCmd_SetCompositionMode, mode: " << mode;
343  break; }
344 
346  debug << "ExCmd_SetOpacity: " << d_ptr->variants.at(cmd.offset).toDouble();
347  break; }
348 
350  debug << "ExCmd_DrawVectorPath: size: " << cmd.size
351 // << ", hints:" << d->ints[cmd.offset2+cmd.size]
352  << "pts/elms:" << cmd.offset << cmd.offset2;
353  break; }
354 
356  QPen pen = qvariant_cast<QPen>(d_ptr->variants.at(cmd.extra));
357  debug << "ExCmd_StrokeVectorPath: size: " << cmd.size
358 // << ", hints:" << d->ints[cmd.offset2+cmd.size]
359  << "pts/elms:" << cmd.offset << cmd.offset2 << pen;
360  break; }
361 
363  QBrush brush = qvariant_cast<QBrush>(d_ptr->variants.at(cmd.extra));
364  debug << "ExCmd_FillVectorPath: size: " << cmd.size
365 // << ", hints:" << d->ints[cmd.offset2+cmd.size]
366  << "pts/elms:" << cmd.offset << cmd.offset2 << brush;
367  break; }
368 
370  QBrush brush = qvariant_cast<QBrush>(d_ptr->variants.at(cmd.extra));
371  QRectF *rect = (QRectF *)(d_ptr->floats.constData() + cmd.offset);
372  debug << "ExCmd_FillRectBrush, offset: " << cmd.offset << " rect: " << *rect << " brush: " << brush;
373  break; }
374 
376  QColor color = qvariant_cast<QColor>(d_ptr->variants.at(cmd.extra));
377  QRectF *rect = (QRectF *)(d_ptr->floats.constData() + cmd.offset);
378  debug << "ExCmd_FillRectBrush, offset: " << cmd.offset << " rect: " << *rect << " color: " << color;
379  break; }
380 
382  debug << "ExCmd_DrawPolygonF, offset: " << cmd.offset << " size: " << cmd.size
383  << " mode: " << cmd.extra
384  << d_ptr->floats.at(cmd.offset)
385  << d_ptr->floats.at(cmd.offset+1);
386  break; }
387 
389  debug << "ExCmd_DrawPolygonI, offset: " << cmd.offset << " size: " << cmd.size
390  << " mode: " << cmd.extra
391  << d_ptr->ints.at(cmd.offset)
392  << d_ptr->ints.at(cmd.offset+1);
393  break; }
394 
396  debug << "ExCmd_DrawEllipseF, offset: " << cmd.offset;
397  break; }
398 
400  debug << "ExCmd_DrawLineF, offset: " << cmd.offset << " size: " << cmd.size;
401  break; }
402 
404  debug << "ExCmd_DrawLineI, offset: " << cmd.offset << " size: " << cmd.size;
405  break; }
406 
408  debug << "ExCmd_DrawPointsF, offset: " << cmd.offset << " size: " << cmd.size;
409  break; }
410 
412  debug << "ExCmd_DrawPointsI, offset: " << cmd.offset << " size: " << cmd.size;
413  break; }
414 
416  debug << "ExCmd_DrawPolylineF, offset: " << cmd.offset << " size: " << cmd.size;
417  break; }
418 
420  debug << "ExCmd_DrawPolylineI, offset: " << cmd.offset << " size: " << cmd.size;
421  break; }
422 
424  debug << "ExCmd_DrawRectF, offset: " << cmd.offset << " size: " << cmd.size;
425  break; }
426 
428  debug << "ExCmd_DrawRectI, offset: " << cmd.offset << " size: " << cmd.size;
429  break; }
430 
432  bool clipEnabled = d_ptr->variants.at(cmd.offset).toBool();
433  debug << "ExCmd_SetClipEnabled:" << clipEnabled;
434  break; }
435 
437  QVectorPathCmd path(d_ptr, cmd);
438  debug << "ExCmd_ClipVectorPath:" << path().elementCount();
439  break; }
440 
442  QRect rect(QPoint(d_ptr->ints.at(cmd.offset), d_ptr->ints.at(cmd.offset + 1)),
443  QPoint(d_ptr->ints.at(cmd.offset + 2), d_ptr->ints.at(cmd.offset + 3)));
444  debug << "ExCmd_ClipRect:" << rect << cmd.extra;
445  break; }
446 
448  QRegion region(d_ptr->variants.at(cmd.offset).value<QRegion>());
449  debug << "ExCmd_ClipRegion:" << region.boundingRect() << cmd.extra;
450  break; }
451 
453  QPen pen = qvariant_cast<QPen>(d_ptr->variants.at(cmd.offset));
454  debug << "Cmd_SetPen: " << pen;
455  break; }
456 
459  debug << "Cmd_SetTransform, offset: " << cmd.offset << xform;
460  break; }
461 
463  debug << "Cmd_SetRenderHints, hints: " << cmd.extra;
464  break; }
465 
467  debug << "Cmd_SetBackgroundMode: " << cmd.extra;
468  break; }
469 
471  debug << "Cmd_DrawConvexPolygonF, offset: " << cmd.offset << " size: " << cmd.size;
472  break; }
473 
475  debug << "Cmd_DrawConvexPolygonI, offset: " << cmd.offset << " size: " << cmd.size;
476  break; }
477 
479  debug << "Cmd_DrawEllipseI, offset: " << cmd.offset;
480  break; }
481 
483  QPixmap pm(d_ptr->variants.at(cmd.offset).value<QPixmap>());
484  QRectF r(d_ptr->floats.at(cmd.extra), d_ptr->floats.at(cmd.extra+1),
485  d_ptr->floats.at(cmd.extra+2), d_ptr->floats.at(cmd.extra+3));
486 
487  QRectF sr(d_ptr->floats.at(cmd.extra+4), d_ptr->floats.at(cmd.extra+5),
488  d_ptr->floats.at(cmd.extra+6), d_ptr->floats.at(cmd.extra+7));
489  debug << "Cmd_DrawPixmapRect:" << r << sr << pm.size();
490  break; }
491 
493  QPixmap pm(d_ptr->variants.at(cmd.offset).value<QPixmap>());
494  QPointF pos(d_ptr->floats.at(cmd.extra), d_ptr->floats.at(cmd.extra+1));
495  debug << "Cmd_DrawPixmapPos:" << pos << pm.size();
496  break; }
497 
499  QPixmap pm(d_ptr->variants.at(cmd.offset).value<QPixmap>());
500  QRectF r(d_ptr->floats.at(cmd.extra), d_ptr->floats.at(cmd.extra+1),
501  d_ptr->floats.at(cmd.extra+2), d_ptr->floats.at(cmd.extra+3));
502 
503  QPointF offset(d_ptr->floats.at(cmd.extra+4), d_ptr->floats.at(cmd.extra+5));
504  debug << "Cmd_DrawTiledPixmap:" << r << offset << pm.size();
505  break; }
506 
508  QImage image(d_ptr->variants.at(cmd.offset).value<QImage>());
509  QRectF r(d_ptr->floats.at(cmd.extra), d_ptr->floats.at(cmd.extra+1),
510  d_ptr->floats.at(cmd.extra+2), d_ptr->floats.at(cmd.extra+3));
511  QRectF sr(d_ptr->floats.at(cmd.extra+4), d_ptr->floats.at(cmd.extra+5),
512  d_ptr->floats.at(cmd.extra+6), d_ptr->floats.at(cmd.extra+7));
513  debug << "Cmd_DrawImageRect:" << r << sr << image.size();
514  break; }
515 
517  QImage image(d_ptr->variants.at(cmd.offset).value<QImage>());
518  QPointF pos(d_ptr->floats.at(cmd.extra), d_ptr->floats.at(cmd.extra+1));
519  debug << "Cmd_DrawImagePos:" << pos << image.size();
520  break; }
521 
523  QPointF pos(d_ptr->floats.at(cmd.extra), d_ptr->floats.at(cmd.extra+1));
525 
526  QFont font(variants.at(0).value<QFont>());
527  QString text(variants.at(1).value<QString>());
528 
529  debug << "Cmd_DrawText:" << pos << text << font.family();
530  break; }
531 
533  QPointF pos(d_ptr->floats.at(cmd.extra), d_ptr->floats.at(cmd.extra+1));
534  QTextItemIntCopy *tiCopy = reinterpret_cast<QTextItemIntCopy *>(qvariant_cast<void *>(d_ptr->variants.at(cmd.offset)));
535  QTextItemInt &ti = (*tiCopy)();
536  QString text(ti.text());
537 
538  debug << "Cmd_DrawTextItem:" << pos << " " << text;
539  break; }
541  QRegion systemClip(d_ptr->variants.at(cmd.offset).value<QRegion>());
542 
543  debug << "Cmd_SystemStateChanged:" << systemClip;
544  break; }
546  QPointF delta(d_ptr->floats.at(cmd.extra), d_ptr->floats.at(cmd.extra+1));
547  debug << "Cmd_Translate:" << delta;
548  break; }
550  debug << "Cmd_DrawStaticText";
551  break; }
552  }
553 
554  return desc;
555 }
556 #endif
557 
559 {
560  return d_ptr->boundingRect;
561 }
562 
564 {
565  d_ptr->boundingRect = rect;
566  d_ptr->calculateBoundingRect = false;
567 }
568 
569 
571 {
573 public:
576  q->buffer->addCommand(QPaintBufferPrivate::Cmd_SystemStateChanged, QVariant(systemClip));
577  }
578 
580 };
581 
582 
583 /************************************************************************
584  *
585  * QPaintBufferEngine
586  *
587  ************************************************************************/
588 
591  , buffer(b)
592  , m_begin_detected(false)
593  , m_save_detected(false)
594  , m_stream_raw_text_items(false)
595 {
596 }
597 
599 {
601  painter()->save();
602  d->systemStateChanged();
603  return true;
604 }
605 
607 {
608  painter()->restore();
609  m_created_state = 0;
610  return true;
611 }
612 
614 {
615 #ifdef QPAINTBUFFER_DEBUG_DRAW
616  qDebug() << "QPaintBufferEngine: createState, orig=" << orig << ", current=" << state();
617 #endif
618 
621 
622  if (orig == 0) {
623  m_begin_detected = true;
624  return new QPainterState();
625  } else {
626  m_save_detected = true;
627  return new QPainterState(orig);
628  }
629 }
630 
632 {
633 #ifdef QPAINTBUFFER_DEBUG_DRAW
634  qDebug() << "QPaintBufferEngine: clip vpath:" << path.elementCount() << "op:" << op;
635 #endif
636  QPaintBufferCommand *cmd =
638  cmd->extra = op;
639 }
640 
642 {
643 #ifdef QPAINTBUFFER_DEBUG_DRAW
644  qDebug() << "QPaintBufferEngine: clip rect:" << rect << "op:" << op;
645 #endif
646  QPaintBufferCommand *cmd =
647  buffer->addCommand(QPaintBufferPrivate::Cmd_ClipRect, (int *) &rect, 4, 1);
648  cmd->extra = op;
649 }
650 
652 {
653 #ifdef QPAINTBUFFER_DEBUG_DRAW
654  qDebug() << "QPaintBufferEngine: clip region br:" << region.boundingRect() << "op:" << op;
655 #endif
656  QPaintBufferCommand *cmd =
658  cmd->extra = op;
659 }
660 
662 {
663  // ### TODO
664 // QPaintBufferCommand *cmd =
665 // buffer->addCommand(QPaintBufferPrivate::Cmd_ClipPath, QVariant(path));
666 // cmd->extra = op;
667  QPaintEngineEx::clip(path, op);
668 }
669 
671 {
672 #ifdef QPAINTBUFFER_DEBUG_DRAW
673  qDebug() << "QPaintBufferEngine: clip enable change" << state()->clipEnabled;
674 #endif
675 
677 }
678 
680 {
681  const QPen &pen = state()->pen;
682 
683  if (!buffer->commands.isEmpty()
685 #ifdef QPAINTBUFFER_DEBUG_DRAW
686  qDebug() << "QPaintBufferEngine: penChanged (compressed)" << state()->pen;
687 #endif
689  return;
690  }
691 
693  if (pen.style() == Qt::NoPen) {
695  } else {
696  qreal penWidth = (pen.widthF() == 0) ? 1 : pen.widthF();
697  QPointF transformedWidth(penWidth, penWidth);
698  if (!pen.isCosmetic())
699  transformedWidth = painter()->transform().map(transformedWidth);
700  buffer->penWidthAdjustment = transformedWidth.x() / 2.0;
701  }
702  }
703 #ifdef QPAINTBUFFER_DEBUG_DRAW
704  qDebug() << "QPaintBufferEngine: penChanged" << state()->pen;
705 #endif
707 }
708 
710 {
711  const QBrush &brush = state()->brush;
712 
713  if (!buffer->commands.isEmpty()
715 #ifdef QPAINTBUFFER_DEBUG_DRAW
716  qDebug() << "QPaintBufferEngine: brushChanged (compressed)" << state()->brush;
717 #endif
718  buffer->variants[buffer->commands.last().offset] = brush;
719  return;
720  }
721 
722 #ifdef QPAINTBUFFER_DEBUG_DRAW
723  qDebug() << "QPaintBufferEngine: brushChanged" << state()->brush;
724 #endif
726 }
727 
729 {
730 #ifdef QPAINTBUFFER_DEBUG_DRAW
731  qDebug() << "QPaintBufferEngine: brush origin changed" << state()->brushOrigin;
732 #endif
734 }
735 
737 {
738 #ifdef QPAINTBUFFER_DEBUG_DRAW
739  qDebug() << "QPaintBufferEngine: opacity changed" << state()->opacity;
740 #endif
742 }
743 
745 {
746 #ifdef QPAINTBUFFER_DEBUG_DRAW
747  qDebug() << "QPaintBufferEngine: composition mode" << state()->composition_mode;
748 #endif
749  QPaintBufferCommand *cmd =
751  cmd->extra = state()->composition_mode;
752 }
753 
755 {
756 #ifdef QPAINTBUFFER_DEBUG_DRAW
757  qDebug() << "QPaintBufferEngine: render hints changed" << state()->renderHints;
758 #endif
759  QPaintBufferCommand *cmd =
761  cmd->extra = state()->renderHints;
762 }
763 
765 {
767  const QTransform &transform = state()->matrix;
768 
769  QTransform delta;
770 
771  bool invertible = false;
772  if (transform.type() <= QTransform::TxScale && transform.type() == d->last.type())
773  delta = transform * d->last.inverted(&invertible);
774 
775  d->last = transform;
776 
777  if (invertible && delta.type() == QTransform::TxNone)
778  return;
779 
780  if (invertible && delta.type() == QTransform::TxTranslate) {
781 #ifdef QPAINTBUFFER_DEBUG_DRAW
782  qDebug() << "QPaintBufferEngine: transformChanged (translate only) " << state()->matrix;
783 #endif
784  QPaintBufferCommand *cmd =
786 
787  qreal data[] = { delta.dx(), delta.dy() };
788  cmd->extra = buffer->addData((qreal *) data, 2);
789  return;
790  }
791 
792  // ### accumulate, like in QBrush case...
793  if (!buffer->commands.isEmpty()
795 #ifdef QPAINTBUFFER_DEBUG_DRAW
796  qDebug() << "QPaintBufferEngine: transformChanged (compressing) " << state()->matrix;
797 #endif
799  return;
800  }
801 
802 #ifdef QPAINTBUFFER_DEBUG_DRAW
803  qDebug() << "QPaintBufferEngine: transformChanged:" << state()->matrix;
804 #endif
806 }
807 
809 {
810 #ifdef QPAINTBUFFER_DEBUG_DRAW
811  qDebug() << "QPaintEngineBuffer: background mode changed" << state()->bgMode;
812 #endif
814  cmd->extra = state()->bgMode;
815 }
816 
818 {
819 #ifdef QPAINTBUFFER_DEBUG_DRAW
820  qDebug() << "QPaintBufferEngine: draw vpath:" << path.elementCount();
821 #endif
822 
823  bool hasBrush = qbrush_style(state()->brush) != Qt::NoBrush;
824  bool hasPen = qpen_style(state()->pen) != Qt::NoPen
825  && qbrush_style(qpen_brush(state()->pen)) != Qt::NoBrush;
826 
827  if (hasPen || hasBrush)
829 #ifdef QPAINTBUFFER_DEBUG_DRAW
830  else
831  qDebug() << " - no pen or brush active, discarded...\n";
832 #endif
833 
834 // if (buffer->calculateBoundingRect) {
835 // QRealRect r = path.controlPointRect();
836 // buffer->updateBoundingRect(QRectF(r.x1, r.y1, r.x2 - r.x1, r.y2 - r.y1));
837 // }
838 }
839 
840 void QPaintBufferEngine::fill(const QVectorPath &path, const QBrush &brush)
841 {
842 #ifdef QPAINTBUFFER_DEBUG_DRAW
843  qDebug() << "QPaintBufferEngine: fill vpath:" << path.elementCount() << brush;
844 #endif
845  QPaintBufferCommand *cmd =
847  cmd->extra = buffer->addData(QVariant(brush));
848 // if (buffer->calculateBoundingRect) {
849 // QRealRect r = path.controlPointRect();
850 // buffer->updateBoundingRect(QRectF(r.x1, r.y1, r.x2 - r.x1, r.y2 - r.y1));
851 // }
852 }
853 
854 void QPaintBufferEngine::stroke(const QVectorPath &path, const QPen &pen)
855 {
856 #ifdef QPAINTBUFFER_DEBUG_DRAW
857  qDebug() << "QPaintBufferEngine: stroke vpath:" << path.elementCount() << pen;
858 #endif
859  QPaintBufferCommand *cmd =
861  cmd->extra = buffer->addData(QVariant(pen));
862 // if (buffer->calculateBoundingRect) {
863 // QRealRect r = path.controlPointRect();
864 // buffer->updateBoundingRect(QRectF(r.x1, r.y1, r.x2 - r.x1, r.y2 - r.y1));
865 // }
866 }
867 
868 void QPaintBufferEngine::fillRect(const QRectF &rect, const QBrush &brush)
869 {
870 #ifdef QPAINTBUFFER_DEBUG_DRAW
871  qDebug() << "QPaintBufferEngine: fillRect brush:" << rect << brush;
872 #endif
873  QPaintBufferCommand *cmd =
875  cmd->extra = buffer->addData(brush);
877  buffer->updateBoundingRect(rect);
878 }
879 
880 void QPaintBufferEngine::fillRect(const QRectF &rect, const QColor &color)
881 {
882 #ifdef QPAINTBUFFER_DEBUG_DRAW
883  qDebug() << "QPaintBufferEngine: fillRect color:" << rect << color;
884 #endif
885  QPaintBufferCommand *cmd =
887  cmd->extra = buffer->addData(color);
889  buffer->updateBoundingRect(rect);
890 }
891 
892 void QPaintBufferEngine::drawRects(const QRect *rects, int rectCount)
893 {
894 #ifdef QPAINTBUFFER_DEBUG_DRAW
895  qDebug() << "QPaintBufferEngine: drawRectsI:" << rectCount;
896 #endif
897  QPaintBufferCommand *cmd =
898  buffer->addCommand(QPaintBufferPrivate::Cmd_DrawRectI, (int *) rects, 4 * rectCount, rectCount);
899  cmd->extra = rectCount;
900 
902  if (rectCount == 1) {
903  buffer->updateBoundingRect(rects[0]);
904  } else {
905  int min_x = rects[0].left();
906  int min_y = rects[0].top();
907  int max_x = rects[0].left() + rects[0].width();
908  int max_y = rects[0].top() + rects[0].height();
909  for (int i=1; i< rectCount; ++i) {
910  if (rects[i].left() < min_x)
911  min_x = rects[i].left();
912  if (rects[i].top() < min_y)
913  min_y = rects[i].top();
914  if (rects[i].right() > max_x)
915  max_x = rects[i].left() + rects[i].width();
916  if (rects[i].bottom() > max_y)
917  max_y = rects[i].top() + rects[i].height();
918 
919  }
920  buffer->updateBoundingRect(QRectF(min_x, min_y, max_x - min_x, max_y - min_y));
921  }
922  }
923 }
924 
925 void QPaintBufferEngine::drawRects(const QRectF *rects, int rectCount)
926 {
927 #ifdef QPAINTBUFFER_DEBUG_DRAW
928  qDebug() << "QPaintBufferEngine: drawRectsF:" << rectCount;
929 #endif
930  QPaintBufferCommand *cmd =
931  buffer->addCommand(QPaintBufferPrivate::Cmd_DrawRectF, (qreal *) rects, 4 * rectCount, rectCount);
932  cmd->extra = rectCount;
933 
935  if (rectCount == 1) {
936  buffer->updateBoundingRect(rects[0]);
937  } else {
938  qreal min_x = rects[0].left();
939  qreal min_y = rects[0].top();
940  qreal max_x = rects[0].right();
941  qreal max_y = rects[0].bottom();
942  for (int i=1; i< rectCount; ++i) {
943  if (rects[i].left() < min_x)
944  min_x = rects[i].left();
945  if (rects[i].top() < min_y)
946  min_y = rects[i].top();
947  if (rects[i].right() > max_x)
948  max_x = rects[i].right();
949  if (rects[i].bottom() > max_y)
950  max_y = rects[i].bottom();
951 
952  }
953  buffer->updateBoundingRect(QRectF(min_x, min_y, max_x - min_x, max_y - min_y));
954  }
955  }
956 }
957 
958 void QPaintBufferEngine::drawLines(const QLine *lines, int lineCount)
959 {
960 #ifdef QPAINTBUFFER_DEBUG_DRAW
961  qDebug() << "QPaintBufferEngine: drawLinesI:" << lineCount;
962 #endif
963  QPaintBufferCommand *cmd =
964  buffer->addCommand(QPaintBufferPrivate::Cmd_DrawLineI, (int *) lines, 4 * lineCount, lineCount);
965  cmd->extra = lineCount;
966 
968  int min_x = lines[0].p1().x();
969  int min_y = lines[0].p1().y();
970  int max_x = lines[0].p2().x();
971  int max_y = lines[0].p2().y();
972  if (min_x > max_x)
973  qSwap(min_x, max_x);
974  if (min_y > max_y)
975  qSwap(min_y, max_y);
976  for (int i=1; i < lineCount; ++i) {
977  int p1_x = lines[i].p1().x();
978  int p1_y = lines[i].p1().y();
979  int p2_x = lines[i].p2().x();
980  int p2_y = lines[i].p2().y();
981  if (p1_x > p2_x) {
982  min_x = qMin(p2_x, min_x);
983  max_x = qMax(p1_x, max_x);
984  } else {
985  min_x = qMin(p1_x, min_x);
986  max_x = qMax(p2_x, max_x);
987  }
988  if (p1_y > p2_y) {
989  min_y = qMin(p2_y, min_y);
990  max_y = qMax(p1_y, max_y);
991  } else {
992  min_y = qMin(p1_y, min_y);
993  max_y = qMax(p2_y, max_y);
994  }
995  }
996  buffer->updateBoundingRect(QRectF(min_x, min_y, max_x - min_x, max_y - min_y));
997  }
998 }
999 
1000 void QPaintBufferEngine::drawLines(const QLineF *lines, int lineCount)
1001 {
1002 #ifdef QPAINTBUFFER_DEBUG_DRAW
1003  qDebug() << "QPaintBufferEngine: drawLinesF:" << lineCount;
1004 #endif
1005  QPaintBufferCommand *cmd =
1006  buffer->addCommand(QPaintBufferPrivate::Cmd_DrawLineF, (qreal *) lines, 4 * lineCount, lineCount);
1007  cmd->extra = lineCount;
1008 
1010  qreal min_x = lines[0].p1().x();
1011  qreal min_y = lines[0].p1().y();
1012  qreal max_x = lines[0].p2().x();
1013  qreal max_y = lines[0].p2().y();
1014  if (min_x > max_x)
1015  qSwap(min_x, max_x);
1016  if (min_y > max_y)
1017  qSwap(min_y, max_y);
1018  for (int i=1; i < lineCount; ++i) {
1019  qreal p1_x = lines[i].p1().x();
1020  qreal p1_y = lines[i].p1().y();
1021  qreal p2_x = lines[i].p2().x();
1022  qreal p2_y = lines[i].p2().y();
1023  if (p1_x > p2_x) {
1024  min_x = qMin(p2_x, min_x);
1025  max_x = qMax(p1_x, max_x);
1026  } else {
1027  min_x = qMin(p1_x, min_x);
1028  max_x = qMax(p2_x, max_x);
1029  }
1030  if (p1_y > p2_y) {
1031  min_y = qMin(p2_y, min_y);
1032  max_y = qMax(p1_y, max_y);
1033  } else {
1034  min_y = qMin(p1_y, min_y);
1035  max_y = qMax(p2_y, max_y);
1036  }
1037  }
1038  buffer->updateBoundingRect(QRectF(min_x, min_y, max_x - min_x, max_y - min_y));
1039  }
1040 }
1041 
1043 {
1044 #ifdef QPAINTBUFFER_DEBUG_DRAW
1045  qDebug() << "QPaintBufferEngine: drawEllipseF:" << r;
1046 #endif
1050 }
1051 
1053 {
1054 #ifdef QPAINTBUFFER_DEBUG_DRAW
1055  qDebug() << "QPaintBufferEngine: drawEllipseI:" << r;
1056 #endif
1060 }
1061 
1063 {
1064 // #ifdef QPAINTBUFFER_DEBUG_DRAW
1065 // qDebug() << "QPaintBufferEngine: drawPath: element count:" << path.elementCount();
1066 // #endif
1067 // // ### Path -> QVariant
1068 // // buffer->addCommand(QPaintBufferPrivate::Cmd_DrawPath, QVariant(path));
1070 
1071 // if (buffer->calculateBoundingRect)
1072 // buffer->updateBoundingRect(path.boundingRect());
1073 }
1074 
1075 void QPaintBufferEngine::drawPoints(const QPoint *points, int pointCount)
1076 {
1077 #ifdef QPAINTBUFFER_DEBUG_DRAW
1078  qDebug() << "QPaintBufferEngine: drawPointsI: " << pointCount;
1079 #endif
1080  buffer->addCommand(QPaintBufferPrivate::Cmd_DrawPointsI, (int *) points, 2 * pointCount, pointCount);
1081 
1083  int min_x = points[0].x();
1084  int min_y = points[0].y();
1085  int max_x = points[0].x()+1;
1086  int max_y = points[0].y()+1;
1087  for (int i=1; i<pointCount; ++i) {
1088  int x = points[i].x();
1089  int y = points[i].y();
1090  min_x = qMin(min_x, x);
1091  min_y = qMin(min_y, y);
1092  max_x = qMax(max_x, x+1);
1093  max_y = qMax(max_y, y+1);
1094  }
1095  buffer->updateBoundingRect(QRectF(min_x, min_y, max_x - min_x, max_y - min_y));
1096  }
1097 }
1098 
1099 void QPaintBufferEngine::drawPoints(const QPointF *points, int pointCount)
1100 {
1101 #ifdef QPAINTBUFFER_DEBUG_DRAW
1102  qDebug() << "QPaintBufferEngine: drawPointsF: " << pointCount;
1103 #endif
1104  buffer->addCommand(QPaintBufferPrivate::Cmd_DrawPointsF, (qreal *) points, 2 * pointCount, pointCount);
1105 
1107  qreal min_x = points[0].x();
1108  qreal min_y = points[0].y();
1109  qreal max_x = points[0].x()+1;
1110  qreal max_y = points[0].y()+1;
1111  for (int i=1; i<pointCount; ++i) {
1112  qreal x = points[i].x();
1113  qreal y = points[i].y();
1114  min_x = qMin(min_x, x);
1115  min_y = qMin(min_y, y);
1116  max_x = qMax(max_x, x+1);
1117  max_y = qMax(max_y, y+1);
1118  }
1119  buffer->updateBoundingRect(QRectF(min_x, min_y, max_x - min_x, max_y - min_y));
1120  }
1121 }
1122 
1123 void QPaintBufferEngine::drawPolygon(const QPoint *pts, int count, PolygonDrawMode mode)
1124 {
1125 #ifdef QPAINTBUFFER_DEBUG_DRAW
1126  qDebug() << "QPaintBufferEngine: drawPolygonI: size:" << count << ", mode:" << mode;
1127 #endif
1128  if (mode == QPaintEngine::OddEvenMode || mode == QPaintEngine::WindingMode) {
1130  (int *) pts, 2 * count, count);
1131  cmd->extra = mode;
1132  } else if (mode == QPaintEngine::PolylineMode) {
1133  buffer->addCommand(QPaintBufferPrivate::Cmd_DrawPolylineI, (int *) pts, 2 * count, count);
1134  } else {
1135  buffer->addCommand(QPaintBufferPrivate::Cmd_DrawConvexPolygonI, (int *) pts, 2 * count, count);
1136  }
1137 
1139  int min_x = pts[0].x();
1140  int min_y = pts[0].y();
1141  int max_x = pts[0].x();
1142  int max_y = pts[0].y();
1143  for (int i=1; i<count; ++i) {
1144  int x = pts[i].x();
1145  int y = pts[i].y();
1146  min_x = qMin(min_x, x);
1147  min_y = qMin(min_y, y);
1148  max_x = qMax(max_x, x);
1149  max_y = qMax(max_y, y);
1150  }
1151  buffer->updateBoundingRect(QRectF(min_x, min_y, max_x - min_x, max_y - min_y));
1152  }
1153 }
1154 
1156 {
1157 #ifdef QPAINTBUFFER_DEBUG_DRAW
1158  qDebug() << "QPaintBufferEngine: drawPolygonF: size:" << count << ", mode:" << mode;
1159 #endif
1160  if (mode == QPaintEngine::OddEvenMode || mode == QPaintEngine::WindingMode) {
1162  (qreal *) pts, 2 * count, count);
1163  cmd->extra = mode;
1164  } else if (mode == QPaintEngine::PolylineMode) {
1165  buffer->addCommand(QPaintBufferPrivate::Cmd_DrawPolylineF, (qreal *) pts, 2 * count, count);
1166  } else {
1168  }
1169 
1171  qreal min_x = pts[0].x();
1172  qreal min_y = pts[0].y();
1173  qreal max_x = pts[0].x();
1174  qreal max_y = pts[0].y();
1175  for (int i=1; i<count; ++i) {
1176  qreal x = pts[i].x();
1177  qreal y = pts[i].y();
1178  min_x = qMin(min_x, x);
1179  min_y = qMin(min_y, y);
1180  max_x = qMax(max_x, x);
1181  max_y = qMax(max_y, y);
1182  }
1183  buffer->updateBoundingRect(QRectF(min_x, min_y, max_x - min_x, max_y - min_y));
1184  }
1185 }
1186 
1187 void QPaintBufferEngine::drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr)
1188 {
1189 #ifdef QPAINTBUFFER_DEBUG_DRAW
1190  qDebug() << "QPaintBufferEngine: drawPixmap: src/dest rects " << r << sr;
1191 #endif
1192  QPaintBufferCommand *cmd =
1194  cmd->extra = buffer->addData((qreal *) &r, 4);
1195  buffer->addData((qreal *) &sr, 4);
1198 }
1199 
1201 {
1202 #ifdef QPAINTBUFFER_DEBUG_DRAW
1203  qDebug() << "QPaintBufferEngine: drawPixmap: pos:" << pos;
1204 #endif
1205  QPaintBufferCommand *cmd =
1207  cmd->extra = buffer->addData((qreal *) &pos, 2);
1209  buffer->updateBoundingRect(QRectF(pos, pm.size()));
1210 }
1211 
1212 static inline QImage qpaintbuffer_storable_image(const QImage &src)
1213 {
1214  QImageData *d = const_cast<QImage &>(src).data_ptr();
1215  return d->own_data ? src : src.copy();
1216 }
1217 
1218 void QPaintBufferEngine::drawImage(const QRectF &r, const QImage &image, const QRectF &sr,
1219  Qt::ImageConversionFlags /*flags */)
1220 {
1221 #ifdef QPAINTBUFFER_DEBUG_DRAW
1222  qDebug() << "QPaintBufferEngine: drawImage: src/dest rects " << r << sr;
1223 #endif
1224  QPaintBufferCommand *cmd =
1227  cmd->extra = buffer->addData((qreal *) &r, 4);
1228  buffer->addData((qreal *) &sr, 4);
1229  // ### flags...
1232 }
1233 
1234 void QPaintBufferEngine::drawImage(const QPointF &pos, const QImage &image)
1235 {
1236 #ifdef QPAINTBUFFER_DEBUG_DRAW
1237  qDebug() << "QPaintBufferEngine: drawImage: pos:" << pos;
1238 #endif
1239  QPaintBufferCommand *cmd =
1242  cmd->extra = buffer->addData((qreal *) &pos, 2);
1244  buffer->updateBoundingRect(QRectF(pos, image.size()));
1245 }
1246 
1247 void QPaintBufferEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pm, const QPointF &s)
1248 {
1249 #ifdef QPAINTBUFFER_DEBUG_DRAW
1250  qDebug() << "QPaintBufferEngine: drawTiledPixmap: src rect/offset:" << r << s;
1251 #endif
1252  QPaintBufferCommand *cmd =
1254  cmd->extra = buffer->addData((qreal *) &r, 4);
1255  buffer->addData((qreal *) &s, 2);
1258 }
1259 
1261 {
1262  QVariantList variants;
1263 
1264  variants << QVariant(staticTextItem->font);
1265  for (int i=0; i<staticTextItem->numGlyphs; ++i) {
1266  variants.append(staticTextItem->glyphs[i]);
1267  variants.append(staticTextItem->glyphPositions[i].toPointF());
1268  }
1269 
1271 }
1272 
1274 {
1275 #ifdef QPAINTBUFFER_DEBUG_DRAW
1276  qDebug() << "QPaintBufferEngine: drawTextItem: pos:" << pos << ti.text();
1277 #endif
1279  QPaintBufferCommand *cmd = buffer->addCommand(QPaintBufferPrivate::Cmd_DrawTextItem, QVariant::fromValue<void *>(new QTextItemIntCopy(ti)));
1280 
1281  QFont font(ti.font());
1282  font.setUnderline(false);
1283  font.setStrikeOut(false);
1284  font.setOverline(false);
1285 
1286  const QTextItemInt &si = static_cast<const QTextItemInt &>(ti);
1287  qreal justificationWidth = 0;
1288  if (si.justified)
1289  justificationWidth = si.width.toReal();
1290  int renderFlags = ti.renderFlags();
1291  qreal scaleFactor = font.d->dpi/qreal(qt_defaultDpiY());
1292 
1293  buffer->addData(QVariant(font));
1294  cmd->extra = buffer->addData((qreal *) &pos, 2);
1295  buffer->addData((qreal *) &justificationWidth, 1);
1296  buffer->addData((qreal *) &scaleFactor, 1);
1297  cmd->offset2 = buffer->addData((int *) &renderFlags, 1);
1298  } else {
1299  QList<QVariant> variants;
1300  variants << QVariant(ti.font()) << QVariant(ti.text());
1302  cmd->extra = buffer->addData((qreal *) &pos, 2);
1303  }
1304 
1306  buffer->updateBoundingRect(QRectF(pos, QSize(ti.width(), ti.ascent() + ti.descent() + 1)));
1307 }
1308 
1309 
1311 {
1313  if (m_begin_detected) {
1314 #ifdef QPAINTBUFFER_DEBUG_DRAW
1315  qDebug() << "QPaintBufferEngine: setState: begin, ignoring.";
1316 #endif
1317  m_begin_detected = false;
1318  } else if (m_save_detected) {
1319 #ifdef QPAINTBUFFER_DEBUG_DRAW
1320  qDebug() << "QPaintBufferEngine: setState: save.";
1321 #endif
1322  m_save_detected = false;
1324  } else {
1325 #ifdef QPAINTBUFFER_DEBUG_DRAW
1326  qDebug() << "QPaintBufferEngine: setState: restore.";
1327 #endif
1329  }
1330 
1331  d->last = s->matrix;
1332 
1334 }
1335 
1336 
1337 /***********************************************************************
1338  *
1339  * class QPaintBufferPlayback_Painter
1340  *
1341  */
1342 
1343 // QFakeDevice is used to create fonts with a custom DPI
1344 //
1345 class QFakeDevice : public QPaintDevice
1346 {
1347 public:
1348  QFakeDevice() { dpi_x = qt_defaultDpiX(); dpi_y = qt_defaultDpiY(); }
1349  void setDpiX(int dpi) { dpi_x = dpi; }
1350  void setDpiY(int dpi) { dpi_y = dpi; }
1351  QPaintEngine *paintEngine() const { return 0; }
1353  {
1354  switch(m) {
1355  case PdmPhysicalDpiX:
1356  case PdmDpiX:
1357  return dpi_x;
1358  case PdmPhysicalDpiY:
1359  case PdmDpiY:
1360  return dpi_y;
1361  default:
1362  return QPaintDevice::metric(m);
1363  }
1364  }
1365 
1366 private:
1367  int dpi_x;
1368  int dpi_y;
1369 };
1370 
1371 
1373 {
1374  painter = _painter;
1375  m_world_matrix = painter->transform();
1376  m_world_matrix.scale(qreal(painter->device()->logicalDpiX()) / qreal(qt_defaultDpiX()),
1378  painter->setTransform(m_world_matrix);
1379 }
1380 
1382 {
1383  d = buffer.d_ptr;
1384  painter = p;
1385 
1386  for (int cmdIndex = begin; cmdIndex < end; ++cmdIndex) {
1387  const QPaintBufferCommand &cmd = d->commands.at(cmdIndex);
1388  process(cmd);
1389  }
1390 }
1391 
1393 {
1394  if (!d_ptr->commands.isEmpty())
1395  d_ptr->frames << d_ptr->commands.size();
1396 }
1397 
1399 {
1400  return d_ptr->frames.size() + 1;
1401 }
1402 
1404 {
1405  switch (cmd.id) {
1407 #ifdef QPAINTBUFFER_DEBUG_DRAW
1408  qDebug() << " -> Cmd_Save";
1409 #endif
1410  painter->save();
1411  break; }
1412 
1414 #ifdef QPAINTBUFFER_DEBUG_DRAW
1415  qDebug() << " -> Cmd_Restore";
1416 #endif
1417  painter->restore();
1418  break; }
1419 
1421  QPen pen = qvariant_cast<QPen>(d->variants.at(cmd.offset));
1422 #ifdef QPAINTBUFFER_DEBUG_DRAW
1423  qDebug() << " -> Cmd_SetPen: " << pen;
1424 #endif
1425  painter->setPen(pen);
1426  break; }
1427 
1429  QBrush brush = qvariant_cast<QBrush>(d->variants.at(cmd.offset));
1430 #ifdef QPAINTBUFFER_DEBUG_DRAW
1431  qDebug() << " -> Cmd_SetBrush: " << brush;
1432 #endif
1433  painter->setBrush(brush);
1434  break; }
1435 
1437 #ifdef QPAINTBUFFER_DEBUG_DRAW
1438  qDebug() << " -> Cmd_SetBrushOrigin: " << d->variants.at(cmd.offset).toPointF();
1439 #endif
1440  painter->setBrushOrigin(d->variants.at(cmd.offset).toPointF());
1441  break; }
1442 
1444  QTransform xform = qvariant_cast<QTransform>(d->variants.at(cmd.offset));
1445 #ifdef QPAINTBUFFER_DEBUG_DRAW
1446  qDebug() << " -> Cmd_SetTransform, offset: " << cmd.offset << xform;
1447 #endif
1448  painter->setTransform(xform * m_world_matrix);
1449  break; }
1450 
1452  QPointF delta(d->floats.at(cmd.extra), d->floats.at(cmd.extra+1));
1453 #ifdef QPAINTBUFFER_DEBUG_DRAW
1454  qDebug() << " -> Cmd_Translate, offset: " << cmd.offset << delta;
1455 #endif
1456  painter->translate(delta.x(), delta.y());
1457  return;
1458  }
1459 
1462 #ifdef QPAINTBUFFER_DEBUG_DRAW
1463  qDebug() << " -> Cmd_SetCompositionMode, mode: " << mode;
1464 #endif
1465  painter->setCompositionMode(mode);
1466  break; }
1467 
1469 #ifdef QPAINTBUFFER_DEBUG_DRAW
1470  qDebug() << " -> Cmd_SetRenderHints, hints: " << cmd.extra;
1471 #endif
1472  QPainter::RenderHints ph = painter->renderHints();
1473  QPainter::RenderHints nh = (QPainter::RenderHints) cmd.extra;
1474  QPainter::RenderHints xored = ph ^ nh;
1475  if (xored & QPainter::Antialiasing)
1476  painter->setRenderHint(QPainter::Antialiasing, nh & QPainter::Antialiasing);
1478  painter->setRenderHint(QPainter::HighQualityAntialiasing, nh & QPainter::HighQualityAntialiasing);
1479  if (xored & QPainter::TextAntialiasing)
1480  painter->setRenderHint(QPainter::TextAntialiasing, nh & QPainter::TextAntialiasing);
1481  if (xored & QPainter::SmoothPixmapTransform)
1482  painter->setRenderHint(QPainter::SmoothPixmapTransform, nh & QPainter::SmoothPixmapTransform);
1483  if (xored & QPainter::NonCosmeticDefaultPen)
1484  painter->setRenderHint(QPainter::NonCosmeticDefaultPen, nh & QPainter::NonCosmeticDefaultPen);
1485  break; }
1486 
1488 #ifdef QPAINTBUFFER_DEBUG_DRAW
1489  qDebug() << " -> Cmd_SetOpacity: " << d->variants.at(cmd.offset).toDouble();
1490 #endif
1491  painter->setOpacity(d->variants.at(cmd.offset).toDouble());
1492  break; }
1493 
1495 #ifdef QPAINTBUFFER_DEBUG_DRAW
1496  qDebug() << " -> Cmd_SetBackgroundMode: " << cmd.extra;
1497 #endif
1499  break; }
1500 
1502 #ifdef QPAINTBUFFER_DEBUG_DRAW
1503  qDebug() << " -> Cmd_DrawVectorPath: size: " << cmd.size
1504 // << ", hints:" << d->ints[cmd.offset2+cmd.size]
1505  << "pts/elms:" << cmd.offset << cmd.offset2;
1506 #endif
1507  QVectorPathCmd path(d, cmd);
1508  painter->drawPath(path().convertToPainterPath());
1509  break; }
1510 
1512  QPen pen = qvariant_cast<QPen>(d->variants.at(cmd.extra));
1513 #ifdef QPAINTBUFFER_DEBUG_DRAW
1514  qDebug() << " -> Cmd_StrokeVectorPath: size: " << cmd.size
1515 // << ", hints:" << d->ints[cmd.offset2+cmd.size]
1516  << "pts/elms:" << cmd.offset << cmd.offset2;
1517 #endif
1518  QVectorPathCmd path(d, cmd);
1519  painter->strokePath(path().convertToPainterPath(), pen);
1520  break; }
1521 
1523  QBrush brush = qvariant_cast<QBrush>(d->variants.at(cmd.extra));
1524 #ifdef QPAINTBUFFER_DEBUG_DRAW
1525  qDebug() << " -> Cmd_FillVectorPath: size: " << cmd.size
1526 // << ", hints:" << d->ints[cmd.offset2+cmd.size]
1527  << "pts/elms:" << cmd.offset << cmd.offset2 << brush;
1528 #endif
1529  QVectorPathCmd path(d, cmd);
1530  painter->fillPath(path().convertToPainterPath(), brush);
1531  break; }
1532 
1534 #ifdef QPAINTBUFFER_DEBUG_DRAW
1535  qDebug() << " -> Cmd_DrawPolygonF, offset: " << cmd.offset << " size: " << cmd.size
1536  << " mode: " << cmd.extra
1537  << d->floats.at(cmd.offset)
1538  << d->floats.at(cmd.offset+1);
1539 #endif
1542  painter->drawPolygon((QPointF *) (d->floats.constData() + cmd.offset), cmd.size, fill);
1543  break; }
1544 
1546 #ifdef QPAINTBUFFER_DEBUG_DRAW
1547  qDebug() << " -> Cmd_DrawPolygonI, offset: " << cmd.offset << " size: " << cmd.size
1548  << " mode: " << cmd.extra
1549  << d->ints.at(cmd.offset)
1550  << d->ints.at(cmd.offset+1);
1551 #endif
1554  painter->drawPolygon((QPoint *) (d->ints.constData() + cmd.offset), cmd.size, fill);
1555  break; }
1556 
1558 #ifdef QPAINTBUFFER_DEBUG_DRAW
1559  qDebug() << " -> Cmd_DrawPolylineF, offset: " << cmd.offset << " size: " << cmd.size;
1560 #endif
1561  painter->drawPolyline((QPointF *) (d->floats.constData() + cmd.offset), cmd.size);
1562  break; }
1563 
1565 #ifdef QPAINTBUFFER_DEBUG_DRAW
1566  qDebug() << " -> Cmd_DrawPolylineI, offset: " << cmd.offset << " size: " << cmd.size;
1567 #endif
1568  painter->drawPolyline((QPoint *) (d->ints.constData() + cmd.offset), cmd.size);
1569  break; }
1570 
1572 #ifdef QPAINTBUFFER_DEBUG_DRAW
1573  qDebug() << " -> Cmd_DrawConvexPolygonF, offset: " << cmd.offset << " size: " << cmd.size;
1574 #endif
1575  painter->drawConvexPolygon((QPointF *) (d->floats.constData() + cmd.offset), cmd.size);
1576  break; }
1577 
1579 #ifdef QPAINTBUFFER_DEBUG_DRAW
1580  qDebug() << " -> Cmd_DrawConvexPolygonI, offset: " << cmd.offset << " size: " << cmd.size;
1581 #endif
1582  painter->drawConvexPolygon((QPoint *) (d->ints.constData() + cmd.offset), cmd.size);
1583  break; }
1584 
1586 #ifdef QPAINTBUFFER_DEBUG_DRAW
1587  qDebug() << " -> Cmd_DrawEllipseF, offset: " << cmd.offset;
1588 #endif
1589  painter->drawEllipse(*(QRectF *)(d->floats.constData() + cmd.offset));
1590  break; }
1591 
1593 #ifdef QPAINTBUFFER_DEBUG_DRAW
1594  qDebug() << " -> Cmd_DrawEllipseI, offset: " << cmd.offset;
1595 #endif
1596  painter->drawEllipse(*(QRect *)(d->ints.constData() + cmd.offset));
1597  break; }
1598 
1600 #ifdef QPAINTBUFFER_DEBUG_DRAW
1601  qDebug() << " -> Cmd_DrawLineF, offset: " << cmd.offset << " size: " << cmd.size;
1602 #endif
1603  painter->drawLines((QLineF *)(d->floats.constData() + cmd.offset), cmd.size);
1604  break; }
1605 
1607 #ifdef QPAINTBUFFER_DEBUG_DRAW
1608  qDebug() << " -> Cmd_DrawLineI, offset: " << cmd.offset << " size: " << cmd.size;
1609 #endif
1610  painter->drawLines((QLine *)(d->ints.constData() + cmd.offset), cmd.size);
1611  break; }
1612 
1614 #ifdef QPAINTBUFFER_DEBUG_DRAW
1615  qDebug() << " -> Cmd_DrawPointsF, offset: " << cmd.offset << " size: " << cmd.size;
1616 #endif
1617  painter->drawPoints((QPointF *)(d->floats.constData() + cmd.offset), cmd.size);
1618  break; }
1619 
1621 #ifdef QPAINTBUFFER_DEBUG_DRAW
1622  qDebug() << " -> Cmd_DrawPointsI, offset: " << cmd.offset << " size: " << cmd.size;
1623 #endif
1624  painter->drawPoints((QPoint *)(d->ints.constData() + cmd.offset), cmd.size);
1625  break; }
1626 
1628  QPixmap pm(d->variants.at(cmd.offset).value<QPixmap>());
1629  QRectF r(d->floats.at(cmd.extra), d->floats.at(cmd.extra+1),
1630  d->floats.at(cmd.extra+2), d->floats.at(cmd.extra+3));
1631 
1632  QRectF sr(d->floats.at(cmd.extra+4), d->floats.at(cmd.extra+5),
1633  d->floats.at(cmd.extra+6), d->floats.at(cmd.extra+7));
1634 #ifdef QPAINTBUFFER_DEBUG_DRAW
1635  qDebug() << " -> Cmd_DrawPixmapRect:" << r << sr;
1636 #endif
1637  painter->drawPixmap(r, pm, sr);
1638  break; }
1639 
1641  QPixmap pm(d->variants.at(cmd.offset).value<QPixmap>());
1642  QPointF pos(d->floats.at(cmd.extra), d->floats.at(cmd.extra+1));
1643 #ifdef QPAINTBUFFER_DEBUG_DRAW
1644  qDebug() << " -> Cmd_DrawPixmapPos:" << pos;
1645 #endif
1646  painter->drawPixmap(pos, pm);
1647  break; }
1648 
1650  QPixmap pm(d->variants.at(cmd.offset).value<QPixmap>());
1651  QRectF r(d->floats.at(cmd.extra), d->floats.at(cmd.extra+1),
1652  d->floats.at(cmd.extra+2), d->floats.at(cmd.extra+3));
1653 
1654  QPointF offset(d->floats.at(cmd.extra+4), d->floats.at(cmd.extra+5));
1655 #ifdef QPAINTBUFFER_DEBUG_DRAW
1656  qDebug() << " -> Cmd_DrawTiledPixmap:" << r << offset;
1657 #endif
1658  painter->drawTiledPixmap(r, pm, offset);
1659  break; }
1660 
1662  QImage image(d->variants.at(cmd.offset).value<QImage>());
1663  QRectF r(d->floats.at(cmd.extra), d->floats.at(cmd.extra+1),
1664  d->floats.at(cmd.extra+2), d->floats.at(cmd.extra+3));
1665  QRectF sr(d->floats.at(cmd.extra+4), d->floats.at(cmd.extra+5),
1666  d->floats.at(cmd.extra+6), d->floats.at(cmd.extra+7));
1667 #ifdef QPAINTBUFFER_DEBUG_DRAW
1668  qDebug() << " -> Cmd_DrawImageRect:" << r << sr;
1669 #endif
1670  painter->drawImage(r, image, sr);
1671  break; }
1672 
1674  QImage image(d->variants.at(cmd.offset).value<QImage>());
1675  QPointF pos(d->floats.at(cmd.extra), d->floats.at(cmd.extra+1));
1676 #ifdef QPAINTBUFFER_DEBUG_DRAW
1677  qDebug() << " -> Cmd_DrawImagePos:" << pos;
1678 #endif
1679  painter->drawImage(pos, image);
1680  break; }
1681 
1683 #ifdef QPAINTBUFFER_DEBUG_DRAW
1684  qDebug() << " -> Cmd_DrawRectF, offset: " << cmd.offset;
1685 #endif
1686  painter->drawRects((QRectF *)(d->floats.constData() + cmd.offset), cmd.size);
1687  break; }
1688 
1690 #ifdef QPAINTBUFFER_DEBUG_DRAW
1691  qDebug() << " -> Cmd_DrawRectI, offset: " << cmd.offset;
1692 #endif
1693  painter->drawRects((QRect *)(d->ints.constData() + cmd.offset), cmd.size);
1694  break; }
1695 
1697  QBrush brush = qvariant_cast<QBrush>(d->variants.at(cmd.extra));
1698  QRectF *rect = (QRectF *)(d->floats.constData() + cmd.offset);
1699 #ifdef QPAINTBUFFER_DEBUG_DRAW
1700  qDebug() << " -> Cmd_FillRectBrush, offset: " << cmd.offset << " rect: " << *rect << " brush: " << brush;
1701 #endif
1702  painter->fillRect(*rect, brush);
1703  break; }
1704 
1706  QColor color = qvariant_cast<QColor>(d->variants.at(cmd.extra));
1707  QRectF *rect = (QRectF *)(d->floats.constData() + cmd.offset);
1708 #ifdef QPAINTBUFFER_DEBUG_DRAW
1709  qDebug() << " -> Cmd_FillRectBrush, offset: " << cmd.offset << " rect: " << *rect << " color: " << color;
1710 #endif
1711  painter->fillRect(*rect, color);
1712  break; }
1713 
1715  bool clipEnabled = d->variants.at(cmd.offset).toBool();
1716 #ifdef QPAINTBUFFER_DEBUG_DRAW
1717  qDebug() << " -> Cmd_SetClipEnabled:" << clipEnabled;
1718 #endif
1719  painter->setClipping(clipEnabled);
1720  break; }
1721 
1723  QVectorPathCmd path(d, cmd);
1724 #ifdef QPAINTBUFFER_DEBUG_DRAW
1725  qDebug() << " -> Cmd_ClipVectorPath:" << path().elementCount();
1726 #endif
1727  painter->setClipPath(path().convertToPainterPath(), Qt::ClipOperation(cmd.extra));
1728  break; }
1729 
1730 
1732  QRect rect(QPoint(d->ints.at(cmd.offset), d->ints.at(cmd.offset + 1)),
1733  QPoint(d->ints.at(cmd.offset + 2), d->ints.at(cmd.offset + 3)));
1734 #ifdef QPAINTBUFFER_DEBUG_DRAW
1735  qDebug() << " -> Cmd_ClipRect:" << rect << cmd.extra;
1736 #endif
1738  break; }
1739 
1741  QRegion region(d->variants.at(cmd.offset).value<QRegion>());
1742 #ifdef QPAINTBUFFER_DEBUG_DRAW
1743  qDebug() << " -> Cmd_ClipRegion:" << region.boundingRect() << cmd.extra;
1744 #endif
1746  break; }
1747 
1748 #if !defined(QT_NO_RAWFONT)
1750 
1751  QVariantList variants(d->variants.at(cmd.offset).value<QVariantList>());
1752 
1753  QFont font = variants.at(0).value<QFont>();
1754 
1755  QVector<quint32> glyphIndexes;
1757 
1758  for (int i=0; i<(variants.size() - 1) / 2; ++i) {
1759  glyphIndexes.append(variants.at(i*2 + 1).toUInt());
1760  positions.append(variants.at(i*2 + 2).toPointF());
1761  }
1762 
1763  painter->setFont(font);
1764 
1765  QRawFont rawFont;
1766  QRawFontPrivate *rawFontD = QRawFontPrivate::get(rawFont);
1767  QFontPrivate *fontD = QFontPrivate::get(font);
1769  rawFontD->fontEngine->ref.ref();
1770 
1771  QGlyphRun glyphs;
1772  glyphs.setRawFont(rawFont);
1773  glyphs.setGlyphIndexes(glyphIndexes);
1774  glyphs.setPositions(positions);
1775 
1776  painter->drawGlyphRun(QPointF(), glyphs);
1777  break;
1778  }
1779 #endif
1780 
1782  QPointF pos(d->floats.at(cmd.extra), d->floats.at(cmd.extra+1));
1783  QList<QVariant> variants(d->variants.at(cmd.offset).value<QList<QVariant> >());
1784 
1785  QFont font(variants.at(0).value<QFont>());
1786  QString text(variants.at(1).value<QString>());
1787 
1788  painter->setFont(font);
1789  painter->drawText(pos, text);
1790  break; }
1791 
1793  QPointF pos(d->floats.at(cmd.extra), d->floats.at(cmd.extra+1));
1794  QTextItemIntCopy *tiCopy = reinterpret_cast<QTextItemIntCopy *>(qvariant_cast<void *>(d->variants.at(cmd.offset)));
1795  QTextItemInt &ti = (*tiCopy)();
1796  QString text(ti.text());
1797 
1798  QFont font(ti.font());
1799  font.setUnderline(false);
1800  font.setStrikeOut(false);
1801  font.setOverline(false);
1802 
1803  const QTextItemInt &si = static_cast<const QTextItemInt &>(ti);
1804  qreal justificationWidth = 0;
1805  if (si.justified)
1806  justificationWidth = si.width.toReal();
1807  qreal scaleFactor = font.d->dpi/qreal(qt_defaultDpiY());
1808 
1809 #ifdef QPAINTBUFFER_DEBUG_DRAW
1810  qDebug() << " -> Cmd_DrawTextItem:" << pos << " " << text << " " << scaleFactor;
1811 #endif
1812 
1813  if (scaleFactor != 1.0) {
1814  QFont fnt(font);
1815  QFakeDevice fake;
1816  fake.setDpiX(qRound(scaleFactor*qt_defaultDpiX()));
1817  fake.setDpiY(qRound(scaleFactor*qt_defaultDpiY()));
1818  font = QFont(fnt, &fake);
1819  }
1820 
1822  QSizeF size(1, 1);
1823  if (justificationWidth > 0) {
1824  size.setWidth(justificationWidth);
1825  flags |= Qt::TextJustificationForced;
1826  flags |= Qt::AlignJustify;
1827  }
1828 
1829  QFontMetrics fm(font);
1830  QPointF pt(pos.x(), pos.y() - fm.ascent());
1831  qt_format_text(font, QRectF(pt, size), flags, /*opt*/0,
1832  text, /*brect=*/0, /*tabstops=*/0, /*...*/0, /*tabarraylen=*/0, painter);
1833  break; }
1835  QRegion systemClip(d->variants.at(cmd.offset).value<QRegion>());
1836 
1837 #ifdef QPAINTBUFFER_DEBUG_DRAW
1838  qDebug() << " -> Cmd_SystemStateChanged:" << systemClip;
1839 #endif
1840 
1841  painter->paintEngine()->setSystemClip(systemClip);
1843  break; }
1844  }
1845 }
1846 
1848 {
1850  QPaintEngineEx *xengine = static_cast<QPaintEngineEx *>(painter->paintEngine());
1851 
1852  switch (cmd.id) {
1854 #ifdef QPAINTBUFFER_DEBUG_DRAW
1855  qDebug() << " -> ExCmd_SetBrushOrigin: " << d->variants.at(cmd.offset).toPointF();
1856 #endif
1857  xengine->state()->brushOrigin = d->variants.at(cmd.offset).toPointF();
1858  xengine->brushOriginChanged();
1859  break; }
1860 
1863 #ifdef QPAINTBUFFER_DEBUG_DRAW
1864  qDebug() << " -> ExCmd_SetCompositionMode, mode: " << mode;
1865 #endif
1866  xengine->state()->composition_mode = mode;
1867  xengine->compositionModeChanged();
1868  break; }
1869 
1871 #ifdef QPAINTBUFFER_DEBUG_DRAW
1872  qDebug() << " -> ExCmd_SetOpacity: " << d->variants.at(cmd.offset).toDouble();
1873 #endif
1874  xengine->state()->opacity = d->variants.at(cmd.offset).toDouble();
1875  xengine->opacityChanged();
1876  break; }
1877 
1879 #ifdef QPAINTBUFFER_DEBUG_DRAW
1880  qDebug() << " -> ExCmd_DrawVectorPath: size: " << cmd.size
1881 // << ", hints:" << d->ints[cmd.offset2+cmd.size]
1882  << "pts/elms:" << cmd.offset << cmd.offset2;
1883 #endif
1884  QVectorPathCmd path(d, cmd);
1885  xengine->draw(path());
1886  break; }
1887 
1889  QPen pen = qvariant_cast<QPen>(d->variants.at(cmd.extra));
1890 #ifdef QPAINTBUFFER_DEBUG_DRAW
1891  qDebug() << " -> ExCmd_StrokeVectorPath: size: " << cmd.size
1892 // << ", hints:" << d->ints[cmd.offset2+cmd.size]
1893  << "pts/elms:" << cmd.offset << cmd.offset2;
1894 #endif
1895  QVectorPathCmd path(d, cmd);
1896  xengine->stroke(path(), pen);
1897  break; }
1898 
1900  QBrush brush = qvariant_cast<QBrush>(d->variants.at(cmd.extra));
1901 #ifdef QPAINTBUFFER_DEBUG_DRAW
1902  qDebug() << " -> ExCmd_FillVectorPath: size: " << cmd.size
1903 // << ", hints:" << d->ints[cmd.offset2+cmd.size]
1904  << "pts/elms:" << cmd.offset << cmd.offset2 << brush;
1905 #endif
1906  QVectorPathCmd path(d, cmd);
1907  xengine->fill(path(), brush);
1908  break; }
1909 
1911  QBrush brush = qvariant_cast<QBrush>(d->variants.at(cmd.extra));
1912  QRectF *rect = (QRectF *)(d->floats.constData() + cmd.offset);
1913 #ifdef QPAINTBUFFER_DEBUG_DRAW
1914  qDebug() << " -> ExCmd_FillRectBrush, offset: " << cmd.offset << " rect: " << *rect << " brush: " << brush;
1915 #endif
1916  xengine->fillRect(*rect, brush);
1917  break; }
1918 
1920  QColor color = qvariant_cast<QColor>(d->variants.at(cmd.extra));
1921  QRectF *rect = (QRectF *)(d->floats.constData() + cmd.offset);
1922 #ifdef QPAINTBUFFER_DEBUG_DRAW
1923  qDebug() << " -> ExCmd_FillRectBrush, offset: " << cmd.offset << " rect: " << *rect << " color: " << color;
1924 #endif
1925  xengine->fillRect(*rect, color);
1926  break; }
1927 
1929 #ifdef QPAINTBUFFER_DEBUG_DRAW
1930  qDebug() << " -> ExCmd_DrawPolygonF, offset: " << cmd.offset << " size: " << cmd.size
1931  << " mode: " << cmd.extra
1932  << d->floats.at(cmd.offset)
1933  << d->floats.at(cmd.offset+1);
1934 #endif
1935  xengine->drawPolygon((QPointF *) (d->floats.constData() + cmd.offset), cmd.size,
1937  break; }
1938 
1940 #ifdef QPAINTBUFFER_DEBUG_DRAW
1941  qDebug() << " -> ExCmd_DrawPolygonI, offset: " << cmd.offset << " size: " << cmd.size
1942  << " mode: " << cmd.extra
1943  << d->ints.at(cmd.offset)
1944  << d->ints.at(cmd.offset+1);
1945 #endif
1946  xengine->drawPolygon((QPoint *) (d->ints.constData() + cmd.offset), cmd.size,
1948  break; }
1949 
1951 #ifdef QPAINTBUFFER_DEBUG_DRAW
1952  qDebug() << " -> ExCmd_DrawEllipseF, offset: " << cmd.offset;
1953 #endif
1954  xengine->drawEllipse(*(QRectF *)(d->floats.constData() + cmd.offset));
1955  break; }
1956 
1958 #ifdef QPAINTBUFFER_DEBUG_DRAW
1959  qDebug() << " -> ExCmd_DrawEllipseI, offset: " << cmd.offset;
1960 #endif
1961  xengine->drawEllipse(*(QRect *)(d->ints.constData() + cmd.offset));
1962  break; }
1963 
1965 #ifdef QPAINTBUFFER_DEBUG_DRAW
1966  qDebug() << " -> ExCmd_DrawLineF, offset: " << cmd.offset << " size: " << cmd.size;
1967 #endif
1968  xengine->drawLines((QLineF *)(d->floats.constData() + cmd.offset), cmd.size);
1969  break; }
1970 
1972 #ifdef QPAINTBUFFER_DEBUG_DRAW
1973  qDebug() << " -> ExCmd_DrawLineI, offset: " << cmd.offset << " size: " << cmd.size;
1974 #endif
1975  xengine->drawLines((QLine *)(d->ints.constData() + cmd.offset), cmd.size);
1976  break; }
1977 
1979 #ifdef QPAINTBUFFER_DEBUG_DRAW
1980  qDebug() << " -> ExCmd_DrawPointsF, offset: " << cmd.offset << " size: " << cmd.size;
1981 #endif
1982  xengine->drawPoints((QPointF *)(d->floats.constData() + cmd.offset), cmd.size);
1983  break; }
1984 
1986 #ifdef QPAINTBUFFER_DEBUG_DRAW
1987  qDebug() << " -> ExCmd_DrawPointsI, offset: " << cmd.offset << " size: " << cmd.size;
1988 #endif
1989  xengine->drawPoints((QPoint *)(d->ints.constData() + cmd.offset), cmd.size);
1990  break; }
1991 
1993 #ifdef QPAINTBUFFER_DEBUG_DRAW
1994  qDebug() << " -> ExCmd_DrawPolylineF, offset: " << cmd.offset << " size: " << cmd.size;
1995 #endif
1996  xengine->drawPolygon((QPointF *) (d->floats.constData() + cmd.offset), cmd.size, QPaintEngine::PolylineMode);
1997  break; }
1998 
2000 #ifdef QPAINTBUFFER_DEBUG_DRAW
2001  qDebug() << " -> ExCmd_DrawPolylineI, offset: " << cmd.offset << " size: " << cmd.size;
2002 #endif
2003  xengine->drawPolygon((QPoint *) (d->ints.constData() + cmd.offset), cmd.size, QPaintEngine::PolylineMode);
2004  break; }
2005 
2007 #ifdef QPAINTBUFFER_DEBUG_DRAW
2008  qDebug() << " -> ExCmd_DrawRectF, offset: " << cmd.offset << " size: " << cmd.size;
2009 #endif
2010  xengine->drawRects((QRectF *) (d->floats.constData() + cmd.offset), cmd.size);
2011  break; }
2012 
2014 #ifdef QPAINTBUFFER_DEBUG_DRAW
2015  qDebug() << " -> ExCmd_DrawRectI, offset: " << cmd.offset << " size: " << cmd.size;
2016 #endif
2017  xengine->drawRects((QRect *) (d->ints.constData() + cmd.offset), cmd.size);
2018  break; }
2019 
2021  bool clipEnabled = d->variants.at(cmd.offset).toBool();
2022 #ifdef QPAINTBUFFER_DEBUG_DRAW
2023  qDebug() << " -> ExCmd_SetClipEnabled:" << clipEnabled;
2024 #endif
2025  xengine->state()->clipEnabled = clipEnabled;
2026  xengine->clipEnabledChanged();
2027  break; }
2028 
2030  QVectorPathCmd path(d, cmd);
2031 #ifdef QPAINTBUFFER_DEBUG_DRAW
2032  qDebug() << " -> ExCmd_ClipVectorPath:" << path().elementCount();
2033 #endif
2034  xengine->clip(path(), Qt::ClipOperation(cmd.extra));
2035  break; }
2036 
2037 
2039  QRect rect(QPoint(d->ints.at(cmd.offset), d->ints.at(cmd.offset + 1)),
2040  QPoint(d->ints.at(cmd.offset + 2), d->ints.at(cmd.offset + 3)));
2041 #ifdef QPAINTBUFFER_DEBUG_DRAW
2042  qDebug() << " -> ExCmd_ClipRect:" << rect << cmd.extra;
2043 #endif
2044  xengine->clip(rect, Qt::ClipOperation(cmd.extra));
2045  break; }
2046 
2048  QRegion region(d->variants.at(cmd.offset).value<QRegion>());
2049 #ifdef QPAINTBUFFER_DEBUG_DRAW
2050  qDebug() << " -> ExCmd_ClipRegion:" << region.boundingRect() << cmd.extra;
2051 #endif
2052  xengine->clip(region, Qt::ClipOperation(cmd.extra));
2053  break; }
2054 
2055  default:
2057  break;
2058  }
2059 }
2060 
2061 QPaintBufferResource::QPaintBufferResource(FreeFunc f, QObject *parent) : QObject(parent), free(f)
2062 {
2063  connect(QPaintBufferSignalProxy::instance(), SIGNAL(aboutToDestroy(const QPaintBufferPrivate*)), this, SLOT(remove(const QPaintBufferPrivate*)));
2064 }
2065 
2067 {
2068  for (Cache::iterator it = m_cache.begin(); it != m_cache.end(); ++it)
2069  free(it.value());
2070 }
2071 
2073 {
2074  Cache::iterator it = m_cache.find(key);
2075  if (it != m_cache.end()) {
2076  free(it.value());
2077  it.value() = value;
2078  } else {
2079  m_cache.insert(key, value);
2080  }
2081 }
2082 
2084 {
2085  Cache::iterator it = m_cache.find(key);
2086  if (it != m_cache.end())
2087  return it.value();
2088  return 0;
2089 }
2090 
2092 {
2093  Cache::iterator it = m_cache.find(key);
2094  if (it != m_cache.end()) {
2095  free(it.value());
2096  m_cache.erase(it);
2097  }
2098 }
2099 
2101 {
2102  quint32 id = command.id;
2103  quint32 size = command.size;
2104  stream << id << size;
2105  stream << command.offset << command.offset2 << command.extra;
2106  return stream;
2107 }
2108 
2110 {
2111  quint32 id;
2112  quint32 size;
2113  stream >> id >> size;
2114  stream >> command.offset >> command.offset2 >> command.extra;
2115  command.id = id;
2116  command.size = size;
2117  return stream;
2118 }
2119 
2121 {
2124 };
2125 
2127 {
2128  enum Type {
2130  PixmapKey
2131  };
2132 
2133  struct Flags {
2134  uint type : 8;
2135  uint key : 24;
2136  };
2137 
2138  union {
2141  };
2142 };
2143 
2148 
2150 {
2151  return stream << entry.type << entry.cacheKey;
2152 }
2153 
2155 {
2156  return stream >> entry.type >> entry.cacheKey;
2157 }
2158 
2160 {
2161  return stream << entry.bits;
2162 }
2163 
2165 {
2166  return stream >> entry.bits;
2167 }
2168 
2170 {
2171  qRegisterMetaType<QPaintBufferCacheEntry>();
2172  qRegisterMetaTypeStreamOperators<QPaintBufferCacheEntry>("QPaintBufferCacheEntry");
2173  qRegisterMetaType<QPaintBufferCacheEntryV2>();
2174  qRegisterMetaTypeStreamOperators<QPaintBufferCacheEntryV2>("QPaintBufferCacheEntryV2");
2175 
2176  return 0; // something
2177 }
2178 
2180 
2181 QDataStream &operator<<(QDataStream &stream, const QPaintBuffer &buffer)
2182 {
2183  QHash<qint64, uint> pixmapKeys;
2184  QHash<qint64, uint> imageKeys;
2185 
2186  QHash<qint64, QPixmap> pixmaps;
2187  QHash<qint64, QImage> images;
2188 
2189  QVector<QVariant> variants = buffer.d_ptr->variants;
2190  for (int i = 0; i < variants.size(); ++i) {
2191  const QVariant &v = variants.at(i);
2192  if (v.type() == QVariant::Image) {
2193  const QImage image(v.value<QImage>());
2194 
2197 
2198  QHash<qint64, uint>::iterator it = imageKeys.find(image.cacheKey());
2199  if (it != imageKeys.end()) {
2200  entry.flags.key = *it;
2201  } else {
2202  imageKeys[image.cacheKey()] = entry.flags.key = images.size();
2203  images[images.size()] = image;
2204  }
2205 
2206  variants[i] = QVariant::fromValue(entry);
2207  } else if (v.type() == QVariant::Pixmap) {
2208  const QPixmap pixmap(v.value<QPixmap>());
2209 
2212 
2213  QHash<qint64, uint>::iterator it = pixmapKeys.find(pixmap.cacheKey());
2214  if (it != pixmapKeys.end()) {
2215  entry.flags.key = *it;
2216  } else {
2217  pixmapKeys[pixmap.cacheKey()] = entry.flags.key = pixmaps.size();
2218  pixmaps[pixmaps.size()] = pixmap;
2219  }
2220 
2221  variants[i] = QVariant::fromValue(entry);
2222  }
2223  }
2224 
2225  stream << pixmaps;
2226  stream << images;
2227 
2228  stream << buffer.d_ptr->ints;
2229  stream << buffer.d_ptr->floats;
2230  stream << variants;
2231  stream << buffer.d_ptr->commands;
2232  stream << buffer.d_ptr->boundingRect;
2233  stream << buffer.d_ptr->frames;
2234 
2235  return stream;
2236 }
2237 
2239 {
2240  QHash<qint64, QPixmap> pixmaps;
2241  QHash<qint64, QImage> images;
2242 
2243  stream >> pixmaps;
2244  stream >> images;
2245 
2246  stream >> buffer.d_ptr->ints;
2247  stream >> buffer.d_ptr->floats;
2248  stream >> buffer.d_ptr->variants;
2249  stream >> buffer.d_ptr->commands;
2250  stream >> buffer.d_ptr->boundingRect;
2251  stream >> buffer.d_ptr->frames;
2252 
2253  QVector<QVariant> &variants = buffer.d_ptr->variants;
2254  for (int i = 0; i < variants.size(); ++i) {
2255  const QVariant &v = variants.at(i);
2258  if (entry.type == QVariant::Image)
2259  variants[i] = QVariant(images.value(entry.cacheKey));
2260  else
2261  variants[i] = QVariant(pixmaps.value(entry.cacheKey));
2262  } else if (v.canConvert<QPaintBufferCacheEntryV2>()) {
2264 
2266  variants[i] = QVariant(images.value(entry.flags.key));
2268  variants[i] = QVariant(pixmaps.value(entry.flags.key));
2269  else
2270  qWarning() << "operator<<(QDataStream &stream, QPaintBuffer &buffer): unrecognized cache entry type:" << entry.flags.type;
2271  }
2272  }
2273 
2274  return stream;
2275 }
2276 
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
QPaintBufferResource(FreeFunc f, QObject *parent=0)
QAtomicInt ref
void setTransform(const QTransform &transform, bool combine=false)
Sets the world transformation matrix.
Definition: qpainter.cpp:9547
void setBackgroundMode(Qt::BGMode mode)
Sets the background mode of the painter to the given mode.
Definition: qpainter.cpp:3998
virtual uint flags() const
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
The QDebug class provides an output stream for debugging information.
Definition: qdebug.h:62
QPaintDevice * device() const
Returns the paint device on which this painter is currently painting, or 0 if the painter is not acti...
Definition: qpainter.cpp:1530
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
double d
Definition: qnumeric_p.h:62
virtual void drawPath(const QPainterPath &path)
The default implementation ignores the path and does nothing.
QFontEngine * fontEngine
QDataStream & operator>>(QDataStream &stream, QPaintBufferCommand &command)
qreal dy() const
Returns the vertical translation factor.
Definition: qtransform.h:277
qreal right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:527
QGlyphJustification * justifications
void drawPath(const QPainterPath &path)
Draws the given painter path using the current pen for outline and the current brush for filling...
Definition: qpainter.cpp:3502
QImage copy(const QRect &rect=QRect()) const
Returns a sub-area of the image as a new image.
Definition: qimage.cpp:1410
QFixed * advances_y
int frameEndIndex(int frame) const
virtual void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode)
Reimplement this virtual function to draw the polygon defined by the pointCount first points in point...
virtual void drawImage(const QRectF &r, const QImage &pm, const QRectF &sr, Qt::ImageConversionFlags flags=Qt::AutoColor)
Reimplement this function to draw the part of the image specified by the sr rectangle in the given re...
double qreal
Definition: qglobal.h:1193
char * data()
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
The QFontMetrics class provides font metrics information.
Definition: qfontmetrics.h:65
const QTransform & transform() const
Returns the world transformation matrix.
Definition: qpainter.cpp:9558
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
QPaintBufferEngine(QPaintBufferPrivate *buffer)
QPointF toPointF() const
Returns the variant as a QPointF if the variant has type() Point or PointF ; otherwise returns a null...
Definition: qvariant.cpp:2509
QPaintBufferPrivate * d_ptr
QSize size() const
Returns the size of the pixmap.
Definition: qpixmap.cpp:661
int elementCount() const
virtual void drawPath(const QPainterPath &path)
The default implementation ignores the path and does nothing.
QFixed * advances_x
CompositionMode
Defines the modes supported for digital image compositing.
Definition: qpainter.h:138
The QLine class provides a two-dimensional vector using integer precision.
Definition: qline.h:57
void drawPoints(const QPointF *points, int pointCount)
Draws the first pointCount points in the array points using the current pen&#39;s color.
Definition: qpainter.cpp:3816
QPainter::RenderHints renderHints
Definition: qpainter_p.h:158
virtual void drawPoints(const QPointF *points, int pointCount)
Draws the first pointCount points in the buffer points.
virtual void drawRects(const QRect *rects, int rectCount)
The default implementation converts the first rectCount rectangles in the buffer rects to a QRectF an...
virtual QPainterState * createState(QPainterState *orig) const
virtual void process(const QPaintBufferCommand &cmd)
int qCeil(qreal v)
Definition: qmath.h:63
void setupTransform(QPainter *painter)
QPainter::CompositionMode composition_mode
Definition: qpainter_p.h:174
#define it(className, varName)
int logicalDpiY() const
Definition: qpaintdevice.h:96
Qt::BrushStyle qbrush_style(const QBrush &b)
Definition: qpainter_p.h:96
const QChar * chars
QFixedPoint * glyphPositions
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:67
HB_Glyph * glyphs
virtual void compositionModeChanged()
void setUnderline(bool)
If enable is true, sets underline on; otherwise sets underline off.
Definition: qfont.cpp:1331
Q_GUI_EXPORT int qt_defaultDpiY()
Definition: qfont.cpp:201
void setDpiY(int dpi)
int frameStartIndex(int frame) const
Qt::PenStyle style() const
Returns the pen style.
Definition: qpen.cpp:428
virtual void penChanged()
void setPositions(const QVector< QPointF > &positions)
Sets the positions of the edge of the baseline for each glyph in this set of glyph indexes to positio...
Definition: qglyphrun.cpp:244
void setClipRect(const QRectF &, Qt::ClipOperation op=Qt::ReplaceClip)
Enables clipping, and sets the clip region to the given rectangle using the given clip operation...
Definition: qpainter.cpp:2801
QRectF boundingRect() const
Q_GUI_EXPORT int qt_defaultDpiX()
Definition: qfont.cpp:162
virtual bool begin(QPaintDevice *device)
Reimplement this function to initialise your paint engine when painting is to start on the paint devi...
#define SLOT(a)
Definition: qobjectdefs.h:226
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
virtual int devType() const
FillRule
Definition: qnamespace.h:1485
qreal left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:525
void qt_format_text(const QFont &font, const QRectF &_r, int tf, const QTextOption *option, const QString &str, QRectF *brect, int tabstops, int *tabarray, int tabarraylen, QPainter *painter)
Definition: qpainter.cpp:8458
static QRawFontPrivate * get(const QRawFont &font)
Definition: qrawfont_p.h:109
void restore()
Restores the current painter state (pops a saved state off the stack).
Definition: qpainter.cpp:1620
virtual void fill(const QVectorPath &path, const QBrush &brush)
void emitAboutToDestroy(const QPaintBufferPrivate *buffer)
bool toBool() const
Returns the variant as a bool if the variant has type() Bool.
Definition: qvariant.cpp:2691
const unsigned short * logClusters
QRect boundingRect() const
Returns the bounding rectangle of this region.
Definition: qregion.cpp:4363
bool isExtended() const
Returns true if the paint engine is a QPaintEngineEx derivative.
Definition: qpaintengine.h:234
static QFontPrivate * get(const QFont &font)
Definition: qfont_p.h:202
bool ref()
Atomically increments the value of this QAtomicInt.
T & value() const
Returns a modifiable reference to the current item&#39;s value.
Definition: qhash.h:348
QTransform matrix
Definition: qpainter_p.h:161
virtual bool end()
Reimplement this function to finish painting on the current paint device.
The QString class provides a Unicode character string.
Definition: qstring.h:83
void setWidth(qreal w)
Sets the width to the given width.
Definition: qsize.h:290
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
TransformationType type() const
Returns the transformation type of this matrix.
QString text() const
Returns the text that should be drawn.
#define Q_CONSTRUCTOR_FUNCTION(AFUNC)
Definition: qglobal.h:829
#define Q_D(Class)
Definition: qglobal.h:2482
The QPen class defines how a QPainter should draw lines and outlines of shapes.
Definition: qpen.h:64
void setBrushOrigin(int x, int y)
Sets the brush&#39;s origin to point (x, y).
Definition: qpainter.h:825
The QSizeF class defines the size of a two-dimensional object using floating point precision...
Definition: qsize.h:202
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
void save()
Saves the current painter state (pushes the state onto a stack).
Definition: qpainter.cpp:1590
virtual void brushOriginChanged()
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:753
#define Q_Q(Class)
Definition: qglobal.h:2483
The QLineF class provides a two-dimensional vector using floating point precision.
Definition: qline.h:212
int ascent() const
Returns the ascent of the font.
Q_CORE_EXPORT void qDebug(const char *,...)
int logicalDpiX() const
Definition: qpaintdevice.h:95
QPaintBufferPrivate * buffer
QGlyphLayout glyphs
#define SIGNAL(a)
Definition: qobjectdefs.h:227
virtual void drawEllipse(const QRectF &r)
Reimplement this function to draw the largest ellipse that can be contained within rectangle rect...
void updateBoundingRect(const QRectF &rect)
QVector< int > ints
void drawText(const QPointF &p, const QString &s)
Draws the given text with the currently defined text direction, beginning at the given position...
Definition: qpainter.cpp:6231
QRect mapRect(const QRect &) const
Creates and returns a QRect object that is a copy of the given rectangle, mapped into the coordinate ...
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
void setRenderHint(RenderHint hint, bool on=true)
Sets the given render hint on the painter if on is true; otherwise clears the render hint...
Definition: qpainter.cpp:7620
int addData(const int *data, int count)
QPainter * painter() const
Returns the paint engine&#39;s painter.
void drawRects(const QRectF *rects, int rectCount)
Draws the first rectCount of the given rectangles using the current pen and brush.
Definition: qpainter.cpp:3641
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
void drawEllipse(const QRectF &r)
Draws the ellipse defined by the given rectangle.
Definition: qpainter.cpp:4464
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
static FILE * stream
QVector< QPaintBufferCommand > commands
virtual void opacityChanged()
bool canConvert(Type t) const
Returns true if the variant&#39;s type can be cast to the requested type, t.
Definition: qvariant.cpp:2886
virtual void fillRect(const QRectF &rect, const QBrush &brush)
void * value(const QPaintBufferPrivate *key)
void drawLines(const QLineF *lines, int lineCount)
Draws the first lineCount lines in the array lines using the current pen.
Definition: qpainter.cpp:4873
void fillPath(const QPainterPath &path, const QBrush &brush)
Fills the given path using the given brush.
Definition: qpainter.cpp:3456
unsigned __int64 quint64
Definition: qglobal.h:943
virtual void setState(QPainterState *s)
QBrush qpen_brush(const QPen &p)
Definition: qpainter_p.h:87
bool isCosmetic() const
Returns true if the pen is cosmetic; otherwise returns false.
Definition: qpen.cpp:840
virtual void drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s)
Reimplement this function to draw the pixmap in the given rect, starting at the given p...
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
void drawConvexPolygon(const QPointF *points, int pointCount)
Draws the convex polygon defined by the first pointCount points in the array points using the current...
Definition: qpainter.cpp:5484
static const QCssKnownValue positions[NumKnownPositionModes - 1]
Definition: qcssparser.cpp:329
qreal height() const
Returns the height of the rectangle.
Definition: qrect.h:710
#define Q_GLOBAL_STATIC(TYPE, NAME)
Declares a global static variable with the given type and name.
Definition: qglobal.h:1968
bool isActive() const
Returns true if begin() has been called and end() has not yet been called; otherwise returns false...
Definition: qpainter.cpp:1545
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
bool deref()
Atomically decrements the value of this QAtomicInt.
void append(const T &t)
Inserts value at the end of the vector.
Definition: qvector.h:573
virtual void stroke(const QVectorPath &path, const QPen &pen)
Q_CORE_EXPORT void qWarning(const char *,...)
QPoint map(const QPoint &p) const
Creates and returns a QPoint object that is a copy of the given point, mapped into the coordinate sys...
Internal QTextItem.
qreal ascent() const
Corresponds to the ascent of the piece of text that is drawn.
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
static const char * data(const QByteArray &arr)
unsigned int uint
Definition: qglobal.h:996
Type
This enum type defines the types of variable that a QVariant can contain.
Definition: qvariant.h:95
void drawGlyphRun(const QPointF &position, const QGlyphRun &glyphRun)
Draws the specified glyphs at the given position.
Definition: qpainter.cpp:6064
qreal width() const
Returns the width of the rectangle.
Definition: qrect.h:707
RenderFlags renderFlags() const
Returns the render flags used.
QPaintEngine * paintEngine() const
Returns the paint engine that the painter is currently operating on if the painter is active; otherwi...
Definition: qpainter.cpp:1991
void drawPolygon(const QPointF *points, int pointCount, Qt::FillRule fillRule=Qt::OddEvenFill)
Draws the polygon defined by the first pointCount points in the array points using the current pen an...
Definition: qpainter.cpp:5205
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
virtual void setState(QPainterState *s)
QPaintEngine * paintEngine() const
QRectF adjusted(qreal x1, qreal y1, qreal x2, qreal y2) const
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
Definition: qrect.h:781
The QGlyphRun class provides direct access to the internal glyphs in a font.
Definition: qglyphrun.h:59
static QVariant fromValue(const T &value)
Returns a QVariant containing a copy of value.
Definition: qvariant.h:336
qreal descent() const
Corresponds to the descent of the piece of text that is drawn.
The QPaintEngine class provides an abstract definition of how QPainter draws to a given device on a g...
Definition: qpaintengine.h:90
void setSystemClip(const QRegion &baseClip)
Sets the system clip for this engine.
static int spaceNeededForGlyphLayout(int totalGlyphs)
QPaintBuffer & operator=(const QPaintBuffer &other)
void strokePath(const QPainterPath &path, const QPen &pen)
Draws the outline (strokes) the path path with the pen specified by pen.
Definition: qpainter.cpp:3413
#define Q_DECLARE_METATYPE(TYPE)
This macro makes the type Type known to QMetaType as long as it provides a public default constructor...
Definition: qmetatype.h:265
void insert(const QPaintBufferPrivate *key, void *value)
virtual void systemStateChanged()
void qSwap(T &value1, T &value2)
Definition: qglobal.h:2181
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
QSize size() const
Returns the size of the image, i.
Definition: qimage.cpp:1587
QFontEngine * engineForScript(int script) const
Definition: qfont.cpp:294
qreal width() const
Specifies the total width of the text to be drawn.
void processCommands(const QPaintBuffer &buffer, QPainter *painter, int begin, int end)
int metric(PaintDeviceMetric m) const
void drawTiledPixmap(const QRectF &rect, const QPixmap &pm, const QPointF &offset=QPointF())
Draws a tiled pixmap, inside the given rectangle with its origin at the given position.
Definition: qpainter.cpp:7146
void remove(const QPaintBufferPrivate *key)
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
QScopedPointer< QPaintEnginePrivate > d_ptr
Definition: qpaintengine.h:246
virtual void clip(const QVectorPath &path, Qt::ClipOperation op)
#define Q_DECLARE_PUBLIC(Class)
Definition: qglobal.h:2477
QPaintBufferEngine * engine
QTextItemInt m_item
void draw(QPainter *painter, int frame=0) const
int size() const
Returns the number of items in the hash.
Definition: qhash.h:295
void setClipRegion(const QRegion &, Qt::ClipOperation op=Qt::ReplaceClip)
Sets the clip region to the given region using the specified clip operation.
Definition: qpainter.cpp:2917
void setCompositionMode(CompositionMode mode)
Sets the composition mode to the given mode.
Definition: qpainter.cpp:2422
virtual void drawTextItem(const QPointF &pos, const QTextItem &ti)
This function draws the text item textItem at position p.
QPointF toPointF() const
Definition: qfixed_p.h:194
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:467
The QRawFont class provides access to a single physical instance of a font.
Definition: qrawfont.h:63
virtual int metric(PaintDeviceMetric m) const
void setClipping(bool enable)
Enables clipping if enable is true, or disables clipping if enable is false.
Definition: qpainter.cpp:2517
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
uint own_data
Definition: qimage_p.h:94
QTextItemIntCopy(const QTextItem &item)
uint clipEnabled
Definition: qpainter_p.h:169
void * data_ptr(const QTransform &t)
Definition: qpainter_p.h:81
QString family() const
Returns the requested font family name, i.e.
Definition: qfont.cpp:906
Type type() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1901
int key
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
T & last()
Returns a reference to the last item in the vector.
Definition: qvector.h:262
void setBrush(const QBrush &brush)
Sets the painter&#39;s brush to the given brush.
Definition: qpainter.cpp:4171
The QHash::iterator class provides an STL-style non-const iterator for QHash and QMultiHash.
Definition: qhash.h:330
uint toUInt(bool *ok=0) const
Returns the variant as an unsigned int if the variant has type() UInt , Bool , ByteArray ...
Definition: qvariant.cpp:2644
unsigned int quint32
Definition: qglobal.h:938
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
virtual QPaintEngine * paintEngine() const
void setPen(const QColor &color)
Sets the painter&#39;s pen to have style Qt::SolidLine, width 0 and the specified color.
Definition: qpainter.cpp:4047
QString commandDescription(int command) const
QPointF brushOrigin
Definition: qpainter_p.h:149
qreal widthF() const
Returns the pen width with floating point precision.
Definition: qpen.cpp:645
if(void) toggleToolbarShown
bool isEmpty() const
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
virtual void drawLines(const QLine *lines, int lineCount)
The default implementation converts the first lineCount lines in lines to a QLineF and calls the floa...
iterator begin()
Returns an STL-style iterator pointing to the first item in the hash.
Definition: qhash.h:464
qreal toReal() const
Definition: qfixed_p.h:77
The QTextOption class provides a description of general rich text properties.
Definition: qtextoption.h:59
int numFrames() const
T qvariant_cast(const QVariant &)
Definition: qvariant.h:571
qint64 cacheKey() const
Returns a number that identifies this QPixmap.
Definition: qpixmap.cpp:1136
qreal dx() const
Returns the horizontal translation factor.
Definition: qtransform.h:273
virtual void draw(const QVectorPath &path)
virtual int metric(PaintDeviceMetric metric) const
double toDouble(bool *ok=0) const
Returns the variant as a double if the variant has type() Double , QMetaType::Float ...
Definition: qvariant.cpp:2710
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
void drawImage(const QRectF &targetRect, const QImage &image, const QRectF &sourceRect, Qt::ImageConversionFlags flags=Qt::AutoColor)
Definition: qpainter.cpp:5936
QPainterState * m_created_state
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
int depth() const
Definition: qpaintdevice.h:103
qreal top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:526
void drawPixmap(const QRectF &targetRect, const QPixmap &pixmap, const QRectF &sourceRect)
Draws the rectangular portion source of the given pixmap into the given target in the paint device...
Definition: qpainter.cpp:5619
HB_GlyphAttributes * attributes
virtual void drawStaticTextItem(QStaticTextItem *staticTextItem)
void beginNewFrame()
QDataStream & operator<<(QDataStream &stream, const QPaintBufferCommand &command)
QFontEngine * fontEngine
Definition: qrawfont_p.h:111
QPaintBufferCommand * addCommand(Command command)
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
void setFont(const QFont &f)
Sets the painter&#39;s font to the given font.
Definition: qpainter.cpp:4288
QBrush brush
Definition: qpainter_p.h:153
int processCommands(QPainter *painter, int begin, int end) const
QTransform & scale(qreal sx, qreal sy)
Scales the coordinate system by sx horizontally and sy vertically, and returns a reference to the mat...
Definition: qtransform.cpp:485
bool isEmpty() const
Returns true if the vector has size 0; otherwise returns false.
Definition: qvector.h:139
The QDataStream class provides serialization of binary data to a QIODevice.
Definition: qdatastream.h:71
RenderHints renderHints() const
Returns a flag that specifies the rendering hints that are set for this painter.
Definition: qpainter.cpp:7675
void setClipPath(const QPainterPath &path, Qt::ClipOperation op=Qt::ReplaceClip)
Enables clipping, and sets the clip path for the painter to the given path, with the clip operation...
Definition: qpainter.cpp:3365
const T * constData() const
Returns a const pointer to the data stored in the vector.
Definition: qvector.h:154
virtual void backgroundModeChanged()
virtual void transformChanged()
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
Qt::BGMode bgMode
Definition: qpainter_p.h:171
iterator find(const Key &key)
Returns an iterator pointing to the item with the key in the hash.
Definition: qhash.h:865
void setOpacity(qreal opacity)
Sets the opacity of the painter to opacity.
Definition: qpainter.cpp:2139
qreal bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:528
The QTextItem class provides all the information required to draw text in a custom paint engine...
Definition: qpaintengine.h:68
bool isEmpty() const
Returns true if the rectangle is empty, otherwise returns false.
Definition: qrect.h:658
T value() const
Returns the stored value converted to the template type T.
Definition: qvariant.h:332
virtual void clipEnabledChanged()
static int qRegisterPaintBufferMetaTypes()
QFixedPoint * offsets
static const KeyPair *const end
virtual void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr)
Reimplement this function to draw the part of the pm specified by the sr rectangle in the given r...
const QFont * f
Qt::PenStyle qpen_style(const QPen &p)
Definition: qpainter_p.h:89
void drawPolyline(const QPointF *points, int pointCount)
Draws the polyline defined by the first pointCount points in points using the current pen...
Definition: qpainter.cpp:5055
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
QRegion systemClip() const
Returns the system clip.
virtual void renderHintsChanged()
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137
QFont font() const
Returns the font that should be used to draw the text.
BGMode
Definition: qnamespace.h:588
virtual void process(const QPaintBufferCommand &cmd)
iterator erase(iterator it)
Removes the (key, value) pair associated with the iterator pos from the hash, and returns an iterator...
Definition: qhash.h:827
QPainterState * state()
QVector< QVariant > variants
Q_DECL_CONSTEXPR int qRound(qreal d)
Definition: qglobal.h:1203
qint64 cacheKey() const
Returns a number that identifies the contents of this QImage object.
Definition: qimage.cpp:6282
void setDpiX(int dpi)
static QPaintBufferSignalProxy * instance()
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
Definition: qpainter.cpp:7420
void setGlyphIndexes(const QVector< quint32 > &glyphIndexes)
Set the glyph indexes for this QGlyphRun object to glyphIndexes.
Definition: qglyphrun.cpp:217
#define text
Definition: qobjectdefs.h:80
QVector< qreal > floats
static QImage qpaintbuffer_storable_image(const QImage &src)
void setBoundingRect(const QRectF &rect)
virtual void brushChanged()
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65
void setRawFont(const QRawFont &rawFont)
Sets the font specified by rawFont to be the font used to look up the glyph indexes.
Definition: qglyphrun.cpp:191
ClipOperation
Definition: qnamespace.h:1495
virtual void clip(const QVectorPath &path, Qt::ClipOperation op)=0
glyph_t * glyphs
void translate(const QPointF &offset)
Translates the coordinate system by the given offset; i.e.
Definition: qpainter.cpp:3311