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

#include <qpainter_p.h>

Public Types

enum  DrawOperation { StrokeDraw = 0x1, FillDraw = 0x2, StrokeAndFillDraw = 0x3 }
 

Public Functions

void checkEmulation ()
 
void detachPainterPrivate (QPainter *q)
 
void draw_helper (const QPainterPath &path, DrawOperation operation=StrokeAndFillDraw)
 
void drawGlyphs (const quint32 *glyphArray, QFixedPoint *positionArray, int glyphCount, const QRawFont &font, bool overline=false, bool underline=false, bool strikeOut=false)
 
void drawOpaqueBackground (const QPainterPath &path, DrawOperation operation)
 
void drawStretchedGradient (const QPainterPath &path, DrawOperation operation)
 
QPainterDummyStatefakeState () const
 
 QPainterPrivate (QPainter *painter)
 
int rectSubtraction () const
 
void updateEmulationSpecifier (QPainterState *s)
 
void updateInvMatrix ()
 
void updateMatrix ()
 
void updateState (QPainterState *state)
 
void updateStateImpl (QPainterState *state)
 
QTransform viewTransform () const
 
 ~QPainterPrivate ()
 

Static Public Functions

static bool attachPainterPrivate (QPainter *q, QPaintDevice *pdev)
 
static QPainterPrivateget (QPainter *painter)
 

Public Variables

QBrush colorBrush
 
QPainterPrivate ** d_ptrs
 
uint d_ptrs_size
 
QPaintDevicedevice
 
QPainterDummyStatedummyState
 
QEmulationPaintEngineemulationEngine
 
QPaintEngineengine
 
QPaintEngineExextended
 
QPaintDevicehelper_device
 
uint inDestructor: 1
 
QTransform invMatrix
 
QPaintDeviceoriginal_device
 
QPainterq_ptr
 
uint refcount
 
QPainterStatestate
 
QVector< QPainterState * > states
 
uint txinv:1
 

Detailed Description

Definition at line 188 of file qpainter_p.h.

Enumerations

◆ DrawOperation

Enumerator
StrokeDraw 
FillDraw 
StrokeAndFillDraw 

Definition at line 215 of file qpainter_p.h.

Constructors and Destructors

◆ QPainterPrivate()

QPainterPrivate::QPainterPrivate ( QPainter painter)
inline

Definition at line 192 of file qpainter_p.h.

Referenced by detachPainterPrivate().

193  : q_ptr(painter), d_ptrs(0), state(0), dummyState(0), txinv(0), inDestructor(false), d_ptrs_size(0),
195  extended(0)
196  {
197  }
QPaintEngineEx * extended
Definition: qpainter_p.h:263
QPainterState * state
Definition: qpainter_p.h:204
QPainterDummyState * dummyState
Definition: qpainter_p.h:207
QPaintDevice * original_device
Definition: qpainter_p.h:259
QPainter * q_ptr
Definition: qpainter_p.h:201
QPainterPrivate ** d_ptrs
Definition: qpainter_p.h:202
QPaintDevice * helper_device
Definition: qpainter_p.h:260
QPaintDevice * device
Definition: qpainter_p.h:258
QEmulationPaintEngine * emulationEngine
Definition: qpainter_p.h:262
QPaintEngine * engine
Definition: qpainter_p.h:261

◆ ~QPainterPrivate()

QPainterPrivate::~QPainterPrivate ( )

Definition at line 213 of file qpainter.cpp.

214 {
215  delete emulationEngine;
216  for (int i=0; i<states.size(); ++i)
217  delete states.at(i);
218 
219  if (dummyState)
220  delete dummyState;
221 }
QPainterDummyState * dummyState
Definition: qpainter_p.h:207
QVector< QPainterState * > states
Definition: qpainter_p.h:205
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 vector.
Definition: qvector.h:137
QEmulationPaintEngine * emulationEngine
Definition: qpainter_p.h:262

Functions

◆ attachPainterPrivate()

bool QPainterPrivate::attachPainterPrivate ( QPainter q,
QPaintDevice pdev 
)
static

Definition at line 240 of file qpainter.cpp.

Referenced by QPainter::begin(), and QPainter::QPainter().

241 {
242  Q_ASSERT(q);
243  Q_ASSERT(pdev);
244 
245  if (pdev->devType() != QInternal::Widget)
246  return false;
247 
248  QWidget *widget = static_cast<QWidget *>(pdev);
249  Q_ASSERT(widget);
250 
251  // Someone either called QPainter::setRedirected in the widget's paint event
252  // right before this painter was created (or begin was called) or
253  // sent a paint event directly to the widget.
254  if (!widget->d_func()->redirectDev)
255  return false;
256 
257  QPainter *sp = widget->d_func()->sharedPainter();
258  if (!sp || !sp->isActive())
259  return false;
260 
261  if (sp->paintEngine()->paintDevice() != widget->d_func()->redirectDev)
262  return false;
263 
264  // Check if we're attempting to paint outside a paint event.
268 
269  qWarning("QPainter::begin: Widget painting can only begin as a result of a paintEvent");
270  return false;
271  }
272 
273  // Save the current state of the shared painter and assign
274  // the current d_ptr to the shared painter's d_ptr.
275  sp->save();
276  if (!sp->d_ptr->d_ptrs) {
277  // Allocate space for 4 d-pointers (enough for up to 4 sub-sequent
278  // redirections within the same paintEvent(), which should be enough
279  // in 99% of all cases). E.g: A renders B which renders C which renders D.
280  sp->d_ptr->d_ptrs_size = 4;
281  sp->d_ptr->d_ptrs = (QPainterPrivate **)malloc(4 * sizeof(QPainterPrivate *));
282  Q_CHECK_PTR(sp->d_ptr->d_ptrs);
283  } else if (sp->d_ptr->refcount - 1 == sp->d_ptr->d_ptrs_size) {
284  // However, to support corner cases we grow the array dynamically if needed.
285  sp->d_ptr->d_ptrs_size <<= 1;
286  const int newSize = sp->d_ptr->d_ptrs_size * sizeof(QPainterPrivate *);
287  sp->d_ptr->d_ptrs = q_check_ptr((QPainterPrivate **)realloc(sp->d_ptr->d_ptrs, newSize));
288  }
289  sp->d_ptr->d_ptrs[++sp->d_ptr->refcount - 2] = q->d_ptr.data();
290  q->d_ptr.take();
291  q->d_ptr.reset(sp->d_ptr.data());
292 
293  Q_ASSERT(q->d_ptr->state);
294 
295  // Now initialize the painter with correct widget properties.
296  q->initFrom(widget);
297  QPoint offset;
298  widget->d_func()->redirected(&offset);
299  offset += q->d_ptr->engine->coordinateOffset();
300 
301  // Update system rect.
302  q->d_ptr->state->ww = q->d_ptr->state->vw = widget->width();
303  q->d_ptr->state->wh = q->d_ptr->state->vh = widget->height();
304 
305  // Update matrix.
306  if (q->d_ptr->state->WxF) {
308  q->d_ptr->state->redirectionMatrix.translate(-offset.x(), -offset.y());
310  q->d_ptr->state->WxF = false;
311  } else {
312  q->d_ptr->state->redirectionMatrix = QTransform::fromTranslate(-offset.x(), -offset.y());
313  }
314  q->d_ptr->updateMatrix();
315 
316  QPaintEnginePrivate *enginePrivate = q->d_ptr->engine->d_func();
317  if (enginePrivate->currentClipWidget == widget) {
318  enginePrivate->systemStateChanged();
319  return true;
320  }
321 
322  // Update system transform and clip.
323  enginePrivate->currentClipWidget = widget;
324  enginePrivate->setSystemTransform(q->d_ptr->state->matrix);
325  return true;
326 }
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
T * q_check_ptr(T *p)
Definition: qglobal.h:1857
QPaintDevice * paintDevice() const
Returns the device that this engine is painting on, if painting is active; otherwise returns 0...
QPointer< QWidget > widget
int width
the width of the widget excluding any window frame
Definition: qwidget.h:166
T * data() const
Returns the value of the pointer referenced by this object.
void setSystemTransform(const QTransform &xform)
QPainterState * state
Definition: qpainter_p.h:204
T * take()
Returns the value of the pointer referenced by this object.
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
void updateMatrix()
Definition: qpainter.cpp:662
QTransform matrix
Definition: qpainter_p.h:161
QTransform & translate(qreal dx, qreal dy)
Moves the coordinate system dx along the x axis and dy along the y axis, and returns a reference to t...
Definition: qtransform.cpp:417
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
virtual int devType() const
Definition: qpaintdevice.h:167
void save()
Saves the current painter state (pushes the state onto a stack).
Definition: qpainter.cpp:1590
int height
the height of the widget excluding any window frame
Definition: qwidget.h:167
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
bool isActive() const
Returns true if begin() has been called and end() has not yet been called; otherwise returns false...
Definition: qpainter.cpp:1545
Q_CORE_EXPORT void qWarning(const char *,...)
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 reset(T *other=0)
Deletes the existing object it is pointing to if any, and sets its pointer to other.
virtual void systemStateChanged()
#define Q_CHECK_PTR(p)
Definition: qglobal.h:1853
QPainterPrivate ** d_ptrs
Definition: qpainter_p.h:202
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
QTransform redirectionMatrix
Definition: qpainter_p.h:162
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
void initFrom(const QWidget *widget)
Initializes the painters pen, background and font to the same as the given widget.
Definition: qpainter.cpp:1558
static QTransform fromTranslate(qreal dx, qreal dy)
Creates a matrix which corresponds to a translation of dx along the x axis and dy along the y axis...
Definition: qtransform.cpp:462
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
QTransform worldMatrix
Definition: qpainter_p.h:160
virtual QPoint coordinateOffset() const
Returns the offset from the painters origo to the engines origo.
QWidget * currentClipWidget
bool hasFeature(PaintEngineFeatures feature) const
Returns true if the paint engine supports the specified feature; otherwise returns false...
Definition: qpaintengine.h:229
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65
QScopedPointer< QPainterPrivate > d_ptr
Definition: qpainter.h:546
QPaintEngine * engine
Definition: qpainter_p.h:261

◆ checkEmulation()

void QPainterPrivate::checkEmulation ( )

Definition at line 182 of file qpainter.cpp.

183 {
186  return;
187 
188  bool doEmulation = false;
189  if (state->bgMode == Qt::OpaqueMode)
190  doEmulation = true;
191 
192  const QGradient *bg = state->brush.gradient();
193  if (bg && bg->coordinateMode() > QGradient::LogicalMode)
194  doEmulation = true;
195 
196  const QGradient *pg = qpen_brush(state->pen).gradient();
197  if (pg && pg->coordinateMode() > QGradient::LogicalMode)
198  doEmulation = true;
199 
200  if (doEmulation) {
201  if (extended != emulationEngine) {
202  if (!emulationEngine)
206  }
207  } else if (emulationEngine == extended) {
209  }
210 }
QPaintEngineEx * extended
Definition: qpainter_p.h:263
const QGradient * gradient() const
Returns the gradient describing this brush.
Definition: qbrush.cpp:871
CoordinateMode coordinateMode() const
Returns the coordinate mode of this gradient.
Definition: qbrush.cpp:1563
QPainterState * state
Definition: qpainter_p.h:204
virtual uint flags() const
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QBrush qpen_brush(const QPen &p)
Definition: qpainter_p.h:87
virtual void setState(QPainterState *s)
The QGradient class is used in combination with QBrush to specify gradient fills. ...
Definition: qbrush.h:201
QBrush brush
Definition: qpainter_p.h:153
Qt::BGMode bgMode
Definition: qpainter_p.h:171
QEmulationPaintEngine * emulationEngine
Definition: qpainter_p.h:262

◆ detachPainterPrivate()

void QPainterPrivate::detachPainterPrivate ( QPainter q)

Definition at line 328 of file qpainter.cpp.

Referenced by QPainter::~QPainter().

329 {
330  Q_ASSERT(refcount > 1);
331  Q_ASSERT(q);
332 
333  QPainterPrivate *original = d_ptrs[--refcount - 1];
334  if (inDestructor) {
335  inDestructor = false;
336  if (original)
337  original->inDestructor = true;
338  } else if (!original) {
339  original = new QPainterPrivate(q);
340  }
341 
342  d_ptrs[refcount - 1] = 0;
343  q->restore();
344  q->d_ptr.take();
345  q->d_ptr.reset(original);
346 
347  if (emulationEngine) {
349  delete emulationEngine;
350  emulationEngine = 0;
351  }
352 }
QPaintEngineEx * extended
Definition: qpainter_p.h:263
T * take()
Returns the value of the pointer referenced by this object.
QPainterPrivate(QPainter *painter)
Definition: qpainter_p.h:192
void restore()
Restores the current painter state (pops a saved state off the stack).
Definition: qpainter.cpp:1620
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
void reset(T *other=0)
Deletes the existing object it is pointing to if any, and sets its pointer to other.
QPainterPrivate ** d_ptrs
Definition: qpainter_p.h:202
QEmulationPaintEngine * emulationEngine
Definition: qpainter_p.h:262
QScopedPointer< QPainterPrivate > d_ptr
Definition: qpainter.h:546

◆ draw_helper()

void QPainterPrivate::draw_helper ( const QPainterPath path,
DrawOperation  operation = StrokeAndFillDraw 
)

Definition at line 355 of file qpainter.cpp.

Referenced by qt_draw_helper().

356 {
357 #ifdef QT_DEBUG_DRAW
358  if (qt_show_painter_debug_output) {
359  printf("QPainter::drawHelper\n");
360  }
361 #endif
362 
363  if (originalPath.isEmpty())
364  return;
365 
366  QPaintEngine::PaintEngineFeatures gradientStretch =
367  QPaintEngine::PaintEngineFeatures(QGradient_StretchToDevice
369 
370  const bool mustEmulateObjectBoundingModeGradients = extended
373 
374  if (!(state->emulationSpecifier & ~gradientStretch)
375  && !mustEmulateObjectBoundingModeGradients) {
376  drawStretchedGradient(originalPath, op);
377  return;
379  drawOpaqueBackground(originalPath, op);
380  return;
381  }
382 
383  Q_Q(QPainter);
384 
385  qreal strokeOffsetX = 0, strokeOffsetY = 0;
386 
387  QPainterPath path = originalPath * state->matrix;
388  QRectF pathBounds = path.boundingRect();
389  QRectF strokeBounds;
390  bool doStroke = (op & StrokeDraw) && (state->pen.style() != Qt::NoPen);
391  if (doStroke) {
392  qreal penWidth = state->pen.widthF();
393  if (penWidth == 0) {
394  strokeOffsetX = 1;
395  strokeOffsetY = 1;
396  } else {
397  // In case of complex xform
399  QPainterPathStroker stroker;
400  stroker.setWidth(penWidth);
401  stroker.setJoinStyle(state->pen.joinStyle());
402  stroker.setCapStyle(state->pen.capStyle());
403  QPainterPath stroke = stroker.createStroke(originalPath);
404  strokeBounds = (stroke * state->matrix).boundingRect();
405  } else {
406  strokeOffsetX = qAbs(penWidth * state->matrix.m11() / qreal(2.0));
407  strokeOffsetY = qAbs(penWidth * state->matrix.m22() / qreal(2.0));
408  }
409  }
410  }
411 
412  QRect absPathRect;
413  if (!strokeBounds.isEmpty()) {
414  absPathRect = strokeBounds.intersected(QRectF(0, 0, device->width(), device->height())).toAlignedRect();
415  } else {
416  absPathRect = pathBounds.adjusted(-strokeOffsetX, -strokeOffsetY, strokeOffsetX, strokeOffsetY)
418  }
419 
420  if (q->hasClipping()) {
421  bool hasPerspectiveTransform = false;
422  for (int i = 0; i < state->clipInfo.size(); ++i) {
423  const QPainterClipInfo &info = state->clipInfo.at(i);
424  if (info.matrix.type() == QTransform::TxProject) {
425  hasPerspectiveTransform = true;
426  break;
427  }
428  }
429  // avoid mapping QRegions with perspective transforms
430  if (!hasPerspectiveTransform) {
431  // The trick with txinv and invMatrix is done in order to
432  // avoid transforming the clip to logical coordinates, and
433  // then back to device coordinates. This is a problem with
434  // QRegion/QRect based clips, since they use integer
435  // coordinates and converting to/from logical coordinates will
436  // lose precision.
437  bool old_txinv = txinv;
438  QTransform old_invMatrix = invMatrix;
439  txinv = true;
440  invMatrix = QTransform();
441  QPainterPath clipPath = q->clipPath();
442  QRectF r = clipPath.boundingRect().intersected(absPathRect);
443  absPathRect = r.toAlignedRect();
444  txinv = old_txinv;
445  invMatrix = old_invMatrix;
446  }
447  }
448 
449 // qDebug("\nQPainterPrivate::draw_helper(), x=%d, y=%d, w=%d, h=%d",
450 // devMinX, devMinY, device->width(), device->height());
451 // qDebug() << " - matrix" << state->matrix;
452 // qDebug() << " - originalPath.bounds" << originalPath.boundingRect();
453 // qDebug() << " - path.bounds" << path.boundingRect();
454 
455  if (absPathRect.width() <= 0 || absPathRect.height() <= 0)
456  return;
457 
458  QImage image(absPathRect.width(), absPathRect.height(), QImage::Format_ARGB32_Premultiplied);
459  image.fill(0);
460 
461  QPainter p(&image);
462 
463  p.d_ptr->helper_device = helper_device;
464 
465  p.setOpacity(state->opacity);
466  p.translate(-absPathRect.x(), -absPathRect.y());
467  p.setTransform(state->matrix, true);
468  p.setPen(doStroke ? state->pen : QPen(Qt::NoPen));
469  p.setBrush((op & FillDraw) ? state->brush : QBrush(Qt::NoBrush));
470  p.setBackground(state->bgBrush);
471  p.setBackgroundMode(state->bgMode);
472  p.setBrushOrigin(state->brushOrigin);
473 
475  p.setRenderHint(QPainter::SmoothPixmapTransform,
477 
478  p.drawPath(originalPath);
479 
480 #ifndef QT_NO_DEBUG
481  static bool do_fallback_overlay = qgetenv("QT_PAINT_FALLBACK_OVERLAY").size() > 0;
482  if (do_fallback_overlay) {
484  QPainter pt(&block);
485  pt.fillRect(0, 0, 8, 8, QColor(196, 0, 196));
486  pt.drawLine(0, 0, 8, 8);
487  pt.end();
488  p.resetTransform();
489  p.setCompositionMode(QPainter::CompositionMode_SourceAtop);
490  p.setOpacity(0.5);
491  p.fillRect(0, 0, image.width(), image.height(), QBrush(block));
492  }
493 #endif
494 
495  p.end();
496 
497  q->save();
498  state->matrix = QTransform();
499  if (extended) {
501  } else {
504  }
505  engine->drawImage(absPathRect,
506  image,
507  QRectF(0, 0, absPathRect.width(), absPathRect.height()),
509  q->restore();
510 }
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
QRect toAlignedRect() const
Returns a QRect based on the values of this rectangle that is the smallest possible integer rectangle...
Definition: qrect.cpp:2817
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
double qreal
Definition: qglobal.h:1193
static mach_timebase_info_data_t info
QPaintEngineEx * extended
Definition: qpainter_p.h:263
virtual void transformChanged()=0
QPainter::RenderHints renderHints
Definition: qpainter_p.h:158
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:67
Qt::PenStyle style() const
Returns the pen style.
Definition: qpen.cpp:428
QPainterState * state
Definition: qpainter_p.h:204
int height() const
Definition: qpaintdevice.h:92
void fill(uint pixel)
Fills the entire image with the given pixelValue.
Definition: qimage.cpp:2032
void setCapStyle(Qt::PenCapStyle style)
Sets the cap style of the generated outlines to style.
qreal m22() const
Returns the vertical scaling factor.
Definition: qtransform.h:253
void updateState(QPainterState *state)
Definition: qpainter.cpp:926
QPaintEngine::DirtyFlags dirtyFlags
Definition: qpaintengine.h:325
QTransform matrix
Definition: qpainter_p.h:161
QRectF intersected(const QRectF &other) const
Returns the intersection of this rectangle and the given rectangle.
Definition: qrect.h:818
Q_DECL_CONSTEXPR T qAbs(const T &t)
Definition: qglobal.h:1201
TransformationType type() const
Returns the transformation type of this matrix.
The QPen class defines how a QPainter should draw lines and outlines of shapes.
Definition: qpen.h:64
void drawOpaqueBackground(const QPainterPath &path, DrawOperation operation)
Definition: qpainter.cpp:512
QBrush bgBrush
Definition: qpainter_p.h:154
#define Q_Q(Class)
Definition: qglobal.h:2483
QRectF boundingRect() const
Returns the bounding rectangle of this painter path as a rectangle with floating point precision...
static const QRectF boundingRect(const QPointF *points, int pointCount)
QTransform invMatrix
Definition: qpainter_p.h:209
void drawStretchedGradient(const QPainterPath &path, DrawOperation operation)
Definition: qpainter.cpp:547
int width() const
Definition: qpaintdevice.h:91
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
QPainterPath createStroke(const QPainterPath &path) const
Generates a new path that is a fillable area representing the outline of the given path...
Qt::PenJoinStyle joinStyle() const
Returns the pen&#39;s join style.
Definition: qpen.cpp:736
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
QList< QPainterClipInfo > clipInfo
Definition: qpainter_p.h:159
The QPainterPathStroker class is used to generate fillable outlines for a given painter path...
Definition: qpainterpath.h:264
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 QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
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...
void setJoinStyle(Qt::PenJoinStyle style)
Sets the join style of the generated outlines to style.
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
QPointF brushOrigin
Definition: qpainter_p.h:149
qreal widthF() const
Returns the pen width with floating point precision.
Definition: qpen.cpp:645
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
int size() const
Returns the number of bytes in this byte array.
Definition: qbytearray.h:402
#define QPaintEngine_OpaqueBackground
Definition: qpainter.cpp:83
QTransform matrix
Definition: qpainter_p.h:118
QPaintDevice * helper_device
Definition: qpainter_p.h:260
#define QGradient_StretchToDevice
Definition: qpainter.cpp:82
QBrush brush
Definition: qpainter_p.h:153
QPaintDevice * device
Definition: qpainter_p.h:258
uint emulationSpecifier
Definition: qpainter_p.h:175
Qt::BGMode bgMode
Definition: qpainter_p.h:171
bool isEmpty() const
Returns true if the rectangle is empty, otherwise returns false.
Definition: qrect.h:658
Qt::PenCapStyle capStyle() const
Returns the pen&#39;s cap style.
Definition: qpen.cpp:706
qreal m11() const
Returns the horizontal scaling factor.
Definition: qtransform.h:237
bool hasFeature(PaintEngineFeatures feature) const
Returns true if the paint engine supports the specified feature; otherwise returns false...
Definition: qpaintengine.h:229
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65
void setWidth(qreal width)
Sets the width of the generated outline painter path to width.
QPaintEngine * engine
Definition: qpainter_p.h:261

◆ drawGlyphs()

void QPainterPrivate::drawGlyphs ( const quint32 glyphArray,
QFixedPoint positionArray,
int  glyphCount,
const QRawFont font,
bool  overline = false,
bool  underline = false,
bool  strikeOut = false 
)

Definition at line 6101 of file qpainter.cpp.

6105 {
6106  Q_Q(QPainter);
6107 
6108  updateState(state);
6109 
6110  QRawFontPrivate *fontD = QRawFontPrivate::get(font);
6111  QFontEngine *fontEngine = fontD->fontEngine;
6112 
6113  QFixed leftMost;
6114  QFixed rightMost;
6115  QFixed baseLine;
6116  for (int i=0; i<glyphCount; ++i) {
6117  glyph_metrics_t gm = fontEngine->boundingBox(glyphArray[i]);
6118  if (i == 0 || leftMost > positions[i].x)
6119  leftMost = positions[i].x;
6120 
6121  // We don't support glyphs that do not share a common baseline. If this turns out to
6122  // be a relevant use case, then we need to find clusters of glyphs that share a baseline
6123  // and do a drawTextItemDecorations call per cluster.
6124  if (i == 0 || baseLine < positions[i].y)
6125  baseLine = positions[i].y;
6126 
6127  // We use the advance rather than the actual bounds to match the algorithm in drawText()
6128  if (i == 0 || rightMost < positions[i].x + gm.xoff)
6129  rightMost = positions[i].x + gm.xoff;
6130  }
6131 
6132  QFixed width = rightMost - leftMost;
6133 
6134  if (extended != 0 && state->matrix.isAffine()) {
6135  QStaticTextItem staticTextItem;
6136  staticTextItem.color = state->pen.color();
6137  staticTextItem.font = state->font;
6138  staticTextItem.setFontEngine(fontEngine);
6139  staticTextItem.numGlyphs = glyphCount;
6140  staticTextItem.glyphs = reinterpret_cast<glyph_t *>(const_cast<glyph_t *>(glyphArray));
6141  staticTextItem.glyphPositions = positions;
6142 
6143  extended->drawStaticTextItem(&staticTextItem);
6144  } else {
6145  QTextItemInt textItem;
6146  textItem.fontEngine = fontEngine;
6147 
6148  QVarLengthArray<QFixed, 128> advances(glyphCount);
6149  QVarLengthArray<QGlyphJustification, 128> glyphJustifications(glyphCount);
6150  QVarLengthArray<HB_GlyphAttributes, 128> glyphAttributes(glyphCount);
6151  qMemSet(glyphAttributes.data(), 0, glyphAttributes.size() * sizeof(HB_GlyphAttributes));
6152  qMemSet(advances.data(), 0, advances.size() * sizeof(QFixed));
6153  qMemSet(glyphJustifications.data(), 0, glyphJustifications.size() * sizeof(QGlyphJustification));
6154 
6155  textItem.glyphs.numGlyphs = glyphCount;
6156  textItem.glyphs.glyphs = reinterpret_cast<HB_Glyph *>(const_cast<quint32 *>(glyphArray));
6157  textItem.glyphs.offsets = positions;
6158  textItem.glyphs.advances_x = advances.data();
6159  textItem.glyphs.advances_y = advances.data();
6160  textItem.glyphs.justifications = glyphJustifications.data();
6161  textItem.glyphs.attributes = glyphAttributes.data();
6162 
6163  engine->drawTextItem(QPointF(0, 0), textItem);
6164  }
6165 
6166  QTextItemInt::RenderFlags flags;
6167  if (underline)
6168  flags |= QTextItemInt::Underline;
6169  if (overline)
6170  flags |= QTextItemInt::Overline;
6171  if (strikeOut)
6172  flags |= QTextItemInt::StrikeOut;
6173 
6174  drawTextItemDecoration(q, QPointF(leftMost.toReal(), baseLine.toReal()),
6175  fontEngine,
6176  (underline
6179  flags, width.toReal(), QTextCharFormat());
6180 }
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
QFontEngine * fontEngine
QGlyphJustification * justifications
QFixed * advances_y
The QTextCharFormat class provides formatting information for characters in a QTextDocument.
Definition: qtextformat.h:372
QPaintEngineEx * extended
Definition: qpainter_p.h:263
QFixed * advances_x
QFixedPoint * glyphPositions
HB_Glyph * glyphs
QPainterState * state
Definition: qpainter_p.h:204
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
static QRawFontPrivate * get(const QRawFont &font)
Definition: qrawfont_p.h:109
void updateState(QPainterState *state)
Definition: qpainter.cpp:926
QColor color() const
Returns the color of this pen&#39;s brush.
Definition: qpen.cpp:771
QTransform matrix
Definition: qpainter_p.h:161
void setFontEngine(QFontEngine *fe)
#define Q_Q(Class)
Definition: qglobal.h:2483
QGlyphLayout glyphs
static const QCssKnownValue positions[NumKnownPositionModes - 1]
Definition: qcssparser.cpp:329
Internal QTextItem.
virtual glyph_metrics_t boundingBox(const QGlyphLayout &glyphs)=0
bool isAffine() const
Returns true if the matrix represent an affine transformation, otherwise returns false.
Definition: qtransform.h:200
void * qMemSet(void *dest, int c, size_t n)
Definition: qglobal.cpp:2509
virtual void drawStaticTextItem(QStaticTextItem *)
unsigned int quint32
Definition: qglobal.h:938
qreal toReal() const
Definition: qfixed_p.h:77
HB_GlyphAttributes * attributes
QFontEngine * fontEngine
Definition: qrawfont_p.h:111
QFixedPoint * offsets
static void drawTextItemDecoration(QPainter *painter, const QPointF &pos, const QFontEngine *fe, QTextCharFormat::UnderlineStyle underlineStyle, QTextItem::RenderFlags flags, qreal width, const QTextCharFormat &charFormat)
Definition: qpainter.cpp:6738
unsigned int glyph_t
QPaintEngine * engine
Definition: qpainter_p.h:261
glyph_t * glyphs
virtual void drawTextItem(const QPointF &p, const QTextItem &textItem)
This function draws the text item textItem at position p.

◆ drawOpaqueBackground()

void QPainterPrivate::drawOpaqueBackground ( const QPainterPath path,
DrawOperation  operation 
)

Definition at line 512 of file qpainter.cpp.

Referenced by draw_helper().

513 {
514  Q_Q(QPainter);
515 
516  q->setBackgroundMode(Qt::TransparentMode);
517 
518  if (op & FillDraw && state->brush.style() != Qt::NoBrush) {
519  q->fillPath(path, state->bgBrush.color());
520  q->fillPath(path, state->brush);
521  }
522 
523  if (op & StrokeDraw && state->pen.style() != Qt::NoPen) {
524  q->strokePath(path, QPen(state->bgBrush.color(), state->pen.width()));
525  q->strokePath(path, state->pen);
526  }
527 
528  q->setBackgroundMode(Qt::OpaqueMode);
529 }
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
const QColor & color() const
Returns the brush color.
Definition: qbrush.h:183
Qt::PenStyle style() const
Returns the pen style.
Definition: qpen.cpp:428
QPainterState * state
Definition: qpainter_p.h:204
The QPen class defines how a QPainter should draw lines and outlines of shapes.
Definition: qpen.h:64
QBrush bgBrush
Definition: qpainter_p.h:154
#define Q_Q(Class)
Definition: qglobal.h:2483
Qt::BrushStyle style() const
Returns the brush style.
Definition: qbrush.h:182
int width() const
Returns the pen width with integer precision.
Definition: qpen.cpp:630
QBrush brush
Definition: qpainter_p.h:153

◆ drawStretchedGradient()

void QPainterPrivate::drawStretchedGradient ( const QPainterPath path,
DrawOperation  operation 
)

Definition at line 547 of file qpainter.cpp.

Referenced by draw_helper().

548 {
549  Q_Q(QPainter);
550 
551  const qreal sw = helper_device->width();
552  const qreal sh = helper_device->height();
553 
554  bool changedPen = false;
555  bool changedBrush = false;
556  bool needsFill = false;
557 
558  const QPen pen = state->pen;
559  const QBrush brush = state->brush;
560 
561  const QGradient::CoordinateMode penMode = coordinateMode(pen.brush());
562  const QGradient::CoordinateMode brushMode = coordinateMode(brush);
563 
565 
566  // Draw the xformed fill if the brush is a stretch gradient.
567  if ((op & FillDraw) && brush.style() != Qt::NoBrush) {
568  if (brushMode == QGradient::StretchToDeviceMode) {
569  q->setPen(Qt::NoPen);
570  changedPen = pen.style() != Qt::NoPen;
571  q->scale(sw, sh);
573 
574  const qreal isw = 1.0 / sw;
575  const qreal ish = 1.0 / sh;
576  QTransform inv(isw, 0, 0, ish, 0, 0);
577  engine->drawPath(path * inv);
578  q->scale(isw, ish);
579  } else {
580  needsFill = true;
581 
582  if (brushMode == QGradient::ObjectBoundingMode) {
584  boundingRect = path.boundingRect();
585  q->setBrush(stretchGradientToUserSpace(brush, boundingRect));
586  changedBrush = true;
587  }
588  }
589  }
590 
591  if ((op & StrokeDraw) && pen.style() != Qt::NoPen) {
592  // Draw the xformed outline if the pen is a stretch gradient.
593  if (penMode == QGradient::StretchToDeviceMode) {
594  q->setPen(Qt::NoPen);
595  changedPen = true;
596 
597  if (needsFill) {
599  engine->drawPath(path);
600  }
601 
602  q->scale(sw, sh);
603  q->setBrush(pen.brush());
604  changedBrush = true;
606 
607  QPainterPathStroker stroker;
608  stroker.setDashPattern(pen.style());
609  stroker.setWidth(pen.widthF());
610  stroker.setJoinStyle(pen.joinStyle());
611  stroker.setCapStyle(pen.capStyle());
612  stroker.setMiterLimit(pen.miterLimit());
613  QPainterPath stroke = stroker.createStroke(path);
614 
615  const qreal isw = 1.0 / sw;
616  const qreal ish = 1.0 / sh;
617  QTransform inv(isw, 0, 0, ish, 0, 0);
618  engine->drawPath(stroke * inv);
619  q->scale(isw, ish);
620  } else {
621  if (!needsFill && brush.style() != Qt::NoBrush) {
622  q->setBrush(Qt::NoBrush);
623  changedBrush = true;
624  }
625 
626  if (penMode == QGradient::ObjectBoundingMode) {
628 
629  // avoid computing the bounding rect twice
630  if (!needsFill || brushMode != QGradient::ObjectBoundingMode)
631  boundingRect = path.boundingRect();
632 
633  QPen p = pen;
635  q->setPen(p);
636  changedPen = true;
637  } else if (changedPen) {
638  q->setPen(pen);
639  changedPen = false;
640  }
641 
643  engine->drawPath(path);
644  }
645  } else if (needsFill) {
646  if (pen.style() != Qt::NoPen) {
647  q->setPen(Qt::NoPen);
648  changedPen = true;
649  }
650 
652  engine->drawPath(path);
653  }
654 
655  if (changedPen)
656  q->setPen(pen);
657  if (changedBrush)
658  q->setBrush(brush);
659 }
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
double qreal
Definition: qglobal.h:1193
void setBrush(const QBrush &brush)
Sets the brush used to fill strokes generated with this pen to the given brush.
Definition: qpen.cpp:808
virtual void drawPath(const QPainterPath &path)
The default implementation ignores the path and does nothing.
static QGradient::CoordinateMode coordinateMode(const QBrush &brush)
Definition: qpainter.cpp:106
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:67
Qt::PenStyle style() const
Returns the pen style.
Definition: qpen.cpp:428
static const uchar inv
Definition: qisciicodec.cpp:91
QPainterState * state
Definition: qpainter_p.h:204
int height() const
Definition: qpaintdevice.h:92
void setCapStyle(Qt::PenCapStyle style)
Sets the cap style of the generated outlines to style.
void updateState(QPainterState *state)
Definition: qpainter.cpp:926
CoordinateMode
This enum specifies how gradient coordinates map to the paint device on which the gradient is used...
Definition: qbrush.h:219
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QPen class defines how a QPainter should draw lines and outlines of shapes.
Definition: qpen.h:64
void setMiterLimit(qreal length)
Sets the miter limit of the generated outlines to limit.
static QBrush stretchGradientToUserSpace(const QBrush &brush, const QRectF &boundingRect)
Definition: qpainter.cpp:531
#define Q_Q(Class)
Definition: qglobal.h:2483
QRectF boundingRect() const
Returns the bounding rectangle of this painter path as a rectangle with floating point precision...
void setDashPattern(Qt::PenStyle)
Sets the dash pattern for the generated outlines to style.
static const QRectF boundingRect(const QPointF *points, int pointCount)
int width() const
Definition: qpaintdevice.h:91
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
QPainterPath createStroke(const QPainterPath &path) const
Generates a new path that is a fillable area representing the outline of the given path...
Qt::PenJoinStyle joinStyle() const
Returns the pen&#39;s join style.
Definition: qpen.cpp:736
The QPainterPathStroker class is used to generate fillable outlines for a given painter path...
Definition: qpainterpath.h:264
QBrush brush() const
Returns the brush used to fill strokes generated with this pen.
Definition: qpen.cpp:797
Qt::BrushStyle style() const
Returns the brush style.
Definition: qbrush.h:182
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
qreal miterLimit() const
Returns the miter limit of the pen.
Definition: qpen.cpp:589
void setJoinStyle(Qt::PenJoinStyle style)
Sets the join style of the generated outlines to style.
qreal widthF() const
Returns the pen width with floating point precision.
Definition: qpen.cpp:645
QPaintDevice * helper_device
Definition: qpainter_p.h:260
QBrush brush
Definition: qpainter_p.h:153
Qt::PenCapStyle capStyle() const
Returns the pen&#39;s cap style.
Definition: qpen.cpp:706
bool hasFeature(PaintEngineFeatures feature) const
Returns true if the paint engine supports the specified feature; otherwise returns false...
Definition: qpaintengine.h:229
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65
void setWidth(qreal width)
Sets the width of the generated outline painter path to width.
QPaintEngine * engine
Definition: qpainter_p.h:261

◆ fakeState()

QPainterDummyState* QPainterPrivate::fakeState ( ) const
inline

Definition at line 220 of file qpainter_p.h.

220  {
221  if (!dummyState)
223  return dummyState;
224  }
QPainterDummyState * dummyState
Definition: qpainter_p.h:207

◆ get()

static QPainterPrivate* QPainterPrivate::get ( QPainter painter)
inlinestatic

Definition at line 249 of file qpainter_p.h.

Referenced by QDeclarativeTextLayout::draw().

250  {
251  return painter->d_ptr.data();
252  }
T * data() const
Returns the value of the pointer referenced by this object.
QScopedPointer< QPainterPrivate > d_ptr
Definition: qpainter.h:546

◆ rectSubtraction()

int QPainterPrivate::rectSubtraction ( ) const
inline

Definition at line 243 of file qpainter_p.h.

243  {
244  return state->pen.style() != Qt::NoPen && state->pen.width() == 0 ? 1 : 0;
245  }
Qt::PenStyle style() const
Returns the pen style.
Definition: qpen.cpp:428
QPainterState * state
Definition: qpainter_p.h:204
int width() const
Returns the pen width with integer precision.
Definition: qpen.cpp:630

◆ updateEmulationSpecifier()

void QPainterPrivate::updateEmulationSpecifier ( QPainterState s)

Definition at line 689 of file qpainter.cpp.

Referenced by updateStateImpl().

690 {
691  bool alpha = false;
692  bool linearGradient = false;
693  bool radialGradient = false;
694  bool extendedRadialGradient = false;
695  bool conicalGradient = false;
696  bool patternBrush = false;
697  bool xform = false;
698  bool complexXform = false;
699 
700  bool skip = true;
701 
702  // Pen and brush properties (we have to check both if one changes because the
703  // one that's unchanged can still be in a state which requires emulation)
705  // Check Brush stroke emulation
708  else
710 
711  skip = false;
712 
713  QBrush penBrush = (qpen_style(s->pen) == Qt::NoPen) ? QBrush(Qt::NoBrush) : qpen_brush(s->pen);
714  Qt::BrushStyle brushStyle = qbrush_style(s->brush);
715  Qt::BrushStyle penBrushStyle = qbrush_style(penBrush);
716  alpha = (penBrushStyle != Qt::NoBrush
717  && (penBrushStyle < Qt::LinearGradientPattern && penBrush.color().alpha() != 255)
718  && !penBrush.isOpaque())
719  || (brushStyle != Qt::NoBrush
720  && (brushStyle < Qt::LinearGradientPattern && s->brush.color().alpha() != 255)
721  && !s->brush.isOpaque());
722  linearGradient = ((penBrushStyle == Qt::LinearGradientPattern) ||
723  (brushStyle == Qt::LinearGradientPattern));
724  radialGradient = ((penBrushStyle == Qt::RadialGradientPattern) ||
725  (brushStyle == Qt::RadialGradientPattern));
726  extendedRadialGradient = radialGradient && (qt_isExtendedRadialGradient(penBrush) || qt_isExtendedRadialGradient(s->brush));
727  conicalGradient = ((penBrushStyle == Qt::ConicalGradientPattern) ||
728  (brushStyle == Qt::ConicalGradientPattern));
729  patternBrush = (((penBrushStyle > Qt::SolidPattern
730  && penBrushStyle < Qt::LinearGradientPattern)
731  || penBrushStyle == Qt::TexturePattern) ||
732  ((brushStyle > Qt::SolidPattern
733  && brushStyle < Qt::LinearGradientPattern)
734  || brushStyle == Qt::TexturePattern));
735 
736  bool penTextureAlpha = false;
737  if (penBrush.style() == Qt::TexturePattern)
738  penTextureAlpha = qHasPixmapTexture(penBrush)
739  ? (penBrush.texture().depth() > 1) && penBrush.texture().hasAlpha()
740  : penBrush.textureImage().hasAlphaChannel();
741  bool brushTextureAlpha = false;
742  if (s->brush.style() == Qt::TexturePattern) {
743  brushTextureAlpha = qHasPixmapTexture(s->brush)
744  ? (s->brush.texture().depth() > 1) && s->brush.texture().hasAlpha()
746  }
747  if (((penBrush.style() == Qt::TexturePattern && penTextureAlpha)
748  || (s->brush.style() == Qt::TexturePattern && brushTextureAlpha))
751  else
753  }
754 
755  if (s->state() & (QPaintEngine::DirtyHints
758  skip = false;
759  }
760 
761  if (skip)
762  return;
763 
764 #if 0
765  qDebug("QPainterPrivate::updateEmulationSpecifier, state=%p\n"
766  " - alpha: %d\n"
767  " - linearGradient: %d\n"
768  " - radialGradient: %d\n"
769  " - conicalGradient: %d\n"
770  " - patternBrush: %d\n"
771  " - hints: %x\n"
772  " - xform: %d\n",
773  s,
774  alpha,
775  linearGradient,
776  radialGradient,
777  conicalGradient,
778  patternBrush,
779  uint(s->renderHints),
780  xform);
781 #endif
782 
783  // XForm properties
784  if (s->state() & QPaintEngine::DirtyTransform) {
785  xform = !s->matrix.isIdentity();
786  complexXform = !s->matrix.isAffine();
787  } else if (s->matrix.type() >= QTransform::TxTranslate) {
788  xform = true;
789  complexXform = !s->matrix.isAffine();
790  }
791 
792  const bool brushXform = (!s->brush.transform().type() == QTransform::TxNone);
793  const bool penXform = (!s->pen.brush().transform().type() == QTransform::TxNone);
794 
795  const bool patternXform = patternBrush && (xform || brushXform || penXform);
796 
797  // Check alphablending
800  else
802 
803  // Linear gradient emulation
806  else
808 
809  // Radial gradient emulation
810  if (extendedRadialGradient || (radialGradient && !engine->hasFeature(QPaintEngine::RadialGradientFill)))
812  else
813  s->emulationSpecifier &= ~QPaintEngine::RadialGradientFill;
814 
815  // Conical gradient emulation
816  if (conicalGradient && !engine->hasFeature(QPaintEngine::ConicalGradientFill))
818  else
820 
821  // Pattern brushes
822  if (patternBrush && !engine->hasFeature(QPaintEngine::PatternBrush))
824  else
826 
827  // Pattern XForms
830  else
832 
833  // Primitive XForms
836  else
838 
839  // Perspective XForms
842  else
844 
845  // Constant opacity
848  else
850 
851  bool gradientStretch = false;
852  bool objectBoundingMode = false;
853  if (linearGradient || conicalGradient || radialGradient) {
856 
857  gradientStretch |= (brushMode == QGradient::StretchToDeviceMode);
858  gradientStretch |= (penMode == QGradient::StretchToDeviceMode);
859 
860  objectBoundingMode |= (brushMode == QGradient::ObjectBoundingMode);
861  objectBoundingMode |= (penMode == QGradient::ObjectBoundingMode);
862  }
863  if (gradientStretch)
865  else
867 
868  if (objectBoundingMode && !engine->hasFeature(QPaintEngine::ObjectBoundingModeGradients))
870  else
872 
873  // Opaque backgrounds...
874  if (s->bgMode == Qt::OpaqueMode &&
877  else
879 
880 #if 0
881  //won't be correct either way because the device can already have
882  // something rendered to it in which case subsequent emulation
883  // on a fully transparent qimage and then blitting the results
884  // won't produce correct results
885  // Blend modes
889  else
891 #endif
892 }
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
BrushStyle
Definition: qnamespace.h:1162
QPainter::RenderHints renderHints
Definition: qpainter_p.h:158
QPainter::CompositionMode composition_mode
Definition: qpainter_p.h:174
static QGradient::CoordinateMode coordinateMode(const QBrush &brush)
Definition: qpainter.cpp:106
Qt::BrushStyle qbrush_style(const QBrush &b)
Definition: qpainter_p.h:96
static bool is_brush_transparent(const QBrush &brush)
Definition: qpainter.cpp:127
QPainterState * state
Definition: qpainter_p.h:204
bool hasAlphaChannel() const
Returns true if the image has a format that respects the alpha channel, otherwise returns false...
Definition: qimage.cpp:6495
CoordinateMode
This enum specifies how gradient coordinates map to the paint device on which the gradient is used...
Definition: qbrush.h:219
QTransform matrix
Definition: qpainter_p.h:161
int depth() const
Returns the depth of the pixmap.
Definition: qpixmap.cpp:695
TransformationType type() const
Returns the transformation type of this matrix.
QTransform transform() const
Returns the current transformation matrix for the brush.
Definition: qbrush.h:185
bool isIdentity() const
Returns true if the matrix is the identity matrix, otherwise returns false.
Definition: qtransform.h:204
Q_CORE_EXPORT void qDebug(const char *,...)
bool qHasPixmapTexture(const QBrush &)
Definition: qbrush.cpp:223
QBrush qpen_brush(const QPen &p)
Definition: qpainter_p.h:87
unsigned int uint
Definition: qglobal.h:996
QBrush brush() const
Returns the brush used to fill strokes generated with this pen.
Definition: qpen.cpp:797
Qt::BrushStyle style() const
Returns the brush style.
Definition: qbrush.h:182
QPixmap texture() const
Returns the custom brush pattern, or a null pixmap if no custom brush pattern has been set...
Definition: qbrush.cpp:785
bool isOpaque() const
Returns true if the brush is fully opaque otherwise false.
Definition: qbrush.cpp:910
The QPaintEngine class provides an abstract definition of how QPainter draws to a given device on a g...
Definition: qpaintengine.h:90
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
bool isAffine() const
Returns true if the matrix represent an affine transformation, otherwise returns false.
Definition: qtransform.h:200
bool hasAlpha() const
Returns true if this pixmap has an alpha channel, or has a mask, otherwise returns false...
Definition: qpixmap.cpp:1938
if(void) toggleToolbarShown
#define QPaintEngine_OpaqueBackground
Definition: qpainter.cpp:83
#define QGradient_StretchToDevice
Definition: qpainter.cpp:82
QBrush brush
Definition: qpainter_p.h:153
uint emulationSpecifier
Definition: qpainter_p.h:175
Qt::BGMode bgMode
Definition: qpainter_p.h:171
Q_GUI_EXPORT bool qt_isExtendedRadialGradient(const QBrush &brush)
Definition: qbrush.cpp:881
Qt::PenStyle qpen_style(const QPen &p)
Definition: qpainter_p.h:89
QImage textureImage() const
Returns the custom brush pattern, or a null image if no custom brush pattern has been set...
Definition: qbrush.cpp:829
static bool is_pen_transparent(const QPen &pen)
Definition: qpainter.cpp:136
bool hasFeature(PaintEngineFeatures feature) const
Returns true if the paint engine supports the specified feature; otherwise returns false...
Definition: qpaintengine.h:229
QPaintEngine * engine
Definition: qpainter_p.h:261
bool isSolid() const
Returns true if the pen has a solid fill, otherwise false.
Definition: qpen.cpp:820

◆ updateInvMatrix()

void QPainterPrivate::updateInvMatrix ( )
Warning
This function is not part of the public interface.

Definition at line 680 of file qpainter.cpp.

Referenced by QPainter::clipBoundingRect(), QPainter::clipPath(), and QPainter::clipRegion().

681 {
682  Q_ASSERT(txinv == false);
683  txinv = true; // creating inverted matrix
685 }
QPainterState * state
Definition: qpainter_p.h:204
QTransform matrix
Definition: qpainter_p.h:161
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QTransform inverted(bool *invertible=0) const
Returns an inverted copy of this matrix.
Definition: qtransform.cpp:364
QTransform invMatrix
Definition: qpainter_p.h:209

◆ updateMatrix()

void QPainterPrivate::updateMatrix ( )

Definition at line 662 of file qpainter.cpp.

Referenced by attachPainterPrivate().

663 {
665  if (state->VxF)
666  state->matrix *= viewTransform();
667 
668  txinv = false; // no inverted matrix
670  if (extended)
672  else
674 
675 // printf("VxF=%d, WxF=%d\n", state->VxF, state->WxF);
676 // qDebug() << " --- using matrix" << state->matrix << redirection_offset;
677 }
QPaintEngineEx * extended
Definition: qpainter_p.h:263
virtual void transformChanged()=0
QPainterState * state
Definition: qpainter_p.h:204
QPaintEngine::DirtyFlags dirtyFlags
Definition: qpaintengine.h:325
QTransform matrix
Definition: qpainter_p.h:161
QTransform viewTransform() const
Definition: qpainter.cpp:224
QTransform redirectionMatrix
Definition: qpainter_p.h:162
QTransform worldMatrix
Definition: qpainter_p.h:160
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65

◆ updateState()

void QPainterPrivate::updateState ( QPainterState state)

Definition at line 926 of file qpainter.cpp.

Referenced by draw_helper(), and drawStretchedGradient().

927 {
928 
929  if (!newState) {
930  engine->state = newState;
931 
932  } else if (newState->state() || engine->state!=newState) {
933  bool setNonCosmeticPen = (newState->renderHints & QPainter::NonCosmeticDefaultPen)
934  && newState->pen.widthF() == 0;
935  if (setNonCosmeticPen) {
936  // Override the default pen's cosmetic state if the
937  // NonCosmeticDefaultPen render hint is used.
938  QPen oldPen = newState->pen;
939  newState->pen.setWidth(1);
940  newState->pen.setCosmetic(false);
941  newState->dirtyFlags |= QPaintEngine::DirtyPen;
942 
943  updateStateImpl(newState);
944 
945  // Restore the state pen back to its default to preserve visible
946  // state.
947  newState->pen = oldPen;
948  } else {
949  updateStateImpl(newState);
950  }
951  }
952 }
QPaintEngineState * state
Definition: qpaintengine.h:239
The QPen class defines how a QPainter should draw lines and outlines of shapes.
Definition: qpen.h:64
void updateStateImpl(QPainterState *state)
Definition: qpainter.cpp:894
qreal widthF() const
Returns the pen width with floating point precision.
Definition: qpen.cpp:645
QPen pen() const
Returns the pen in the current paint engine state.
Definition: qpainter.cpp:9259
void setWidth(int width)
Sets the pen width to the given width in pixels with integer precision.
Definition: qpen.cpp:667
QPaintEngine * engine
Definition: qpainter_p.h:261

◆ updateStateImpl()

void QPainterPrivate::updateStateImpl ( QPainterState state)

Definition at line 894 of file qpainter.cpp.

Referenced by updateState().

895 {
896  // ### we might have to call QPainter::begin() here...
897  if (!engine->state) {
898  engine->state = newState;
900  }
901 
902  if (engine->state->painter() != newState->painter)
903  // ### this could break with clip regions vs paths.
905 
906  // Upon restore, revert all changes since last save
907  else if (engine->state != newState)
908  newState->dirtyFlags |= QPaintEngine::DirtyFlags(static_cast<QPainterState *>(engine->state)->changeFlags);
909 
910  // We need to store all changes made so that restore can deal with them
911  else
912  newState->changeFlags |= newState->dirtyFlags;
913 
914  updateEmulationSpecifier(newState);
915 
916  // Unset potential dirty background mode
917  newState->dirtyFlags &= ~(QPaintEngine::DirtyBackgroundMode
919 
920  engine->state = newState;
921  engine->updateState(*newState);
923 
924 }
QPaintEngineState * state
Definition: qpaintengine.h:239
void clearDirty(DirtyFlags df)
Definition: qpaintengine.h:354
virtual void updateState(const QPaintEngineState &state)=0
Reimplement this function to update the state of a paint engine.
void setDirty(DirtyFlags df)
Definition: qpaintengine.h:349
QPainter * painter() const
Returns a pointer to the painter currently updating the paint engine.
Definition: qpainter.cpp:9514
void updateEmulationSpecifier(QPainterState *s)
Definition: qpainter.cpp:689
QPaintEngine * engine
Definition: qpainter_p.h:261

◆ viewTransform()

QTransform QPainterPrivate::viewTransform ( ) const

Definition at line 224 of file qpainter.cpp.

Referenced by updateMatrix().

225 {
226  if (state->VxF) {
227  qreal scaleW = qreal(state->vw)/qreal(state->ww);
228  qreal scaleH = qreal(state->vh)/qreal(state->wh);
229  return QTransform(scaleW, 0, 0, scaleH,
230  state->vx - state->wx*scaleW, state->vy - state->wy*scaleH);
231  }
232  return QTransform();
233 }
double qreal
Definition: qglobal.h:1193
QPainterState * state
Definition: qpainter_p.h:204
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65

Properties

◆ colorBrush

QBrush QPainterPrivate::colorBrush

Definition at line 264 of file qpainter_p.h.

◆ d_ptrs

QPainterPrivate** QPainterPrivate::d_ptrs

Definition at line 202 of file qpainter_p.h.

Referenced by attachPainterPrivate(), detachPainterPrivate(), and QPainter::~QPainter().

◆ d_ptrs_size

uint QPainterPrivate::d_ptrs_size

Definition at line 212 of file qpainter_p.h.

Referenced by attachPainterPrivate().

◆ device

QPaintDevice* QPainterPrivate::device

Definition at line 258 of file qpainter_p.h.

Referenced by draw_helper(), and qt_cleanup_painter_state().

◆ dummyState

QPainterDummyState* QPainterPrivate::dummyState
mutable

Definition at line 207 of file qpainter_p.h.

Referenced by ~QPainterPrivate().

◆ emulationEngine

QEmulationPaintEngine* QPainterPrivate::emulationEngine

Definition at line 262 of file qpainter_p.h.

Referenced by checkEmulation(), detachPainterPrivate(), and ~QPainterPrivate().

◆ engine

QPaintEngine* QPainterPrivate::engine

◆ extended

QPaintEngineEx* QPainterPrivate::extended

◆ helper_device

QPaintDevice* QPainterPrivate::helper_device

Definition at line 260 of file qpainter_p.h.

Referenced by draw_helper(), and drawStretchedGradient().

◆ inDestructor

uint QPainterPrivate::inDestructor

Definition at line 211 of file qpainter_p.h.

Referenced by detachPainterPrivate(), and QPainter::~QPainter().

◆ invMatrix

QTransform QPainterPrivate::invMatrix

Definition at line 209 of file qpainter_p.h.

Referenced by draw_helper(), and updateInvMatrix().

◆ original_device

QPaintDevice* QPainterPrivate::original_device

Definition at line 259 of file qpainter_p.h.

◆ q_ptr

QPainter* QPainterPrivate::q_ptr

Definition at line 201 of file qpainter_p.h.

◆ refcount

uint QPainterPrivate::refcount

Definition at line 213 of file qpainter_p.h.

Referenced by attachPainterPrivate(), detachPainterPrivate(), and QPainter::~QPainter().

◆ state

QPainterState* QPainterPrivate::state

◆ states

QVector<QPainterState*> QPainterPrivate::states

Definition at line 205 of file qpainter_p.h.

Referenced by qt_cleanup_painter_state(), and ~QPainterPrivate().

◆ txinv

uint QPainterPrivate::txinv

Definition at line 210 of file qpainter_p.h.

Referenced by draw_helper(), updateInvMatrix(), and updateMatrix().


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