Qt 4.8
Public Functions | Properties | List of all members
QMacCGContext Class Reference

#include <qt_mac_p.h>

Public Functions

bool isNull () const
 
 operator CGContextRef ()
 
QMacCGContextoperator= (const QMacCGContext &copy)
 
QMacCGContextoperator= (CGContextRef cg)
 
 QMacCGContext (QPainter *p)
 
 QMacCGContext ()
 
 QMacCGContext (const QPaintDevice *pdev)
 
 QMacCGContext (CGContextRef cg, bool takeOwnership=false)
 
 QMacCGContext (const QMacCGContext &copy)
 
 ~QMacCGContext ()
 

Properties

CGContextRef context
 

Detailed Description

Definition at line 170 of file qt_mac_p.h.

Constructors and Destructors

◆ QMacCGContext() [1/5]

QMacCGContext::QMacCGContext ( QPainter p)

Definition at line 91 of file qpaintengine_mac.cpp.

92 {
93  QPaintEngine *pe = p->paintEngine();
94  if (pe->type() == QPaintEngine::MacPrinter)
95  pe = static_cast<QMacPrintEngine*>(pe)->paintEngine();
96  pe->syncState();
97  context = 0;
98  if(pe->type() == QPaintEngine::CoreGraphics)
99  context = static_cast<QCoreGraphicsPaintEngine*>(pe)->handle();
100 
101  int devType = p->device()->devType();
102  if (pe->type() == QPaintEngine::Raster
103  && (devType == QInternal::Widget || devType == QInternal::Pixmap || devType == QInternal::Image)) {
104 
107  uint flags = kCGImageAlphaPremultipliedFirst;
108 #ifdef kCGBitmapByteOrder32Host //only needed because CGImage.h added symbols in the minor version
109  flags |= kCGBitmapByteOrder32Host;
110 #endif
111  const QImage *image = (const QImage *) pe->paintDevice();
112 
113  context = CGBitmapContextCreate((void *) image->bits(), image->width(), image->height(),
114  8, image->bytesPerLine(), colorspace, flags);
115 
116  CGContextTranslateCTM(context, 0, image->height());
117  CGContextScaleCTM(context, 1, -1);
118 
119  if (devType == QInternal::Widget) {
120  QRegion clip = p->paintEngine()->systemClip();
121  QTransform native = p->deviceTransform();
122  QTransform logical = p->combinedTransform();
123 
124  if (p->hasClipping()) {
125  QRegion r = p->clipRegion();
126  r.translate(native.dx(), native.dy());
127  if (clip.isEmpty())
128  clip = r;
129  else
130  clip &= r;
131  }
132  qt_mac_clip_cg(context, clip, 0);
133 
134  CGContextTranslateCTM(context, native.dx(), native.dy());
135  }
136  } else {
137  CGContextRetain(context);
138  }
139 }
QPaintDevice * device() const
Returns the paint device on which this painter is currently painting, or 0 if the painter is not acti...
Definition: qpainter.cpp:1530
qreal dy() const
Returns the vertical translation factor.
Definition: qtransform.h:277
QPaintDevice * paintDevice() const
Returns the device that this engine is painting on, if painting is active; otherwise returns 0...
void syncState()
Updates all dirty states in this engine.
CGColorSpaceRef qt_mac_colorSpaceForDeviceType(const QPaintDevice *paintDevice)
int bytesPerLine() const
Returns the number of bytes per image scanline.
Definition: qimage.cpp:1812
virtual int devType() const
Definition: qpaintdevice.h:167
CGContextRef context
Definition: qt_mac_p.h:172
QRegion clipRegion() const
Returns the currently set clip region.
Definition: qpainter.cpp:2562
bool hasClipping() const
Returns true if clipping has been set; otherwise returns false.
Definition: qpainter.cpp:2499
bool isEmpty() const
Returns true if the region is empty; otherwise returns false.
Definition: qregion.cpp:4098
void qt_mac_clip_cg(CGContextRef hd, const QRegion &rgn, CGAffineTransform *orig_xform)
virtual Type type() const =0
Reimplement this function to return the paint engine Type.
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
unsigned int uint
Definition: qglobal.h:996
const QTransform & deviceTransform() const
Returns the matrix that transforms from logical coordinates to device coordinates of the platform dep...
Definition: qpainter.cpp:9579
QPaintEngine * paintEngine() const
Returns the paint engine that the painter is currently operating on if the painter is active; otherwi...
Definition: qpainter.cpp:1991
QTransform combinedTransform() const
Returns the transformation matrix combining the current window/viewport and world transformation...
Definition: qpainter.cpp:9669
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
The QPaintEngine class provides an abstract definition of how QPainter draws to a given device on a g...
Definition: qpaintengine.h:90
uchar * bits()
Returns a pointer to the first pixel data.
Definition: qimage.cpp:1946
int width() const
Returns the width of the image.
Definition: qimage.cpp:1557
struct CGColorSpace * CGColorSpaceRef
int height() const
Returns the height of the image.
Definition: qimage.cpp:1572
qreal dx() const
Returns the horizontal translation factor.
Definition: qtransform.h:273
void translate(int dx, int dy)
Translates (moves) the region dx along the X axis and dy along the Y axis.
Definition: qregion.cpp:4116
QRegion systemClip() const
Returns the system clip.
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65

◆ QMacCGContext() [2/5]

QMacCGContext::QMacCGContext ( )
inline

Definition at line 175 of file qt_mac_p.h.

175 { context = 0; }
CGContextRef context
Definition: qt_mac_p.h:172

◆ QMacCGContext() [3/5]

QMacCGContext::QMacCGContext ( const QPaintDevice pdev)
inline

Definition at line 176 of file qt_mac_p.h.

176  {
178  context = qt_mac_cg_context(pdev);
179  }
CGContextRef context
Definition: qt_mac_p.h:172
CGContextRef qt_mac_cg_context(const QPaintDevice *pdev)
Returns the CoreGraphics CGContextRef of the paint device.
struct CGContext * CGContextRef

◆ QMacCGContext() [4/5]

QMacCGContext::QMacCGContext ( CGContextRef  cg,
bool  takeOwnership = false 
)
inline

Definition at line 180 of file qt_mac_p.h.

180  {
181  context = cg;
182  if(!takeOwnership)
183  CGContextRetain(context);
184  }
CGContextRef context
Definition: qt_mac_p.h:172

◆ QMacCGContext() [5/5]

QMacCGContext::QMacCGContext ( const QMacCGContext copy)
inline

Definition at line 185 of file qt_mac_p.h.

185 : context(0) { *this = copy; }
CGContextRef context
Definition: qt_mac_p.h:172

◆ ~QMacCGContext()

QMacCGContext::~QMacCGContext ( )
inline

Definition at line 186 of file qt_mac_p.h.

186  {
187  if(context)
188  CGContextRelease(context);
189  }
CGContextRef context
Definition: qt_mac_p.h:172

Functions

◆ isNull()

bool QMacCGContext::isNull ( ) const
inline

Definition at line 190 of file qt_mac_p.h.

190 { return context; }
CGContextRef context
Definition: qt_mac_p.h:172

◆ operator CGContextRef()

QMacCGContext::operator CGContextRef ( )
inline

Definition at line 191 of file qt_mac_p.h.

191 { return context; }
CGContextRef context
Definition: qt_mac_p.h:172

◆ operator=() [1/2]

QMacCGContext& QMacCGContext::operator= ( const QMacCGContext copy)
inline

Definition at line 192 of file qt_mac_p.h.

192  {
193  if(context)
194  CGContextRelease(context);
195  context = copy.context;
196  CGContextRetain(context);
197  return *this;
198  }
CGContextRef context
Definition: qt_mac_p.h:172

◆ operator=() [2/2]

QMacCGContext& QMacCGContext::operator= ( CGContextRef  cg)
inline

Definition at line 199 of file qt_mac_p.h.

199  {
200  if(context)
201  CGContextRelease(context);
202  context = cg;
203  CGContextRetain(context); //we do not take ownership
204  return *this;
205  }
CGContextRef context
Definition: qt_mac_p.h:172

Properties

◆ context

CGContextRef QMacCGContext::context
private

Definition at line 172 of file qt_mac_p.h.

Referenced by operator=(), and QMacCGContext().


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