Qt 4.8
Public Types | Public Functions | Public Variables | List of all members
QPaintBufferPrivate Class Reference

#include <qpaintbuffer_p.h>

Public Types

enum  Command {
  Cmd_Save, Cmd_Restore, Cmd_SetBrush, Cmd_SetBrushOrigin,
  Cmd_SetClipEnabled, Cmd_SetCompositionMode, Cmd_SetOpacity, Cmd_SetPen,
  Cmd_SetRenderHints, Cmd_SetTransform, Cmd_SetBackgroundMode, Cmd_ClipPath,
  Cmd_ClipRect, Cmd_ClipRegion, Cmd_ClipVectorPath, Cmd_DrawVectorPath,
  Cmd_FillVectorPath, Cmd_StrokeVectorPath, Cmd_DrawConvexPolygonF, Cmd_DrawConvexPolygonI,
  Cmd_DrawEllipseF, Cmd_DrawEllipseI, Cmd_DrawLineF, Cmd_DrawLineI,
  Cmd_DrawPath, Cmd_DrawPointsF, Cmd_DrawPointsI, Cmd_DrawPolygonF,
  Cmd_DrawPolygonI, Cmd_DrawPolylineF, Cmd_DrawPolylineI, Cmd_DrawRectF,
  Cmd_DrawRectI, Cmd_FillRectBrush, Cmd_FillRectColor, Cmd_DrawText,
  Cmd_DrawTextItem, Cmd_DrawImagePos, Cmd_DrawImageRect, Cmd_DrawPixmapPos,
  Cmd_DrawPixmapRect, Cmd_DrawTiledPixmap, Cmd_SystemStateChanged, Cmd_Translate,
  Cmd_DrawStaticText, Cmd_LastCommand
}
 

Public Functions

QPaintBufferCommandaddCommand (Command command)
 
QPaintBufferCommandaddCommand (Command command, const QVariant &var)
 
QPaintBufferCommandaddCommand (Command command, const QVectorPath &path)
 
QPaintBufferCommandaddCommand (Command command, const qreal *pts, int arrayLength, int elementCount)
 
QPaintBufferCommandaddCommand (Command command, const int *pts, int arrayLength, int elementCount)
 
int addData (const int *data, int count)
 
int addData (const qreal *data, int count)
 
int addData (const QVariant &var)
 
 QPaintBufferPrivate ()
 
void updateBoundingRect (const QRectF &rect)
 
 ~QPaintBufferPrivate ()
 

Public Variables

QRectF boundingRect
 
void * cache
 
uint calculateBoundingRect: 1
 
QVector< QPaintBufferCommandcommands
 
QPaintBufferEngineengine
 
QVector< qrealfloats
 
QList< int > frames
 
QVector< int > ints
 
qreal penWidthAdjustment
 
QAtomicInt ref
 
QVector< QVariantvariants
 

Detailed Description

Definition at line 139 of file qpaintbuffer_p.h.

Enumerations

◆ Command

Enumerator
Cmd_Save 
Cmd_Restore 
Cmd_SetBrush 
Cmd_SetBrushOrigin 
Cmd_SetClipEnabled 
Cmd_SetCompositionMode 
Cmd_SetOpacity 
Cmd_SetPen 
Cmd_SetRenderHints 
Cmd_SetTransform 
Cmd_SetBackgroundMode 
Cmd_ClipPath 
Cmd_ClipRect 
Cmd_ClipRegion 
Cmd_ClipVectorPath 
Cmd_DrawVectorPath 
Cmd_FillVectorPath 
Cmd_StrokeVectorPath 
Cmd_DrawConvexPolygonF 
Cmd_DrawConvexPolygonI 
Cmd_DrawEllipseF 
Cmd_DrawEllipseI 
Cmd_DrawLineF 
Cmd_DrawLineI 
Cmd_DrawPath 
Cmd_DrawPointsF 
Cmd_DrawPointsI 
Cmd_DrawPolygonF 
Cmd_DrawPolygonI 
Cmd_DrawPolylineF 
Cmd_DrawPolylineI 
Cmd_DrawRectF 
Cmd_DrawRectI 
Cmd_FillRectBrush 
Cmd_FillRectColor 
Cmd_DrawText 
Cmd_DrawTextItem 
Cmd_DrawImagePos 
Cmd_DrawImageRect 
Cmd_DrawPixmapPos 
Cmd_DrawPixmapRect 
Cmd_DrawTiledPixmap 
Cmd_SystemStateChanged 
Cmd_Translate 
Cmd_DrawStaticText 
Cmd_LastCommand 

Definition at line 142 of file qpaintbuffer_p.h.

142  {
143  Cmd_Save,
144  Cmd_Restore,
145 
146  Cmd_SetBrush,
151  Cmd_SetPen,
155 
156  Cmd_ClipPath,
157  Cmd_ClipRect,
160 
164 
171  Cmd_DrawPath,
180 
183 
184  Cmd_DrawText,
186 
192 
196 
197  // new commands must be added above this line
198 
200  };

Constructors and Destructors

◆ QPaintBufferPrivate()

QPaintBufferPrivate::QPaintBufferPrivate ( )

Definition at line 118 of file qpaintbuffer.cpp.

119  : ref(1), engine(0), penWidthAdjustment(0)
120  , calculateBoundingRect(true)
121  , cache(0)
122 {
123 }
QPaintBufferEngine * engine

◆ ~QPaintBufferPrivate()

QPaintBufferPrivate::~QPaintBufferPrivate ( )

Definition at line 125 of file qpaintbuffer.cpp.

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 }
void emitAboutToDestroy(const QPaintBufferPrivate *buffer)
QVector< QPaintBufferCommand > commands
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
T qvariant_cast(const QVariant &)
Definition: qvariant.h:571
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137
QVector< QVariant > variants
static QPaintBufferSignalProxy * instance()

Functions

◆ addCommand() [1/5]

QPaintBufferCommand* QPaintBufferPrivate::addCommand ( Command  command)
inline

Definition at line 228 of file qpaintbuffer_p.h.

Referenced by QPaintBufferEngine::backgroundModeChanged(), QPaintBufferEngine::brushChanged(), QPaintBufferEngine::brushOriginChanged(), QPaintBufferEngine::clip(), QPaintBufferEngine::clipEnabledChanged(), QPaintBufferEngine::compositionModeChanged(), QPaintBufferEngine::draw(), QPaintBufferEngine::drawEllipse(), QPaintBufferEngine::drawImage(), QPaintBufferEngine::drawLines(), QPaintBufferEngine::drawPixmap(), QPaintBufferEngine::drawPoints(), QPaintBufferEngine::drawPolygon(), QPaintBufferEngine::drawRects(), QPaintBufferEngine::drawStaticTextItem(), QPaintBufferEngine::drawTextItem(), QPaintBufferEngine::drawTiledPixmap(), QPaintBufferEngine::fill(), QPaintBufferEngine::fillRect(), QPaintBufferEngine::opacityChanged(), QPaintBufferEngine::penChanged(), QPaintBufferEngine::renderHintsChanged(), QPaintBufferEngine::setState(), QPaintBufferEngine::stroke(), and QPaintBufferEngine::transformChanged().

228  {
230  cmd.id = command;
231  cmd.size = cmd.offset = cmd.offset2 = cmd.extra = 0;
232  commands << cmd;
233  return &commands.last();
234  }
QVector< QPaintBufferCommand > commands
T & last()
Returns a reference to the last item in the vector.
Definition: qvector.h:262

◆ addCommand() [2/5]

QPaintBufferCommand* QPaintBufferPrivate::addCommand ( Command  command,
const QVariant var 
)
inline

Definition at line 236 of file qpaintbuffer_p.h.

236  {
238  cmd.id = command;
239  cmd.offset = addData(var);
240  cmd.size = cmd.offset2 = cmd.extra = 0;
241  commands << cmd;
242  return &commands.last();
243  }
int addData(const int *data, int count)
QVector< QPaintBufferCommand > commands
T & last()
Returns a reference to the last item in the vector.
Definition: qvector.h:262

◆ addCommand() [3/5]

QPaintBufferCommand* QPaintBufferPrivate::addCommand ( Command  command,
const QVectorPath path 
)
inline

Definition at line 245 of file qpaintbuffer_p.h.

245  {
247  cmd.id = command;
248  cmd.offset = addData(path.points(), path.elementCount() * 2);
249  cmd.offset2 = ints.size();
250  ints << path.hints();
251  // The absence of path elements is indicated by setting the highest bit in 'cmd.offset2'.
252  if (path.elements())
253  addData((const int *) path.elements(), path.elementCount());
254  else
255  cmd.offset2 |= 0x80000000;
256  cmd.size = path.elementCount();
257  cmd.extra = 0;
258  commands << cmd;
259  return &commands.last();
260  }
int elementCount() const
const QPainterPath::ElementType * elements() const
QVector< int > ints
int addData(const int *data, int count)
QVector< QPaintBufferCommand > commands
uint hints() const
T & last()
Returns a reference to the last item in the vector.
Definition: qvector.h:262
const qreal * points() const
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137

◆ addCommand() [4/5]

QPaintBufferCommand* QPaintBufferPrivate::addCommand ( Command  command,
const qreal pts,
int  arrayLength,
int  elementCount 
)
inline

Definition at line 262 of file qpaintbuffer_p.h.

262  {
264  cmd.id = command;
265  cmd.offset = addData(pts, arrayLength);
266  cmd.size = elementCount;
267  cmd.offset2 = cmd.extra = 0;
268  commands << cmd;
269  return &commands.last();
270  }
int addData(const int *data, int count)
QVector< QPaintBufferCommand > commands
T & last()
Returns a reference to the last item in the vector.
Definition: qvector.h:262

◆ addCommand() [5/5]

QPaintBufferCommand* QPaintBufferPrivate::addCommand ( Command  command,
const int *  pts,
int  arrayLength,
int  elementCount 
)
inline

Definition at line 272 of file qpaintbuffer_p.h.

272  {
274  cmd.id = command;
275  cmd.offset = addData(pts, arrayLength);
276  cmd.size = elementCount;
277  cmd.offset2 = cmd.extra = 0;
278  commands << cmd;
279  return &commands.last();
280  }
int addData(const int *data, int count)
QVector< QPaintBufferCommand > commands
T & last()
Returns a reference to the last item in the vector.
Definition: qvector.h:262

◆ addData() [1/3]

int QPaintBufferPrivate::addData ( const int *  data,
int  count 
)
inline

Definition at line 205 of file qpaintbuffer_p.h.

Referenced by QPaintBufferEngine::drawImage(), QPaintBufferEngine::drawPixmap(), QPaintBufferEngine::drawTextItem(), QPaintBufferEngine::drawTiledPixmap(), QPaintBufferEngine::fill(), QPaintBufferEngine::fillRect(), QPaintBufferEngine::stroke(), and QPaintBufferEngine::transformChanged().

205  {
206  if (count <= 0)
207  return 0;
208  int pos = ints.size();
209  ints.resize(pos + count);
210  memcpy(ints.data() + pos, data, count * sizeof(int));
211  return pos;
212  }
void resize(int size)
Sets the size of the vector to size.
Definition: qvector.h:342
QVector< int > ints
static const char * data(const QByteArray &arr)
T * data()
Returns a pointer to the data stored in the vector.
Definition: qvector.h:152
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137

◆ addData() [2/3]

int QPaintBufferPrivate::addData ( const qreal data,
int  count 
)
inline

Definition at line 214 of file qpaintbuffer_p.h.

214  {
215  if (count <= 0)
216  return 0;
217  int pos = floats.size();
218  floats.resize(pos + count);
219  memcpy(floats.data() + pos, data, count * sizeof(qreal));
220  return pos;
221  }
double qreal
Definition: qglobal.h:1193
void resize(int size)
Sets the size of the vector to size.
Definition: qvector.h:342
static const char * data(const QByteArray &arr)
T * data()
Returns a pointer to the data stored in the vector.
Definition: qvector.h:152
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137
QVector< qreal > floats

◆ addData() [3/3]

int QPaintBufferPrivate::addData ( const QVariant var)
inline

Definition at line 223 of file qpaintbuffer_p.h.

223  {
224  variants << var;
225  return variants.size() - 1;
226  }
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137
QVector< QVariant > variants

◆ updateBoundingRect()

void QPaintBufferPrivate::updateBoundingRect ( const QRectF rect)
inline

Definition at line 137 of file qpaintbuffer.cpp.

Referenced by QPaintBufferEngine::drawEllipse(), QPaintBufferEngine::drawImage(), QPaintBufferEngine::drawLines(), QPaintBufferEngine::drawPixmap(), QPaintBufferEngine::drawPoints(), QPaintBufferEngine::drawPolygon(), QPaintBufferEngine::drawRects(), QPaintBufferEngine::drawTextItem(), QPaintBufferEngine::drawTiledPixmap(), and QPaintBufferEngine::fillRect().

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 }
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
qreal right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:527
double qreal
Definition: qglobal.h:1193
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
qreal left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:525
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
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.
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
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
QPaintBufferEngine * engine
qreal top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:526
qreal bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:528
bool isEmpty() const
Returns true if the rectangle is empty, otherwise returns false.
Definition: qrect.h:658
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65

Properties

◆ boundingRect

QRectF QPaintBufferPrivate::boundingRect

◆ cache

void* QPaintBufferPrivate::cache

Definition at line 298 of file qpaintbuffer_p.h.

◆ calculateBoundingRect

uint QPaintBufferPrivate::calculateBoundingRect

◆ commands

QVector<QPaintBufferCommand> QPaintBufferPrivate::commands

◆ engine

QPaintBufferEngine* QPaintBufferPrivate::engine

Definition at line 293 of file qpaintbuffer_p.h.

Referenced by QPaintBuffer::paintEngine(), and updateBoundingRect().

◆ floats

QVector<qreal> QPaintBufferPrivate::floats

Definition at line 287 of file qpaintbuffer_p.h.

Referenced by QPaintBuffer::commandDescription(), and operator>>().

◆ frames

QList<int> QPaintBufferPrivate::frames

◆ ints

QVector<int> QPaintBufferPrivate::ints

Definition at line 286 of file qpaintbuffer_p.h.

Referenced by QPaintBuffer::commandDescription(), and operator>>().

◆ penWidthAdjustment

qreal QPaintBufferPrivate::penWidthAdjustment

Definition at line 295 of file qpaintbuffer_p.h.

Referenced by QPaintBufferEngine::penChanged(), and updateBoundingRect().

◆ ref

QAtomicInt QPaintBufferPrivate::ref

◆ variants

QVector<QVariant> QPaintBufferPrivate::variants

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