Qt 4.8
Public Types | Public Functions | Protected Functions | Protected Variables | Private Functions | Friends | List of all members
QPaintEngine Class Referenceabstract

The QPaintEngine class provides an abstract definition of how QPainter draws to a given device on a given platform. More...

#include <qpaintengine.h>

Inheritance diagram for QPaintEngine:
QAlphaPaintEngine QCoreGraphicsPaintEngine QMacPrintEngine QPaintEngineEx QPicturePaintEngine QPreviewPaintEngine QSvgPaintEngine QtopiaPrintEngine QX11PaintEngine

Public Types

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 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 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)
 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 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 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 drawTextItem (const QPointF &p, const QTextItem &textItem)
 This function draws the text item textItem at position p. More...
 
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 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 void updateState (const QPaintEngineState &state)=0
 Reimplement this function to update the state of a paint engine. More...
 
virtual ~QPaintEngine ()
 Destroys the paint engine. More...
 

Protected Functions

 QPaintEngine (QPaintEnginePrivate &data, PaintEngineFeatures devcaps=0)
 

Protected Variables

uint active: 1
 
QScopedPointer< QPaintEnginePrivated_ptr
 
uint extended: 1
 
PaintEngineFeatures gccaps
 
uint selfDestruct: 1
 
QPaintEngineStatestate
 

Private Functions

bool autoDestruct () const
 
void setAutoDestruct (bool autoDestr)
 

Friends

class QFontEngineBox
 
class QFontEngineFT
 
class QFontEngineMac
 
class QFontEngineQPF
 
class QFontEngineQPF1
 
class QFontEngineWin
 
class QMacCGContext
 
class QMacPrintEngine
 
class QMacPrintEnginePrivate
 
class QPainter
 
class QPainterPrivate
 
class QPainterReplayer
 
class QPreviewPaintEngine
 
class QProxyFontEngine
 
class QPSPrintEngine
 
class QtopiaPrintEngine
 
class QtopiaPrintEnginePrivate
 
class QWidget
 
class QWidgetPrivate
 
class QWin32PaintEngine
 
class QWin32PaintEnginePrivate
 
class QX11GLPixmapData
 

Detailed Description

The QPaintEngine class provides an abstract definition of how QPainter draws to a given device on a given platform.

Qt 4.0 provides several premade implementations of QPaintEngine for the different painter backends we support. We provide one paint engine for each window system and painting framework we support. This includes X11 on Unix/Linux and CoreGraphics on Mac OS X. In addition we provide QPaintEngine implementations for OpenGL (accessible through QGLWidget) and PostScript (accessible through QPSPrinter on X11). Additionally there is a raster-based paint engine that is a fallback for when an engine does not support a certain capability.

If one wants to use QPainter to draw to a different backend, one must subclass QPaintEngine and reimplement all its virtual functions. The QPaintEngine implementation is then made available by subclassing QPaintDevice and reimplementing the virtual function QPaintDevice::paintEngine().

QPaintEngine is created and owned by the QPaintDevice that created it.

The big advantage of the QPaintEngine approach opposed to Qt 3's QPainter/QPaintDevice::cmd() approach is that it is now possible to adapt to multiple technologies on each platform and take advantage of each to the fullest.

See also
QPainter, QPaintDevice::paintEngine(), {Paint System}

Definition at line 90 of file qpaintengine.h.

Enumerations

◆ DirtyFlag

QPaintEngine::updateState().

  • DirtyPen The pen is dirty and needs to be updated.
  • DirtyBrush The brush is dirty and needs to be updated.
  • DirtyBrushOrigin The brush origin is dirty and needs to updated.
  • DirtyFont The font is dirty and needs to be updated.
  • DirtyBackground The background is dirty and needs to be updated.
  • DirtyBackgroundMode The background mode is dirty and needs to be updated.
  • DirtyTransform The transform is dirty and needs to be updated.
  • DirtyClipRegion The clip region is dirty and needs to be updated.
  • DirtyClipPath The clip path is dirty and needs to be updated.
  • DirtyHints The render hints is dirty and needs to be updated.
  • DirtyCompositionMode The composition mode is dirty and needs to be updated.
  • DirtyClipEnabled Whether clipping is enabled or not is dirty and needs to be updated.
  • DirtyOpacity The constant opacity has changed and needs to be updated as part of the state change in
  • AllDirty Convenience enum used internally.

These types are used by QPainter to trigger lazy updates of the various states in the QPaintEngine using QPaintEngine::updateState().

A paint engine must update every dirty state.

Enumerator
DirtyPen 
DirtyBrush 
DirtyBrushOrigin 
DirtyFont 
DirtyBackground 
DirtyBackgroundMode 
DirtyTransform 
DirtyClipRegion 
DirtyClipPath 
DirtyHints 
DirtyCompositionMode 
DirtyClipEnabled 
DirtyOpacity 
AllDirty 

Definition at line 125 of file qpaintengine.h.

◆ PaintEngineFeature

This enum is used to describe the features or capabilities that the paint engine has.

If a feature is not supported by the engine, QPainter will do a best effort to emulate that feature through other means and pass on an alpha blended QImage to the engine with the emulated results. Some features cannot be emulated: AlphaBlend and PorterDuff.

  • AlphaBlend The engine can alpha blend primitives.
  • Antialiasing The engine can use antialising to improve the appearance of rendered primitives.
  • BlendModes The engine supports blending modes.
  • BrushStroke The engine supports drawing strokes that contain brushes as fills, not just solid colors (e.g. a dashed gradient line of width 2).
  • ConicalGradientFill The engine supports conical gradient fills.
  • ConstantOpacity The engine supports the feature provided by QPainter::setOpacity().
  • LinearGradientFill The engine supports linear gradient fills.
  • MaskedBrush The engine is capable of rendering brushes that has a texture with an alpha channel or a mask.
  • ObjectBoundingModeGradients The engine has native support for gradients with coordinate mode QGradient::ObjectBoundingMode. Otherwise, if QPaintEngine::PatternTransform is supported, object bounding mode gradients are converted to gradients with coordinate mode QGradient::LogicalMode and a brush transform for the coordinate mapping.
  • PainterPaths The engine has path support.
  • PaintOutsidePaintEvent The engine is capable of painting outside of paint events.
  • PatternBrush The engine is capable of rendering brushes with the brush patterns specified in Qt::BrushStyle.
  • PatternTransform The engine has support for transforming brush patterns.
  • PerspectiveTransform The engine has support for performing perspective transformations on primitives.
  • PixmapTransform The engine can transform pixmaps, including rotation and shearing.
  • PorterDuff The engine supports Porter-Duff operations
  • PrimitiveTransform The engine has support for transforming drawing primitives.
  • RadialGradientFill The engine supports radial gradient fills.
  • RasterOpModes The engine supports bitwise raster operations.
  • AllFeatures All of the above features. This enum value is usually used as a bit mask.
Enumerator
PrimitiveTransform 
PatternTransform 
PixmapTransform 
PatternBrush 
LinearGradientFill 
RadialGradientFill 
ConicalGradientFill 
AlphaBlend 
PorterDuff 
PainterPaths 
Antialiasing 
BrushStroke 
ConstantOpacity 
MaskedBrush 
PerspectiveTransform 
BlendModes 
ObjectBoundingModeGradients 
RasterOpModes 
PaintOutsidePaintEvent 
AllFeatures 

Definition at line 94 of file qpaintengine.h.

94  {
95  PrimitiveTransform = 0x00000001, // Can transform primitives brushes
96  PatternTransform = 0x00000002, // Can transform pattern brushes
97  PixmapTransform = 0x00000004, // Can transform pixmaps
98  PatternBrush = 0x00000008, // Can fill with pixmaps and standard patterns
99  LinearGradientFill = 0x00000010, // Can fill gradient areas
100  RadialGradientFill = 0x00000020, // Can render radial gradients
101  ConicalGradientFill = 0x00000040, // Can render conical gradients
102  AlphaBlend = 0x00000080, // Can do source over alpha blend
103  PorterDuff = 0x00000100, // Can do general porter duff compositions
104  PainterPaths = 0x00000200, // Can fill, outline and clip paths
105  Antialiasing = 0x00000400, // Can antialias lines
106  BrushStroke = 0x00000800, // Can render brush based pens
107  ConstantOpacity = 0x00001000, // Can render at constant opacity
108  MaskedBrush = 0x00002000, // Can fill with textures that has an alpha channel or mask
109  PerspectiveTransform = 0x00004000, // Can do perspective transformations
110  BlendModes = 0x00008000, // Can do extended Porter&Duff composition
111  ObjectBoundingModeGradients = 0x00010000, // Can do object bounding mode gradients
112  RasterOpModes = 0x00020000, // Can do logical raster operations
113  PaintOutsidePaintEvent = 0x20000000, // Engine is capable of painting outside paint events
114  /* 0x10000000, // Used for emulating
115  QGradient::StretchToDevice,
116  defined in qpainter.cpp
117 
118  0x40000000, // Used internally for emulating opaque backgrounds
119  */
120 
121  AllFeatures = 0xffffffff // For convenience
122  };

◆ PolygonDrawMode

  • OddEvenMode The polygon should be drawn using OddEven fill rule.
  • WindingMode The polygon should be drawn using Winding fill rule.
  • ConvexMode The polygon is a convex polygon and can be drawn using specialized algorithms where available.
  • PolylineMode Only the outline of the polygon should be drawn.
Enumerator
OddEvenMode 
WindingMode 
ConvexMode 
PolylineMode 

Definition at line 144 of file qpaintengine.h.

◆ Type

  • X11
  • Windows
  • MacPrinter
  • CoreGraphics Mac OS X's Quartz2D (CoreGraphics)
  • QuickDraw Mac OS X's QuickDraw
  • QWindowSystem Qt for Embedded Linux
  • PostScript
  • OpenGL
  • Picture QPicture format
  • SVG Scalable Vector Graphics XML format
  • Raster
  • Direct3D Windows only, Direct3D based engine
  • Pdf Portable Document Format
  • OpenVG
  • User First user type ID
  • MaxUser Last user type ID
  • OpenGL2
  • PaintBuffer
  • Blitter
Enumerator
X11 
Windows 
QuickDraw 
CoreGraphics 
MacPrinter 
QWindowSystem 
PostScript 
OpenGL 
Picture 
SVG 
Raster 
Direct3D 
Pdf 
OpenVG 
OpenGL2 
PaintBuffer 
Blitter 
User 
MaxUser 

Definition at line 201 of file qpaintengine.h.

Constructors and Destructors

◆ QPaintEngine() [1/2]

QPaintEngine::QPaintEngine ( PaintEngineFeatures  features = 0)
explicit

Creates a paint engine with the featureset specified by caps.

Definition at line 758 of file qpaintengine.cpp.

759  : state(0),
760  gccaps(caps),
761  active(0),
762  selfDestruct(false),
763  extended(false),
765 {
766  d_ptr->q_ptr = this;
767 }
PaintEngineFeatures gccaps
Definition: qpaintengine.h:240
QPaintEngineState * state
Definition: qpaintengine.h:239
QScopedPointer< QPaintEnginePrivate > d_ptr
Definition: qpaintengine.h:246
QPaintEngine * q_ptr

◆ ~QPaintEngine()

QPaintEngine::~QPaintEngine ( )
virtual

Destroys the paint engine.

Definition at line 787 of file qpaintengine.cpp.

788 {
789 }

◆ QPaintEngine() [2/2]

QPaintEngine::QPaintEngine ( QPaintEnginePrivate dptr,
PaintEngineFeatures  caps = 0 
)
protected
Warning
This function is not part of the public interface.

Definition at line 773 of file qpaintengine.cpp.

774  : state(0),
775  gccaps(caps),
776  active(0),
777  selfDestruct(false),
778  extended(false),
779  d_ptr(&dptr)
780 {
781  d_ptr->q_ptr = this;
782 }
PaintEngineFeatures gccaps
Definition: qpaintengine.h:240
QPaintEngineState * state
Definition: qpaintengine.h:239
QScopedPointer< QPaintEnginePrivate > d_ptr
Definition: qpaintengine.h:246
QPaintEngine * q_ptr

Functions

◆ autoDestruct()

bool QPaintEngine::autoDestruct ( ) const
inlineprivate

Definition at line 250 of file qpaintengine.h.

Referenced by QWidgetPrivate::drawWidget().

250 { return selfDestruct; }

◆ begin()

bool QPaintEngine::begin ( QPaintDevice pdev)
pure virtual

◆ clearDirty()

void QPaintEngine::clearDirty ( DirtyFlags  df)
inline
Warning
This function is not part of the public interface.

Definition at line 354 of file qpaintengine.h.

Referenced by QPainterPrivate::updateStateImpl().

355 {
356  Q_ASSERT(state);
357  state->dirtyFlags &= ~static_cast<uint>(df);
358 }
QPaintEngineState * state
Definition: qpaintengine.h:239
QPaintEngine::DirtyFlags dirtyFlags
Definition: qpaintengine.h:325
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
unsigned int uint
Definition: qglobal.h:996

◆ coordinateOffset()

QPoint QPaintEngine::coordinateOffset ( ) const
virtual

Returns the offset from the painters origo to the engines origo.

Warning
This function is not part of the public interface.

This value is used by QPainter for engines who have internal double buffering.

This function only makes sense when the engine is active.

Reimplemented in QOnScreenRasterPaintEngine, and QRasterPaintEngine.

Definition at line 1021 of file qpaintengine.cpp.

Referenced by QPainterPrivate::attachPainterPrivate().

1022 {
1023  return QPoint();
1024 }
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53

◆ drawEllipse() [1/2]

void QPaintEngine::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 in QPaintBufferEngine, QPaintEngineEx, QRasterPaintEngine, QOpenGLPaintEngine, QVGPaintEngine, QX11PaintEngine, QMacPrintEngine, QCoreGraphicsPaintEngine, QDirectFBPaintEngine, QPicturePaintEngine, and QBlitterPaintEngine.

Definition at line 551 of file qpaintengine.cpp.

Referenced by QX11PaintEngine::drawEllipse(), and QCoreGraphicsPaintEngine::drawEllipse().

552 {
553  QPainterPath path;
554  path.addEllipse(rect);
555  if (hasFeature(PainterPaths)) {
556  drawPath(path);
557  } else {
558  QPolygonF polygon = path.toFillPolygon();
559  drawPolygon(polygon.data(), polygon.size(), ConvexMode);
560  }
561 }
virtual void drawPath(const QPainterPath &path)
The default implementation ignores the path and does nothing.
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:67
QPolygonF toFillPolygon(const QMatrix &matrix=QMatrix()) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
The QPolygonF class provides a vector of points using floating point precision.
Definition: qpolygon.h:134
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 point...
T * data()
Returns a pointer to the data stored in the vector.
Definition: qvector.h:152
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137
void addEllipse(const QRectF &rect)
Creates an ellipse within the specified boundingRectangle and adds it to the painter path as a closed...
bool hasFeature(PaintEngineFeatures feature) const
Returns true if the paint engine supports the specified feature; otherwise returns false...
Definition: qpaintengine.h:229

◆ drawEllipse() [2/2]

void QPaintEngine::drawEllipse ( const QRect r)
virtual

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

Reimplemented in QPaintBufferEngine, QPaintEngineEx, QVGPaintEngine, QCoreGraphicsPaintEngine, and QX11PaintEngine.

Definition at line 567 of file qpaintengine.cpp.

568 {
569  drawEllipse(QRectF(rect));
570 }
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()

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

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

Reimplemented in QPaintBufferEngine, QPaintEngineEx, QRasterPaintEngine, QVGPaintEngine, QOpenGLPaintEngine, QGL2PaintEngineEx, QX11PaintEngine, QMacPrintEngine, QCoreGraphicsPaintEngine, QPicturePaintEngine, QPdfEngine, QBlitterPaintEngine, QPSPrintEngine, QEmulationPaintEngine, and QDirectFBPaintEngine.

Definition at line 670 of file qpaintengine.cpp.

Referenced by QPainterPrivate::draw_helper(), and QX11PaintEngine::drawImage().

672 {
673  QRectF baseSize(0, 0, image.width(), image.height());
674  QImage im = image;
675  if (baseSize != sr)
676  im = im.copy(qFloor(sr.x()), qFloor(sr.y()),
677  qCeil(sr.width()), qCeil(sr.height()));
678  QPixmap pm = QPixmap::fromImage(im, flags);
679  drawPixmap(r, pm, QRectF(QPointF(0, 0), pm.size()));
680 }
static QPixmap fromImage(const QImage &image, Qt::ImageConversionFlags flags=Qt::AutoColor)
Converts the given image to a pixmap using the specified flags to control the conversion.
Definition: qpixmap.cpp:2197
qreal y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:667
QImage copy(const QRect &rect=QRect()) const
Returns a sub-area of the image as a new image.
Definition: qimage.cpp:1410
QSize size() const
Returns the size of the pixmap.
Definition: qpixmap.cpp:661
int qCeil(qreal v)
Definition: qmath.h:63
int qFloor(qreal v)
Definition: qmath.h:73
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...
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
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
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
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
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71

◆ drawLines() [1/2]

void QPaintEngine::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 in QPaintBufferEngine, QRasterPaintEngine, QPaintEngineEx, QOpenGLPaintEngine, QCoreGraphicsPaintEngine, QVGPaintEngine, QX11PaintEngine, and QDirectFBPaintEngine.

Definition at line 867 of file qpaintengine.cpp.

Referenced by QCoreGraphicsPaintEngine::drawLines().

868 {
869  struct PointF {
870  qreal x;
871  qreal y;
872  };
873  struct LineF {
874  PointF p1;
875  PointF p2;
876  };
877  Q_ASSERT(sizeof(PointF) == sizeof(QPointF));
878  Q_ASSERT(sizeof(LineF) == sizeof(QLineF));
879  LineF fl[256];
880  while (lineCount) {
881  int i = 0;
882  while (i < lineCount && i < 256) {
883  fl[i].p1.x = lines[i].x1();
884  fl[i].p1.y = lines[i].y1();
885  fl[i].p2.x = lines[i].x2();
886  fl[i].p2.y = lines[i].y2();
887  ++i;
888  }
889  drawLines((QLineF *)(void *)fl, i);
890  lines += i;
891  lineCount -= i;
892  }
893 }
double qreal
Definition: qglobal.h:1193
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
int y1() const
Returns the y-coordinate of the line&#39;s start point.
Definition: qline.h:117
The QLineF class provides a two-dimensional vector using floating point precision.
Definition: qline.h:212
int x2() const
Returns the x-coordinate of the line&#39;s end point.
Definition: qline.h:122
virtual void drawLines(const QLine *lines, int lineCount)
The default implementation converts the first lineCount lines in lines to a QLineF and calls the floa...
int y2() const
Returns the y-coordinate of the line&#39;s end point.
Definition: qline.h:127
int x1() const
Returns the x-coordinate of the line&#39;s start point.
Definition: qline.h:112

◆ drawLines() [2/2]

void QPaintEngine::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 in QPaintBufferEngine, QPdfBaseEngine, QRasterPaintEngine, QPaintEngineEx, QOpenGLPaintEngine, QVGPaintEngine, QMacPrintEngine, QX11PaintEngine, QCoreGraphicsPaintEngine, and QDirectFBPaintEngine.

Definition at line 842 of file qpaintengine.cpp.

843 {
844  for (int i=0; i<lineCount; ++i) {
845  QPointF pts[2] = { lines[i].p1(), lines[i].p2() };
846 
847  if (pts[0] == pts[1]) {
848  if (state->pen().capStyle() != Qt::FlatCap)
849  drawPoints(pts, 1);
850  continue;
851  }
852 
853  drawPolygon(pts, 2, PolylineMode);
854  }
855 }
QPaintEngineState * state
Definition: qpaintengine.h:239
QPointF p1() const
Returns the line&#39;s start point.
Definition: qline.h:314
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
virtual void drawPoints(const QPointF *points, int pointCount)
Draws the first pointCount points in the buffer points.
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 point...
QPointF p2() const
Returns the line&#39;s end point.
Definition: qline.h:319
QPen pen() const
Returns the pen in the current paint engine state.
Definition: qpainter.cpp:9259
Qt::PenCapStyle capStyle() const
Returns the pen&#39;s cap style.
Definition: qpen.cpp:706

◆ drawPath()

void QPaintEngine::drawPath ( const QPainterPath path)
virtual

The default implementation ignores the path and does nothing.

Reimplemented in QPaintBufferEngine, QPdfBaseEngine, QPaintEngineEx, QSvgPaintEngine, QOpenGLPaintEngine, QVGPaintEngine, QX11PaintEngine, QMacPrintEngine, QCoreGraphicsPaintEngine, QPicturePaintEngine, QDirectFBPaintEngine, QWin32PrintEngine, QPreviewPaintEngine, and QAlphaPaintEngine.

Definition at line 803 of file qpaintengine.cpp.

Referenced by drawRects(), and QPainterPrivate::drawStretchedGradient().

804 {
805  if (hasFeature(PainterPaths)) {
806  qWarning("QPaintEngine::drawPath: Must be implemented when feature PainterPaths is set");
807  }
808 }
Q_CORE_EXPORT void qWarning(const char *,...)
bool hasFeature(PaintEngineFeatures feature) const
Returns true if the paint engine supports the specified feature; otherwise returns false...
Definition: qpaintengine.h:229

◆ drawPixmap()

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

◆ drawPoints() [1/2]

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

Draws the first pointCount points in the buffer points.

Reimplemented in QPaintBufferEngine, QRasterPaintEngine, QPdfBaseEngine, QPaintEngineEx, QVGPaintEngine, QOpenGLPaintEngine, QX11PaintEngine, QMacPrintEngine, QBlitterPaintEngine, QCoreGraphicsPaintEngine, and QDirectFBPaintEngine.

Definition at line 479 of file qpaintengine.cpp.

Referenced by drawLines(), QCoreGraphicsPaintEngine::drawPoints(), and QOpenGLPaintEngine::drawPoints().

480 {
481  QPainter *p = painter();
482  if (!p)
483  return;
484 
485  qreal penWidth = p->pen().widthF();
486  if (penWidth == 0)
487  penWidth = 1;
488 
489  bool ellipses = p->pen().capStyle() == Qt::RoundCap;
490 
491  p->save();
492 
493  QTransform transform;
494  if (p->pen().isCosmetic()) {
495  transform = p->transform();
496  p->setTransform(QTransform());
497  }
498 
499  p->setBrush(p->pen().brush());
500  p->setPen(Qt::NoPen);
501 
502  for (int i=0; i<pointCount; ++i) {
503  QPointF pos = transform.map(points[i]);
504  QRectF rect(pos.x() - penWidth / 2, pos.y() - penWidth / 2, penWidth, penWidth);
505 
506  if (ellipses)
507  p->drawEllipse(rect);
508  else
509  p->drawRect(rect);
510  }
511 
512  p->restore();
513 }
void setTransform(const QTransform &transform, bool combine=false)
Sets the world transformation matrix.
Definition: qpainter.cpp:9547
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
double qreal
Definition: qglobal.h:1193
const QTransform & transform() const
Returns the world transformation matrix.
Definition: qpainter.cpp:9558
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
void restore()
Restores the current painter state (pops a saved state off the stack).
Definition: qpainter.cpp:1620
void save()
Saves the current painter state (pushes the state onto a stack).
Definition: qpainter.cpp:1590
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
QPainter * painter() const
Returns the paint engine&#39;s painter.
const QPen & pen() const
Returns the painter&#39;s current pen.
Definition: qpainter.cpp:4152
void drawEllipse(const QRectF &r)
Draws the ellipse defined by the given rectangle.
Definition: qpainter.cpp:4464
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
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...
QBrush brush() const
Returns the brush used to fill strokes generated with this pen.
Definition: qpen.cpp:797
void setBrush(const QBrush &brush)
Sets the painter&#39;s brush to the given brush.
Definition: qpainter.cpp:4171
void setPen(const QColor &color)
Sets the painter&#39;s pen to have style Qt::SolidLine, width 0 and the specified color.
Definition: qpainter.cpp:4047
qreal widthF() const
Returns the pen width with floating point precision.
Definition: qpen.cpp:645
void drawRect(const QRectF &rect)
Draws the current rectangle with the current pen and brush.
Definition: qpainter.h:650
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
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65

◆ drawPoints() [2/2]

void QPaintEngine::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 in QPaintBufferEngine, QRasterPaintEngine, QPaintEngineEx, QVGPaintEngine, QOpenGLPaintEngine, QCoreGraphicsPaintEngine, QX11PaintEngine, QBlitterPaintEngine, and QDirectFBPaintEngine.

Definition at line 523 of file qpaintengine.cpp.

524 {
525  Q_ASSERT(sizeof(QT_PointF) == sizeof(QPointF));
526  QT_PointF fp[256];
527  while (pointCount) {
528  int i = 0;
529  while (i < pointCount && i < 256) {
530  fp[i].x = points[i].x();
531  fp[i].y = points[i].y();
532  ++i;
533  }
534  drawPoints((QPointF *)(void *)fp, i);
535  points += i;
536  pointCount -= i;
537  }
538 }
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
virtual void drawPoints(const QPointF *points, int pointCount)
Draws the first pointCount points in the buffer points.
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
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

◆ drawPolygon() [1/2]

void QPaintEngine::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 in QPaintBufferEngine, QPdfBaseEngine, QPaintEngineEx, QSvgPaintEngine, QRasterPaintEngine, QOpenGLPaintEngine, QVGPaintEngine, QX11PaintEngine, QMacPrintEngine, QCoreGraphicsPaintEngine, QPicturePaintEngine, QDirectFBPaintEngine, QWin32PrintEngine, QBlitterPaintEngine, QPreviewPaintEngine, and QAlphaPaintEngine.

Definition at line 360 of file qpaintengine.cpp.

Referenced by drawLines(), QX11PaintEngine::drawPolygon(), QCoreGraphicsPaintEngine::drawPolygon(), and drawRects().

361 {
362  Q_ASSERT_X(qt_polygon_recursion != this, "QPaintEngine::drawPolygon",
363  "At least one drawPolygon function must be implemented");
364  qt_polygon_recursion = this;
365  Q_ASSERT(sizeof(QT_Point) == sizeof(QPoint));
366  QVarLengthArray<QT_Point> p(pointCount);
367  for (int i = 0; i < pointCount; ++i) {
368  p[i].x = qRound(points[i].x());
369  p[i].y = qRound(points[i].y());
370  }
371  drawPolygon((QPoint *)p.data(), pointCount, mode);
373 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
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 point...
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
static QPaintEngine * qt_polygon_recursion
Q_DECL_CONSTEXPR int qRound(qreal d)
Definition: qglobal.h:1203

◆ drawPolygon() [2/2]

void QPaintEngine::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 in QPaintBufferEngine, QPaintEngineEx, QRasterPaintEngine, QOpenGLPaintEngine, QVGPaintEngine, QCoreGraphicsPaintEngine, QX11PaintEngine, QDirectFBPaintEngine, and QBlitterPaintEngine.

Definition at line 390 of file qpaintengine.cpp.

391 {
392  Q_ASSERT_X(qt_polygon_recursion != this, "QPaintEngine::drawPolygon",
393  "At least one drawPolygon function must be implemented");
394  qt_polygon_recursion = this;
395  Q_ASSERT(sizeof(QT_PointF) == sizeof(QPointF));
396  QVarLengthArray<QT_PointF> p(pointCount);
397  for (int i=0; i<pointCount; ++i) {
398  p[i].x = points[i].x();
399  p[i].y = points[i].y();
400  }
401  drawPolygon((QPointF *)p.data(), pointCount, mode);
403 }
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
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 point...
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
static QPaintEngine * qt_polygon_recursion
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128

◆ drawRects() [1/2]

void QPaintEngine::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 in QPaintBufferEngine, QRasterPaintEngine, QPaintEngineEx, QOpenGLPaintEngine, QCoreGraphicsPaintEngine, QVGPaintEngine, QX11PaintEngine, QBlitterPaintEngine, and QDirectFBPaintEngine.

Definition at line 906 of file qpaintengine.cpp.

Referenced by QX11PaintEngine::drawRects(), QCoreGraphicsPaintEngine::drawRects(), and QPdfBaseEngine::drawRects().

907 {
908  struct RectF {
909  qreal x;
910  qreal y;
911  qreal w;
912  qreal h;
913  };
914  Q_ASSERT(sizeof(RectF) == sizeof(QRectF));
915  RectF fr[256];
916  while (rectCount) {
917  int i = 0;
918  while (i < rectCount && i < 256) {
919  fr[i].x = rects[i].x();
920  fr[i].y = rects[i].y();
921  fr[i].w = rects[i].width();
922  fr[i].h = rects[i].height();
923  ++i;
924  }
925  drawRects((QRectF *)(void *)fr, i);
926  rects += i;
927  rectCount -= i;
928  }
929 }
double qreal
Definition: qglobal.h:1193
virtual void drawRects(const QRect *rects, int rectCount)
The default implementation converts the first rectCount rectangles in the buffer rects to a QRectF an...
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
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

◆ drawRects() [2/2]

void QPaintEngine::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 in QPaintBufferEngine, QPdfBaseEngine, QRasterPaintEngine, QPaintEngineEx, QOpenGLPaintEngine, QVGPaintEngine, QMacPrintEngine, QX11PaintEngine, QCoreGraphicsPaintEngine, QBlitterPaintEngine, and QDirectFBPaintEngine.

Definition at line 936 of file qpaintengine.cpp.

937 {
938  if (hasFeature(PainterPaths) &&
939  !state->penNeedsResolving() &&
941  for (int i=0; i<rectCount; ++i) {
942  QPainterPath path;
943  path.addRect(rects[i]);
944  if (path.isEmpty())
945  continue;
946  drawPath(path);
947  }
948  } else {
949  for (int i=0; i<rectCount; ++i) {
950  QRectF rf = rects[i];
951  QPointF pts[4] = { QPointF(rf.x(), rf.y()),
952  QPointF(rf.x() + rf.width(), rf.y()),
953  QPointF(rf.x() + rf.width(), rf.y() + rf.height()),
954  QPointF(rf.x(), rf.y() + rf.height()) };
955  drawPolygon(pts, 4, ConvexMode);
956  }
957  }
958 }
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
qreal y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:667
bool brushNeedsResolving() const
Returns whether the coordinate of the fill have been specified as bounded by the current rendering op...
Definition: qpainter.cpp:9411
virtual void drawPath(const QPainterPath &path)
The default implementation ignores the path and does nothing.
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:67
QPaintEngineState * state
Definition: qpaintengine.h:239
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
bool penNeedsResolving() const
Returns whether the coordinate of the stroke have been specified as bounded by the current rendering ...
Definition: qpainter.cpp:9428
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
void addRect(const QRectF &rect)
Adds the given rectangle to this path as a closed subpath.
qreal width() const
Returns the width of the rectangle.
Definition: qrect.h:707
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 point...
qreal x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:664
bool hasFeature(PaintEngineFeatures feature) const
Returns true if the paint engine supports the specified feature; otherwise returns false...
Definition: qpaintengine.h:229

◆ drawTextItem()

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

This function draws the text item textItem at position p.

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

Reimplemented in QPaintBufferEngine, QPdfBaseEngine, QRasterPaintEngine, QSvgPaintEngine, QVGPaintEngine, QOpenGLPaintEngine, QGL2PaintEngineEx, QX11PaintEngine, QMacPrintEngine, QPicturePaintEngine, QCoreGraphicsPaintEngine, QDirectFBPaintEngine, QBlitterPaintEngine, QWin32PrintEngine, QtopiaPrintEngine, QEmulationPaintEngine, QAlphaPaintEngine, and QPreviewPaintEngine.

Definition at line 816 of file qpaintengine.cpp.

Referenced by QRasterPaintEngine::drawCachedGlyphs(), QX11PaintEngine::drawFreetype(), QEmulationPaintEngine::drawTextItem(), QWin32PrintEngine::drawTextItem(), QCoreGraphicsPaintEngine::drawTextItem(), QPicturePaintEngine::drawTextItem(), QGL2PaintEngineEx::drawTextItem(), QOpenGLPaintEngine::drawTextItem(), QVGPaintEngine::drawTextItem(), QRasterPaintEngine::drawTextItem(), QPdfBaseEngine::drawTextItem(), QX11PaintEngine::drawXLFD(), and QVGPaintEngine::type().

817 {
818  const QTextItemInt &ti = static_cast<const QTextItemInt &>(textItem);
819 
820  QPainterPath path;
821 #ifndef Q_WS_MAC
823 #endif
824  if (ti.glyphs.numGlyphs)
825  ti.fontEngine->addOutlineToPath(0, 0, ti.glyphs, &path, ti.flags);
826  if (!path.isEmpty()) {
827  painter()->save();
829  bool((painter()->renderHints() & QPainter::TextAntialiasing)
830  && !(painter()->font().styleStrategy() & QFont::NoAntialias)));
831  painter()->translate(p.x(), p.y());
832  painter()->fillPath(path, state->pen().brush());
833  painter()->restore();
834  }
835 }
QFontEngine * fontEngine
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
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:67
QPaintEngineState * state
Definition: qpaintengine.h:239
RenderFlags flags
virtual void addOutlineToPath(qreal, qreal, const QGlyphLayout &, QPainterPath *, QTextItem::RenderFlags flags)
void restore()
Restores the current painter state (pops a saved state off the stack).
Definition: qpainter.cpp:1620
void save()
Saves the current painter state (pushes the state onto a stack).
Definition: qpainter.cpp:1590
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
void setFillRule(Qt::FillRule fillRule)
Sets the fill rule of the painter path to the given fillRule.
QGlyphLayout glyphs
void setRenderHint(RenderHint hint, bool on=true)
Sets the given render hint on the painter if on is true; otherwise clears the render hint...
Definition: qpainter.cpp:7620
QPainter * painter() const
Returns the paint engine&#39;s painter.
void fillPath(const QPainterPath &path, const QBrush &brush)
Fills the given path using the given brush.
Definition: qpainter.cpp:3456
Internal QTextItem.
QBrush brush() const
Returns the brush used to fill strokes generated with this pen.
Definition: qpen.cpp:797
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287
QPen pen() const
Returns the pen in the current paint engine state.
Definition: qpainter.cpp:9259
void translate(const QPointF &offset)
Translates the coordinate system by the given offset; i.e.
Definition: qpainter.cpp:3311

◆ drawTiledPixmap()

void QPaintEngine::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 in QPaintBufferEngine, QPaintEngineEx, QRasterPaintEngine, QVGPaintEngine, QOpenGLPaintEngine, QX11PaintEngine, QMacPrintEngine, QPicturePaintEngine, QCoreGraphicsPaintEngine, QPdfEngine, QBlitterPaintEngine, QWin32PrintEngine, QPSPrintEngine, QPreviewPaintEngine, QDirectFBPaintEngine, QEmulationPaintEngine, and QAlphaPaintEngine.

Definition at line 632 of file qpaintengine.cpp.

Referenced by QWin32PrintEngine::drawTiledPixmap().

633 {
634  int sw = pixmap.width();
635  int sh = pixmap.height();
636 
637  if (sw*sh < 8192 && sw*sh < 16*rect.width()*rect.height()) {
638  int tw = sw, th = sh;
639  while (tw*th < 32678 && tw < rect.width()/2)
640  tw *= 2;
641  while (tw*th < 32678 && th < rect.height()/2)
642  th *= 2;
643  QPixmap tile;
644  if (pixmap.depth() == 1) {
645  tile = QBitmap(tw, th);
646  } else {
647  tile = QPixmap(tw, th);
648  if (pixmap.hasAlphaChannel())
649  tile.fill(Qt::transparent);
650  }
651  qt_fill_tile(&tile, pixmap);
652  qt_draw_tile(this, rect.x(), rect.y(), rect.width(), rect.height(), tile, p.x(), p.y());
653  } else {
654  qt_draw_tile(this, rect.x(), rect.y(), rect.width(), rect.height(), pixmap, p.x(), p.y());
655  }
656 }
qreal y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:667
int width() const
Returns the width of the pixmap.
Definition: qpixmap.cpp:630
void qt_draw_tile(QPaintEngine *gc, qreal x, qreal y, qreal w, qreal h, const QPixmap &pixmap, qreal xOffset, qreal yOffset)
int depth() const
Returns the depth of the pixmap.
Definition: qpixmap.cpp:695
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
The QBitmap class provides monochrome (1-bit depth) pixmaps.
Definition: qbitmap.h:55
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
void fill(const QColor &fillColor=Qt::white)
Fills the pixmap with the given color.
Definition: qpixmap.cpp:1080
qreal x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:664
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
int height() const
Returns the height of the pixmap.
Definition: qpixmap.cpp:645
void qt_fill_tile(QPixmap *tile, const QPixmap &pixmap)
bool hasAlphaChannel() const
Returns true if the pixmap has a format that respects the alpha channel, otherwise returns false...
Definition: qpixmap.cpp:1965

◆ end()

bool QPaintEngine::end ( )
pure virtual

◆ fix_neg_rect()

void QPaintEngine::fix_neg_rect ( int *  x,
int *  y,
int *  w,
int *  h 
)
inline
Warning
This function is not part of the public interface.

Definition at line 332 of file qpaintengine.h.

333 {
334  if (*w < 0) {
335  *w = -*w;
336  *x -= *w - 1;
337  }
338  if (*h < 0) {
339  *h = -*h;
340  *y -= *h - 1;
341  }
342 }

◆ getDC()

HDC QPaintEngine::getDC ( ) const
virtual

Empty default implementation.

Warning
This function is not part of the public interface.

Reimplemented in QRasterPaintEngine, and QWin32PrintEngine.

Definition at line 988 of file qpaintengine.cpp.

Referenced by QWindowsXPStylePrivate::drawBackground(), QWindowsXPStylePrivate::drawBackgroundDirectly(), QVistaHelper::drawTitleBar(), XPThemeData::mask(), and QVistaBackButton::paintEvent().

989 {
990  return 0;
991 }

◆ hasFeature()

bool QPaintEngine::hasFeature ( PaintEngineFeatures  feature) const
inline

◆ isActive()

bool QPaintEngine::isActive ( ) const
inline

◆ isExtended()

bool QPaintEngine::isExtended ( ) const
inline

Returns true if the paint engine is a QPaintEngineEx derivative.

Warning
This function is not part of the public interface.

Definition at line 234 of file qpaintengine.h.

Referenced by QPixmapConvolutionFilter::draw(), QPixmapBlurFilter::draw(), QPixmapColorizeFilter::draw(), QPixmapDropShadowFilter::draw(), QPaintEngineExReplayer::process(), QPaintBuffer::processCommands(), and syncState().

234 { return extended; }

◆ paintDevice()

QPaintDevice * QPaintEngine::paintDevice ( ) const

◆ painter()

QPainter * QPaintEngine::painter ( ) const

◆ releaseDC()

void QPaintEngine::releaseDC ( HDC  hdc) const
virtual

Empty default implementation.

Warning
This function is not part of the public interface.

Reimplemented in QRasterPaintEngine, and QWin32PrintEngine.

Definition at line 1003 of file qpaintengine.cpp.

Referenced by XPThemeData::mask().

1004 {
1005 }

◆ setActive()

void QPaintEngine::setActive ( bool  state)
inline

◆ setAutoDestruct()

void QPaintEngine::setAutoDestruct ( bool  autoDestr)
inlineprivate

Definition at line 249 of file qpaintengine.h.

Referenced by QWidget::paintEngine().

249 { selfDestruct = autoDestr; }

◆ setDirty()

void QPaintEngine::setDirty ( DirtyFlags  df)
inline
Warning
This function is not part of the public interface.

Definition at line 349 of file qpaintengine.h.

Referenced by QCoreGraphicsPaintEngine::begin(), QX11PaintEngine::begin(), QRasterPaintEngine::begin(), QPreviewPaintEngine::newPage(), and QPainterPrivate::updateStateImpl().

349  {
350  Q_ASSERT(state);
351  state->dirtyFlags |= df;
352 }
QPaintEngineState * state
Definition: qpaintengine.h:239
QPaintEngine::DirtyFlags dirtyFlags
Definition: qpaintengine.h:325
#define Q_ASSERT(cond)
Definition: qglobal.h:1823

◆ setPaintDevice()

void QPaintEngine::setPaintDevice ( QPaintDevice device)
Warning
This function is not part of the public interface. Sets the paintdevice that this engine operates on to device

Definition at line 964 of file qpaintengine.cpp.

965 {
966  d_func()->pdev = device;
967 }

◆ setSystemClip()

void QPaintEngine::setSystemClip ( const QRegion region)

Sets the system clip for this engine.

Warning
This function is not part of the public interface.

The system clip defines the basis area that the engine has to draw in. All clips that are set will be be an intersection with the system clip.

Reset the systemclip to no clip by setting an empty region.

Definition at line 1038 of file qpaintengine.cpp.

Referenced by QX11PaintEngine::begin(), QX11PaintEngine::end(), make_widget_eventUPP(), QSystemTrayIconSys::paintEvent(), QPainterReplayer::process(), QWidgetBackingStore::removeDirtyWidget(), and QWidgetBackingStore::showYellowThing().

1039 {
1040  Q_D(QPaintEngine);
1041  d->systemClip = region;
1042  // Be backward compatible and only call d->systemStateChanged()
1043  // if we currently have a system transform/viewport set.
1044  if (d->hasSystemTransform || d->hasSystemViewport) {
1045  d->transformSystemClip();
1046  d->systemStateChanged();
1047  }
1048 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QPaintEngine class provides an abstract definition of how QPainter draws to a given device on a g...
Definition: qpaintengine.h:90

◆ setSystemRect()

void QPaintEngine::setSystemRect ( const QRect rect)

Sets the target rect for drawing within the backing store.

Warning
This function is not part of the public interface.

This function should ONLY be used by the backing store.

Definition at line 1075 of file qpaintengine.cpp.

1076 {
1077  if (isActive()) {
1078  qWarning("QPaintEngine::setSystemRect: Should not be changed while engine is active");
1079  return;
1080  }
1081  d_func()->systemRect = rect;
1082 }
bool isActive() const
Returns true if the paint engine is actively drawing; otherwise returns false.
Definition: qpaintengine.h:154
Q_CORE_EXPORT void qWarning(const char *,...)

◆ syncState()

void QPaintEngine::syncState ( )

Updates all dirty states in this engine.

Warning
This function is not part of the public interface.

This function should ONLY be used when drawing with native handles directly and immediate sync from QPainters state to the native state is required.

Definition at line 335 of file qpaintengine.cpp.

Referenced by QMacStyle::drawComplexControl(), QPreviewPaintEngine::newPage(), QMacPrintEnginePrivate::newPage_helper(), and QMacCGContext::QMacCGContext().

336 {
337  Q_ASSERT(state);
338  updateState(*state);
339 
340  if (isExtended())
341  static_cast<QPaintEngineEx *>(this)->sync();
342 }
QPaintEngineState * state
Definition: qpaintengine.h:239
virtual void updateState(const QPaintEngineState &state)=0
Reimplement this function to update the state of a paint engine.
bool isExtended() const
Returns true if the paint engine is a QPaintEngineEx derivative.
Definition: qpaintengine.h:234
#define Q_ASSERT(cond)
Definition: qglobal.h:1823

◆ systemClip()

QRegion QPaintEngine::systemClip ( ) const

◆ systemRect()

QRect QPaintEngine::systemRect ( ) const

Retrieves the rect for drawing within the backing store.

Warning
This function is not part of the public interface.

This function should ONLY be used by the backing store.

Definition at line 1093 of file qpaintengine.cpp.

Referenced by QWidgetPrivate::drawWidget().

1094 {
1095  return d_func()->systemRect;
1096 }

◆ testDirty()

bool QPaintEngine::testDirty ( DirtyFlags  df)
inline
Warning
This function is not part of the public interface.

Definition at line 344 of file qpaintengine.h.

344  {
345  Q_ASSERT(state);
346  return ((state->dirtyFlags & df) != 0);
347 }
QPaintEngineState * state
Definition: qpaintengine.h:239
QPaintEngine::DirtyFlags dirtyFlags
Definition: qpaintengine.h:325
#define Q_ASSERT(cond)
Definition: qglobal.h:1823

◆ type()

Type QPaintEngine::type ( ) const
pure virtual

◆ updateState()

void QPaintEngine::updateState ( const QPaintEngineState state)
pure 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

Implemented in QPaintEngineEx, QPdfBaseEngine, QSvgPaintEngine, QOpenGLPaintEngine, QMacPrintEngine, QX11PaintEngine, QtopiaPrintEngine, QCoreGraphicsPaintEngine, QWin32PrintEngine, QPicturePaintEngine, QPreviewPaintEngine, and QAlphaPaintEngine.

Referenced by QPainterPrivate::updateStateImpl().

Friends and Related Functions

◆ QFontEngineBox

friend class QFontEngineBox
friend

Definition at line 254 of file qpaintengine.h.

◆ QFontEngineFT

friend class QFontEngineFT
friend

Definition at line 258 of file qpaintengine.h.

◆ QFontEngineMac

friend class QFontEngineMac
friend

Definition at line 255 of file qpaintengine.h.

◆ QFontEngineQPF

friend class QFontEngineQPF
friend

Definition at line 264 of file qpaintengine.h.

◆ QFontEngineQPF1

friend class QFontEngineQPF1
friend

Definition at line 261 of file qpaintengine.h.

◆ QFontEngineWin

friend class QFontEngineWin
friend

Definition at line 256 of file qpaintengine.h.

◆ QMacCGContext

friend class QMacCGContext
friend

Definition at line 283 of file qpaintengine.h.

◆ QMacPrintEngine

friend class QMacPrintEngine
friend

Definition at line 267 of file qpaintengine.h.

◆ QMacPrintEnginePrivate

Definition at line 268 of file qpaintengine.h.

◆ QPainter

friend class QPainter
friend

◆ QPainterPrivate

friend class QPainterPrivate
friend

Definition at line 278 of file qpaintengine.h.

◆ QPainterReplayer

friend class QPainterReplayer
friend

Definition at line 253 of file qpaintengine.h.

◆ QPreviewPaintEngine

friend class QPreviewPaintEngine
friend

Definition at line 284 of file qpaintengine.h.

◆ QProxyFontEngine

friend class QProxyFontEngine
friend

Definition at line 272 of file qpaintengine.h.

◆ QPSPrintEngine

friend class QPSPrintEngine
friend

Definition at line 266 of file qpaintengine.h.

◆ QtopiaPrintEngine

friend class QtopiaPrintEngine
friend

Definition at line 270 of file qpaintengine.h.

◆ QtopiaPrintEnginePrivate

Definition at line 271 of file qpaintengine.h.

◆ QWidget

friend class QWidget
friend

Definition at line 279 of file qpaintengine.h.

◆ QWidgetPrivate

friend class QWidgetPrivate
friend

Definition at line 280 of file qpaintengine.h.

◆ QWin32PaintEngine

friend class QWin32PaintEngine
friend

Definition at line 281 of file qpaintengine.h.

◆ QWin32PaintEnginePrivate

friend class QWin32PaintEnginePrivate
friend

Definition at line 282 of file qpaintengine.h.

◆ QX11GLPixmapData

friend class QX11GLPixmapData
friend

Definition at line 285 of file qpaintengine.h.

Properties

◆ active

uint QPaintEngine::active
protected

Definition at line 242 of file qpaintengine.h.

◆ d_ptr

QScopedPointer<QPaintEnginePrivate> QPaintEngine::d_ptr
protected

◆ extended

uint QPaintEngine::extended
protected

Definition at line 244 of file qpaintengine.h.

Referenced by QPaintEngineEx::QPaintEngineEx().

◆ gccaps

PaintEngineFeatures QPaintEngine::gccaps
protected

◆ selfDestruct

uint QPaintEngine::selfDestruct
protected

Definition at line 243 of file qpaintengine.h.

◆ state

QPaintEngineState* QPaintEngine::state
protected

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