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 QPAINTENGINEEX_P_H
5#define QPAINTENGINEEX_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 <QtGui/private/qtguiglobal_p.h>
19#include <QtGui/qpaintengine.h>
20
21#include <private/qpaintengine_p.h>
22#include <private/qstroker_p.h>
23#include <private/qpainter_p.h>
24#include <private/qvectorpath_p.h>
25
26
27QT_BEGIN_NAMESPACE
28
29
30class QPainterState;
31class QPaintEngineExPrivate;
32class QStaticTextItem;
33struct StrokeHandler;
34
35#ifndef QT_NO_DEBUG_STREAM
36QDebug Q_GUI_EXPORT &operator<<(QDebug &, const QVectorPath &path);
37#endif
38
39class Q_GUI_EXPORT QPaintEngineEx : public QPaintEngine
40{
41 Q_DECLARE_PRIVATE(QPaintEngineEx)
42public:
43 QPaintEngineEx();
44
45 virtual QPainterState *createState(QPainterState *orig) const;
46
47 virtual void draw(const QVectorPath &path);
48 virtual void fill(const QVectorPath &path, const QBrush &brush) = 0;
49 virtual void stroke(const QVectorPath &path, const QPen &pen);
50
51 virtual void clip(const QVectorPath &path, Qt::ClipOperation op) = 0;
52 virtual void clip(const QRect &rect, Qt::ClipOperation op);
53 virtual void clip(const QRegion &region, Qt::ClipOperation op);
54 virtual void clip(const QPainterPath &path, Qt::ClipOperation op);
55
56 virtual void clipEnabledChanged() = 0;
57 virtual void penChanged() = 0;
58 virtual void brushChanged() = 0;
59 virtual void brushOriginChanged() = 0;
60 virtual void opacityChanged() = 0;
61 virtual void compositionModeChanged() = 0;
62 virtual void renderHintsChanged() = 0;
63 virtual void transformChanged() = 0;
64
65 virtual void fillRect(const QRectF &rect, const QBrush &brush);
66 virtual void fillRect(const QRectF &rect, const QColor &color);
67
68 virtual void drawRoundedRect(const QRectF &rect, qreal xrad, qreal yrad, Qt::SizeMode mode);
69
70 virtual void drawRects(const QRect *rects, int rectCount) override;
71 virtual void drawRects(const QRectF *rects, int rectCount) override;
72
73 virtual void drawLines(const QLine *lines, int lineCount) override;
74 virtual void drawLines(const QLineF *lines, int lineCount) override;
75
76 virtual void drawEllipse(const QRectF &r) override;
77 virtual void drawEllipse(const QRect &r) override;
78
79 virtual void drawPath(const QPainterPath &path) override;
80
81 virtual void drawPoints(const QPointF *points, int pointCount) override;
82 virtual void drawPoints(const QPoint *points, int pointCount) override;
83
84 virtual void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode) override;
85 virtual void drawPolygon(const QPoint *points, int pointCount, PolygonDrawMode mode) override;
86
87 virtual void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) override = 0;
88 virtual void drawPixmap(const QPointF &pos, const QPixmap &pm);
89
90 virtual void drawImage(const QRectF &r, const QImage &pm, const QRectF &sr,
91 Qt::ImageConversionFlags flags = Qt::AutoColor) override = 0;
92 virtual void drawImage(const QPointF &pos, const QImage &image);
93
94 virtual void drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s) override;
95
96 virtual void drawPixmapFragments(const QPainter::PixmapFragment *fragments, int fragmentCount, const QPixmap &pixmap,
97 QFlags<QPainter::PixmapFragmentHint> hints);
98
99 virtual void updateState(const QPaintEngineState &state) override;
100
101 virtual void drawStaticTextItem(QStaticTextItem *);
102
103 virtual void setState(QPainterState *s);
104 inline QPainterState *state() { return static_cast<QPainterState *>(QPaintEngine::state); }
105 inline const QPainterState *state() const { return static_cast<const QPainterState *>(QPaintEngine::state); }
106
107 virtual void sync() {}
108
109 virtual void beginNativePainting() {}
110 virtual void endNativePainting() {}
111
112 // These flags are needed in the implementation of paint buffers.
113 enum Flags
114 {
115 DoNotEmulate = 0x01, // If set, QPainter will not wrap this engine in an emulation engine.
116 IsEmulationEngine = 0x02 // If set, this object is a QEmulationEngine.
117 };
118 virtual uint flags() const {return 0;}
119 virtual bool requiresPretransformedGlyphPositions(QFontEngine *fontEngine, const QTransform &m) const;
120 virtual bool shouldDrawCachedGlyphs(QFontEngine *fontEngine, const QTransform &m) const;
121
122protected:
123 QPaintEngineEx(QPaintEngineExPrivate &data);
124};
125
126class Q_GUI_EXPORT QPaintEngineExPrivate : public QPaintEnginePrivate
127{
128 Q_DECLARE_PUBLIC(QPaintEngineEx)
129public:
130 QPaintEngineExPrivate();
131 ~QPaintEngineExPrivate();
132
133 void replayClipOperations();
134 bool hasClipOperations() const;
135
136 QStroker stroker;
137 QDashStroker dasher;
138 StrokeHandler *strokeHandler;
139 QStrokerOps *activeStroker;
140 QPen strokerPen;
141
142 QRect exDeviceRect;
143};
144
145QT_END_NAMESPACE
146
147#endif
148

source code of qtbase/src/gui/painting/qpaintengineex_p.h