Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
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// Qt-Security score:significant reason:default
4
5#ifndef QPAINTENGINE_MAC_P_H
6#define QPAINTENGINE_MAC_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtPrintSupport/qtprintsupportglobal.h>
20
21#include <QtGui/qpaintengine.h>
22#include <QtGui/private/qpaintengine_p.h>
23#include <QtGui/private/qfont_p.h>
24#include <QtCore/qhash.h>
25
26typedef struct CGColorSpace *CGColorSpaceRef;
27typedef struct CGContext *CGContextRef;
28
29QT_BEGIN_NAMESPACE
30
31class QCoreGraphicsPaintEnginePrivate;
33{
35
36public:
39
40 bool begin(QPaintDevice *pdev);
41 bool end();
42
43 void updateState(const QPaintEngineState &state);
44
45 void updatePen(const QPen &pen);
46 void updateBrush(const QBrush &brush, const QPointF &pt);
47 void updateFont(const QFont &font);
48 void updateOpacity(qreal opacity);
49 void updateMatrix(const QTransform &matrix);
50 void updateTransform(const QTransform &matrix);
51 void updateClipRegion(const QRegion &region, Qt::ClipOperation op);
52 void updateClipPath(const QPainterPath &path, Qt::ClipOperation op);
53 void updateCompositionMode(QPainter::CompositionMode mode);
54 void updateRenderHints(QPainter::RenderHints hints);
55
56 void drawLines(const QLineF *lines, int lineCount);
57 void drawRects(const QRectF *rects, int rectCount);
58 void drawPoints(const QPointF *p, int pointCount);
59 void drawEllipse(const QRectF &r);
60 void drawPath(const QPainterPath &path);
61
62 void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode);
63 void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr);
64 void drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s);
65
66 void drawTextItem(const QPointF &pos, const QTextItem &item);
67 void drawImage(const QRectF &r, const QImage &pm, const QRectF &sr,
68 Qt::ImageConversionFlags flags = Qt::AutoColor);
69
70 Type type() const { return QPaintEngine::CoreGraphics; }
71
72 CGContextRef handle() const;
73
74 static void initialize();
75 static void cleanup();
76
78
79 //avoid partial shadowed overload warnings...
80 void drawLines(const QLine *lines, int lineCount) { QPaintEngine::drawLines(lines, lineCount); }
81 void drawRects(const QRect *rects, int rectCount) { QPaintEngine::drawRects(rects, rectCount); }
82 void drawPoints(const QPoint *p, int pointCount) { QPaintEngine::drawPoints(p, pointCount); }
83 void drawEllipse(const QRect &r) { QPaintEngine::drawEllipse(r); }
84 void drawPolygon(const QPoint *points, int pointCount, PolygonDrawMode mode)
85 { QPaintEngine::drawPolygon(points, pointCount, mode); }
86
87protected:
88 friend class QMacPrintEngine;
90 QCoreGraphicsPaintEngine(QPaintEnginePrivate &dptr);
91
92private:
94};
95
96/*****************************************************************************
97 Private data
98 *****************************************************************************/
100{
101 Q_DECLARE_PUBLIC(QCoreGraphicsPaintEngine)
102public:
104 : hd(nullptr), shading(nullptr), stackCount(0), complexXForm(false), disabledSmoothFonts(false)
105 {
106 }
107
108 struct {
115
116 //state info (shared with QD)
118
119 //cg structures
126
127 // pixel and cosmetic pen size in user coordinates.
130
131 //internal functions
132 enum { CGStroke=0x01, CGEOFill=0x02, CGFill=0x04 };
133 void drawPath(uchar ops, CGMutablePathRef path = nullptr);
134 void setClip(const QRegion *rgn = nullptr);
135 void resetClip();
136 void setFillBrush(const QPointF &origin=QPoint());
137 void setStrokePen(const QPen &pen);
138 inline void saveGraphicsState();
139 inline void restoreGraphicsState();
140 float penOffset();
142 float adjustPenWidth(float penWidth);
143 inline void setTransform(const QTransform *matrix = nullptr)
144 {
145 CGContextConcatCTM(hd, CGAffineTransformInvert(CGContextGetCTM(hd)));
146 CGAffineTransform xform = orig_xform;
147 if (matrix) {
148 extern CGAffineTransform qt_mac_convert_transform_to_cg(const QTransform &);
149 xform = CGAffineTransformConcat(qt_mac_convert_transform_to_cg(*matrix), xform);
150 }
151 CGContextConcatCTM(hd, xform);
152 CGContextSetTextMatrix(hd, xform);
153 }
154};
155
157{
158 ++stackCount;
159 CGContextSaveGState(hd);
160}
161
163{
164 --stackCount;
165 Q_ASSERT(stackCount >= 0);
166 CGContextRestoreGState(hd);
167}
168
169QT_END_NAMESPACE
170
171#endif // QPAINTENGINE_MAC_P_H
void setTransform(const QTransform *matrix=nullptr)
void setFillBrush(const QPointF &origin=QPoint())
QPointF devicePixelSize(CGContextRef context)
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 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
QCoreGraphicsPaintEngine(QPaintEnginePrivate &dptr)
void updateFont(const QFont &font)
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 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)
PMPrintSession session() const
QPrinter::PrinterState state
QSharedPointer< QCocoaPrintDevice > m_printDevice
Qt::HANDLE nativeHandle() override
QPaintEngine * aggregateEngine() override
PMPrintSettings settings() const
PMPageFormat format() const
void setPageSize(const QPageSize &pageSize)
QHash< QMacPrintEngine::PrintEnginePropertyKey, QVariant > valueCache
bool isPrintSessionInitialized() const
virtual void drawPoints(const QPointF *p, int pointCount)
Draws the first pointCount points in the buffer points.
void updateState(const QPaintEngineState &state)
Reimplement this function to update the state of a paint engine.
QPaintEngine * paintEngine() const
virtual void drawImage(const QRectF &r, const QImage &pm, const QRectF &sr, Qt::ImageConversionFlags flags)
Reimplement this function to draw the part of the image specified by the sr rectangle in the given re...
virtual void drawTextItem(const QPointF &p, const QTextItem &ti)
This function draws the text item textItem at position p.
QVariant property(PrintEnginePropertyKey key) const
Returns the print engine's property specified by key.
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.
virtual void drawPath(const QPainterPath &)
The default implementation ignores the path and does nothing.
bool newPage()
Instructs the print engine to start a new page.
Qt::HANDLE handle() const
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...
QPrinter::PrinterState printerState() const
Returns the current state of the printer being used by the print engine.
virtual void drawRects(const QRectF *r, int num)
Draws the first rectCount rectangles in the buffer rects.
NSPrintInfo * printInfo()
bool end()
Reimplement this function to finish painting on the current paint device.
bool begin(QPaintDevice *dev)
Reimplement this function to initialise your paint engine when painting is to start on the paint devi...
virtual 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.
bool abort()
Instructs the print engine to abort the printing process.
int metric(QPaintDevice::PaintDeviceMetric) const
Returns the metric for the given id.
virtual void drawEllipse(const QRectF &r)
Reimplement this function to draw the largest ellipse that can be contained within rectangle rect.
void setProperty(PrintEnginePropertyKey key, const QVariant &value)
Sets the print engine's property specified by key to the given value.
virtual void drawLines(const QLineF *lines, int lineCount)
The default implementation splits the list of lines in lines into lineCount separate calls to drawPat...
virtual QPaintEngine::Type type() const
Reimplement this function to return the paint engine \l{Type}.
Q_FORWARD_DECLARE_OBJC_CLASS(NSObject)
struct CGContext * CGContextRef