Qt 4.8
Public Functions | Properties | Friends | List of all members
QPaintBuffer Class Reference

#include <qpaintbuffer_p.h>

Inheritance diagram for QPaintBuffer:
QPaintDevice

Public Functions

void beginNewFrame ()
 
QRectF boundingRect () const
 
QString commandDescription (int command) const
 
virtual int devType () const
 
void draw (QPainter *painter, int frame=0) const
 
int frameEndIndex (int frame) const
 
int frameStartIndex (int frame) const
 
bool isEmpty () const
 
virtual int metric (PaintDeviceMetric m) const
 
int numFrames () const
 
QPaintBufferoperator= (const QPaintBuffer &other)
 
virtual QPaintEnginepaintEngine () const
 
int processCommands (QPainter *painter, int begin, int end) const
 
 QPaintBuffer ()
 
 QPaintBuffer (const QPaintBuffer &other)
 
void setBoundingRect (const QRectF &rect)
 
 ~QPaintBuffer ()
 
- Public Functions inherited from QPaintDevice
int colorCount () const
 
int depth () const
 
virtual HDC getDC () const
 
int height () const
 
int heightMM () const
 
int logicalDpiX () const
 
int logicalDpiY () const
 
QT_DEPRECATED int numColors () const
 
bool paintingActive () const
 
int physicalDpiX () const
 
int physicalDpiY () const
 
virtual void releaseDC (HDC hdc) const
 
int width () const
 
int widthMM () const
 
virtual ~QPaintDevice ()
 

Properties

QPaintBufferPrivated_ptr
 

Friends

Q_GUI_EXPORT QDataStreamoperator<< (QDataStream &stream, const QPaintBuffer &buffer)
 
Q_GUI_EXPORT QDataStreamoperator>> (QDataStream &stream, QPaintBuffer &buffer)
 
class QOpenGLReplayer
 
class QPainterReplayer
 

Additional Inherited Members

- Public Types inherited from QPaintDevice
enum  PaintDeviceMetric {
  PdmWidth = 1, PdmHeight, PdmWidthMM, PdmHeightMM,
  PdmNumColors, PdmDepth, PdmDpiX, PdmDpiY,
  PdmPhysicalDpiX, PdmPhysicalDpiY
}
 
- Static Public Functions inherited from QPaintDevice
static QWSDisplayqwsDisplay ()
 
- Protected Functions inherited from QPaintDevice
 QPaintDevice ()
 
- Protected Variables inherited from QPaintDevice
ushort painters
 

Detailed Description

Definition at line 67 of file qpaintbuffer_p.h.

Constructors and Destructors

◆ QPaintBuffer() [1/2]

QPaintBuffer::QPaintBuffer ( )

Definition at line 171 of file qpaintbuffer.cpp.

173 {
174 }
QPaintBufferPrivate * d_ptr

◆ QPaintBuffer() [2/2]

QPaintBuffer::QPaintBuffer ( const QPaintBuffer other)

Definition at line 182 of file qpaintbuffer.cpp.

183  : QPaintDevice(), d_ptr(other.d_ptr)
184 {
185  d_ptr->ref.ref();
186 }
QPaintBufferPrivate * d_ptr
bool ref()
Atomically increments the value of this QAtomicInt.

◆ ~QPaintBuffer()

QPaintBuffer::~QPaintBuffer ( )

Definition at line 176 of file qpaintbuffer.cpp.

177 {
178  if (!d_ptr->ref.deref())
179  delete d_ptr;
180 }
QPaintBufferPrivate * d_ptr
bool deref()
Atomically decrements the value of this QAtomicInt.

Functions

◆ beginNewFrame()

void QPaintBuffer::beginNewFrame ( )

Definition at line 1392 of file qpaintbuffer.cpp.

Referenced by QTraceWindowSurface::beginPaint().

1393 {
1394  if (!d_ptr->commands.isEmpty())
1395  d_ptr->frames << d_ptr->commands.size();
1396 }
QPaintBufferPrivate * d_ptr
QVector< QPaintBufferCommand > commands
bool isEmpty() const
Returns true if the vector has size 0; otherwise returns false.
Definition: qvector.h:139
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137

◆ boundingRect()

QRectF QPaintBuffer::boundingRect ( ) const

Definition at line 558 of file qpaintbuffer.cpp.

559 {
560  return d_ptr->boundingRect;
561 }
QPaintBufferPrivate * d_ptr

◆ commandDescription()

QString QPaintBuffer::commandDescription ( int  command) const

Definition at line 315 of file qpaintbuffer.cpp.

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 }
The QDebug class provides an output stream for debugging information.
Definition: qdebug.h:62
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
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
CompositionMode
Defines the modes supported for digital image compositing.
Definition: qpainter.h:138
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
bool toBool() const
Returns the variant as a bool if the variant has type() Bool.
Definition: qvariant.cpp:2691
The QString class provides a Unicode character string.
Definition: qstring.h:83
QString text() const
Returns the text that should be drawn.
The QPen class defines how a QPainter should draw lines and outlines of shapes.
Definition: qpen.h:64
QVector< int > ints
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
QVector< QPaintBufferCommand > commands
Internal QTextItem.
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
T qvariant_cast(const QVariant &)
Definition: qvariant.h:571
QSizeF size() const
Returns the size of the rectangle.
Definition: qrect.h:713
double toDouble(bool *ok=0) const
Returns the variant as a double if the variant has type() Double , QMetaType::Float ...
Definition: qvariant.cpp:2710
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
const T * constData() const
Returns a const pointer to the data stored in the vector.
Definition: qvector.h:154
T value() const
Returns the stored value converted to the template type T.
Definition: qvariant.h:332
QVector< QVariant > variants
#define text
Definition: qobjectdefs.h:80
QVector< qreal > floats
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65

◆ devType()

int QPaintBuffer::devType ( ) const
virtual

Reimplemented from QPaintDevice.

Definition at line 222 of file qpaintbuffer.cpp.

223 {
224  return QInternal::PaintBuffer;
225 }

◆ draw()

void QPaintBuffer::draw ( QPainter painter,
int  frame = 0 
) const

Definition at line 246 of file qpaintbuffer.cpp.

Referenced by QTraceWindowSurface::endPaint().

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 }
double d
Definition: qnumeric_p.h:62
int frameEndIndex(int frame) const
int frameStartIndex(int frame) const
#define Q_D(Class)
Definition: qglobal.h:2482
Q_CORE_EXPORT void qDebug(const char *,...)
int processCommands(QPainter *painter, int begin, int end) const

◆ frameEndIndex()

int QPaintBuffer::frameEndIndex ( int  frame) const

Definition at line 283 of file qpaintbuffer.cpp.

Referenced by draw().

284 {
285  return (frame == d_ptr->frames.size()) ? d_ptr->commands.size() : d_ptr->frames.at(frame);
286 }
QPaintBufferPrivate * d_ptr
QVector< QPaintBufferCommand > commands
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137

◆ frameStartIndex()

int QPaintBuffer::frameStartIndex ( int  frame) const

Definition at line 278 of file qpaintbuffer.cpp.

Referenced by draw().

279 {
280  return (frame == 0) ? 0 : d_ptr->frames.at(frame - 1);
281 }
QPaintBufferPrivate * d_ptr
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468

◆ isEmpty()

bool QPaintBuffer::isEmpty ( ) const

Definition at line 239 of file qpaintbuffer.cpp.

240 {
241  return d_ptr->commands.isEmpty();
242 }
QPaintBufferPrivate * d_ptr
QVector< QPaintBufferCommand > commands
bool isEmpty() const
Returns true if the vector has size 0; otherwise returns false.
Definition: qvector.h:139

◆ metric()

int QPaintBuffer::metric ( PaintDeviceMetric  m) const
virtual

Reimplemented from QPaintDevice.

Definition at line 197 of file qpaintbuffer.cpp.

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:
217  }
218 
219  return val;
220 }
QPaintBufferPrivate * d_ptr
int qCeil(qreal v)
Definition: qmath.h:63
Q_GUI_EXPORT int qt_defaultDpiY()
Definition: qfont.cpp:201
Q_GUI_EXPORT int qt_defaultDpiX()
Definition: qfont.cpp:162
qreal height() const
Returns the height of the rectangle.
Definition: qrect.h:710
qreal width() const
Returns the width of the rectangle.
Definition: qrect.h:707
virtual int metric(PaintDeviceMetric m) const
virtual int metric(PaintDeviceMetric metric) const

◆ numFrames()

int QPaintBuffer::numFrames ( ) const

Definition at line 1398 of file qpaintbuffer.cpp.

Referenced by QTraceWindowSurface::endPaint().

1399 {
1400  return d_ptr->frames.size() + 1;
1401 }
QPaintBufferPrivate * d_ptr
int size() const
Returns the number of items in the list.
Definition: qlist.h:137

◆ operator=()

QPaintBuffer & QPaintBuffer::operator= ( const QPaintBuffer other)

Definition at line 227 of file qpaintbuffer.cpp.

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 }
QPaintBufferPrivate * d_ptr
bool ref()
Atomically increments the value of this QAtomicInt.
bool deref()
Atomically decrements the value of this QAtomicInt.
static const char * data(const QByteArray &arr)

◆ paintEngine()

QPaintEngine * QPaintBuffer::paintEngine ( ) const
virtual

Implements QPaintDevice.

Definition at line 188 of file qpaintbuffer.cpp.

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 }
double d
Definition: qnumeric_p.h:62
QPaintBufferPrivate * d_ptr
QPaintBufferEngine * engine

◆ processCommands()

int QPaintBuffer::processCommands ( QPainter painter,
int  begin,
int  end 
) const

Definition at line 288 of file qpaintbuffer.cpp.

Referenced by draw().

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 }
QPaintBufferPrivate * d_ptr
bool isExtended() const
Returns true if the paint engine is a QPaintEngineEx derivative.
Definition: qpaintengine.h:234
QVector< QPaintBufferCommand > commands
bool isActive() const
Returns true if begin() has been called and end() has not yet been called; otherwise returns false...
Definition: qpainter.cpp:1545
QPaintEngine * paintEngine() const
Returns the paint engine that the painter is currently operating on if the painter is active; otherwi...
Definition: qpainter.cpp:1991
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
void processCommands(const QPaintBuffer &buffer, QPainter *painter, int begin, int end)
int depth() const
Definition: qpaintdevice.h:103
static const KeyPair *const end

◆ setBoundingRect()

void QPaintBuffer::setBoundingRect ( const QRectF rect)

Definition at line 563 of file qpaintbuffer.cpp.

Referenced by QTraceWindowSurface::paintDevice().

564 {
565  d_ptr->boundingRect = rect;
566  d_ptr->calculateBoundingRect = false;
567 }
QPaintBufferPrivate * d_ptr

Friends and Related Functions

◆ operator<<

Q_GUI_EXPORT QDataStream& operator<< ( QDataStream stream,
const QPaintBuffer buffer 
)
friend

Definition at line 2181 of file qpaintbuffer.cpp.

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 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
QPaintBufferPrivate * d_ptr
#define it(className, varName)
QVector< int > ints
static FILE * stream
QVector< QPaintBufferCommand > commands
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
static QVariant fromValue(const T &value)
Returns a QVariant containing a copy of value.
Definition: qvariant.h:336
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
int size() const
Returns the number of items in the hash.
Definition: qhash.h:295
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:467
Type type() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1901
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
iterator find(const Key &key)
Returns an iterator pointing to the item with the key in the hash.
Definition: qhash.h:865
T value() const
Returns the stored value converted to the template type T.
Definition: qvariant.h:332
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137
QVector< QVariant > variants
QVector< qreal > floats

◆ operator>>

Q_GUI_EXPORT QDataStream& operator>> ( QDataStream stream,
QPaintBuffer buffer 
)
friend

Definition at line 2238 of file qpaintbuffer.cpp.

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 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
QPaintBufferPrivate * d_ptr
The QHash class is a template class that provides a hash-table-based dictionary.
Definition: qdatastream.h:66
QVector< int > ints
static FILE * stream
QVector< QPaintBufferCommand > commands
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
Q_CORE_EXPORT void qWarning(const char *,...)
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
T value() const
Returns the stored value converted to the template type T.
Definition: qvariant.h:332
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137
QVector< QVariant > variants
QVector< qreal > floats

◆ QOpenGLReplayer

friend class QOpenGLReplayer
friend

Definition at line 100 of file qpaintbuffer_p.h.

◆ QPainterReplayer

friend class QPainterReplayer
friend

Definition at line 99 of file qpaintbuffer_p.h.

Properties

◆ d_ptr

QPaintBufferPrivate* QPaintBuffer::d_ptr
private

The documentation for this class was generated from the following files: