|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the QtGui module of the Qt Toolkit. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #ifndef QPAINTENGINEEX_P_H |
|
43 #define QPAINTENGINEEX_P_H |
|
44 |
|
45 // |
|
46 // W A R N I N G |
|
47 // ------------- |
|
48 // |
|
49 // This file is not part of the Qt API. It exists purely as an |
|
50 // implementation detail. This header file may change from version to |
|
51 // version without notice, or even be removed. |
|
52 // |
|
53 // We mean it. |
|
54 // |
|
55 |
|
56 #include <QtGui/qpaintengine.h> |
|
57 #include <QtGui/qdrawutil.h> |
|
58 |
|
59 #include <private/qpaintengine_p.h> |
|
60 #include <private/qstroker_p.h> |
|
61 #include <private/qpainter_p.h> |
|
62 #include <private/qvectorpath_p.h> |
|
63 |
|
64 |
|
65 QT_BEGIN_HEADER |
|
66 |
|
67 QT_BEGIN_NAMESPACE |
|
68 |
|
69 QT_MODULE(Gui) |
|
70 |
|
71 class QPainterState; |
|
72 class QPaintEngineExPrivate; |
|
73 struct StrokeHandler; |
|
74 |
|
75 struct QIntRect { |
|
76 int x1, y1, x2, y2; |
|
77 inline void set(const QRect &r) { |
|
78 x1 = r.x(); |
|
79 y1 = r.y(); |
|
80 x2 = r.right() + 1; |
|
81 y2 = r.bottom() + 1; |
|
82 // We will assume normalized for later... |
|
83 Q_ASSERT(x2 >= x1); |
|
84 Q_ASSERT(y2 >= y1); |
|
85 } |
|
86 }; |
|
87 |
|
88 class QRectVectorPath : public QVectorPath { |
|
89 public: |
|
90 inline void set(const QRect &r) { |
|
91 qreal left = r.x(); |
|
92 qreal right = r.x() + r.width(); |
|
93 qreal top = r.y(); |
|
94 qreal bottom = r.y() + r.height(); |
|
95 pts[0] = left; |
|
96 pts[1] = top; |
|
97 pts[2] = right; |
|
98 pts[3] = top; |
|
99 pts[4] = right; |
|
100 pts[5] = bottom; |
|
101 pts[6] = left; |
|
102 pts[7] = bottom; |
|
103 } |
|
104 |
|
105 inline void set(const QRectF &r) { |
|
106 qreal left = r.x(); |
|
107 qreal right = r.x() + r.width(); |
|
108 qreal top = r.y(); |
|
109 qreal bottom = r.y() + r.height(); |
|
110 pts[0] = left; |
|
111 pts[1] = top; |
|
112 pts[2] = right; |
|
113 pts[3] = top; |
|
114 pts[4] = right; |
|
115 pts[5] = bottom; |
|
116 pts[6] = left; |
|
117 pts[7] = bottom; |
|
118 } |
|
119 inline QRectVectorPath(const QRect &r) |
|
120 : QVectorPath(pts, 4, 0, QVectorPath::RectangleHint | QVectorPath::ImplicitClose) |
|
121 { |
|
122 set(r); |
|
123 } |
|
124 inline QRectVectorPath(const QRectF &r) |
|
125 : QVectorPath(pts, 4, 0, QVectorPath::RectangleHint | QVectorPath::ImplicitClose) |
|
126 { |
|
127 set(r); |
|
128 } |
|
129 inline QRectVectorPath() |
|
130 : QVectorPath(pts, 4, 0, QVectorPath::RectangleHint | QVectorPath::ImplicitClose) |
|
131 { } |
|
132 |
|
133 qreal pts[8]; |
|
134 }; |
|
135 |
|
136 #ifndef QT_NO_DEBUG_STREAM |
|
137 QDebug Q_GUI_EXPORT &operator<<(QDebug &, const QVectorPath &path); |
|
138 #endif |
|
139 |
|
140 class QPixmapFilter; |
|
141 |
|
142 class Q_GUI_EXPORT QPaintEngineEx : public QPaintEngine |
|
143 { |
|
144 Q_DECLARE_PRIVATE(QPaintEngineEx) |
|
145 public: |
|
146 QPaintEngineEx(); |
|
147 |
|
148 virtual QPainterState *createState(QPainterState *orig) const; |
|
149 |
|
150 virtual void draw(const QVectorPath &path); |
|
151 virtual void fill(const QVectorPath &path, const QBrush &brush) = 0; |
|
152 virtual void stroke(const QVectorPath &path, const QPen &pen); |
|
153 |
|
154 virtual void clip(const QVectorPath &path, Qt::ClipOperation op) = 0; |
|
155 virtual void clip(const QRect &rect, Qt::ClipOperation op); |
|
156 virtual void clip(const QRegion ®ion, Qt::ClipOperation op); |
|
157 virtual void clip(const QPainterPath &path, Qt::ClipOperation op); |
|
158 |
|
159 virtual void clipEnabledChanged() = 0; |
|
160 virtual void penChanged() = 0; |
|
161 virtual void brushChanged() = 0; |
|
162 virtual void brushOriginChanged() = 0; |
|
163 virtual void opacityChanged() = 0; |
|
164 virtual void compositionModeChanged() = 0; |
|
165 virtual void renderHintsChanged() = 0; |
|
166 virtual void transformChanged() = 0; |
|
167 |
|
168 virtual void fillRect(const QRectF &rect, const QBrush &brush); |
|
169 virtual void fillRect(const QRectF &rect, const QColor &color); |
|
170 |
|
171 virtual void drawRoundedRect(const QRectF &rect, qreal xrad, qreal yrad, Qt::SizeMode mode); |
|
172 |
|
173 virtual void drawRects(const QRect *rects, int rectCount); |
|
174 virtual void drawRects(const QRectF *rects, int rectCount); |
|
175 |
|
176 virtual void drawLines(const QLine *lines, int lineCount); |
|
177 virtual void drawLines(const QLineF *lines, int lineCount); |
|
178 |
|
179 virtual void drawEllipse(const QRectF &r); |
|
180 virtual void drawEllipse(const QRect &r); |
|
181 |
|
182 virtual void drawPath(const QPainterPath &path); |
|
183 |
|
184 virtual void drawPoints(const QPointF *points, int pointCount); |
|
185 virtual void drawPoints(const QPoint *points, int pointCount); |
|
186 |
|
187 virtual void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode); |
|
188 virtual void drawPolygon(const QPoint *points, int pointCount, PolygonDrawMode mode); |
|
189 |
|
190 virtual void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) = 0; |
|
191 virtual void drawPixmap(const QPointF &pos, const QPixmap &pm); |
|
192 |
|
193 virtual void drawImage(const QRectF &r, const QImage &pm, const QRectF &sr, |
|
194 Qt::ImageConversionFlags flags = Qt::AutoColor) = 0; |
|
195 virtual void drawImage(const QPointF &pos, const QImage &image); |
|
196 |
|
197 virtual void drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s); |
|
198 |
|
199 virtual void drawPixmaps(const QDrawPixmaps::Data *drawingData, int dataCount, const QPixmap &pixmap, QFlags<QDrawPixmaps::DrawingHint> hints); |
|
200 |
|
201 virtual void updateState(const QPaintEngineState &state); |
|
202 |
|
203 virtual void setState(QPainterState *s); |
|
204 inline QPainterState *state() { return static_cast<QPainterState *>(QPaintEngine::state); } |
|
205 inline const QPainterState *state() const { return static_cast<const QPainterState *>(QPaintEngine::state); } |
|
206 |
|
207 virtual void sync() {} |
|
208 |
|
209 virtual void beginNativePainting() {} |
|
210 virtual void endNativePainting() {} |
|
211 |
|
212 // Return a pixmap filter of "type" that can render the parameters |
|
213 // in "prototype". The returned filter is owned by the engine and |
|
214 // will be destroyed when the engine is destroyed. The "prototype" |
|
215 // allows the engine to pick different filters based on the parameters |
|
216 // that will be requested, and not just the "type". |
|
217 virtual QPixmapFilter *pixmapFilter(int /*type*/, const QPixmapFilter * /*prototype*/) { return 0; } |
|
218 |
|
219 // These flags are needed in the implementation of paint buffers. |
|
220 enum Flags |
|
221 { |
|
222 DoNotEmulate = 0x01, // If set, QPainter will not wrap this engine in an emulation engine. |
|
223 IsEmulationEngine = 0x02 // If set, this object is a QEmulationEngine. |
|
224 }; |
|
225 virtual uint flags() const {return 0;} |
|
226 |
|
227 protected: |
|
228 QPaintEngineEx(QPaintEngineExPrivate &data); |
|
229 }; |
|
230 |
|
231 class Q_GUI_EXPORT QPaintEngineExPrivate : public QPaintEnginePrivate |
|
232 { |
|
233 Q_DECLARE_PUBLIC(QPaintEngineEx) |
|
234 public: |
|
235 QPaintEngineExPrivate(); |
|
236 ~QPaintEngineExPrivate(); |
|
237 |
|
238 void replayClipOperations(); |
|
239 bool hasClipOperations() const; |
|
240 |
|
241 QStroker stroker; |
|
242 QDashStroker dasher; |
|
243 StrokeHandler *strokeHandler; |
|
244 QStrokerOps *activeStroker; |
|
245 QPen strokerPen; |
|
246 |
|
247 QRect exDeviceRect; |
|
248 }; |
|
249 |
|
250 inline uint QVectorPath::polygonFlags(QPaintEngine::PolygonDrawMode mode) { |
|
251 switch (mode) { |
|
252 case QPaintEngine::ConvexMode: return ConvexPolygonHint | ImplicitClose; |
|
253 case QPaintEngine::OddEvenMode: return NonCurvedShapeHint | OddEvenFill | ImplicitClose; |
|
254 case QPaintEngine::WindingMode: return NonCurvedShapeHint | WindingFill | ImplicitClose; |
|
255 case QPaintEngine::PolylineMode: return NonCurvedShapeHint; |
|
256 default: return 0; |
|
257 } |
|
258 } |
|
259 |
|
260 QT_END_NAMESPACE |
|
261 |
|
262 QT_END_HEADER |
|
263 |
|
264 #endif |