Qt 4.8
Public Functions | Static Public Functions | Protected Functions | Static Private Functions | Static Private Attributes | Friends | List of all members
QCoreGraphicsPaintEngine Class Reference

#include <qpaintengine_mac_p.h>

Inheritance diagram for QCoreGraphicsPaintEngine:
QPaintEngine

Public Functions

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

Static Public Functions

static void cleanup ()
 
static void clearColorSpace (QWidget *w)
 
static void initialize ()
 
static CGColorSpaceRef macDisplayColorSpace (const QWidget *widget=0)
 
static CGColorSpaceRef macGenericColorSpace ()
 

Protected Functions

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

Static Private Functions

static void cleanUpMacColorSpaces ()
 

Static Private Attributes

static QHash< QWidget *, CGColorSpaceRefm_displayColorSpaceHash
 
static CGColorSpaceRef m_genericColorSpace = 0
 
static bool m_postRoutineRegistered = false
 

Friends

class QMacPrintEngine
 
class QMacPrintEnginePrivate
 
void qt_color_profile_changed (CFNotificationCenterRef center, void *, CFStringRef, const void *, CFDictionaryRef)
 
void qt_mac_display_change_callbk (CGDirectDisplayID, CGDisplayChangeSummaryFlags, void *)
 

Additional Inherited Members

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

Detailed Description

Definition at line 67 of file qpaintengine_mac_p.h.

Constructors and Destructors

◆ QCoreGraphicsPaintEngine() [1/2]

QCoreGraphicsPaintEngine::QCoreGraphicsPaintEngine ( )

Definition at line 544 of file qpaintengine_mac.cpp.

546 {
547 }
QPaintEngine(PaintEngineFeatures features=0)
Creates a paint engine with the featureset specified by caps.
static QPaintEngine::PaintEngineFeatures qt_mac_cg_features()

◆ ~QCoreGraphicsPaintEngine()

QCoreGraphicsPaintEngine::~QCoreGraphicsPaintEngine ( )

Definition at line 554 of file qpaintengine_mac.cpp.

555 {
556 }

◆ QCoreGraphicsPaintEngine() [2/2]

QCoreGraphicsPaintEngine::QCoreGraphicsPaintEngine ( QPaintEnginePrivate dptr)
protected

Definition at line 549 of file qpaintengine_mac.cpp.

551 {
552 }
QPaintEngine(PaintEngineFeatures features=0)
Creates a paint engine with the featureset specified by caps.
static QPaintEngine::PaintEngineFeatures qt_mac_cg_features()

Functions

◆ begin()

bool QCoreGraphicsPaintEngine::begin ( QPaintDevice pdev)
virtual

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

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

See also
end() isActive()

Implements QPaintEngine.

Definition at line 559 of file qpaintengine_mac.cpp.

560 {
562  if(isActive()) { // already active painting
563  qWarning("QCoreGraphicsPaintEngine::begin: Painter already active");
564  return false;
565  }
566 
567  //initialization
568  d->pdev = pdev;
569  d->complexXForm = false;
571  d->cosmeticPenSize = 1;
572  d->current.clipEnabled = false;
573  d->pixelSize = QPoint(1,1);
574  d->hd = qt_mac_cg_context(pdev);
575  if(d->hd) {
576  d->saveGraphicsState();
577  d->orig_xform = CGContextGetCTM(d->hd);
578  if (d->shading) {
579  CGShadingRelease(d->shading);
580  d->shading = 0;
581  }
582  d->setClip(0); //clear the context's clipping
583  }
584 
585  setActive(true);
586 
587  if(d->pdev->devType() == QInternal::Widget) { // device is a widget
588  QWidget *w = (QWidget*)d->pdev;
589  bool unclipped = w->testAttribute(Qt::WA_PaintUnclipped);
590 
591  if((w->windowType() == Qt::Desktop)) {
592  if(!unclipped)
593  qWarning("QCoreGraphicsPaintEngine::begin: Does not support clipped desktop on Mac OS X");
594  // ## need to do [qt_mac_window_for(w) makeKeyAndOrderFront]; (need to rename the file)
595  } else if(unclipped) {
596  qWarning("QCoreGraphicsPaintEngine::begin: Does not support unclipped painting");
597  }
598  } else if(d->pdev->devType() == QInternal::Pixmap) { // device is a pixmap
599  QPixmap *pm = (QPixmap*)d->pdev;
600  if(pm->isNull()) {
601  qWarning("QCoreGraphicsPaintEngine::begin: Cannot paint null pixmap");
602  end();
603  return false;
604  }
605  }
606 
611  return true;
612 }
double d
Definition: qnumeric_p.h:62
bool end()
Reimplement this function to finish painting on the current paint device.
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
bool isActive() const
Returns true if the paint engine is actively drawing; otherwise returns false.
Definition: qpaintengine.h:154
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
void setActive(bool newState)
Sets the active state of the paint engine to state.
Definition: qpaintengine.h:155
CGContextRef qt_mac_cg_context(const QPaintDevice *)
Returns the CoreGraphics CGContextRef of the paint device.
Q_CORE_EXPORT void qWarning(const char *,...)
void setDirty(DirtyFlags df)
Definition: qpaintengine.h:349
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
Qt::WindowType windowType() const
Returns the window type of this widget.
Definition: qwidget.h:937
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
Definition: qpixmap.cpp:615

◆ cleanup()

void QCoreGraphicsPaintEngine::cleanup ( )
static

Definition at line 1066 of file qpaintengine_mac.cpp.

Referenced by type().

1067 {
1068 }

◆ cleanUpMacColorSpaces()

void QCoreGraphicsPaintEngine::cleanUpMacColorSpaces ( )
staticprivate

Definition at line 366 of file qpaintengine_mac.cpp.

Referenced by macDisplayColorSpace(), macGenericColorSpace(), qt_color_profile_changed(), and qt_mac_display_change_callbk().

367 {
368  if (m_genericColorSpace) {
369  CFRelease(m_genericColorSpace);
371  }
373  while (it != m_displayColorSpaceHash.constEnd()) {
374  if (it.value())
375  CFRelease(it.value());
376  ++it;
377  }
379 }
void clear()
Removes all items from the hash.
Definition: qhash.h:574
#define it(className, varName)
The QHash class is a template class that provides a hash-table-based dictionary.
Definition: qdatastream.h:66
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the hash.
Definition: qhash.h:466
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:469
static QHash< QWidget *, CGColorSpaceRef > m_displayColorSpaceHash
static CGColorSpaceRef m_genericColorSpace

◆ clearColorSpace()

void QCoreGraphicsPaintEngine::clearColorSpace ( QWidget w)
static

Definition at line 1070 of file qpaintengine_mac.cpp.

Referenced by QWidget::destroy(), and type().

1071 {
1073 }
int remove(const Key &key)
Removes all the items that have the key from the hash.
Definition: qhash.h:784
static QHash< QWidget *, CGColorSpaceRef > m_displayColorSpaceHash

◆ drawEllipse() [1/2]

void QCoreGraphicsPaintEngine::drawEllipse ( const QRectF rect)
virtual

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

The default implementation calls drawPolygon().

Reimplemented from QPaintEngine.

Definition at line 909 of file qpaintengine_mac.cpp.

910 {
912  Q_ASSERT(isActive());
913 
915  return;
916 
917  CGMutablePathRef path = CGPathCreateMutable();
918  CGAffineTransform transform = CGAffineTransformMakeScale(r.width() / r.height(), 1);
919  CGPathAddArc(path, &transform,(r.x() + (r.width() / 2)) / (r.width() / r.height()),
920  r.y() + (r.height() / 2), r.height() / 2, 0, (2 * M_PI), false);
922  path);
923  CGPathRelease(path);
924 }
double d
Definition: qnumeric_p.h:62
QPaintEngineState * state
Definition: qpaintengine.h:239
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
#define M_PI
Definition: qmath.h:261
bool isActive() const
Returns true if the paint engine is actively drawing; otherwise returns false.
Definition: qpaintengine.h:154
QPainter::CompositionMode compositionMode() const
Returns the composition mode in the current paint engine state.
Definition: qpainter.cpp:9503

◆ drawEllipse() [2/2]

void QCoreGraphicsPaintEngine::drawEllipse ( const QRect r)
inlinevirtual

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

Reimplemented from QPaintEngine.

Definition at line 121 of file qpaintengine_mac_p.h.

virtual void drawEllipse(const QRectF &r)
Reimplement this function to draw the largest ellipse that can be contained within rectangle rect...

◆ drawImage()

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

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

Reimplemented from QPaintEngine.

Definition at line 1043 of file qpaintengine_mac.cpp.

1045 {
1047  Q_UNUSED(flags);
1048  Q_ASSERT(isActive());
1049 
1051  return;
1052 
1053  const QImage *image;
1054  QCFType<CGImageRef> cgimage = qt_mac_createCGImageFromQImage(img, &image);
1055  CGRect rect = CGRectMake(r.x(), r.y(), r.width(), r.height());
1056  if (QRectF(0, 0, img.width(), img.height()) != sr)
1057  cgimage = CGImageCreateWithImageInRect(cgimage, CGRectMake(sr.x(), sr.y(),
1058  sr.width(), sr.height()));
1059  qt_mac_drawCGImage(d->hd, &rect, cgimage);
1060 }
double d
Definition: qnumeric_p.h:62
qreal y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:667
QPaintEngineState * state
Definition: qpaintengine.h:239
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
bool isActive() const
Returns true if the paint engine is actively drawing; otherwise returns false.
Definition: qpaintengine.h:154
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
QPainter::CompositionMode compositionMode() const
Returns the composition mode in the current paint engine state.
Definition: qpainter.cpp:9503
qreal width() const
Returns the width of the rectangle.
Definition: qrect.h:707
struct CGRect CGRect
qreal x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:664
OSStatus qt_mac_drawCGImage(CGContextRef inContext, const CGRect *inBounds, CGImageRef inImage)
#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
CGImageRef qt_mac_createCGImageFromQImage(const QImage &img, const QImage **imagePtr=0)

◆ drawLines() [1/2]

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

Definition at line 950 of file qpaintengine_mac.cpp.

951 {
953  Q_ASSERT(isActive());
954 
956  return;
957 
958  CGMutablePathRef path = CGPathCreateMutable();
959  for(int i = 0; i < lineCount; i++) {
960  const QPointF start = lines[i].p1(), end = lines[i].p2();
961  CGPathMoveToPoint(path, 0, start.x(), start.y());
962  CGPathAddLineToPoint(path, 0, end.x(), end.y());
963  }
965  CGPathRelease(path);
966 }
double d
Definition: qnumeric_p.h:62
bool end()
Reimplement this function to finish painting on the current paint device.
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
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
bool isActive() const
Returns true if the paint engine is actively drawing; otherwise returns false.
Definition: qpaintengine.h:154
QPainter::CompositionMode compositionMode() const
Returns the composition mode in the current paint engine state.
Definition: qpainter.cpp:9503
QPointF p2() const
Returns the line&#39;s end point.
Definition: qline.h:319
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287

◆ drawLines() [2/2]

void QCoreGraphicsPaintEngine::drawLines ( const QLine lines,
int  lineCount 
)
inlinevirtual

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.

Definition at line 118 of file qpaintengine_mac_p.h.

118 { QPaintEngine::drawLines(lines, lineCount); }
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...

◆ drawPath()

void QCoreGraphicsPaintEngine::drawPath ( const QPainterPath path)
virtual

The default implementation ignores the path and does nothing.

Reimplemented from QPaintEngine.

Definition at line 835 of file qpaintengine_mac.cpp.

836 {
838  Q_ASSERT(isActive());
839 
841  return;
842 
843  CGMutablePathRef path = qt_mac_compose_path(p);
845  if(p.fillRule() == Qt::WindingFill)
847  else
849  CGContextBeginPath(d->hd);
850  d->drawPath(ops, path);
851  CGPathRelease(path);
852 }
double d
Definition: qnumeric_p.h:62
static CGMutablePathRef qt_mac_compose_path(const QPainterPath &p, float off=0)
QPaintEngineState * state
Definition: qpaintengine.h:239
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
unsigned char uchar
Definition: qglobal.h:994
bool isActive() const
Returns true if the paint engine is actively drawing; otherwise returns false.
Definition: qpaintengine.h:154
QPainter::CompositionMode compositionMode() const
Returns the composition mode in the current paint engine state.
Definition: qpainter.cpp:9503

◆ drawPixmap()

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

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

Implements QPaintEngine.

Definition at line 968 of file qpaintengine_mac.cpp.

969 {
971  Q_ASSERT(isActive());
972 
974  return;
975 
976  if(pm.isNull())
977  return;
978 
979  bool differentSize = (QRectF(0, 0, pm.width(), pm.height()) != sr), doRestore = false;
980  CGRect rect = CGRectMake(r.x(), r.y(), r.width(), r.height());
981  QCFType<CGImageRef> image;
982  bool isBitmap = (pm.depth() == 1);
983  if (isBitmap) {
984  doRestore = true;
985  d->saveGraphicsState();
986 
987  const QColor &col = d->current.pen.color();
988  CGContextSetFillColorWithColor(d->hd, cgColorForQColor(col, d->pdev));
989  image = qt_mac_create_imagemask(pm, sr);
990  } else if (differentSize) {
992  image = CGImageCreateWithImageInRect(img, CGRectMake(qRound(sr.x()), qRound(sr.y()), qRound(sr.width()), qRound(sr.height())));
993  } else {
994  image = (CGImageRef)pm.macCGHandle();
995  }
996  qt_mac_drawCGImage(d->hd, &rect, image);
997  if (doRestore)
998  d->restoreGraphicsState();
999 }
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
double d
Definition: qnumeric_p.h:62
static QCFType< CGColorRef > cgColorForQColor(const QColor &col, QPaintDevice *pdev)
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
QPaintEngineState * state
Definition: qpaintengine.h:239
struct CGImage * CGImageRef
int depth() const
Returns the depth of the pixmap.
Definition: qpixmap.cpp:695
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
CGImageRef qt_mac_create_imagemask(const QPixmap &px, const QRectF &sr)
bool isActive() const
Returns true if the paint engine is actively drawing; otherwise returns false.
Definition: qpaintengine.h:154
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
QPainter::CompositionMode compositionMode() const
Returns the composition mode in the current paint engine state.
Definition: qpainter.cpp:9503
qreal width() const
Returns the width of the rectangle.
Definition: qrect.h:707
struct CGRect CGRect
qreal x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:664
OSStatus qt_mac_drawCGImage(CGContextRef inContext, const CGRect *inBounds, CGImageRef inImage)
int height() const
Returns the height of the pixmap.
Definition: qpixmap.cpp:645
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
Definition: qpixmap.cpp:615
CGImageRef toMacCGImageRef() const
Creates a CGImageRef equivalent to the QPixmap.
Q_DECL_CONSTEXPR int qRound(qreal d)
Definition: qglobal.h:1203

◆ drawPoints() [1/2]

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

Draws the first pointCount points in the buffer points.

Reimplemented from QPaintEngine.

Definition at line 875 of file qpaintengine_mac.cpp.

876 {
878  Q_ASSERT(isActive());
879 
881  return;
882 
883  if (d->current.pen.capStyle() == Qt::FlatCap)
884  CGContextSetLineCap(d->hd, kCGLineCapSquare);
885 
886  CGMutablePathRef path = CGPathCreateMutable();
887  for(int i=0; i < pointCount; i++) {
888  float x = points[i].x(), y = points[i].y();
889  CGPathMoveToPoint(path, 0, x, y);
890  CGPathAddLineToPoint(path, 0, x+0.001, y);
891  }
892 
893  bool doRestore = false;
895  //we don't want adjusted pens for point rendering
896  doRestore = true;
897  d->saveGraphicsState();
898  CGContextSetLineWidth(d->hd, d->current.pen.widthF());
899  }
901  if (doRestore)
902  d->restoreGraphicsState();
903  CGPathRelease(path);
904  if (d->current.pen.capStyle() == Qt::FlatCap)
905  CGContextSetLineCap(d->hd, kCGLineCapButt);
906 }
double d
Definition: qnumeric_p.h:62
QPaintEngineState * state
Definition: qpaintengine.h:239
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
bool isActive() const
Returns true if the paint engine is actively drawing; otherwise returns false.
Definition: qpaintengine.h:154
QPainter::CompositionMode compositionMode() const
Returns the composition mode in the current paint engine state.
Definition: qpainter.cpp:9503
QPainter::RenderHints renderHints() const
Returns the render hints in the current paint engine state.
Definition: qpainter.cpp:9488
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287

◆ drawPoints() [2/2]

void QCoreGraphicsPaintEngine::drawPoints ( const QPoint points,
int  pointCount 
)
inlinevirtual

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.

Definition at line 120 of file qpaintengine_mac_p.h.

120 { QPaintEngine::drawPoints(p, pointCount); }
virtual void drawPoints(const QPointF *points, int pointCount)
Draws the first pointCount points in the buffer points.

◆ drawPolygon() [1/2]

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

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

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

Reimplemented from QPaintEngine.

Definition at line 927 of file qpaintengine_mac.cpp.

928 {
930  Q_ASSERT(isActive());
931 
933  return;
934 
935  CGMutablePathRef path = CGPathCreateMutable();
936  CGPathMoveToPoint(path, 0, points[0].x(), points[0].y());
937  for(int x = 1; x < pointCount; ++x)
938  CGPathAddLineToPoint(path, 0, points[x].x(), points[x].y());
939  if(mode != PolylineMode && points[0] != points[pointCount-1])
940  CGPathAddLineToPoint(path, 0, points[0].x(), points[0].y());
942  if (mode != PolylineMode)
945  d->drawPath(op, path);
946  CGPathRelease(path);
947 }
double d
Definition: qnumeric_p.h:62
QPaintEngineState * state
Definition: qpaintengine.h:239
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
bool isActive() const
Returns true if the paint engine is actively drawing; otherwise returns false.
Definition: qpaintengine.h:154
QPainter::CompositionMode compositionMode() const
Returns the composition mode in the current paint engine state.
Definition: qpainter.cpp:9503
unsigned int uint
Definition: qglobal.h:996

◆ drawPolygon() [2/2]

void QCoreGraphicsPaintEngine::drawPolygon ( const QPoint points,
int  pointCount,
PolygonDrawMode  mode 
)
inlinevirtual

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.

Definition at line 122 of file qpaintengine_mac_p.h.

123  { QPaintEngine::drawPolygon(points, pointCount, mode); }
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...

◆ drawRects() [1/2]

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

Definition at line 855 of file qpaintengine_mac.cpp.

856 {
858  Q_ASSERT(isActive());
859 
861  return;
862 
863  for (int i=0; i<rectCount; ++i) {
864  QRectF r = rects[i];
865 
866  CGMutablePathRef path = CGPathCreateMutable();
867  CGPathAddRect(path, 0, qt_mac_compose_rect(r));
869  path);
870  CGPathRelease(path);
871  }
872 }
double d
Definition: qnumeric_p.h:62
QPaintEngineState * state
Definition: qpaintengine.h:239
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
bool isActive() const
Returns true if the paint engine is actively drawing; otherwise returns false.
Definition: qpaintengine.h:154
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
QPainter::CompositionMode compositionMode() const
Returns the composition mode in the current paint engine state.
Definition: qpainter.cpp:9503
static CGRect qt_mac_compose_rect(const QRectF &r, float off=0)

◆ drawRects() [2/2]

void QCoreGraphicsPaintEngine::drawRects ( const QRect rects,
int  rectCount 
)
inlinevirtual

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.

Definition at line 119 of file qpaintengine_mac_p.h.

119 { QPaintEngine::drawRects(rects, rectCount); }
virtual void drawRects(const QRect *rects, int rectCount)
The default implementation converts the first rectCount rectangles in the buffer rects to a QRectF an...

◆ drawTextItem()

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

This function draws the text item textItem at position p.

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

Reimplemented from QPaintEngine.

Definition at line 1126 of file qpaintengine_mac.cpp.

1127 {
1129  if (d->current.transform.type() == QTransform::TxProject
1130 #ifndef QMAC_NATIVE_GRADIENTS
1131  || painter()->pen().brush().gradient() //Just let the base engine "emulate" the gradient
1132 #endif
1133  ) {
1134  QPaintEngine::drawTextItem(pos, item);
1135  return;
1136  }
1137 
1139  return;
1140 
1141  const QTextItemInt &ti = static_cast<const QTextItemInt &>(item);
1142 
1143  QPen oldPen = painter()->pen();
1144  QBrush oldBrush = painter()->brush();
1145  QPointF oldBrushOrigin = painter()->brushOrigin();
1147  updateBrush(oldPen.brush(), QPointF(0, 0));
1148 
1150 
1151  QFontEngine *fe = ti.fontEngine;
1152 
1154  const bool lineAA = state->renderHints() & QPainter::Antialiasing;
1155  if(textAA != lineAA)
1156  CGContextSetShouldAntialias(d->hd, textAA);
1157 
1158  if (ti.glyphs.numGlyphs) {
1159  switch (fe->type()) {
1160  case QFontEngine::Mac:
1161 #ifdef QT_MAC_USE_COCOA
1162  static_cast<QCoreTextFontEngine *>(fe)->draw(d->hd, pos.x(), pos.y(), ti, paintDevice()->height());
1163 #else
1164  static_cast<QFontEngineMac *>(fe)->draw(d->hd, pos.x(), pos.y(), ti, paintDevice()->height());
1165 #endif
1166  break;
1167  case QFontEngine::Box:
1168  d->drawBoxTextItem(pos, ti);
1169  break;
1170  default:
1171  break;
1172  }
1173  }
1174 
1175  if(textAA != lineAA)
1176  CGContextSetShouldAntialias(d->hd, !textAA);
1177 
1178  updatePen(oldPen);
1179  updateBrush(oldBrush, oldBrushOrigin);
1180 }
double d
Definition: qnumeric_p.h:62
QFontEngine * fontEngine
QPaintDevice * paintDevice() const
Returns the device that this engine is painting on, if painting is active; otherwise returns 0...
const QGradient * gradient() const
Returns the gradient describing this brush.
Definition: qbrush.cpp:871
qreal pointSize
Definition: qfont_p.h:89
QPaintEngineState * state
Definition: qpaintengine.h:239
int qt_antialiasing_threshold
int height() const
Definition: qpaintdevice.h:92
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
void updatePen(const QPen &pen)
void updateBrush(const QBrush &brush, const QPointF &pt)
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
The QPen class defines how a QPainter should draw lines and outlines of shapes.
Definition: qpen.h:64
virtual Type type() const =0
QGlyphLayout glyphs
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
QPoint brushOrigin() const
Returns the currently set brush origin.
Definition: qpainter.cpp:2168
Internal QTextItem.
QPainter::CompositionMode compositionMode() const
Returns the composition mode in the current paint engine state.
Definition: qpainter.cpp:9503
Type type() const
Reimplement this function to return the paint engine Type.
QBrush brush() const
Returns the brush used to fill strokes generated with this pen.
Definition: qpen.cpp:797
const QBrush & brush() const
Returns the painter&#39;s current brush.
Definition: qpainter.cpp:4232
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
QPainter::RenderHints renderHints() const
Returns the render hints in the current paint engine state.
Definition: qpainter.cpp:9488
QFontDef fontDef
uint styleStrategy
Definition: qfont_p.h:92
virtual void drawTextItem(const QPointF &p, const QTextItem &textItem)
This function draws the text item textItem at position p.

◆ drawTiledPixmap()

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

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

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

Reimplemented from QPaintEngine.

Definition at line 1082 of file qpaintengine_mac.cpp.

1084 {
1086  Q_ASSERT(isActive());
1087 
1089  return;
1090 
1091  //save the old state
1092  d->saveGraphicsState();
1093 
1094  //setup the pattern
1095  QMacPattern *qpattern = new QMacPattern;
1096  qpattern->data.pixmap = pixmap;
1097  qpattern->foreground = d->current.pen.color();
1098  qpattern->pdev = d->pdev;
1099  CGPatternCallbacks callbks;
1100  callbks.version = 0;
1101  callbks.drawPattern = qt_mac_draw_pattern;
1102  callbks.releaseInfo = qt_mac_dispose_pattern;
1103  const int width = qpattern->width(), height = qpattern->height();
1104  CGAffineTransform trans = CGContextGetCTM(d->hd);
1105  CGPatternRef pat = CGPatternCreate(qpattern, CGRectMake(0, 0, width, height),
1106  trans, width, height,
1107  kCGPatternTilingNoDistortion, true, &callbks);
1108  CGColorSpaceRef cs = CGColorSpaceCreatePattern(0);
1109  CGContextSetFillColorSpace(d->hd, cs);
1110  CGFloat component = 1.0; //just one
1111  CGContextSetFillPattern(d->hd, pat, &component);
1112  CGSize phase = CGSizeApplyAffineTransform(CGSizeMake(-(p.x()-r.x()), -(p.y()-r.y())), trans);
1113  CGContextSetPatternPhase(d->hd, phase);
1114 
1115  //fill the rectangle
1116  CGRect mac_rect = CGRectMake(r.x(), r.y(), r.width(), r.height());
1117  CGContextFillRect(d->hd, mac_rect);
1118 
1119  //restore the state
1120  d->restoreGraphicsState();
1121  //cleanup
1122  CGColorSpaceRelease(cs);
1123  CGPatternRelease(pat);
1124 }
double d
Definition: qnumeric_p.h:62
QPaintEngineState * state
Definition: qpaintengine.h:239
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
struct QMacPattern::@240 data
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
bool isActive() const
Returns true if the paint engine is actively drawing; otherwise returns false.
Definition: qpaintengine.h:154
QPainter::CompositionMode compositionMode() const
Returns the composition mode in the current paint engine state.
Definition: qpainter.cpp:9503
static qreal component(const QPointF &point, unsigned int i)
static void qt_mac_dispose_pattern(void *info)
static void qt_mac_draw_pattern(void *info, CGContextRef c)
QPaintDevice * pdev
struct CGRect CGRect
struct CGColorSpace * CGColorSpaceRef
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287
float CGFloat

◆ end()

bool QCoreGraphicsPaintEngine::end ( )
virtual

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

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

See also
begin() isActive()

Implements QPaintEngine.

Definition at line 615 of file qpaintengine_mac.cpp.

Referenced by begin(), and drawLines().

616 {
618  setActive(false);
619  if(d->pdev->devType() == QInternal::Widget && static_cast<QWidget*>(d->pdev)->windowType() == Qt::Desktop) {
620 #ifndef QT_MAC_USE_COCOA
621  HideWindow(qt_mac_window_for(static_cast<QWidget*>(d->pdev)));
622 #else
623 // // ### need to do [qt_mac_window_for(static_cast<QWidget *>(d->pdev)) orderOut]; (need to rename)
624 #endif
625 
626  }
627  if(d->shading) {
628  CGShadingRelease(d->shading);
629  d->shading = 0;
630  }
631  d->pdev = 0;
632  if(d->hd) {
633  d->restoreGraphicsState();
634  CGContextSynchronize(d->hd);
635  CGContextRelease(d->hd);
636  d->hd = 0;
637  }
638  return true;
639 }
double d
Definition: qnumeric_p.h:62
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
void setActive(bool newState)
Sets the active state of the paint engine to state.
Definition: qpaintengine.h:155
OSWindowRef qt_mac_window_for(const QWidget *)
Definition: qwidget_mac.mm:484

◆ handle()

CGContextRef QCoreGraphicsPaintEngine::handle ( ) const

Definition at line 1076 of file qpaintengine_mac.cpp.

Referenced by type().

1077 {
1078  return d_func()->hd;
1079 }

◆ initialize()

void QCoreGraphicsPaintEngine::initialize ( )
static

Definition at line 1062 of file qpaintengine_mac.cpp.

Referenced by qt_init(), and type().

1063 {
1064 }

◆ macDisplayColorSpace()

CGColorSpaceRef QCoreGraphicsPaintEngine::macDisplayColorSpace ( const QWidget widget = 0)
static

Definition at line 319 of file qpaintengine_mac.cpp.

Referenced by QMacPixmapData::macCreateCGImageRef(), qt_mac_colorSpaceForDeviceType(), and QNativeImage::systemFormat().

320 {
321  // The color space depends on which screen the widget's window is on.
322  // widget == 0 is a spacial case where we use the main display.
323  QWidget *window = widget ? widget->window() : 0;
324 
325  // Check for cached color space and return if found.
326  if (m_displayColorSpaceHash.contains(window))
327  return m_displayColorSpaceHash.value(window);
328 
329  // Find which display the window is on.
330  CGDirectDisplayID displayID;
331  if (window == 0) {
332  displayID = CGMainDisplayID();
333  } else {
334  const QRect &qrect = window->geometry();
335  CGRect rect = CGRectMake(qrect.x(), qrect.y(), qrect.width(), qrect.height());
336  CGDisplayCount throwAway;
337  CGDisplayErr dErr = CGGetDisplaysWithRect(rect, 1, &displayID, &throwAway);
338  if (dErr != kCGErrorSuccess)
339  displayID = CGMainDisplayID();
340  }
341 
342  // Get the color space from the display profile.
343  CGColorSpaceRef colorSpace = 0;
344  CMProfileRef displayProfile = 0;
345  CMError err = CMGetProfileByAVID((CMDisplayIDType)displayID, &displayProfile);
346  if (err == noErr) {
347  colorSpace = CGColorSpaceCreateWithPlatformColorSpace(displayProfile);
348  CMCloseProfile(displayProfile);
349  }
350 
351  // Fallback: use generic DeviceRGB
352  if (colorSpace == 0)
353  colorSpace = CGColorSpaceCreateDeviceRGB();
354 
355  // Install cleanup routines
359  }
360 
361  // Cache and return.
362  m_displayColorSpaceHash.insert(window, colorSpace);
363  return colorSpace;
364 }
void qAddPostRoutine(QtCleanUpFunction p)
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
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
bool contains(const Key &key) const
Returns true if the hash contains an item with the key; otherwise returns false.
Definition: qhash.h:872
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:753
NSWindow * window
struct CGRect CGRect
static QHash< QWidget *, CGColorSpaceRef > m_displayColorSpaceHash
struct CGColorSpace * CGColorSpaceRef
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
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
QRect geometry
the geometry of the widget relative to its parent and excluding the window frame
Definition: qwidget.h:158

◆ macGenericColorSpace()

CGColorSpaceRef QCoreGraphicsPaintEngine::macGenericColorSpace ( )
static

Definition at line 295 of file qpaintengine_mac.cpp.

Referenced by QMacStyle::drawComplexControl(), QMacStyle::drawControl(), QFontEngineMac::imageForGlyph(), qt_mac_createCGImageFromQImage(), qt_mac_grabScreenRect(), qt_mac_image_to_cgimage(), and QCoreGraphicsPaintEnginePrivate::setFillBrush().

296 {
297 #if 0
298  if (!m_genericColorSpace) {
299 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
301  m_genericColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
302  } else
303 #endif
304  {
305  m_genericColorSpace = CGColorSpaceCreateDeviceRGB();
306  }
310  }
311  }
312  return m_genericColorSpace;
313 #else
314  // Just return the main display colorspace for the moment.
315  return macDisplayColorSpace();
316 #endif
317 }
static CGColorSpaceRef macDisplayColorSpace(const QWidget *widget=0)
void qAddPostRoutine(QtCleanUpFunction p)
static CGColorSpaceRef m_genericColorSpace
static const MacVersion MacintoshVersion
the version of the Macintosh operating system on which the application is run (Mac only)...
Definition: qglobal.h:1646

◆ supportedRenderHints()

QPainter::RenderHints QCoreGraphicsPaintEngine::supportedRenderHints ( ) const

◆ supportsTransformations()

bool QCoreGraphicsPaintEngine::supportsTransformations ( qreal  ,
const QTransform  
) const
inline

Definition at line 125 of file qpaintengine_mac_p.h.

125 { return true; };

◆ type()

Type QCoreGraphicsPaintEngine::type ( ) const
inlinevirtual

Reimplement this function to return the paint engine Type.

Implements QPaintEngine.

Definition at line 107 of file qpaintengine_mac_p.h.

Referenced by drawTextItem().

◆ updateBrush()

void QCoreGraphicsPaintEngine::updateBrush ( const QBrush brush,
const QPointF pt 
)

Definition at line 712 of file qpaintengine_mac.cpp.

Referenced by drawTextItem(), and updateState().

713 {
715  Q_ASSERT(isActive());
716  d->current.brush = brush;
717 
718 #ifdef QT_MAC_USE_NATIVE_GRADIENTS
719  // Quartz supports only pad spread
720  if (const QGradient *gradient = brush.gradient()) {
721  if (drawGradientNatively(gradient)) {
723  } else {
725  }
726  }
727 #endif
728 
729  if (d->shading) {
730  CGShadingRelease(d->shading);
731  d->shading = 0;
732  }
733  d->setFillBrush(brushOrigin);
734 }
double d
Definition: qnumeric_p.h:62
const QGradient * gradient() const
Returns the gradient describing this brush.
Definition: qbrush.cpp:871
PaintEngineFeatures gccaps
Definition: qpaintengine.h:240
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
bool isActive() const
Returns true if the paint engine is actively drawing; otherwise returns false.
Definition: qpaintengine.h:154
The QGradient class is used in combination with QBrush to specify gradient fills. ...
Definition: qbrush.h:201

◆ updateClipPath()

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

Definition at line 770 of file qpaintengine_mac.cpp.

Referenced by updateState().

771 {
773  Q_ASSERT(isActive());
774  if(op == Qt::NoClip) {
775  if(d->current.clipEnabled) {
776  d->current.clipEnabled = false;
777  d->current.clip = QRegion();
778  d->setClip(0);
779  }
780  } else {
781  if(!d->current.clipEnabled)
782  op = Qt::ReplaceClip;
783  d->current.clipEnabled = true;
784  QRegion clipRegion(p.toFillPolygon().toPolygon(), p.fillRule());
785  if(op == Qt::ReplaceClip) {
786  d->current.clip = clipRegion;
787  d->setClip(0);
788  if(p.isEmpty()) {
789  CGRect rect = CGRectMake(0, 0, 0, 0);
790  CGContextClipToRect(d->hd, rect);
791  } else {
792  CGMutablePathRef path = qt_mac_compose_path(p);
793  CGContextBeginPath(d->hd);
794  CGContextAddPath(d->hd, path);
795  if(p.fillRule() == Qt::WindingFill)
796  CGContextClip(d->hd);
797  else
798  CGContextEOClip(d->hd);
799  CGPathRelease(path);
800  }
801  } else if(op == Qt::IntersectClip) {
802  d->current.clip = d->current.clip.intersected(clipRegion);
803  d->setClip(&d->current.clip);
804  } else if(op == Qt::UniteClip) {
805  d->current.clip = d->current.clip.united(clipRegion);
806  d->setClip(&d->current.clip);
807  }
808  }
809 }
double d
Definition: qnumeric_p.h:62
static CGMutablePathRef qt_mac_compose_path(const QPainterPath &p, float off=0)
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
bool isActive() const
Returns true if the paint engine is actively drawing; otherwise returns false.
Definition: qpaintengine.h:154
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
struct CGRect CGRect

◆ updateClipRegion()

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

Definition at line 812 of file qpaintengine_mac.cpp.

Referenced by updateState().

813 {
815  Q_ASSERT(isActive());
816  if(op == Qt::NoClip) {
817  d->current.clipEnabled = false;
818  d->current.clip = QRegion();
819  d->setClip(0);
820  } else {
821  if(!d->current.clipEnabled)
822  op = Qt::ReplaceClip;
823  d->current.clipEnabled = true;
824  if(op == Qt::IntersectClip)
825  d->current.clip = d->current.clip.intersected(clipRegion);
826  else if(op == Qt::ReplaceClip)
827  d->current.clip = clipRegion;
828  else if(op == Qt::UniteClip)
829  d->current.clip = d->current.clip.united(clipRegion);
830  d->setClip(&d->current.clip);
831  }
832 }
double d
Definition: qnumeric_p.h:62
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
bool isActive() const
Returns true if the paint engine is actively drawing; otherwise returns false.
Definition: qpaintengine.h:154
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68

◆ updateCompositionMode()

void QCoreGraphicsPaintEngine::updateCompositionMode ( QPainter::CompositionMode  mode)

Definition at line 1206 of file qpaintengine_mac.cpp.

Referenced by updateState().

1207 {
1208 #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
1210  int cg_mode = kCGBlendModeNormal;
1211  switch(mode) {
1213  cg_mode = kCGBlendModeMultiply;
1214  break;
1216  cg_mode = kCGBlendModeScreen;
1217  break;
1219  cg_mode = kCGBlendModeOverlay;
1220  break;
1222  cg_mode = kCGBlendModeDarken;
1223  break;
1225  cg_mode = kCGBlendModeLighten;
1226  break;
1228  cg_mode = kCGBlendModeColorDodge;
1229  break;
1231  cg_mode = kCGBlendModeColorBurn;
1232  break;
1234  cg_mode = kCGBlendModeHardLight;
1235  break;
1237  cg_mode = kCGBlendModeSoftLight;
1238  break;
1240  cg_mode = kCGBlendModeDifference;
1241  break;
1243  cg_mode = kCGBlendModeExclusion;
1244  break;
1246  cg_mode = kCGBlendModePlusLighter;
1247  break;
1249  cg_mode = kCGBlendModeNormal;
1250  break;
1252  cg_mode = kCGBlendModeDestinationOver;
1253  break;
1255  cg_mode = kCGBlendModeClear;
1256  break;
1258  cg_mode = kCGBlendModeCopy;
1259  break;
1261  cg_mode = -1;
1262  break;
1264  cg_mode = kCGBlendModeSourceIn;
1265  break;
1268  break;
1270  cg_mode = kCGBlendModeSourceOut;
1271  break;
1273  cg_mode = kCGBlendModeDestinationOver;
1274  break;
1276  cg_mode = kCGBlendModeSourceAtop;
1277  break;
1279  cg_mode = kCGBlendModeDestinationAtop;
1280  break;
1282  cg_mode = kCGBlendModeXOR;
1283  break;
1284  default:
1285  break;
1286  }
1287  if (cg_mode > -1) {
1288  CGContextSetBlendMode(d_func()->hd, CGBlendMode(cg_mode));
1289  }
1290  } else
1291 #endif
1292  // The standard porter duff ops.
1294  && mode <= QPainter::CompositionMode_Xor) {
1295  int cg_mode = kCGCompositeModeCopy;
1296  switch (mode) {
1298  cg_mode = kCGCompositeModeSourceOver;
1299  break;
1302  break;
1304  cg_mode = kCGCompositeModeClear;
1305  break;
1306  default:
1307  qWarning("QCoreGraphicsPaintEngine: Unhandled composition mode %d", (int)mode);
1308  break;
1310  cg_mode = kCGCompositeModeCopy;
1311  break;
1313  cg_mode = CGCompositeMode(-1);
1314  break;
1316  cg_mode = kCGCompositeModeSourceIn;
1317  break;
1320  break;
1322  cg_mode = kCGCompositeModeSourceOut;
1323  break;
1326  break;
1328  cg_mode = kCGCompositeModeSourceAtop;
1329  break;
1332  break;
1334  cg_mode = kCGCompositeModeXOR;
1335  break;
1336  }
1337  if (cg_mode > -1)
1338  CGContextSetCompositeOperation(d_func()->hd, CGCompositeMode(cg_mode));
1339  } else {
1340 #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4)
1341  bool needPrivateAPI = false;
1343  int cg_mode = kCGBlendModeNormal;
1344  switch (mode) {
1346  cg_mode = kCGBlendModeMultiply;
1347  break;
1349  cg_mode = kCGBlendModeScreen;
1350  break;
1352  cg_mode = kCGBlendModeOverlay;
1353  break;
1355  cg_mode = kCGBlendModeDarken;
1356  break;
1358  cg_mode = kCGBlendModeLighten;
1359  break;
1361  cg_mode = kCGBlendModeColorDodge;
1362  break;
1364  cg_mode = kCGBlendModeColorBurn;
1365  break;
1367  cg_mode = kCGBlendModeHardLight;
1368  break;
1370  cg_mode = kCGBlendModeSoftLight;
1371  break;
1373  cg_mode = kCGBlendModeDifference;
1374  break;
1376  cg_mode = kCGBlendModeExclusion;
1377  break;
1379  needPrivateAPI = true;
1380  cg_mode = kCGCompositeModePlusLighter;
1381  break;
1382  default:
1383  break;
1384  }
1385  if (!needPrivateAPI)
1386  CGContextSetBlendMode(d_func()->hd, CGBlendMode(cg_mode));
1387  else
1388  CGContextSetCompositeOperation(d_func()->hd, CGCompositeMode(cg_mode));
1389  }
1390 #endif
1391  }
1392 }
CGCompositeMode
Q_CORE_EXPORT void qWarning(const char *,...)
void CGContextSetCompositeOperation(CGContextRef, int)
static const MacVersion MacintoshVersion
the version of the Macintosh operating system on which the application is run (Mac only)...
Definition: qglobal.h:1646

◆ updateFont()

void QCoreGraphicsPaintEngine::updateFont ( const QFont font)

Definition at line 744 of file qpaintengine_mac.cpp.

Referenced by updateState().

745 {
747  Q_ASSERT(isActive());
748  updatePen(d->current.pen);
749 }
double d
Definition: qnumeric_p.h:62
void updatePen(const QPen &pen)
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
bool isActive() const
Returns true if the paint engine is actively drawing; otherwise returns false.
Definition: qpaintengine.h:154

◆ updateMatrix()

void QCoreGraphicsPaintEngine::updateMatrix ( const QTransform matrix)

Definition at line 752 of file qpaintengine_mac.cpp.

Referenced by updateState().

753 {
755  Q_ASSERT(isActive());
756 
757  if (qt_is_nan(transform.m11()) || qt_is_nan(transform.m12()) || qt_is_nan(transform.m13())
758  || qt_is_nan(transform.m21()) || qt_is_nan(transform.m22()) || qt_is_nan(transform.m23())
759  || qt_is_nan(transform.m31()) || qt_is_nan(transform.m32()) || qt_is_nan(transform.m33()))
760  return;
761 
762  d->current.transform = transform;
763  d->setTransform(transform.isIdentity() ? 0 : &transform);
764  d->complexXForm = (transform.m11() != 1 || transform.m22() != 1
765  || transform.m12() != 0 || transform.m21() != 0);
766  d->pixelSize = d->devicePixelSize(d->hd);
767 }
double d
Definition: qnumeric_p.h:62
static bool qt_is_nan(double d)
Definition: qnumeric_p.h:183
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
bool isActive() const
Returns true if the paint engine is actively drawing; otherwise returns false.
Definition: qpaintengine.h:154

◆ updateOpacity()

void QCoreGraphicsPaintEngine::updateOpacity ( qreal  opacity)

Definition at line 737 of file qpaintengine_mac.cpp.

Referenced by updateState().

738 {
740  CGContextSetAlpha(d->hd, opacity);
741 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ updatePen()

void QCoreGraphicsPaintEngine::updatePen ( const QPen pen)

Definition at line 703 of file qpaintengine_mac.cpp.

Referenced by drawTextItem(), updateFont(), and updateState().

704 {
706  Q_ASSERT(isActive());
707  d->current.pen = pen;
708  d->setStrokePen(pen);
709 }
double d
Definition: qnumeric_p.h:62
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
bool isActive() const
Returns true if the paint engine is actively drawing; otherwise returns false.
Definition: qpaintengine.h:154

◆ updateRenderHints()

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

Definition at line 1395 of file qpaintengine_mac.cpp.

Referenced by updateState().

1396 {
1398  CGContextSetShouldAntialias(d->hd, hints & QPainter::Antialiasing);
1399  static const CGFloat ScaleFactor = qt_mac_get_scalefactor();
1400  if (ScaleFactor > 1.) {
1401  CGContextSetInterpolationQuality(d->hd, kCGInterpolationHigh);
1402  } else {
1403  CGContextSetInterpolationQuality(d->hd, (hints & QPainter::SmoothPixmapTransform) ?
1404  kCGInterpolationHigh : kCGInterpolationNone);
1405  }
1406  bool textAntialiasing = (hints & QPainter::TextAntialiasing) == QPainter::TextAntialiasing;
1407  if (!textAntialiasing || d->disabledSmoothFonts) {
1408  d->disabledSmoothFonts = !textAntialiasing;
1409  CGContextSetShouldSmoothFonts(d->hd, textAntialiasing);
1410  }
1411 }
double d
Definition: qnumeric_p.h:62
CGFloat qt_mac_get_scalefactor()
#define Q_D(Class)
Definition: qglobal.h:2482
float CGFloat

◆ updateState()

void QCoreGraphicsPaintEngine::updateState ( const QPaintEngineState state)
virtual

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

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

See also
QPaintEngineState

Implements QPaintEngine.

Definition at line 642 of file qpaintengine_mac.cpp.

643 {
645  QPaintEngine::DirtyFlags flags = state.state();
646 
647  if (flags & DirtyTransform)
648  updateMatrix(state.transform());
649 
650  if (flags & DirtyClipEnabled) {
651  if (state.isClipEnabled())
653  else
655  }
656 
657  if (flags & DirtyClipPath) {
658  updateClipPath(state.clipPath(), state.clipOperation());
659  } else if (flags & DirtyClipRegion) {
660  updateClipRegion(state.clipRegion(), state.clipOperation());
661  }
662 
663  // If the clip has changed we need to update all other states
664  // too, since they are included in the system context on OSX,
665  // and changing the clip resets that context back to scratch.
666  if (flags & (DirtyClipPath | DirtyClipRegion | DirtyClipEnabled))
667  flags |= AllDirty;
668 
669  if (flags & DirtyPen)
670  updatePen(state.pen());
671  if (flags & (DirtyBrush|DirtyBrushOrigin))
672  updateBrush(state.brush(), state.brushOrigin());
673  if (flags & DirtyFont)
674  updateFont(state.font());
675  if (flags & DirtyOpacity)
676  updateOpacity(state.opacity());
677  if (flags & DirtyHints)
679  if (flags & DirtyCompositionMode)
681 
682  if (flags & (DirtyPen | DirtyTransform)) {
683  if (!d->current.pen.isCosmetic()) {
685  } else if (d->current.transform.m11() < d->current.transform.m22()-1.0 ||
686  d->current.transform.m11() > d->current.transform.m22()+1.0) {
688  d->cosmeticPenSize = d->adjustPenWidth(d->current.pen.widthF());
689  if (!d->cosmeticPenSize)
690  d->cosmeticPenSize = 1.0;
691  } else {
693  static const float sqrt2 = sqrt(2);
694  qreal width = d->current.pen.widthF();
695  if (!width)
696  width = 1;
697  d->cosmeticPenSize = sqrt(pow(d->pixelSize.y(), 2) + pow(d->pixelSize.x(), 2)) / sqrt2 * width;
698  }
699  }
700 }
QPainterPath clipPath() const
Returns the currently clip as a path.
Definition: qpainter.cpp:2690
double d
Definition: qnumeric_p.h:62
QPaintEngine::DirtyFlags state() const
Returns a combination of flags identifying the set of properties that need to be updated when updatin...
Definition: qpaintengine.h:292
double qreal
Definition: qglobal.h:1193
qreal opacity() const
Returns the opacity in the current paint engine state.
Definition: qpainter.cpp:9529
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:67
void updateRenderHints(QPainter::RenderHints hints)
QTransform transform() const
Returns the matrix in the current paint engine state.
Definition: qpainter.cpp:9377
void updateClipPath(const QPainterPath &path, Qt::ClipOperation op)
void updatePen(const QPen &pen)
void updateBrush(const QBrush &brush, const QPointF &pt)
bool isClipEnabled() const
Returns whether clipping is enabled or not in the current paint engine state.
Definition: qpainter.cpp:9473
#define Q_D(Class)
Definition: qglobal.h:2482
void updateClipRegion(const QRegion &region, Qt::ClipOperation op)
QPainter * painter() const
Returns the paint engine&#39;s painter.
QBrush brush() const
Returns the brush in the current paint engine state.
Definition: qpainter.cpp:9273
void updateCompositionMode(QPainter::CompositionMode mode)
void updateMatrix(const QTransform &matrix)
Qt::ClipOperation clipOperation() const
Returns the clip operation in the current paint engine state.
Definition: qpainter.cpp:9396
QPointF brushOrigin() const
Returns the brush origin in the current paint engine state.
Definition: qpainter.cpp:9287
void updateOpacity(qreal opacity)
QFont font() const
Returns the font in the current paint engine state.
Definition: qpainter.cpp:9331
QPainter::CompositionMode compositionMode() const
Returns the composition mode in the current paint engine state.
Definition: qpainter.cpp:9503
QPainterPath clipPath() const
Returns the clip path in the current paint engine state.
Definition: qpainter.cpp:9457
void updateFont(const QFont &font)
QPainter::RenderHints renderHints() const
Returns the render hints in the current paint engine state.
Definition: qpainter.cpp:9488
QRegion clipRegion() const
Returns the clip region in the current paint engine state.
Definition: qpainter.cpp:9443
QPen pen() const
Returns the pen in the current paint engine state.
Definition: qpainter.cpp:9259

◆ updateTransform()

void QCoreGraphicsPaintEngine::updateTransform ( const QTransform matrix)

Friends and Related Functions

◆ QMacPrintEngine

friend class QMacPrintEngine
friend

Definition at line 125 of file qpaintengine_mac_p.h.

◆ QMacPrintEnginePrivate

Definition at line 129 of file qpaintengine_mac_p.h.

◆ qt_color_profile_changed

void qt_color_profile_changed ( CFNotificationCenterRef  center,
void *  ,
CFStringRef  ,
const void *  ,
CFDictionaryRef   
)
friend

Definition at line 1122 of file qapplication_mac.mm.

◆ qt_mac_display_change_callbk

void qt_mac_display_change_callbk ( CGDirectDisplayID  ,
CGDisplayChangeSummaryFlags  flags,
void *   
)
friend

Definition at line 352 of file qapplication_mac.mm.

353 {
354 #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
355  const bool resized = flags & kCGDisplayDesktopShapeChangedFlag;
356 #else
357  Q_UNUSED(flags);
358  const bool resized = true;
359 #endif
360  if (resized && qApp) {
361  if (QDesktopWidget *dw = qApp->desktop()) {
362  QResizeEvent *re = new QResizeEvent(dw->size(), dw->size());
363  QApplication::postEvent(dw, re);
365  }
366  }
367 }
static void postEvent(QObject *receiver, QEvent *event)
Adds the event event, with the object receiver as the receiver of the event, to an event queue and re...
#define qApp
The QResizeEvent class contains event parameters for resize events.
Definition: qevent.h:349
#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

Properties

◆ m_displayColorSpaceHash

QHash< QWidget *, CGColorSpaceRef > QCoreGraphicsPaintEngine::m_displayColorSpaceHash
staticprivate

Definition at line 138 of file qpaintengine_mac_p.h.

Referenced by clearColorSpace(), and qt_mac_compose_path().

◆ m_genericColorSpace

CGColorSpaceRef QCoreGraphicsPaintEngine::m_genericColorSpace = 0
staticprivate

Definition at line 137 of file qpaintengine_mac_p.h.

Referenced by qt_mac_compose_path().

◆ m_postRoutineRegistered

bool QCoreGraphicsPaintEngine::m_postRoutineRegistered = false
staticprivate

Definition at line 136 of file qpaintengine_mac_p.h.

Referenced by qt_mac_compose_path().


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