Qt 4.8
Public Functions | Protected Functions | Private Functions | List of all members
QPicturePaintEngine Class Reference

#include <qpaintengine_pic_p.h>

Inheritance diagram for QPicturePaintEngine:
QPaintEngine

Public Functions

bool begin (QPaintDevice *pdev)
 Reimplement this function to initialise your paint engine when painting is to start on the paint device pdev. More...
 
void drawEllipse (const QRectF &rect)
 Reimplement this function to draw the largest ellipse that can be contained within rectangle rect. More...
 
void drawImage (const QRectF &r, const QImage &image, 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 rectangle using the given conversion flags flags, to convert it to a pixmap. More...
 
void drawPath (const QPainterPath &path)
 The default implementation ignores the path and does nothing. More...
 
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. More...
 
void drawPolygon (const QPointF *points, int numPoints, PolygonDrawMode mode)
 Reimplement this virtual function to draw the polygon defined by the pointCount first points in points, using mode mode. More...
 
void drawTextItem (const QPointF &p, const QTextItem &ti)
 This function draws the text item textItem at position p. More...
 
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. More...
 
bool end ()
 Reimplement this function to finish painting on the current paint device. More...
 
 QPicturePaintEngine ()
 
Type type () const
 Reimplement this function to return the paint engine Type. More...
 
void updateBackground (Qt::BGMode bgmode, const QBrush &bgBrush)
 
void updateBrush (const QBrush &brush)
 
void updateBrushOrigin (const QPointF &origin)
 
void updateClipEnabled (bool enabled)
 
void updateClipPath (const QPainterPath &path, Qt::ClipOperation op)
 
void updateClipRegion (const QRegion &region, Qt::ClipOperation op)
 
void updateCompositionMode (QPainter::CompositionMode cmode)
 
void updateFont (const QFont &font)
 
void updateMatrix (const QTransform &matrix)
 
void updateOpacity (qreal opacity)
 
void updatePen (const QPen &pen)
 
void updateRenderHints (QPainter::RenderHints hints)
 
void updateState (const QPaintEngineState &state)
 Reimplement this function to update the state of a paint engine. More...
 
 ~QPicturePaintEngine ()
 
- Public Functions inherited from QPaintEngine
void clearDirty (DirtyFlags df)
 
virtual QPoint coordinateOffset () const
 Returns the offset from the painters origo to the engines origo. More...
 
virtual void drawEllipse (const QRect &r)
 The default implementation of this function calls the floating point version of this function. More...
 
virtual void drawLines (const QLine *lines, int lineCount)
 The default implementation converts the first lineCount lines in lines to a QLineF and calls the floating point version of this function. More...
 
virtual void drawLines (const QLineF *lines, int lineCount)
 The default implementation splits the list of lines in lines into lineCount separate calls to drawPath() or drawPolygon() depending on the feature set of the paint engine. More...
 
virtual void drawPoints (const QPointF *points, int pointCount)
 Draws the first pointCount points in the buffer points. More...
 
virtual void drawPoints (const QPoint *points, int pointCount)
 Draws the first pointCount points in the buffer points. More...
 
virtual void drawPolygon (const QPoint *points, int pointCount, PolygonDrawMode mode)
 Reimplement this virtual function to draw the polygon defined by the pointCount first points in points, using mode mode. More...
 
virtual void drawRects (const QRect *rects, int rectCount)
 The default implementation converts the first rectCount rectangles in the buffer rects to a QRectF and calls the floating point version of this function. More...
 
virtual void drawRects (const QRectF *rects, int rectCount)
 Draws the first rectCount rectangles in the buffer rects. More...
 
void fix_neg_rect (int *x, int *y, int *w, int *h)
 
virtual HDC getDC () const
 Empty default implementation. More...
 
bool hasFeature (PaintEngineFeatures feature) const
 Returns true if the paint engine supports the specified feature; otherwise returns false. More...
 
bool isActive () const
 Returns true if the paint engine is actively drawing; otherwise returns false. More...
 
bool isExtended () const
 Returns true if the paint engine is a QPaintEngineEx derivative. More...
 
QPaintDevicepaintDevice () const
 Returns the device that this engine is painting on, if painting is active; otherwise returns 0. More...
 
QPainterpainter () const
 Returns the paint engine's painter. More...
 
 QPaintEngine (PaintEngineFeatures features=0)
 Creates a paint engine with the featureset specified by caps. More...
 
virtual void releaseDC (HDC hdc) const
 Empty default implementation. More...
 
void setActive (bool newState)
 Sets the active state of the paint engine to state. More...
 
void setDirty (DirtyFlags df)
 
void setPaintDevice (QPaintDevice *device)
 
void setSystemClip (const QRegion &baseClip)
 Sets the system clip for this engine. More...
 
void setSystemRect (const QRect &rect)
 Sets the target rect for drawing within the backing store. More...
 
void syncState ()
 Updates all dirty states in this engine. More...
 
QRegion systemClip () const
 Returns the system clip. More...
 
QRect systemRect () const
 Retrieves the rect for drawing within the backing store. More...
 
bool testDirty (DirtyFlags df)
 
virtual ~QPaintEngine ()
 Destroys the paint engine. More...
 

Protected Functions

 QPicturePaintEngine (QPaintEnginePrivate &dptr)
 
- Protected Functions inherited from QPaintEngine
 QPaintEngine (QPaintEnginePrivate &data, PaintEngineFeatures devcaps=0)
 

Private Functions

void writeCmdLength (int pos, const QRectF &r, bool corr)
 

Additional Inherited Members

- Public Types inherited from QPaintEngine
enum  DirtyFlag {
  DirtyPen = 0x0001, DirtyBrush = 0x0002, DirtyBrushOrigin = 0x0004, DirtyFont = 0x0008,
  DirtyBackground = 0x0010, DirtyBackgroundMode = 0x0020, DirtyTransform = 0x0040, DirtyClipRegion = 0x0080,
  DirtyClipPath = 0x0100, DirtyHints = 0x0200, DirtyCompositionMode = 0x0400, DirtyClipEnabled = 0x0800,
  DirtyOpacity = 0x1000, AllDirty = 0xffff
}
 QPaintEngine::updateState(). More...
 
enum  PaintEngineFeature {
  PrimitiveTransform = 0x00000001, PatternTransform = 0x00000002, PixmapTransform = 0x00000004, PatternBrush = 0x00000008,
  LinearGradientFill = 0x00000010, RadialGradientFill = 0x00000020, ConicalGradientFill = 0x00000040, AlphaBlend = 0x00000080,
  PorterDuff = 0x00000100, PainterPaths = 0x00000200, Antialiasing = 0x00000400, BrushStroke = 0x00000800,
  ConstantOpacity = 0x00001000, MaskedBrush = 0x00002000, PerspectiveTransform = 0x00004000, BlendModes = 0x00008000,
  ObjectBoundingModeGradients = 0x00010000, RasterOpModes = 0x00020000, PaintOutsidePaintEvent = 0x20000000, AllFeatures = 0xffffffff
}
 This enum is used to describe the features or capabilities that the paint engine has. More...
 
enum  PolygonDrawMode { OddEvenMode, WindingMode, ConvexMode, PolylineMode }
 
enum  Type {
  X11, Windows, QuickDraw, CoreGraphics,
  MacPrinter, QWindowSystem, PostScript, OpenGL,
  Picture, SVG, Raster, Direct3D,
  Pdf, OpenVG, OpenGL2, PaintBuffer,
  Blitter, User = 50, MaxUser = 100
}
 
- Protected Variables inherited from QPaintEngine
uint active: 1
 
QScopedPointer< QPaintEnginePrivated_ptr
 
uint extended: 1
 
PaintEngineFeatures gccaps
 
uint selfDestruct: 1
 
QPaintEngineStatestate
 

Detailed Description

Definition at line 66 of file qpaintengine_pic_p.h.

Constructors and Destructors

◆ QPicturePaintEngine() [1/2]

QPicturePaintEngine::QPicturePaintEngine ( )

Definition at line 74 of file qpaintengine_pic.cpp.

Referenced by type().

76 {
78  d->pt = 0;
79 }
double d
Definition: qnumeric_p.h:62
QPaintEngine(PaintEngineFeatures features=0)
Creates a paint engine with the featureset specified by caps.
#define Q_D(Class)
Definition: qglobal.h:2482

◆ ~QPicturePaintEngine()

QPicturePaintEngine::~QPicturePaintEngine ( )

Definition at line 88 of file qpaintengine_pic.cpp.

89 {
90 }

◆ QPicturePaintEngine() [2/2]

QPicturePaintEngine::QPicturePaintEngine ( QPaintEnginePrivate dptr)
protected

Definition at line 81 of file qpaintengine_pic.cpp.

82  : QPaintEngine(dptr, AllFeatures)
83 {
85  d->pt = 0;
86 }
double d
Definition: qnumeric_p.h:62
QPaintEngine(PaintEngineFeatures features=0)
Creates a paint engine with the featureset specified by caps.
#define Q_D(Class)
Definition: qglobal.h:2482

Functions

◆ begin()

bool QPicturePaintEngine::begin ( QPaintDevice pdev)
virtual

Reimplement this function to initialise your paint engine when painting is to start on the paint device pdev.

Return true if the initialization was successful; otherwise return false.

See also
end() isActive()

Implements QPaintEngine.

Definition at line 92 of file qpaintengine_pic.cpp.

93 {
95 #ifdef QT_PICTURE_DEBUG
96  qDebug() << "QPicturePaintEngine::begin()";
97 #endif
98  Q_ASSERT(pd);
99  QPicture *pic = static_cast<QPicture *>(pd);
100 
101  d->pdev = pd;
102  d->pic_d = pic->d_func();
103  Q_ASSERT(d->pic_d);
104 
105  d->s.setDevice(&d->pic_d->pictb);
106  d->s.setVersion(d->pic_d->formatMajor);
107 
108  d->pic_d->pictb.open(QIODevice::WriteOnly | QIODevice::Truncate);
109  d->s.writeRawData(qt_mfhdr_tag, 4);
110  d->s << (quint16) 0 << (quint16) d->pic_d->formatMajor << (quint16) d->pic_d->formatMinor;
111  d->s << (quint8) QPicturePrivate::PdcBegin << (quint8) sizeof(qint32);
112  d->pic_d->brect = QRect();
113  if (d->pic_d->formatMajor >= 4) {
114  QRect r = pic->boundingRect();
115  d->s << (qint32) r.left() << (qint32) r.top() << (qint32) r.width()
116  << (qint32) r.height();
117  }
118  d->pic_d->trecs = 0;
119  d->s << (quint32)d->pic_d->trecs; // total number of records
120  d->pic_d->formatOk = false;
121  setActive(true);
122  return true;
123 }
double d
Definition: qnumeric_p.h:62
int qint32
Definition: qglobal.h:937
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
unsigned char quint8
Definition: qglobal.h:934
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
Q_CORE_EXPORT void qDebug(const char *,...)
void setActive(bool newState)
Sets the active state of the paint engine to state.
Definition: qpaintengine.h:155
QRect boundingRect() const
Returns the picture&#39;s bounding rectangle or an invalid rectangle if the picture contains no data...
Definition: qpicture.cpp:385
unsigned short quint16
Definition: qglobal.h:936
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
unsigned int quint32
Definition: qglobal.h:938
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
const char * qt_mfhdr_tag
Definition: qpicture.cpp:112
The QPicture class is a paint device that records and replays QPainter commands.
Definition: qpicture.h:58

◆ drawEllipse()

void QPicturePaintEngine::drawEllipse ( const QRectF rect)
virtual

Reimplement this function to draw the largest ellipse that can be contained within rectangle rect.

The default implementation calls drawPolygon().

Reimplemented from QPaintEngine.

Definition at line 376 of file qpaintengine_pic.cpp.

377 {
379 #ifdef QT_PICTURE_DEBUG
380  qDebug() << " -> drawEllipse():" << rect;
381 #endif
382  int pos;
384  d->s << rect;
385  writeCmdLength(pos, rect, true);
386 }
double d
Definition: qnumeric_p.h:62
#define SERIALIZE_CMD(c)
#define Q_D(Class)
Definition: qglobal.h:2482
Q_CORE_EXPORT void qDebug(const char *,...)
void writeCmdLength(int pos, const QRectF &r, bool corr)

◆ drawImage()

void QPicturePaintEngine::drawImage ( const QRectF r,
const QImage pm,
const QRectF sr,
Qt::ImageConversionFlags  flags = Qt::AutoColor 
)
virtual

Reimplement this function to draw the part of the image specified by the sr rectangle in the given rectangle using the given conversion flags flags, to convert it to a pixmap.

Reimplemented from QPaintEngine.

Definition at line 461 of file qpaintengine_pic.cpp.

463 {
465 #ifdef QT_PICTURE_DEBUG
466  qDebug() << " -> drawImage():" << r << sr;
467 #endif
468  int pos;
470  if (d->pic_d->in_memory_only) {
471  int index = d->pic_d->image_list.size();
472  d->pic_d->image_list.append(image);
473  d->s << r << index << sr << (quint32) flags;
474  } else {
475  d->s << r << image << sr << (quint32) flags;
476  }
477  writeCmdLength(pos, r, false);
478 }
double d
Definition: qnumeric_p.h:62
#define SERIALIZE_CMD(c)
#define Q_D(Class)
Definition: qglobal.h:2482
Q_CORE_EXPORT void qDebug(const char *,...)
unsigned int quint32
Definition: qglobal.h:938
quint16 index
void writeCmdLength(int pos, const QRectF &r, bool corr)

◆ drawPath()

void QPicturePaintEngine::drawPath ( const QPainterPath path)
virtual

The default implementation ignores the path and does nothing.

Reimplemented from QPaintEngine.

Definition at line 388 of file qpaintengine_pic.cpp.

389 {
391 #ifdef QT_PICTURE_DEBUG
392  qDebug() << " -> drawPath():" << path.boundingRect();
393 #endif
394  int pos;
396  d->s << path;
397  writeCmdLength(pos, path.boundingRect(), true);
398 }
double d
Definition: qnumeric_p.h:62
#define SERIALIZE_CMD(c)
#define Q_D(Class)
Definition: qglobal.h:2482
QRectF boundingRect() const
Returns the bounding rectangle of this painter path as a rectangle with floating point precision...
Q_CORE_EXPORT void qDebug(const char *,...)
void writeCmdLength(int pos, const QRectF &r, bool corr)

◆ drawPixmap()

void QPicturePaintEngine::drawPixmap ( const QRectF r,
const QPixmap pm,
const QRectF sr 
)
virtual

Reimplement this function to draw the part of the pm specified by the sr rectangle in the given r.

Implements QPaintEngine.

Definition at line 424 of file qpaintengine_pic.cpp.

425 {
427 #ifdef QT_PICTURE_DEBUG
428  qDebug() << " -> drawPixmap():" << r;
429 #endif
430  int pos;
432 
433  if (d->pic_d->in_memory_only) {
434  int index = d->pic_d->pixmap_list.size();
435  d->pic_d->pixmap_list.append(pm);
436  d->s << r << index << sr;
437  } else {
438  d->s << r << pm << sr;
439  }
440  writeCmdLength(pos, r, false);
441 }
double d
Definition: qnumeric_p.h:62
#define SERIALIZE_CMD(c)
#define Q_D(Class)
Definition: qglobal.h:2482
Q_CORE_EXPORT void qDebug(const char *,...)
quint16 index
void writeCmdLength(int pos, const QRectF &r, bool corr)

◆ drawPolygon()

void QPicturePaintEngine::drawPolygon ( const QPointF points,
int  pointCount,
PolygonDrawMode  mode 
)
virtual

Reimplement this virtual function to draw the polygon defined by the pointCount first points in points, using mode mode.

Note
At least one of the drawPolygon() functions must be reimplemented.

Reimplemented from QPaintEngine.

Definition at line 400 of file qpaintengine_pic.cpp.

401 {
403 #ifdef QT_PICTURE_DEBUG
404  qDebug() << " -> drawPolygon(): size=" << numPoints;
405 #endif
406  int pos;
407 
408  QPolygonF polygon;
409  for (int i=0; i<numPoints; ++i)
410  polygon << points[i];
411 
412  if (mode == PolylineMode) {
414  d->s << polygon;
415  } else {
417  d->s << polygon;
418  d->s << (qint8)(mode == OddEvenMode ? 0 : 1);
419  }
420 
421  writeCmdLength(pos, polygon.boundingRect(), true);
422 }
double d
Definition: qnumeric_p.h:62
#define SERIALIZE_CMD(c)
QRectF boundingRect() const
Returns the bounding rectangle of the polygon, or QRectF(0,0,0,0) if the polygon is empty...
Definition: qpolygon.cpp:742
#define Q_D(Class)
Definition: qglobal.h:2482
Q_CORE_EXPORT void qDebug(const char *,...)
signed char qint8
Definition: qglobal.h:933
The QPolygonF class provides a vector of points using floating point precision.
Definition: qpolygon.h:134
void writeCmdLength(int pos, const QRectF &r, bool corr)

◆ drawTextItem()

void QPicturePaintEngine::drawTextItem ( const QPointF p,
const QTextItem textItem 
)
virtual

This function draws the text item textItem at position p.

The default implementation of this function converts the text to a QPainterPath and paints the resulting path.

Reimplemented from QPaintEngine.

Definition at line 480 of file qpaintengine_pic.cpp.

481 {
483 #ifdef QT_PICTURE_DEBUG
484  qDebug() << " -> drawTextItem():" << p << ti.text();
485 #endif
486 
487  const QTextItemInt &si = static_cast<const QTextItemInt &>(ti);
488  if (si.chars == 0)
489  QPaintEngine::drawTextItem(p, ti); // Draw as path
490 
491  if (d->pic_d->formatMajor >= 9) {
492  int pos;
494  QFont fnt = ti.font();
495  fnt.setUnderline(false);
496  fnt.setStrikeOut(false);
497  fnt.setOverline(false);
498 
499  qreal justificationWidth = 0;
500  if (si.justified)
501  justificationWidth = si.width.toReal();
502 
503  d->s << p << ti.text() << fnt << ti.renderFlags() << double(fnt.d->dpi)/qt_defaultDpi() << justificationWidth;
504  writeCmdLength(pos, /*brect=*/QRectF(), /*corr=*/false);
505  } else if (d->pic_d->formatMajor >= 8) {
506  // old old (buggy) format
507  int pos;
509  d->s << QPointF(p.x(), p.y() - ti.ascent()) << ti.text() << ti.font() << ti.renderFlags();
510  writeCmdLength(pos, /*brect=*/QRectF(), /*corr=*/false);
511  } else {
512  // old (buggy) format
513  int pos;
515  d->s << p << ti.text();
516  writeCmdLength(pos, QRectF(p, QSizeF(1,1)), true);
517  }
518 }
double d
Definition: qnumeric_p.h:62
double qreal
Definition: qglobal.h:1193
const QChar * chars
void setUnderline(bool)
If enable is true, sets underline on; otherwise sets underline off.
Definition: qfont.cpp:1331
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
#define SERIALIZE_CMD(c)
#define Q_D(Class)
Definition: qglobal.h:2482
The QSizeF class defines the size of a two-dimensional object using floating point precision...
Definition: qsize.h:202
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
Q_CORE_EXPORT void qDebug(const char *,...)
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
void setStrikeOut(bool)
If enable is true, sets strikeout on; otherwise sets strikeout off.
Definition: qfont.cpp:1378
Internal QTextItem.
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
Q_GUI_EXPORT int qt_defaultDpi()
Definition: qfont.cpp:240
void setOverline(bool)
If enable is true, sets overline on; otherwise sets overline off.
Definition: qfont.cpp:1354
QExplicitlySharedDataPointer< QFontPrivate > d
Definition: qfont.h:343
qreal toReal() const
Definition: qfixed_p.h:77
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287
void writeCmdLength(int pos, const QRectF &r, bool corr)
virtual void drawTextItem(const QPointF &p, const QTextItem &textItem)
This function draws the text item textItem at position p.

◆ drawTiledPixmap()

void QPicturePaintEngine::drawTiledPixmap ( const QRectF rect,
const QPixmap pixmap,
const QPointF p 
)
virtual

Reimplement this function to draw the pixmap in the given rect, starting at the given p.

The pixmap will be drawn repeatedly until the rect is filled.

Reimplemented from QPaintEngine.

Definition at line 443 of file qpaintengine_pic.cpp.

444 {
446 #ifdef QT_PICTURE_DEBUG
447  qDebug() << " -> drawTiledPixmap():" << r << s;
448 #endif
449  int pos;
451  if (d->pic_d->in_memory_only) {
452  int index = d->pic_d->pixmap_list.size();
453  d->pic_d->pixmap_list.append(pixmap);
454  d->s << r << index << s;
455  } else {
456  d->s << r << pixmap << s;
457  }
458  writeCmdLength(pos, r, false);
459 }
double d
Definition: qnumeric_p.h:62
#define SERIALIZE_CMD(c)
#define Q_D(Class)
Definition: qglobal.h:2482
Q_CORE_EXPORT void qDebug(const char *,...)
quint16 index
void writeCmdLength(int pos, const QRectF &r, bool corr)

◆ end()

bool QPicturePaintEngine::end ( )
virtual

Reimplement this function to finish painting on the current paint device.

Return true if painting was finished successfully; otherwise return false.

See also
begin() isActive()

Implements QPaintEngine.

Definition at line 125 of file qpaintengine_pic.cpp.

126 {
128 #ifdef QT_PICTURE_DEBUG
129  qDebug() << "QPicturePaintEngine::end()";
130 #endif
131  d->pic_d->trecs++;
132  d->s << (quint8) QPicturePrivate::PdcEnd << (quint8) 0;
133  int cs_start = sizeof(quint32); // pos of checksum word
134  int data_start = cs_start + sizeof(quint16);
135  int brect_start = data_start + 2*sizeof(qint16) + 2*sizeof(quint8);
136  int pos = d->pic_d->pictb.pos();
137  d->pic_d->pictb.seek(brect_start);
138  if (d->pic_d->formatMajor >= 4) { // bounding rectangle
139  QRect r = static_cast<QPicture *>(d->pdev)->boundingRect();
140  d->s << (qint32) r.left() << (qint32) r.top() << (qint32) r.width()
141  << (qint32) r.height();
142  }
143  d->s << (quint32) d->pic_d->trecs; // write number of records
144  d->pic_d->pictb.seek(cs_start);
145  QByteArray buf = d->pic_d->pictb.buffer();
146  quint16 cs = (quint16) qChecksum(buf.constData() + data_start, pos - data_start);
147  d->s << cs; // write checksum
148  d->pic_d->pictb.close();
149  setActive(false);
150  return true;
151 }
double d
Definition: qnumeric_p.h:62
int qint32
Definition: qglobal.h:937
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
unsigned char quint8
Definition: qglobal.h:934
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
#define Q_D(Class)
Definition: qglobal.h:2482
static const QRectF boundingRect(const QPointF *points, int pointCount)
Q_CORE_EXPORT void qDebug(const char *,...)
Q_CORE_EXPORT quint16 qChecksum(const char *s, uint len)
void setActive(bool newState)
Sets the active state of the paint engine to state.
Definition: qpaintengine.h:155
short qint16
Definition: qglobal.h:935
unsigned short quint16
Definition: qglobal.h:936
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
unsigned int quint32
Definition: qglobal.h:938
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
The QPicture class is a paint device that records and replays QPainter commands.
Definition: qpicture.h:58

◆ type()

Type QPicturePaintEngine::type ( ) const
inlinevirtual

Reimplement this function to return the paint engine Type.

Implements QPaintEngine.

Definition at line 107 of file qpaintengine_pic_p.h.

107 { return Picture; }

◆ updateBackground()

void QPicturePaintEngine::updateBackground ( Qt::BGMode  bgmode,
const QBrush bgBrush 
)

Definition at line 257 of file qpaintengine_pic.cpp.

Referenced by updateState().

258 {
260 #ifdef QT_PICTURE_DEBUG
261  qDebug() << " -> updateBackground(): mode:" << bgMode << "style:" << bgBrush.style();
262 #endif
263  int pos;
265  d->s << bgBrush.color();
266  writeCmdLength(pos, QRect(), false);
267 
269  d->s << (qint8) bgMode;
270  writeCmdLength(pos, QRectF(), false);
271 }
double d
Definition: qnumeric_p.h:62
const QColor & color() const
Returns the brush color.
Definition: qbrush.h:183
#define SERIALIZE_CMD(c)
#define Q_D(Class)
Definition: qglobal.h:2482
Q_CORE_EXPORT void qDebug(const char *,...)
signed char qint8
Definition: qglobal.h:933
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
Qt::BrushStyle style() const
Returns the brush style.
Definition: qbrush.h:182
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
void writeCmdLength(int pos, const QRectF &r, bool corr)

◆ updateBrush()

void QPicturePaintEngine::updateBrush ( const QBrush brush)

Definition at line 214 of file qpaintengine_pic.cpp.

Referenced by updateState().

215 {
217 #ifdef QT_PICTURE_DEBUG
218  qDebug() << " -> updateBrush(): style:" << brush.style();
219 #endif
220  int pos;
222  if (d->pic_d->in_memory_only) {
223  int index = d->pic_d->brush_list.size();
224  d->pic_d->brush_list.append(brush);
225  d->s << index;
226  } else {
227  d->s << brush;
228  }
229  writeCmdLength(pos, QRect(), false);
230 }
double d
Definition: qnumeric_p.h:62
#define SERIALIZE_CMD(c)
#define Q_D(Class)
Definition: qglobal.h:2482
Q_CORE_EXPORT void qDebug(const char *,...)
Qt::BrushStyle style() const
Returns the brush style.
Definition: qbrush.h:182
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
quint16 index
void writeCmdLength(int pos, const QRectF &r, bool corr)

◆ updateBrushOrigin()

void QPicturePaintEngine::updateBrushOrigin ( const QPointF origin)

Definition at line 232 of file qpaintengine_pic.cpp.

Referenced by updateState().

233 {
235 #ifdef QT_PICTURE_DEBUG
236  qDebug() << " -> updateBrushOrigin(): " << p;
237 #endif
238  int pos;
240  d->s << p;
241  writeCmdLength(pos, QRect(), false);
242 }
double d
Definition: qnumeric_p.h:62
#define SERIALIZE_CMD(c)
#define Q_D(Class)
Definition: qglobal.h:2482
Q_CORE_EXPORT void qDebug(const char *,...)
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
void writeCmdLength(int pos, const QRectF &r, bool corr)

◆ updateClipEnabled()

void QPicturePaintEngine::updateClipEnabled ( bool  enabled)

Definition at line 190 of file qpaintengine_pic.cpp.

Referenced by updateState().

191 {
193 #ifdef QT_PICTURE_DEBUG
194  qDebug() << " -> updateClipEnabled():" << enabled;
195 #endif
196  int pos;
198  d->s << enabled;
199  writeCmdLength(pos, QRectF(), false);
200 }
double d
Definition: qnumeric_p.h:62
#define SERIALIZE_CMD(c)
#define Q_D(Class)
Definition: qglobal.h:2482
Q_CORE_EXPORT void qDebug(const char *,...)
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
#define enabled
void writeCmdLength(int pos, const QRectF &r, bool corr)

◆ updateClipPath()

void QPicturePaintEngine::updateClipPath ( const QPainterPath path,
Qt::ClipOperation  op 
)

Definition at line 298 of file qpaintengine_pic.cpp.

Referenced by updateState().

299 {
301 #ifdef QT_PICTURE_DEBUG
302  qDebug() << " -> updateClipPath(): op:" << op
303  << "bounding rect:" << path.boundingRect();
304 #endif
305  int pos;
306 
308  d->s << path << qint8(op);
309  writeCmdLength(pos, QRectF(), false);
310 }
double d
Definition: qnumeric_p.h:62
#define SERIALIZE_CMD(c)
#define Q_D(Class)
Definition: qglobal.h:2482
QRectF boundingRect() const
Returns the bounding rectangle of this painter path as a rectangle with floating point precision...
Q_CORE_EXPORT void qDebug(const char *,...)
signed char qint8
Definition: qglobal.h:933
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
void writeCmdLength(int pos, const QRectF &r, bool corr)

◆ updateClipRegion()

void QPicturePaintEngine::updateClipRegion ( const QRegion region,
Qt::ClipOperation  op 
)

Definition at line 285 of file qpaintengine_pic.cpp.

Referenced by updateState().

286 {
288 #ifdef QT_PICTURE_DEBUG
289  qDebug() << " -> updateClipRegion(): op:" << op
290  << "bounding rect:" << region.boundingRect();
291 #endif
292  int pos;
294  d->s << region << qint8(op);
295  writeCmdLength(pos, QRectF(), false);
296 }
double d
Definition: qnumeric_p.h:62
#define SERIALIZE_CMD(c)
QRect boundingRect() const
Returns the bounding rectangle of this region.
Definition: qregion.cpp:4363
#define Q_D(Class)
Definition: qglobal.h:2482
Q_CORE_EXPORT void qDebug(const char *,...)
signed char qint8
Definition: qglobal.h:933
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
void writeCmdLength(int pos, const QRectF &r, bool corr)

◆ updateCompositionMode()

void QPicturePaintEngine::updateCompositionMode ( QPainter::CompositionMode  cmode)

Definition at line 178 of file qpaintengine_pic.cpp.

Referenced by updateState().

179 {
181 #ifdef QT_PICTURE_DEBUG
182  qDebug() << " -> updateCompositionMode():" << cmode;
183 #endif
184  int pos;
186  d->s << (qint32)cmode;
187  writeCmdLength(pos, QRectF(), false);
188 }
double d
Definition: qnumeric_p.h:62
int qint32
Definition: qglobal.h:937
#define SERIALIZE_CMD(c)
#define Q_D(Class)
Definition: qglobal.h:2482
Q_CORE_EXPORT void qDebug(const char *,...)
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
void writeCmdLength(int pos, const QRectF &r, bool corr)

◆ updateFont()

void QPicturePaintEngine::updateFont ( const QFont font)

Definition at line 244 of file qpaintengine_pic.cpp.

Referenced by updateState().

245 {
247 #ifdef QT_PICTURE_DEBUG
248  qDebug() << " -> updateFont(): pt sz:" << font.pointSize();
249 #endif
250  int pos;
252  QFont fnt = font;
253  d->s << fnt;
254  writeCmdLength(pos, QRectF(), false);
255 }
double d
Definition: qnumeric_p.h:62
#define SERIALIZE_CMD(c)
#define Q_D(Class)
Definition: qglobal.h:2482
Q_CORE_EXPORT void qDebug(const char *,...)
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
int pointSize() const
Returns the point size of the font.
Definition: qfont.cpp:981
void writeCmdLength(int pos, const QRectF &r, bool corr)

◆ updateMatrix()

void QPicturePaintEngine::updateMatrix ( const QTransform matrix)

Definition at line 273 of file qpaintengine_pic.cpp.

Referenced by updateState().

274 {
276 #ifdef QT_PICTURE_DEBUG
277  qDebug() << " -> updateMatrix():" << matrix;
278 #endif
279  int pos;
281  d->s << matrix << (qint8) false;
282  writeCmdLength(pos, QRectF(), false);
283 }
double d
Definition: qnumeric_p.h:62
#define SERIALIZE_CMD(c)
#define Q_D(Class)
Definition: qglobal.h:2482
Q_CORE_EXPORT void qDebug(const char *,...)
signed char qint8
Definition: qglobal.h:933
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
void writeCmdLength(int pos, const QRectF &r, bool corr)

◆ updateOpacity()

void QPicturePaintEngine::updateOpacity ( qreal  opacity)

Definition at line 202 of file qpaintengine_pic.cpp.

Referenced by updateState().

203 {
205 #ifdef QT_PICTURE_DEBUG
206  qDebug() << " -> updateOpacity():" << opacity;
207 #endif
208  int pos;
210  d->s << double(opacity);
211  writeCmdLength(pos, QRectF(), false);
212 }
double d
Definition: qnumeric_p.h:62
#define SERIALIZE_CMD(c)
#define Q_D(Class)
Definition: qglobal.h:2482
Q_CORE_EXPORT void qDebug(const char *,...)
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
void writeCmdLength(int pos, const QRectF &r, bool corr)

◆ updatePen()

void QPicturePaintEngine::updatePen ( const QPen pen)

Definition at line 159 of file qpaintengine_pic.cpp.

Referenced by updateState().

160 {
162 #ifdef QT_PICTURE_DEBUG
163  qDebug() << " -> updatePen(): width:" << pen.width() << "style:"
164  << pen.style() << "color:" << pen.color();
165 #endif
166  int pos;
168  if (d->pic_d->in_memory_only) {
169  int index = d->pic_d->pen_list.size();
170  d->pic_d->pen_list.append(pen);
171  d->s << index;
172  } else {
173  d->s << pen;
174  }
175  writeCmdLength(pos, QRect(), false);
176 }
double d
Definition: qnumeric_p.h:62
Qt::PenStyle style() const
Returns the pen style.
Definition: qpen.cpp:428
QColor color() const
Returns the color of this pen&#39;s brush.
Definition: qpen.cpp:771
#define SERIALIZE_CMD(c)
#define Q_D(Class)
Definition: qglobal.h:2482
Q_CORE_EXPORT void qDebug(const char *,...)
int width() const
Returns the pen width with integer precision.
Definition: qpen.cpp:630
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
quint16 index
void writeCmdLength(int pos, const QRectF &r, bool corr)

◆ updateRenderHints()

void QPicturePaintEngine::updateRenderHints ( QPainter::RenderHints  hints)

Definition at line 312 of file qpaintengine_pic.cpp.

Referenced by updateState().

313 {
315 #ifdef QT_PICTURE_DEBUG
316  qDebug() << " -> updateRenderHints(): " << hints;
317 #endif
318  int pos;
320  d->s << (quint32) hints;
321  writeCmdLength(pos, QRect(), false);
322 }
double d
Definition: qnumeric_p.h:62
#define SERIALIZE_CMD(c)
#define Q_D(Class)
Definition: qglobal.h:2482
Q_CORE_EXPORT void qDebug(const char *,...)
unsigned int quint32
Definition: qglobal.h:938
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
void writeCmdLength(int pos, const QRectF &r, bool corr)

◆ updateState()

void QPicturePaintEngine::updateState ( const QPaintEngineState state)
virtual

Reimplement this function to update the state of a paint engine.

When implemented, this function is responsible for checking the paint engine's current state and update the properties that are changed. Use the QPaintEngineState::state() function to find out which properties that must be updated, then use the corresponding GetFunction{get function} to retrieve the current values for the given properties.

See also
QPaintEngineState

Implements QPaintEngine.

Definition at line 520 of file qpaintengine_pic.cpp.

521 {
522  QPaintEngine::DirtyFlags flags = state.state();
523  if (flags & DirtyPen) updatePen(state.pen());
524  if (flags & DirtyBrush) updateBrush(state.brush());
525  if (flags & DirtyBrushOrigin) updateBrushOrigin(state.brushOrigin());
526  if (flags & DirtyFont) updateFont(state.font());
527  if (flags & DirtyBackground) updateBackground(state.backgroundMode(), state.backgroundBrush());
528  if (flags & DirtyTransform) updateMatrix(state.transform());
529  if (flags & DirtyClipEnabled) updateClipEnabled(state.isClipEnabled());
530  if (flags & DirtyClipRegion) updateClipRegion(state.clipRegion(), state.clipOperation());
531  if (flags & DirtyClipPath) updateClipPath(state.clipPath(), state.clipOperation());
532  if (flags & DirtyHints) updateRenderHints(state.renderHints());
534  if (flags & DirtyOpacity) updateOpacity(state.opacity());
535 }
Qt::BGMode backgroundMode() const
Returns the background mode in the current paint engine state.
Definition: qpainter.cpp:9316
QPaintEngine::DirtyFlags state() const
Returns a combination of flags identifying the set of properties that need to be updated when updatin...
Definition: qpaintengine.h:292
void updateOpacity(qreal opacity)
qreal opacity() const
Returns the opacity in the current paint engine state.
Definition: qpainter.cpp:9529
void updateBackground(Qt::BGMode bgmode, const QBrush &bgBrush)
QTransform transform() const
Returns the matrix in the current paint engine state.
Definition: qpainter.cpp:9377
void updateBrush(const QBrush &brush)
bool isClipEnabled() const
Returns whether clipping is enabled or not in the current paint engine state.
Definition: qpainter.cpp:9473
void updatePen(const QPen &pen)
void updateFont(const QFont &font)
QBrush brush() const
Returns the brush in the current paint engine state.
Definition: qpainter.cpp:9273
Qt::ClipOperation clipOperation() const
Returns the clip operation in the current paint engine state.
Definition: qpainter.cpp:9396
QPointF brushOrigin() const
Returns the brush origin in the current paint engine state.
Definition: qpainter.cpp:9287
QFont font() const
Returns the font in the current paint engine state.
Definition: qpainter.cpp:9331
void updateClipEnabled(bool enabled)
QPainter::CompositionMode compositionMode() const
Returns the composition mode in the current paint engine state.
Definition: qpainter.cpp:9503
QPainterPath clipPath() const
Returns the clip path in the current paint engine state.
Definition: qpainter.cpp:9457
void updateMatrix(const QTransform &matrix)
void updateCompositionMode(QPainter::CompositionMode cmode)
QPainter::RenderHints renderHints() const
Returns the render hints in the current paint engine state.
Definition: qpainter.cpp:9488
void updateClipRegion(const QRegion &region, Qt::ClipOperation op)
QRegion clipRegion() const
Returns the clip region in the current paint engine state.
Definition: qpainter.cpp:9443
QPen pen() const
Returns the pen in the current paint engine state.
Definition: qpainter.cpp:9259
void updateClipPath(const QPainterPath &path, Qt::ClipOperation op)
void updateBrushOrigin(const QPointF &origin)
void updateRenderHints(QPainter::RenderHints hints)
QBrush backgroundBrush() const
Returns the background brush in the current paint engine state.
Definition: qpainter.cpp:9301

◆ writeCmdLength()

void QPicturePaintEngine::writeCmdLength ( int  pos,
const QRectF r,
bool  corr 
)
private

Definition at line 324 of file qpaintengine_pic.cpp.

Referenced by drawEllipse(), drawImage(), drawPath(), drawPixmap(), drawPolygon(), drawTextItem(), drawTiledPixmap(), type(), updateBackground(), updateBrush(), updateBrushOrigin(), updateClipEnabled(), updateClipPath(), updateClipRegion(), updateCompositionMode(), updateFont(), updateMatrix(), updateOpacity(), updatePen(), and updateRenderHints().

325 {
327  int newpos = d->pic_d->pictb.pos(); // new position
328  int length = newpos - pos;
329  QRectF br(r);
330 
331  if (length < 255) { // write 8-bit length
332  d->pic_d->pictb.seek(pos - 1); // position to right index
333  d->s << (quint8)length;
334  } else { // write 32-bit length
335  d->s << (quint32)0; // extend the buffer
336  d->pic_d->pictb.seek(pos - 1); // position to right index
337  d->s << (quint8)255; // indicate 32-bit length
338  char *p = d->pic_d->pictb.buffer().data();
339  memmove(p+pos+4, p+pos, length); // make room for 4 byte
340  d->s << (quint32)length;
341  newpos += 4;
342  }
343  d->pic_d->pictb.seek(newpos); // set to new position
344 
345  if (br.width() > 0.0 || br.height() > 0.0) {
346  if (corr) { // widen bounding rect
347  int w2 = painter()->pen().width() / 2;
348  br.setCoords(br.left() - w2, br.top() - w2,
349  br.right() + w2, br.bottom() + w2);
350  }
351  br = painter()->transform().mapRect(br);
352  if (painter()->hasClipping()) {
353  QRect cr = painter()->clipRegion().boundingRect();
354  br &= cr;
355  }
356 
357  if (br.width() > 0.0 || br.height() > 0.0) {
358  int minx = qFloor(br.left());
359  int miny = qFloor(br.top());
360  int maxx = qCeil(br.right());
361  int maxy = qCeil(br.bottom());
362 
363  if (d->pic_d->brect.width() > 0 || d->pic_d->brect.height() > 0) {
364  minx = qMin(minx, d->pic_d->brect.left());
365  miny = qMin(miny, d->pic_d->brect.top());
366  maxx = qMax(maxx, d->pic_d->brect.x() + d->pic_d->brect.width());
367  maxy = qMax(maxy, d->pic_d->brect.y() + d->pic_d->brect.height());
368  d->pic_d->brect = QRect(minx, miny, maxx - minx, maxy - miny);
369  } else {
370  d->pic_d->brect = QRect(minx, miny, maxx - minx, maxy - miny);
371  }
372  }
373  }
374 }
double d
Definition: qnumeric_p.h:62
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
const QTransform & transform() const
Returns the world transformation matrix.
Definition: qpainter.cpp:9558
int qCeil(qreal v)
Definition: qmath.h:63
int qFloor(qreal v)
Definition: qmath.h:73
QRect boundingRect() const
Returns the bounding rectangle of this region.
Definition: qregion.cpp:4363
unsigned char quint8
Definition: qglobal.h:934
#define Q_D(Class)
Definition: qglobal.h:2482
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
QRegion clipRegion() const
Returns the currently set clip region.
Definition: qpainter.cpp:2562
QRect mapRect(const QRect &) const
Creates and returns a QRect object that is a copy of the given rectangle, mapped into the coordinate ...
QPainter * painter() const
Returns the paint engine&#39;s painter.
const QPen & pen() const
Returns the painter&#39;s current pen.
Definition: qpainter.cpp:4152
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
int width() const
Returns the pen width with integer precision.
Definition: qpen.cpp:630
unsigned int quint32
Definition: qglobal.h:938
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58

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