Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qpaintengine_mac_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QPAINTENGINE_MAC_P_H
5#define QPAINTENGINE_MAC_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtPrintSupport/qtprintsupportglobal.h>
19
20#include <QtGui/qpaintengine.h>
21#include <QtGui/private/qpaintengine_p.h>
22#include <QtGui/private/qfont_p.h>
23#include <QtCore/qhash.h>
24
25typedef struct CGColorSpace *CGColorSpaceRef;
26typedef struct CGContext *CGContextRef;
27
29
32{
33 Q_DECLARE_PRIVATE(QCoreGraphicsPaintEngine)
34
35public:
38
39 bool begin(QPaintDevice *pdev);
40 bool end();
41
43
44 void updatePen(const QPen &pen);
45 void updateBrush(const QBrush &brush, const QPointF &pt);
46 void updateFont(const QFont &font);
47 void updateOpacity(qreal opacity);
48 void updateMatrix(const QTransform &matrix);
50 void updateClipRegion(const QRegion &region, Qt::ClipOperation op);
53 void updateRenderHints(QPainter::RenderHints hints);
54
55 void drawLines(const QLineF *lines, int lineCount);
56 void drawRects(const QRectF *rects, int rectCount);
57 void drawPoints(const QPointF *p, int pointCount);
58 void drawEllipse(const QRectF &r);
59 void drawPath(const QPainterPath &path);
60
61 void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode);
62 void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr);
63 void drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s);
64
65 void drawTextItem(const QPointF &pos, const QTextItem &item);
66 void drawImage(const QRectF &r, const QImage &pm, const QRectF &sr,
67 Qt::ImageConversionFlags flags = Qt::AutoColor);
68
70
71 CGContextRef handle() const;
72
73 static void initialize();
74 static void cleanup();
75
76 QPainter::RenderHints supportedRenderHints() const;
77
78 //avoid partial shadowed overload warnings...
79 void drawLines(const QLine *lines, int lineCount) { QPaintEngine::drawLines(lines, lineCount); }
80 void drawRects(const QRect *rects, int rectCount) { QPaintEngine::drawRects(rects, rectCount); }
81 void drawPoints(const QPoint *p, int pointCount) { QPaintEngine::drawPoints(p, pointCount); }
83 void drawPolygon(const QPoint *points, int pointCount, PolygonDrawMode mode)
84 { QPaintEngine::drawPolygon(points, pointCount, mode); }
85
86protected:
87 friend class QMacPrintEngine;
90
91private:
92 Q_DISABLE_COPY(QCoreGraphicsPaintEngine)
93};
94
95/*****************************************************************************
96 Private data
97 *****************************************************************************/
99{
100 Q_DECLARE_PUBLIC(QCoreGraphicsPaintEngine)
101public:
106
107 struct {
114
115 //state info (shared with QD)
116 CGAffineTransform orig_xform;
117
118 //cg structures
120 CGShadingRef shading;
125
126 // pixel and cosmetic pen size in user coordinates.
129
130 //internal functions
131 enum { CGStroke=0x01, CGEOFill=0x02, CGFill=0x04 };
132 void drawPath(uchar ops, CGMutablePathRef path = nullptr);
133 void setClip(const QRegion *rgn = nullptr);
134 void resetClip();
135 void setFillBrush(const QPointF &origin=QPoint());
136 void setStrokePen(const QPen &pen);
137 inline void saveGraphicsState();
138 inline void restoreGraphicsState();
139 float penOffset();
141 float adjustPenWidth(float penWidth);
142 inline void setTransform(const QTransform *matrix = nullptr)
143 {
144 CGContextConcatCTM(hd, CGAffineTransformInvert(CGContextGetCTM(hd)));
145 CGAffineTransform xform = orig_xform;
146 if (matrix) {
147 extern CGAffineTransform qt_mac_convert_transform_to_cg(const QTransform &);
148 xform = CGAffineTransformConcat(qt_mac_convert_transform_to_cg(*matrix), xform);
149 }
150 CGContextConcatCTM(hd, xform);
151 CGContextSetTextMatrix(hd, xform);
152 }
153};
154
156{
157 ++stackCount;
158 CGContextSaveGState(hd);
159}
160
162{
163 --stackCount;
164 Q_ASSERT(stackCount >= 0);
165 CGContextRestoreGState(hd);
166}
167
169
170#endif // QPAINTENGINE_MAC_P_H
\inmodule QtGui
Definition qbrush.h:30
enum QCoreGraphicsPaintEnginePrivate::@472 cosmeticPen
void setTransform(const QTransform *matrix=nullptr)
void setFillBrush(const QPointF &origin=QPoint())
QPointF devicePixelSize(CGContextRef context)
struct QCoreGraphicsPaintEnginePrivate::@471 current
void drawPath(uchar ops, CGMutablePathRef path=nullptr)
void setClip(const QRegion *rgn=nullptr)
void updateState(const QPaintEngineState &state)
Reimplement this function to update the state of a paint engine.
void updateRenderHints(QPainter::RenderHints hints)
void drawImage(const QRectF &r, const QImage &pm, const QRectF &sr, Qt::ImageConversionFlags flags=Qt::AutoColor)
Reimplement this function to draw the part of the image specified by the sr rectangle in the given re...
Type type() const
Reimplement this function to return the paint engine \l{Type}.
void drawPoints(const QPointF *p, int pointCount)
Draws the first pointCount points in the buffer points.
void drawRects(const QRectF *rects, int rectCount)
Draws the first rectCount rectangles in the buffer rects.
void drawTextItem(const QPointF &pos, const QTextItem &item)
This function draws the text item textItem at position p.
void updateMatrix(const QTransform &matrix)
void updateBrush(const QBrush &brush, const QPointF &pt)
QPainter::RenderHints supportedRenderHints() const
void drawPoints(const QPoint *p, int pointCount)
Draws the first pointCount points in the buffer points.
void drawRects(const QRect *rects, int rectCount)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void drawEllipse(const QRect &r)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void updateClipPath(const QPainterPath &path, Qt::ClipOperation op)
bool end()
Reimplement this function to finish painting on the current paint device.
bool begin(QPaintDevice *pdev)
Reimplement this function to initialise your paint engine when painting is to start on the paint devi...
void updateCompositionMode(QPainter::CompositionMode mode)
CGContextRef handle() const
void updateFont(const QFont &font)
void drawPolygon(const QPoint *points, int pointCount, PolygonDrawMode mode)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void drawLines(const QLineF *lines, int lineCount)
The default implementation splits the list of lines in lines into lineCount separate calls to drawPat...
void updateClipRegion(const QRegion &region, Qt::ClipOperation op)
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.
void drawEllipse(const QRectF &r)
Reimplement this function to draw the largest ellipse that can be contained within rectangle rect.
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...
void updatePen(const QPen &pen)
void drawLines(const QLine *lines, int lineCount)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void updateOpacity(qreal opacity)
void drawPath(const QPainterPath &path)
The default implementation ignores the path and does nothing.
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.
void updateTransform(const QTransform &matrix)
\reentrant
Definition qfont.h:22
\inmodule QtGui
Definition qimage.h:37
\inmodule QtCore\compares equality \compareswith equality QLine \endcompareswith
Definition qline.h:192
\inmodule QtCore\compares equality \compareswith equality QLineF \endcompareswith
Definition qline.h:18
The QPaintEngineState class provides information about the active paint engine's current state....
\inmodule QtGui
virtual void drawRects(const QRect *rects, int rectCount)
This is an overloaded member function, provided for convenience. It differs from the above function o...
virtual void drawLines(const QLine *lines, int lineCount)
This is an overloaded member function, provided for convenience. It differs from the above function o...
PolygonDrawMode
\value OddEvenMode The polygon should be drawn using OddEven fill rule.
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...
QPaintEngineState * state
virtual void drawEllipse(const QRectF &r)
Reimplement this function to draw the largest ellipse that can be contained within rectangle rect.
\inmodule QtGui
CompositionMode
Defines the modes supported for digital image compositing.
Definition qpainter.h:97
\inmodule QtGui
Definition qpen.h:28
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
Definition qpixmap.h:27
\inmodule QtCore\reentrant
Definition qpoint.h:217
\inmodule QtCore\reentrant
Definition qpoint.h:25
\inmodule QtCore\reentrant
Definition qrect.h:484
\inmodule QtCore\reentrant
Definition qrect.h:30
The QRegion class specifies a clip region for a painter.
Definition qregion.h:27
\inmodule QtGui
The QTransform class specifies 2D transformations of a coordinate system.
Definition qtransform.h:20
Combined button and popup list for selecting options.
@ AutoColor
Definition qnamespace.h:478
ClipOperation
Definition brush.cpp:5
static void * context
GLenum mode
GLboolean r
[2]
GLbitfield flags
GLfixed GLfixed GLint GLint GLfixed points
GLdouble s
[6]
Definition qopenglext.h:235
GLuint GLenum matrix
GLsizei const GLchar *const * path
GLfloat GLfloat p
[1]
CGAffineTransform qt_mac_convert_transform_to_cg(const QTransform &t)
struct CGContext * CGContextRef
struct CGColorSpace * CGColorSpaceRef
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
unsigned char uchar
Definition qtypes.h:32
unsigned int uint
Definition qtypes.h:34
double qreal
Definition qtypes.h:187
QObject::connect nullptr
QGraphicsItem * item
widget render & pixmap
Definition moc.h:23