Qt 4.8
Public Types | Public Functions | Protected Functions | List of all members
QPaintEngineEx Class Referenceabstract

#include <qpaintengineex_p.h>

Inheritance diagram for QPaintEngineEx:
QPaintEngine QEmulationPaintEngine QGL2PaintEngineEx QOpenGLPaintEngine QPaintBufferEngine QRasterPaintEngine QVGPaintEngine QBlitterPaintEngine QDirectFBPaintEngine QOnScreenRasterPaintEngine QVolatileImagePaintEngine

Public Types

enum  Flags { DoNotEmulate = 0x01, IsEmulationEngine = 0x02 }
 
- 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
}
 

Public Functions

virtual void beginNativePainting ()
 
virtual void brushChanged ()=0
 
virtual void brushOriginChanged ()=0
 
virtual void clip (const QVectorPath &path, Qt::ClipOperation op)=0
 
virtual void clip (const QRect &rect, Qt::ClipOperation op)
 
virtual void clip (const QRegion &region, Qt::ClipOperation op)
 
virtual void clip (const QPainterPath &path, Qt::ClipOperation op)
 
virtual void clipEnabledChanged ()=0
 
virtual void compositionModeChanged ()=0
 
virtual QPainterStatecreateState (QPainterState *orig) const
 
virtual void draw (const QVectorPath &path)
 
virtual void drawEllipse (const QRectF &r)
 Reimplement this function to draw the largest ellipse that can be contained within rectangle rect. More...
 
virtual void drawEllipse (const QRect &r)
 The default implementation of this function calls the floating point version of this function. More...
 
virtual void drawImage (const QRectF &r, const QImage &pm, const QRectF &sr, Qt::ImageConversionFlags flags=Qt::AutoColor)=0
 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...
 
virtual void drawImage (const QPointF &pos, const QImage &image)
 
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 drawPath (const QPainterPath &path)
 The default implementation ignores the path and does nothing. More...
 
virtual void drawPixmap (const QRectF &r, const QPixmap &pm, const QRectF &sr)=0
 Reimplement this function to draw the part of the pm specified by the sr rectangle in the given r. More...
 
virtual void drawPixmap (const QPointF &pos, const QPixmap &pm)
 
virtual void drawPixmapFragments (const QPainter::PixmapFragment *fragments, int fragmentCount, const QPixmap &pixmap, QPainter::PixmapFragmentHints hints)
 
virtual void drawPixmapFragments (const QRectF *targetRects, const QRectF *sourceRects, int fragmentCount, const QPixmap &pixmap, QPainter::PixmapFragmentHints hints)
 
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 QPointF *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 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...
 
virtual void drawRoundedRect (const QRectF &rect, qreal xrad, qreal yrad, Qt::SizeMode mode)
 
virtual void drawStaticTextItem (QStaticTextItem *)
 
virtual void drawTiledPixmap (const QRectF &r, const QPixmap &pixmap, const QPointF &s)
 Reimplement this function to draw the pixmap in the given rect, starting at the given p. More...
 
virtual void endNativePainting ()
 
virtual void fill (const QVectorPath &path, const QBrush &brush)=0
 
virtual void fillRect (const QRectF &rect, const QBrush &brush)
 
virtual void fillRect (const QRectF &rect, const QColor &color)
 
virtual uint flags () const
 
virtual void opacityChanged ()=0
 
virtual void penChanged ()=0
 
virtual QPixmapFilterpixmapFilter (int, const QPixmapFilter *)
 
 QPaintEngineEx ()
 
virtual void renderHintsChanged ()=0
 
virtual void setState (QPainterState *s)
 
QPainterStatestate ()
 
const QPainterStatestate () const
 
virtual void stroke (const QVectorPath &path, const QPen &pen)
 
virtual bool supportsTransformations (qreal pixelSize, const QTransform &m) const
 
virtual void sync ()
 
virtual void transformChanged ()=0
 
virtual void updateState (const QPaintEngineState &state)
 Reimplement this function to update the state of a paint engine. More...
 
- Public Functions inherited from QPaintEngine
virtual bool begin (QPaintDevice *pdev)=0
 Reimplement this function to initialise your paint engine when painting is to start on the paint device pdev. More...
 
void clearDirty (DirtyFlags df)
 
virtual QPoint coordinateOffset () const
 Returns the offset from the painters origo to the engines origo. More...
 
virtual void drawTextItem (const QPointF &p, const QTextItem &textItem)
 This function draws the text item textItem at position p. More...
 
virtual bool end ()=0
 Reimplement this function to finish painting on the current paint device. 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 Type type () const =0
 Reimplement this function to return the paint engine Type. More...
 
virtual ~QPaintEngine ()
 Destroys the paint engine. More...
 

Protected Functions

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

Additional Inherited Members

- 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 143 of file qpaintengineex_p.h.

Enumerations

◆ Flags

Enumerator
DoNotEmulate 
IsEmulationEngine 

Definition at line 226 of file qpaintengineex_p.h.

227  {
228  DoNotEmulate = 0x01, // If set, QPainter will not wrap this engine in an emulation engine.
229  IsEmulationEngine = 0x02 // If set, this object is a QEmulationEngine.
230  };

Constructors and Destructors

◆ QPaintEngineEx() [1/2]

QPaintEngineEx::QPaintEngineEx ( )

Definition at line 367 of file qpaintengineex.cpp.

369 {
370  extended = true;
371 }
QPaintEngine(PaintEngineFeatures features=0)
Creates a paint engine with the featureset specified by caps.

◆ QPaintEngineEx() [2/2]

QPaintEngineEx::QPaintEngineEx ( QPaintEngineExPrivate data)
protected

Definition at line 373 of file qpaintengineex.cpp.

374  : QPaintEngine(data, AllFeatures)
375 {
376  extended = true;
377 }
QPaintEngine(PaintEngineFeatures features=0)
Creates a paint engine with the featureset specified by caps.

Functions

◆ beginNativePainting()

virtual void QPaintEngineEx::beginNativePainting ( )
inlinevirtual

◆ brushChanged()

virtual void QPaintEngineEx::brushChanged ( )
pure virtual

◆ brushOriginChanged()

virtual void QPaintEngineEx::brushOriginChanged ( )
pure virtual

◆ clip() [1/4]

virtual void QPaintEngineEx::clip ( const QVectorPath path,
Qt::ClipOperation  op 
)
pure virtual

◆ clip() [2/4]

void QPaintEngineEx::clip ( const QRect rect,
Qt::ClipOperation  op 
)
virtual

Reimplemented in QPaintBufferEngine, QRasterPaintEngine, QDirectFBPaintEngine, and QVGPaintEngine.

Definition at line 607 of file qpaintengineex.cpp.

608 {
609  qreal right = r.x() + r.width();
610  qreal bottom = r.y() + r.height();
611  qreal pts[] = { qreal(r.x()), qreal(r.y()),
612  right, qreal(r.y()),
613  right, bottom,
614  qreal(r.x()), bottom,
615  qreal(r.x()), qreal(r.y()) };
617  clip(vp, op);
618 }
double qreal
Definition: qglobal.h:1193
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
virtual void clip(const QVectorPath &path, Qt::ClipOperation op)=0

◆ clip() [3/4]

void QPaintEngineEx::clip ( const QRegion region,
Qt::ClipOperation  op 
)
virtual

Reimplemented in QPaintBufferEngine, QRasterPaintEngine, QDirectFBPaintEngine, and QVGPaintEngine.

Definition at line 620 of file qpaintengineex.cpp.

621 {
622  if (region.rectCount() == 1)
623  clip(region.boundingRect(), op);
624 
625  QVector<QRect> rects = region.rects();
626  if (rects.size() <= 32) {
627  qreal pts[2*32*4];
628  int pos = 0;
629  for (QVector<QRect>::const_iterator i = rects.constBegin(); i != rects.constEnd(); ++i) {
630  qreal x1 = i->x();
631  qreal y1 = i->y();
632  qreal x2 = i->x() + i->width();
633  qreal y2 = i->y() + i->height();
634 
635  pts[pos++] = x1;
636  pts[pos++] = y1;
637 
638  pts[pos++] = x2;
639  pts[pos++] = y1;
640 
641  pts[pos++] = x2;
642  pts[pos++] = y2;
643 
644  pts[pos++] = x1;
645  pts[pos++] = y2;
646  }
647  QVectorPath vp(pts, rects.size() * 4, qpaintengineex_rect4_types_32);
648  clip(vp, op);
649  } else {
650  QVarLengthArray<qreal> pts(rects.size() * 2 * 4);
652  int ppos = 0;
653  int tpos = 0;
654 
655  for (QVector<QRect>::const_iterator i = rects.constBegin(); i != rects.constEnd(); ++i) {
656  qreal x1 = i->x();
657  qreal y1 = i->y();
658  qreal x2 = i->x() + i->width();
659  qreal y2 = i->y() + i->height();
660 
661  pts[ppos++] = x1;
662  pts[ppos++] = y1;
663 
664  pts[ppos++] = x2;
665  pts[ppos++] = y1;
666 
667  pts[ppos++] = x2;
668  pts[ppos++] = y2;
669 
670  pts[ppos++] = x1;
671  pts[ppos++] = y2;
672 
677  }
678 
679  QVectorPath vp(pts.data(), rects.size() * 4, types.data());
680  clip(vp, op);
681  }
682 
683 }
double qreal
Definition: qglobal.h:1193
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the vector...
Definition: qvector.h:252
static QPainterPath::ElementType qpaintengineex_rect4_types_32[]
QRect boundingRect() const
Returns the bounding rectangle of this region.
Definition: qregion.cpp:4363
int rectCount() const
Returns the number of rectangles that will be returned in rects().
Definition: qregion.cpp:4461
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the vector.
Definition: qvector.h:249
static const struct @32 types[]
QVector< QRect > rects() const
Returns an array of non-overlapping rectangles that make up the region.
Definition: qregion.cpp:4412
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137
virtual void clip(const QVectorPath &path, Qt::ClipOperation op)=0

◆ clip() [4/4]

void QPaintEngineEx::clip ( const QPainterPath path,
Qt::ClipOperation  op 
)
virtual

Reimplemented in QPaintBufferEngine, and QVGPaintEngine.

Definition at line 685 of file qpaintengineex.cpp.

686 {
687  if (path.isEmpty()) {
688  QVectorPath vp(0, 0);
689  clip(vp, op);
690  } else {
691  clip(qtVectorPathForPath(path), op);
692  }
693 }
bool isEmpty() const
Returns true if either there are no elements in this path, or if the only element is a MoveToElement;...
Definition: qpainterpath.h:392
const QVectorPath & qtVectorPathForPath(const QPainterPath &path)
virtual void clip(const QVectorPath &path, Qt::ClipOperation op)=0

◆ clipEnabledChanged()

virtual void QPaintEngineEx::clipEnabledChanged ( )
pure virtual

◆ compositionModeChanged()

virtual void QPaintEngineEx::compositionModeChanged ( )
pure virtual

◆ createState()

QPainterState * QPaintEngineEx::createState ( QPainterState orig) const
virtual

Reimplemented in QPaintBufferEngine, QRasterPaintEngine, QGL2PaintEngineEx, QOpenGLPaintEngine, QVGPaintEngine, and QEmulationPaintEngine.

Definition at line 379 of file qpaintengineex.cpp.

Referenced by QEmulationPaintEngine::createState(), and QVGPaintEngine::type().

380 {
381  if (!orig)
382  return new QPainterState;
383  return new QPainterState(orig);
384 }

◆ draw()

void QPaintEngineEx::draw ( const QVectorPath path)
virtual

Reimplemented in QPaintBufferEngine, and QVGPaintEngine.

Definition at line 595 of file qpaintengineex.cpp.

Referenced by QVGPaintEngine::draw(), drawEllipse(), drawPath(), drawPolygon(), drawRects(), drawRoundedRect(), and QVGPaintEngine::type().

596 {
597  const QBrush &brush = state()->brush;
598  if (qbrush_style(brush) != Qt::NoBrush)
599  fill(path, brush);
600 
601  const QPen &pen = state()->pen;
602  if (qpen_style(pen) != Qt::NoPen && qbrush_style(qpen_brush(pen)) != Qt::NoBrush)
603  stroke(path, pen);
604 }
Qt::BrushStyle qbrush_style(const QBrush &b)
Definition: qpainter_p.h:96
The QPen class defines how a QPainter should draw lines and outlines of shapes.
Definition: qpen.h:64
virtual void stroke(const QVectorPath &path, const QPen &pen)
QBrush qpen_brush(const QPen &p)
Definition: qpainter_p.h:87
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
virtual void fill(const QVectorPath &path, const QBrush &brush)=0
QBrush brush
Definition: qpainter_p.h:153
Qt::PenStyle qpen_style(const QPen &p)
Definition: qpainter_p.h:89
QPainterState * state()

◆ drawEllipse() [1/2]

void QPaintEngineEx::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.

Reimplemented in QPaintBufferEngine, QRasterPaintEngine, QOpenGLPaintEngine, QVGPaintEngine, QDirectFBPaintEngine, and QBlitterPaintEngine.

Definition at line 825 of file qpaintengineex.cpp.

Referenced by QVGPaintEngine::drawEllipse(), QOpenGLPaintEngine::drawEllipse(), QRasterPaintEngine::drawEllipse(), drawEllipse(), and QVGPaintEngine::type().

826 {
827  qreal pts[26]; // QPointF[13] without constructors...
828  union {
829  qreal *ptr;
830  QPointF *points;
831  } x;
832  x.ptr = pts;
833 
834  int point_count = 0;
835  x.points[0] = qt_curves_for_arc(r, 0, -360, x.points + 1, &point_count);
837  draw(vp);
838 }
double qreal
Definition: qglobal.h:1193
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
virtual void draw(const QVectorPath &path)
const T * ptr(const T &t)
QPointF qt_curves_for_arc(const QRectF &rect, qreal startAngle, qreal sweepLength, QPointF *curves, int *point_count)
Creates a number of curves for a given arc definition.
Definition: qstroker.cpp:859
static QPainterPath::ElementType qpaintengineex_ellipse_types[]

◆ drawEllipse() [2/2]

void QPaintEngineEx::drawEllipse ( const QRect r)
virtual

The default implementation of this function calls the floating point version of this function.

Reimplemented from QPaintEngine.

Reimplemented in QPaintBufferEngine, and QVGPaintEngine.

Definition at line 840 of file qpaintengineex.cpp.

841 {
842  drawEllipse(QRectF(r));
843 }
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
virtual void drawEllipse(const QRectF &r)
Reimplement this function to draw the largest ellipse that can be contained within rectangle rect...

◆ drawImage() [1/2]

virtual void QPaintEngineEx::drawImage ( const QRectF r,
const QImage pm,
const QRectF sr,
Qt::ImageConversionFlags  flags = Qt::AutoColor 
)
pure 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.

Implemented in QPaintBufferEngine, QRasterPaintEngine, QVGPaintEngine, QOpenGLPaintEngine, QGL2PaintEngineEx, QBlitterPaintEngine, QEmulationPaintEngine, and QDirectFBPaintEngine.

Referenced by QEmulationPaintEngine::drawImage(), drawImage(), and QVGPaintEngine::type().

◆ drawImage() [2/2]

void QPaintEngineEx::drawImage ( const QPointF pos,
const QImage image 
)
virtual

Reimplemented in QPaintBufferEngine, QRasterPaintEngine, QVGPaintEngine, QBlitterPaintEngine, and QDirectFBPaintEngine.

Definition at line 955 of file qpaintengineex.cpp.

956 {
957  drawImage(QRectF(pos, image.size()), image, image.rect());
958 }
virtual void drawImage(const QRectF &r, const QImage &pm, const QRectF &sr, Qt::ImageConversionFlags flags=Qt::AutoColor)=0
Reimplement this function to draw the part of the image specified by the sr rectangle in the given re...
QRect rect() const
Returns the enclosing rectangle (0, 0, width(), height()) of the image.
Definition: qimage.cpp:1603
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
QSize size() const
Returns the size of the image, i.
Definition: qimage.cpp:1587

◆ drawLines() [1/2]

void QPaintEngineEx::drawLines ( const QLine lines,
int  lineCount 
)
virtual

The default implementation converts the first lineCount lines in lines to a QLineF and calls the floating point version of this function.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Reimplemented from QPaintEngine.

Reimplemented in QPaintBufferEngine, QRasterPaintEngine, QOpenGLPaintEngine, QVGPaintEngine, and QDirectFBPaintEngine.

Definition at line 784 of file qpaintengineex.cpp.

Referenced by QVGPaintEngine::drawLines(), QOpenGLPaintEngine::drawLines(), QRasterPaintEngine::drawLines(), and QVGPaintEngine::type().

785 {
786  int elementCount = lineCount << 1;
787  while (elementCount > 0) {
788  int count = qMin(elementCount, 32);
789 
790  qreal pts[64];
791  int count2 = count<<1;
792 #ifdef Q_WS_MAC
793  for (int i=0; i<count2; i+=2) {
794  pts[i] = ((int *) lines)[i+1];
795  pts[i+1] = ((int *) lines)[i];
796  }
797 #else
798  for (int i=0; i<count2; ++i)
799  pts[i] = ((int *) lines)[i];
800 #endif
801 
803  stroke(path, state()->pen);
804 
805  elementCount -= 32;
806  lines += 16;
807  }
808 }
double qreal
Definition: qglobal.h:1193
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
static QPainterPath::ElementType qpaintengineex_line_types_16[]
virtual void stroke(const QVectorPath &path, const QPen &pen)
QPainterState * state()

◆ drawLines() [2/2]

void QPaintEngineEx::drawLines ( const QLineF lines,
int  lineCount 
)
virtual

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.

Reimplemented from QPaintEngine.

Reimplemented in QPaintBufferEngine, QRasterPaintEngine, QOpenGLPaintEngine, QVGPaintEngine, and QDirectFBPaintEngine.

Definition at line 810 of file qpaintengineex.cpp.

811 {
812  int elementCount = lineCount << 1;
813  while (elementCount > 0) {
814  int count = qMin(elementCount, 32);
815 
816  QVectorPath path((qreal *) lines, count, qpaintengineex_line_types_16,
818  stroke(path, state()->pen);
819 
820  elementCount -= 32;
821  lines += 16;
822  }
823 }
double qreal
Definition: qglobal.h:1193
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
static QPainterPath::ElementType qpaintengineex_line_types_16[]
virtual void stroke(const QVectorPath &path, const QPen &pen)
QPainterState * state()

◆ drawPath()

void QPaintEngineEx::drawPath ( const QPainterPath path)
virtual

The default implementation ignores the path and does nothing.

Reimplemented from QPaintEngine.

Reimplemented in QPaintBufferEngine, QOpenGLPaintEngine, QVGPaintEngine, and QDirectFBPaintEngine.

Definition at line 845 of file qpaintengineex.cpp.

Referenced by QDirectFBPaintEngine::drawPath(), QVGPaintEngine::drawPath(), QOpenGLPaintEngine::drawPath(), QPaintBufferEngine::drawPath(), and QVGPaintEngine::type().

846 {
847  if (!path.isEmpty())
848  draw(qtVectorPathForPath(path));
849 }
bool isEmpty() const
Returns true if either there are no elements in this path, or if the only element is a MoveToElement;...
Definition: qpainterpath.h:392
virtual void draw(const QVectorPath &path)
const QVectorPath & qtVectorPathForPath(const QPainterPath &path)

◆ drawPixmap() [1/2]

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

◆ drawPixmap() [2/2]

void QPaintEngineEx::drawPixmap ( const QPointF pos,
const QPixmap pm 
)
virtual

Reimplemented in QPaintBufferEngine, QRasterPaintEngine, QVGPaintEngine, QDirectFBPaintEngine, QBlitterPaintEngine, and QVolatileImagePaintEngine.

Definition at line 950 of file qpaintengineex.cpp.

951 {
952  drawPixmap(QRectF(pos, pm.size()), pm, pm.rect());
953 }
QSize size() const
Returns the size of the pixmap.
Definition: qpixmap.cpp:661
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
virtual void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr)=0
Reimplement this function to draw the part of the pm specified by the sr rectangle in the given r...
QRect rect() const
Returns the pixmap&#39;s enclosing rectangle.
Definition: qpixmap.cpp:676

◆ drawPixmapFragments() [1/2]

void QPaintEngineEx::drawPixmapFragments ( const QPainter::PixmapFragment fragments,
int  fragmentCount,
const QPixmap pixmap,
QPainter::PixmapFragmentHints  hints 
)
virtual

Reimplemented in QGL2PaintEngineEx, and QEmulationPaintEngine.

Definition at line 975 of file qpaintengineex.cpp.

Referenced by QEmulationPaintEngine::drawPixmapFragments(), QGL2PaintEngineEx::drawPixmapFragments(), QVGPaintEngine::drawPixmapFragments(), and QVGPaintEngine::type().

977 {
978  if (pixmap.isNull())
979  return;
980 
981  qreal oldOpacity = state()->opacity;
982  QTransform oldTransform = state()->matrix;
983 
984  for (int i = 0; i < fragmentCount; ++i) {
985  QTransform transform = oldTransform;
986  transform.translate(fragments[i].x, fragments[i].y);
987  transform.rotate(fragments[i].rotation);
988  state()->opacity = oldOpacity * fragments[i].opacity;
989  state()->matrix = transform;
990  opacityChanged();
992 
993  qreal w = fragments[i].scaleX * fragments[i].width;
994  qreal h = fragments[i].scaleY * fragments[i].height;
995  QRectF sourceRect(fragments[i].sourceLeft, fragments[i].sourceTop,
996  fragments[i].width, fragments[i].height);
997  drawPixmap(QRectF(-0.5 * w, -0.5 * h, w, h), pixmap, sourceRect);
998  }
999 
1000  state()->opacity = oldOpacity;
1001  state()->matrix = oldTransform;
1002  opacityChanged();
1003  transformChanged();
1004 }
qreal scaleY
the vertical scale of the target rectangle.
Definition: qpainter.h:112
qreal width
the width of the source rectangle and is used to calculate the width of the target rectangle...
Definition: qpainter.h:109
double qreal
Definition: qglobal.h:1193
virtual void transformChanged()=0
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
qreal opacity
the opacity of the target rectangle, where 0.0 is fully transparent and 1.0 is fully opaque...
Definition: qpainter.h:114
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
QTransform & rotate(qreal a, Qt::Axis axis=Qt::ZAxis)
Rotates the coordinate system counterclockwise by the given angle about the specified axis and return...
Definition: qtransform.cpp:615
virtual void opacityChanged()=0
virtual void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr)=0
Reimplement this function to draw the part of the pm specified by the sr rectangle in the given r...
qreal scaleX
the horizontal scale of the target rectangle.
Definition: qpainter.h:111
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
Definition: qpixmap.cpp:615
qreal height
the height of the source rectangle and is used to calculate the height of the target rectangle...
Definition: qpainter.h:110
QPainterState * state()
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65

◆ drawPixmapFragments() [2/2]

void QPaintEngineEx::drawPixmapFragments ( const QRectF targetRects,
const QRectF sourceRects,
int  fragmentCount,
const QPixmap pixmap,
QPainter::PixmapFragmentHints  hints 
)
virtual

Reimplemented in QGL2PaintEngineEx, and QEmulationPaintEngine.

Definition at line 1006 of file qpaintengineex.cpp.

1008 {
1009  if (pixmap.isNull())
1010  return;
1011 
1012  if (sourceRects) {
1013  for (int i = 0; i < fragmentCount; ++i)
1014  drawPixmap(targetRects[i], pixmap, sourceRects[i]);
1015  } else {
1016  QRectF sourceRect = pixmap.rect();
1017  for (int i = 0; i < fragmentCount; ++i)
1018  drawPixmap(targetRects[i], pixmap, sourceRect);
1019  }
1020 }
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
virtual void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr)=0
Reimplement this function to draw the part of the pm specified by the sr rectangle in the given r...
QRect rect() const
Returns the pixmap&#39;s enclosing rectangle.
Definition: qpixmap.cpp:676
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
Definition: qpixmap.cpp:615

◆ drawPoints() [1/2]

void QPaintEngineEx::drawPoints ( const QPointF points,
int  pointCount 
)
virtual

Draws the first pointCount points in the buffer points.

Reimplemented from QPaintEngine.

Reimplemented in QPaintBufferEngine, QRasterPaintEngine, QVGPaintEngine, QOpenGLPaintEngine, QBlitterPaintEngine, and QDirectFBPaintEngine.

Definition at line 852 of file qpaintengineex.cpp.

Referenced by QOpenGLPaintEngine::drawPoints(), QVGPaintEngine::drawPoints(), QRasterPaintEngine::drawPoints(), and QVGPaintEngine::type().

853 {
854  QPen pen = state()->pen;
855  if (pen.capStyle() == Qt::FlatCap)
857 
858  if (pen.brush().isOpaque()) {
859  while (pointCount > 0) {
860  int count = qMin(pointCount, 16);
861  qreal pts[64];
862  int oset = -1;
863  for (int i=0; i<count; ++i) {
864  pts[++oset] = points[i].x();
865  pts[++oset] = points[i].y();
866  pts[++oset] = points[i].x() + 1/qreal(63.);
867  pts[++oset] = points[i].y();
868  }
870  stroke(path, pen);
871  pointCount -= 16;
872  points += 16;
873  }
874  } else {
875  for (int i=0; i<pointCount; ++i) {
876  qreal pts[] = { points[i].x(), points[i].y(), points[i].x() + 1/qreal(63.), points[i].y() };
877  QVectorPath path(pts, 2, 0);
878  stroke(path, pen);
879  }
880  }
881 }
double qreal
Definition: qglobal.h:1193
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
void setCapStyle(Qt::PenCapStyle pcs)
Sets the pen&#39;s cap style to the given style.
Definition: qpen.cpp:723
static QPainterPath::ElementType qpaintengineex_line_types_16[]
The QPen class defines how a QPainter should draw lines and outlines of shapes.
Definition: qpen.h:64
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
virtual void stroke(const QVectorPath &path, const QPen &pen)
QBrush brush() const
Returns the brush used to fill strokes generated with this pen.
Definition: qpen.cpp:797
bool isOpaque() const
Returns true if the brush is fully opaque otherwise false.
Definition: qbrush.cpp:910
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287
Qt::PenCapStyle capStyle() const
Returns the pen&#39;s cap style.
Definition: qpen.cpp:706
QPainterState * state()

◆ drawPoints() [2/2]

void QPaintEngineEx::drawPoints ( const QPoint points,
int  pointCount 
)
virtual

Draws the first pointCount points in the buffer points.

The default implementation converts the first pointCount QPoints in points to QPointFs and calls the floating point version of drawPoints.

Reimplemented from QPaintEngine.

Reimplemented in QPaintBufferEngine, QRasterPaintEngine, QVGPaintEngine, QOpenGLPaintEngine, QBlitterPaintEngine, and QDirectFBPaintEngine.

Definition at line 883 of file qpaintengineex.cpp.

884 {
885  QPen pen = state()->pen;
886  if (pen.capStyle() == Qt::FlatCap)
888 
889  if (pen.brush().isOpaque()) {
890  while (pointCount > 0) {
891  int count = qMin(pointCount, 16);
892  qreal pts[64];
893  int oset = -1;
894  for (int i=0; i<count; ++i) {
895  pts[++oset] = points[i].x();
896  pts[++oset] = points[i].y();
897  pts[++oset] = points[i].x() + 1/qreal(63.);
898  pts[++oset] = points[i].y();
899  }
901  stroke(path, pen);
902  pointCount -= 16;
903  points += 16;
904  }
905  } else {
906  for (int i=0; i<pointCount; ++i) {
907  qreal pts[] = { qreal(points[i].x()), qreal(points[i].y()),
908  qreal(points[i].x() +1/qreal(63.)), qreal(points[i].y()) };
909  QVectorPath path(pts, 2, 0);
910  stroke(path, pen);
911  }
912  }
913 }
double qreal
Definition: qglobal.h:1193
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
void setCapStyle(Qt::PenCapStyle pcs)
Sets the pen&#39;s cap style to the given style.
Definition: qpen.cpp:723
static QPainterPath::ElementType qpaintengineex_line_types_16[]
The QPen class defines how a QPainter should draw lines and outlines of shapes.
Definition: qpen.h:64
virtual void stroke(const QVectorPath &path, const QPen &pen)
QBrush brush() const
Returns the brush used to fill strokes generated with this pen.
Definition: qpen.cpp:797
bool isOpaque() const
Returns true if the brush is fully opaque otherwise false.
Definition: qbrush.cpp:910
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
Qt::PenCapStyle capStyle() const
Returns the pen&#39;s cap style.
Definition: qpen.cpp:706
QPainterState * state()

◆ drawPolygon() [1/2]

void QPaintEngineEx::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.

Reimplemented in QPaintBufferEngine, QRasterPaintEngine, QOpenGLPaintEngine, QVGPaintEngine, QDirectFBPaintEngine, and QBlitterPaintEngine.

Definition at line 916 of file qpaintengineex.cpp.

Referenced by QVGPaintEngine::drawPolygon(), QOpenGLPaintEngine::drawPolygon(), and QVGPaintEngine::type().

917 {
918  QVectorPath path((qreal *) points, pointCount, 0, QVectorPath::polygonFlags(mode));
919 
920  if (mode == PolylineMode)
921  stroke(path, state()->pen);
922  else
923  draw(path);
924 }
double qreal
Definition: qglobal.h:1193
virtual void draw(const QVectorPath &path)
virtual void stroke(const QVectorPath &path, const QPen &pen)
static uint polygonFlags(QPaintEngine::PolygonDrawMode mode)
QPainterState * state()

◆ drawPolygon() [2/2]

void QPaintEngineEx::drawPolygon ( const QPoint 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.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

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

Reimplemented from QPaintEngine.

Reimplemented in QPaintBufferEngine, QRasterPaintEngine, QOpenGLPaintEngine, QVGPaintEngine, QDirectFBPaintEngine, and QBlitterPaintEngine.

Definition at line 926 of file qpaintengineex.cpp.

927 {
928  int count = pointCount<<1;
929  QVarLengthArray<qreal> pts(count);
930 
931 #ifdef Q_WS_MAC
932  for (int i=0; i<count; i+=2) {
933  pts[i] = ((int *) points)[i+1];
934  pts[i+1] = ((int *) points)[i];
935  }
936 #else
937  for (int i=0; i<count; ++i)
938  pts[i] = ((int *) points)[i];
939 #endif
940 
941  QVectorPath path(pts.data(), pointCount, 0, QVectorPath::polygonFlags(mode));
942 
943  if (mode == PolylineMode)
944  stroke(path, state()->pen);
945  else
946  draw(path);
947 
948 }
virtual void draw(const QVectorPath &path)
virtual void stroke(const QVectorPath &path, const QPen &pen)
static uint polygonFlags(QPaintEngine::PolygonDrawMode mode)
QPainterState * state()

◆ drawRects() [1/2]

void QPaintEngineEx::drawRects ( const QRect rects,
int  rectCount 
)
virtual

The default implementation converts the first rectCount rectangles in the buffer rects to a QRectF and calls the floating point version of this function.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Reimplemented from QPaintEngine.

Reimplemented in QPaintBufferEngine, QRasterPaintEngine, QOpenGLPaintEngine, QVGPaintEngine, QBlitterPaintEngine, and QDirectFBPaintEngine.

Definition at line 708 of file qpaintengineex.cpp.

Referenced by QVGPaintEngine::drawRects(), QOpenGLPaintEngine::drawRects(), QRasterPaintEngine::drawRects(), and QVGPaintEngine::type().

709 {
710  for (int i=0; i<rectCount; ++i) {
711  const QRect &r = rects[i];
712  // ### Is there a one off here?
713  qreal right = r.x() + r.width();
714  qreal bottom = r.y() + r.height();
715  qreal pts[] = { qreal(r.x()), qreal(r.y()),
716  right, qreal(r.y()),
717  right, bottom,
718  qreal(r.x()), bottom,
719  qreal(r.x()), qreal(r.y()) };
721  draw(vp);
722  }
723 }
double qreal
Definition: qglobal.h:1193
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
virtual void draw(const QVectorPath &path)
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58

◆ drawRects() [2/2]

void QPaintEngineEx::drawRects ( const QRectF rects,
int  rectCount 
)
virtual

Draws the first rectCount rectangles in the buffer rects.

The default implementation of this function calls drawPath() or drawPolygon() depending on the feature set of the paint engine.

Reimplemented from QPaintEngine.

Reimplemented in QPaintBufferEngine, QRasterPaintEngine, QOpenGLPaintEngine, QVGPaintEngine, QBlitterPaintEngine, and QDirectFBPaintEngine.

Definition at line 725 of file qpaintengineex.cpp.

726 {
727  for (int i=0; i<rectCount; ++i) {
728  const QRectF &r = rects[i];
729  qreal right = r.x() + r.width();
730  qreal bottom = r.y() + r.height();
731  qreal pts[] = { r.x(), r.y(),
732  right, r.y(),
733  right, bottom,
734  r.x(), bottom,
735  r.x(), r.y() };
737  draw(vp);
738  }
739 }
qreal y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:667
double qreal
Definition: qglobal.h:1193
virtual void draw(const QVectorPath &path)
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
qreal height() const
Returns the height of the rectangle.
Definition: qrect.h:710
qreal width() const
Returns the width of the rectangle.
Definition: qrect.h:707
qreal x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:664

◆ drawRoundedRect()

void QPaintEngineEx::drawRoundedRect ( const QRectF rect,
qreal  xrad,
qreal  yrad,
Qt::SizeMode  mode 
)
virtual

Reimplemented in QVGPaintEngine, and QDirectFBPaintEngine.

Definition at line 742 of file qpaintengineex.cpp.

Referenced by QDirectFBPaintEngine::drawRoundedRect(), QVGPaintEngine::drawRoundedRect(), and QVGPaintEngine::type().

744 {
745  qreal x1 = rect.left();
746  qreal x2 = rect.right();
747  qreal y1 = rect.top();
748  qreal y2 = rect.bottom();
749 
750  if (mode == Qt::RelativeSize) {
751  xRadius = xRadius * rect.width() / qreal(200.);
752  yRadius = yRadius * rect.height() / qreal(200.);
753  }
754 
755  xRadius = qMin(xRadius, rect.width() / 2);
756  yRadius = qMin(yRadius, rect.height() / 2);
757 
758  qreal pts[] = {
759  x1 + xRadius, y1, // MoveTo
760  x2 - xRadius, y1, // LineTo
761  x2 - (1 - KAPPA) * xRadius, y1, // CurveTo
762  x2, y1 + (1 - KAPPA) * yRadius,
763  x2, y1 + yRadius,
764  x2, y2 - yRadius, // LineTo
765  x2, y2 - (1 - KAPPA) * yRadius, // CurveTo
766  x2 - (1 - KAPPA) * xRadius, y2,
767  x2 - xRadius, y2,
768  x1 + xRadius, y2, // LineTo
769  x1 + (1 - KAPPA) * xRadius, y2, // CurveTo
770  x1, y2 - (1 - KAPPA) * yRadius,
771  x1, y2 - yRadius,
772  x1, y1 + yRadius, // LineTo
773  x1, y1 + (1 - KAPPA) * yRadius, // CurveTo
774  x1 + (1 - KAPPA) * xRadius, y1,
775  x1 + xRadius, y1
776  };
777 
779  draw(path);
780 }
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
virtual void draw(const QVectorPath &path)
#define KAPPA
Definition: qbezier.cpp:370
qreal height() const
Returns the height of the rectangle.
Definition: qrect.h:710
qreal width() const
Returns the width of the rectangle.
Definition: qrect.h:707
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
static QPainterPath::ElementType qpaintengineex_roundedrect_types[]

◆ drawStaticTextItem()

void QPaintEngineEx::drawStaticTextItem ( QStaticTextItem staticTextItem)
virtual

Reimplemented in QPaintBufferEngine, QRasterPaintEngine, QVGPaintEngine, QGL2PaintEngineEx, QOpenGLPaintEngine, QDirectFBPaintEngine, QBlitterPaintEngine, and QEmulationPaintEngine.

Definition at line 1078 of file qpaintengineex.cpp.

Referenced by QDeclarativeTextLayout::draw(), QEmulationPaintEngine::drawStaticTextItem(), QGL2PaintEngineEx::drawStaticTextItem(), QRasterPaintEngine::drawStaticTextItem(), and QVGPaintEngine::type().

1079 {
1080  QPainterPath path;
1081 #ifndef Q_WS_MAC
1083 #endif
1084 
1085  if (staticTextItem->numGlyphs == 0)
1086  return;
1087 
1088  QFontEngine *fontEngine = staticTextItem->fontEngine();
1089  fontEngine->addGlyphsToPath(staticTextItem->glyphs, staticTextItem->glyphPositions,
1090  staticTextItem->numGlyphs, &path, 0);
1091  if (!path.isEmpty()) {
1092  QPainterState *s = state();
1093  QPainter::RenderHints oldHints = s->renderHints;
1094  bool changedHints = false;
1095  if (bool(oldHints & QPainter::TextAntialiasing)
1096  && !bool(fontEngine->fontDef.styleStrategy & QFont::NoAntialias)
1097  && !bool(oldHints & QPainter::Antialiasing)) {
1100  changedHints = true;
1101  }
1102 
1103  fill(qtVectorPathForPath(path), s->pen.color());
1104 
1105  if (changedHints) {
1106  s->renderHints = oldHints;
1108  }
1109  }
1110 }
bool isEmpty() const
Returns true if either there are no elements in this path, or if the only element is a MoveToElement;...
Definition: qpainterpath.h:392
QFontEngine * fontEngine() const
QPainter::RenderHints renderHints
Definition: qpainter_p.h:158
QFixedPoint * glyphPositions
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:67
QColor color() const
Returns the color of this pen&#39;s brush.
Definition: qpen.cpp:771
const QVectorPath & qtVectorPathForPath(const QPainterPath &path)
virtual void renderHintsChanged()=0
void setFillRule(Qt::FillRule fillRule)
Sets the fill rule of the painter path to the given fillRule.
virtual void addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int nglyphs, QPainterPath *path, QTextItem::RenderFlags flags)
virtual void fill(const QVectorPath &path, const QBrush &brush)=0
QFontDef fontDef
uint styleStrategy
Definition: qfont_p.h:92
QPainterState * state()
glyph_t * glyphs

◆ drawTiledPixmap()

void QPaintEngineEx::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.

Reimplemented in QPaintBufferEngine, QRasterPaintEngine, QVGPaintEngine, QOpenGLPaintEngine, QBlitterPaintEngine, QDirectFBPaintEngine, and QEmulationPaintEngine.

Definition at line 960 of file qpaintengineex.cpp.

Referenced by QEmulationPaintEngine::drawTiledPixmap(), and QVGPaintEngine::type().

961 {
962  QBrush brush(state()->pen.color(), pixmap);
963  QTransform xform = QTransform::fromTranslate(r.x() - s.x(), r.y() - s.y());
964  brush.setTransform(xform);
965 
966  qreal pts[] = { r.x(), r.y(),
967  r.x() + r.width(), r.y(),
968  r.x() + r.width(), r.y() + r.height(),
969  r.x(), r.y() + r.height() };
970 
971  QVectorPath path(pts, 4, 0, QVectorPath::RectangleHint);
972  fill(path, brush);
973 }
double qreal
Definition: qglobal.h:1193
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
virtual void fill(const QVectorPath &path, const QBrush &brush)=0
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
QPainterState * state()
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65

◆ endNativePainting()

virtual void QPaintEngineEx::endNativePainting ( )
inlinevirtual

◆ fill()

virtual void QPaintEngineEx::fill ( const QVectorPath path,
const QBrush brush 
)
pure virtual

◆ fillRect() [1/2]

void QPaintEngineEx::fillRect ( const QRectF rect,
const QBrush brush 
)
virtual

Reimplemented in QPaintBufferEngine, QRasterPaintEngine, QVGPaintEngine, QDirectFBPaintEngine, and QBlitterPaintEngine.

Definition at line 695 of file qpaintengineex.cpp.

Referenced by QVGPaintEngine::fillRect(), fillRect(), and QVGPaintEngine::type().

696 {
697  qreal pts[] = { r.x(), r.y(), r.x() + r.width(), r.y(),
698  r.x() + r.width(), r.y() + r.height(), r.x(), r.y() + r.height() };
700  fill(vp, brush);
701 }
double qreal
Definition: qglobal.h:1193
virtual void fill(const QVectorPath &path, const QBrush &brush)=0

◆ fillRect() [2/2]

void QPaintEngineEx::fillRect ( const QRectF rect,
const QColor color 
)
virtual

Reimplemented in QPaintBufferEngine, QRasterPaintEngine, QVGPaintEngine, QDirectFBPaintEngine, and QBlitterPaintEngine.

Definition at line 703 of file qpaintengineex.cpp.

704 {
705  fillRect(r, QBrush(color));
706 }
virtual void fillRect(const QRectF &rect, const QBrush &brush)
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76

◆ flags()

virtual uint QPaintEngineEx::flags ( ) const
inlinevirtual

◆ opacityChanged()

virtual void QPaintEngineEx::opacityChanged ( )
pure virtual

◆ penChanged()

virtual void QPaintEngineEx::penChanged ( )
pure virtual

◆ pixmapFilter()

virtual QPixmapFilter* QPaintEngineEx::pixmapFilter ( int  ,
const QPixmapFilter  
)
inlinevirtual

Reimplemented in QGL2PaintEngineEx, and QVGPaintEngine.

Definition at line 223 of file qpaintengineex_p.h.

Referenced by QVGPaintEngine::pixmapFilter(), QGL2PaintEngineEx::pixmapFilter(), and QVGPaintEngine::state().

223 { return 0; }

◆ renderHintsChanged()

virtual void QPaintEngineEx::renderHintsChanged ( )
pure virtual

◆ setState()

void QPaintEngineEx::setState ( QPainterState s)
virtual

◆ state() [1/2]

QPainterState* QPaintEngineEx::state ( )
inline

◆ state() [2/2]

const QPainterState* QPaintEngineEx::state ( ) const
inline

Definition at line 211 of file qpaintengineex_p.h.

211 { return static_cast<const QPainterState *>(QPaintEngine::state); }
QPaintEngineState * state
Definition: qpaintengine.h:239

◆ stroke()

void QPaintEngineEx::stroke ( const QVectorPath path,
const QPen pen 
)
virtual

Reimplemented in QPaintBufferEngine, QRasterPaintEngine, QGL2PaintEngineEx, QBlitterPaintEngine, QVGPaintEngine, QDirectFBPaintEngine, and QEmulationPaintEngine.

Definition at line 388 of file qpaintengineex.cpp.

Referenced by draw(), drawLines(), drawPoints(), QRasterPaintEngine::drawPolygon(), drawPolygon(), QRasterPaintEngine::drawRects(), QEmulationPaintEngine::stroke(), QVGPaintEngine::stroke(), QGL2PaintEngineEx::stroke(), QRasterPaintEngine::stroke(), and QVGPaintEngine::type().

389 {
390 #ifdef QT_DEBUG_DRAW
391  qDebug() << "QPaintEngineEx::stroke()" << pen;
392 #endif
393 
395 
396  if (path.isEmpty())
397  return;
398 
399  if (!d->strokeHandler) {
400  d->strokeHandler = new StrokeHandler(path.elementCount()+4);
401  d->stroker.setMoveToHook(qpaintengineex_moveTo);
402  d->stroker.setLineToHook(qpaintengineex_lineTo);
403  d->stroker.setCubicToHook(qpaintengineex_cubicTo);
404  }
405 
406  if (!qpen_fast_equals(pen, d->strokerPen)) {
407  d->strokerPen = pen;
408  d->stroker.setJoinStyle(pen.joinStyle());
409  d->stroker.setCapStyle(pen.capStyle());
410  d->stroker.setMiterLimit(pen.miterLimit());
411  qreal penWidth = pen.widthF();
412  if (penWidth == 0)
413  d->stroker.setStrokeWidth(1);
414  else
415  d->stroker.setStrokeWidth(penWidth);
416 
417  Qt::PenStyle style = pen.style();
418  if (style == Qt::SolidLine) {
419  d->activeStroker = &d->stroker;
420  } else if (style == Qt::NoPen) {
421  d->activeStroker = 0;
422  } else {
423  d->dasher.setDashPattern(pen.dashPattern());
424  d->dasher.setDashOffset(pen.dashOffset());
425  d->activeStroker = &d->dasher;
426  }
427  }
428 
429  if (!d->activeStroker) {
430  return;
431  }
432 
433  if (pen.style() > Qt::SolidLine) {
434  if (pen.isCosmetic()) {
435  d->activeStroker->setClipRect(d->exDeviceRect);
436  } else {
437  QRectF clipRect = state()->matrix.inverted().mapRect(QRectF(d->exDeviceRect));
438  d->activeStroker->setClipRect(clipRect);
439  }
440  }
441 
442  const QPainterPath::ElementType *types = path.elements();
443  const qreal *points = path.points();
444  int pointCount = path.elementCount();
445 
446  const qreal *lastPoint = points + (pointCount<<1);
447 
448  d->strokeHandler->types.reset();
449  d->strokeHandler->pts.reset();
450 
451  // Some engines might decide to optimize for the non-shape hint later on...
453 
454  if (path.elementCount() > 2)
456 
457  if (d->stroker.capStyle() == Qt::RoundCap || d->stroker.joinStyle() == Qt::RoundJoin)
459 
460  // ### Perspective Xforms are currently not supported...
461  if (!pen.isCosmetic()) {
462  // We include cosmetic pens in this case to avoid having to
463  // change the current transform. Normal transformed,
464  // non-cosmetic pens will be transformed as part of fill
465  // later, so they are also covered here..
466  d->activeStroker->setCurveThresholdFromTransform(state()->matrix);
467  d->activeStroker->begin(d->strokeHandler);
468  if (types) {
469  while (points < lastPoint) {
470  switch (*types) {
472  d->activeStroker->moveTo(points[0], points[1]);
473  points += 2;
474  ++types;
475  break;
477  d->activeStroker->lineTo(points[0], points[1]);
478  points += 2;
479  ++types;
480  break;
482  d->activeStroker->cubicTo(points[0], points[1],
483  points[2], points[3],
484  points[4], points[5]);
485  points += 6;
486  types += 3;
488  break;
489  default:
490  break;
491  }
492  }
493  if (path.hasImplicitClose())
494  d->activeStroker->lineTo(path.points()[0], path.points()[1]);
495 
496  } else {
497  d->activeStroker->moveTo(points[0], points[1]);
498  points += 2;
499  while (points < lastPoint) {
500  d->activeStroker->lineTo(points[0], points[1]);
501  points += 2;
502  }
503  if (path.hasImplicitClose())
504  d->activeStroker->lineTo(path.points()[0], path.points()[1]);
505  }
506  d->activeStroker->end();
507 
508  if (!d->strokeHandler->types.size()) // an empty path...
509  return;
510 
511  QVectorPath strokePath(d->strokeHandler->pts.data(),
512  d->strokeHandler->types.size(),
513  d->strokeHandler->types.data(),
514  flags);
515  fill(strokePath, pen.brush());
516  } else {
517  // For cosmetic pens we need a bit of trickery... We to process xform the input points
518  if (state()->matrix.type() >= QTransform::TxProject) {
519  QPainterPath painterPath = state()->matrix.map(path.convertToPainterPath());
520  d->activeStroker->strokePath(painterPath, d->strokeHandler, QTransform());
521  } else {
522  d->activeStroker->setCurveThresholdFromTransform(QTransform());
523  d->activeStroker->begin(d->strokeHandler);
524  if (types) {
525  while (points < lastPoint) {
526  switch (*types) {
528  QPointF pt = (*(QPointF *) points) * state()->matrix;
529  d->activeStroker->moveTo(pt.x(), pt.y());
530  points += 2;
531  ++types;
532  break;
533  }
535  QPointF pt = (*(QPointF *) points) * state()->matrix;
536  d->activeStroker->lineTo(pt.x(), pt.y());
537  points += 2;
538  ++types;
539  break;
540  }
542  QPointF c1 = ((QPointF *) points)[0] * state()->matrix;
543  QPointF c2 = ((QPointF *) points)[1] * state()->matrix;
544  QPointF e = ((QPointF *) points)[2] * state()->matrix;
545  d->activeStroker->cubicTo(c1.x(), c1.y(), c2.x(), c2.y(), e.x(), e.y());
546  points += 6;
547  types += 3;
549  break;
550  }
551  default:
552  break;
553  }
554  }
555  if (path.hasImplicitClose()) {
556  QPointF pt = * ((QPointF *) path.points()) * state()->matrix;
557  d->activeStroker->lineTo(pt.x(), pt.y());
558  }
559 
560  } else {
561  QPointF p = ((QPointF *)points)[0] * state()->matrix;
562  d->activeStroker->moveTo(p.x(), p.y());
563  points += 2;
564  while (points < lastPoint) {
565  QPointF p = ((QPointF *)points)[0] * state()->matrix;
566  d->activeStroker->lineTo(p.x(), p.y());
567  points += 2;
568  }
569  if (path.hasImplicitClose())
570  d->activeStroker->lineTo(p.x(), p.y());
571  }
572  d->activeStroker->end();
573  }
574 
575  QVectorPath strokePath(d->strokeHandler->pts.data(),
576  d->strokeHandler->types.size(),
577  d->strokeHandler->types.data(),
578  flags);
579 
580  QTransform xform = state()->matrix;
581  state()->matrix = QTransform();
583 
584  QBrush brush = pen.brush();
585  if (qbrush_style(brush) != Qt::SolidPattern)
586  brush.setTransform(brush.transform() * xform);
587 
588  fill(strokePath, brush);
589 
590  state()->matrix = xform;
592  }
593 }
double d
Definition: qnumeric_p.h:62
ElementType
This enum describes the types of elements used to connect vertices in subpaths.
Definition: qpainterpath.h:70
double qreal
Definition: qglobal.h:1193
static void qpaintengineex_lineTo(qreal x, qreal y, void *data)
int elementCount() const
virtual void transformChanged()=0
bool isEmpty() const
Qt::BrushStyle qbrush_style(const QBrush &b)
Definition: qpainter_p.h:96
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:67
void setTransform(const QTransform &)
Sets matrix as an explicit transformation matrix on the current brush.
Definition: qbrush.cpp:968
Qt::PenStyle style() const
Returns the pen style.
Definition: qpen.cpp:428
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
virtual uint flags() const
QTransform matrix
Definition: qpainter_p.h:161
TransformationType type() const
Returns the transformation type of this matrix.
#define Q_D(Class)
Definition: qglobal.h:2482
QTransform transform() const
Returns the current transformation matrix for the brush.
Definition: qbrush.h:185
const QPainterPath::ElementType * elements() const
bool qpen_fast_equals(const QPen &a, const QPen &b)
Definition: qpainter_p.h:86
QVector< qreal > dashPattern() const
Returns the dash pattern of this pen.
Definition: qpen.cpp:466
PenStyle
Definition: qnamespace.h:1134
QTransform inverted(bool *invertible=0) const
Returns an inverted copy of this matrix.
Definition: qtransform.cpp:364
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
Q_CORE_EXPORT void qDebug(const char *,...)
QRect mapRect(const QRect &) const
Creates and returns a QRect object that is a copy of the given rectangle, mapped into the coordinate ...
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
bool isCosmetic() const
Returns true if the pen is cosmetic; otherwise returns false.
Definition: qpen.cpp:840
Qt::PenJoinStyle joinStyle() const
Returns the pen&#39;s join style.
Definition: qpen.cpp:736
QPoint map(const QPoint &p) const
Creates and returns a QPoint object that is a copy of the given point, mapped into the coordinate sys...
unsigned int uint
Definition: qglobal.h:996
static void qpaintengineex_cubicTo(qreal c1x, qreal c1y, qreal c2x, qreal c2y, qreal ex, qreal ey, void *data)
QBrush brush() const
Returns the brush used to fill strokes generated with this pen.
Definition: qpen.cpp:797
const QPainterPath convertToPainterPath() const
static void qpaintengineex_moveTo(qreal x, qreal y, void *data)
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
static const struct @32 types[]
qreal miterLimit() const
Returns the miter limit of the pen.
Definition: qpen.cpp:589
const qreal * points() const
qreal widthF() const
Returns the pen width with floating point precision.
Definition: qpen.cpp:645
bool hasImplicitClose() const
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287
virtual void fill(const QVectorPath &path, const QBrush &brush)=0
qreal dashOffset() const
Returns the dash offset for the pen.
Definition: qpen.cpp:547
Qt::PenCapStyle capStyle() const
Returns the pen&#39;s cap style.
Definition: qpen.cpp:706
QPainterState * state()
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65

◆ supportsTransformations()

bool QPaintEngineEx::supportsTransformations ( qreal  pixelSize,
const QTransform m 
) const
virtual

Reimplemented in QRasterPaintEngine, QGL2PaintEngineEx, QVGPaintEngine, and QOpenGLPaintEngine.

Definition at line 1112 of file qpaintengineex.cpp.

1113 {
1115 
1116  if (!m.isAffine())
1117  return true;
1118 
1119  return false;
1120 }
static float pixelSize(const QFontDef &request, int dpi)
Definition: qfont_win.cpp:80
bool isAffine() const
Returns true if the matrix represent an affine transformation, otherwise returns false.
Definition: qtransform.h:200
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ sync()

virtual void QPaintEngineEx::sync ( )
inlinevirtual

Definition at line 213 of file qpaintengineex_p.h.

213 {}

◆ transformChanged()

virtual void QPaintEngineEx::transformChanged ( )
pure virtual

◆ updateState()

void QPaintEngineEx::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.

Reimplemented in QOpenGLPaintEngine.

Definition at line 1028 of file qpaintengineex.cpp.

1029 {
1030  // do nothing...
1031 }

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