source: trunk/src/gui/painting/qpaintengineex_p.h@ 1108

Last change on this file since 1108 was 846, checked in by Dmitry A. Kuminov, 15 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

File size: 8.9 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
6**
7** This file is part of the QtGui module of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
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** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at [email protected].
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
65QT_BEGIN_HEADER
66
67QT_BEGIN_NAMESPACE
68
69QT_MODULE(Gui)
70
71class QPainterState;
72class QPaintEngineExPrivate;
73class QStaticTextItem;
74struct StrokeHandler;
75
76struct QIntRect {
77 int x1, y1, x2, y2;
78 inline void set(const QRect &r) {
79 x1 = r.x();
80 y1 = r.y();
81 x2 = r.right() + 1;
82 y2 = r.bottom() + 1;
83 // We will assume normalized for later...
84 Q_ASSERT(x2 >= x1);
85 Q_ASSERT(y2 >= y1);
86 }
87};
88
89class QRectVectorPath : public QVectorPath {
90public:
91 inline void set(const QRect &r) {
92 qreal left = r.x();
93 qreal right = r.x() + r.width();
94 qreal top = r.y();
95 qreal bottom = r.y() + r.height();
96 pts[0] = left;
97 pts[1] = top;
98 pts[2] = right;
99 pts[3] = top;
100 pts[4] = right;
101 pts[5] = bottom;
102 pts[6] = left;
103 pts[7] = bottom;
104 }
105
106 inline void set(const QRectF &r) {
107 qreal left = r.x();
108 qreal right = r.x() + r.width();
109 qreal top = r.y();
110 qreal bottom = r.y() + r.height();
111 pts[0] = left;
112 pts[1] = top;
113 pts[2] = right;
114 pts[3] = top;
115 pts[4] = right;
116 pts[5] = bottom;
117 pts[6] = left;
118 pts[7] = bottom;
119 }
120 inline QRectVectorPath(const QRect &r)
121 : QVectorPath(pts, 4, 0, QVectorPath::RectangleHint | QVectorPath::ImplicitClose)
122 {
123 set(r);
124 }
125 inline QRectVectorPath(const QRectF &r)
126 : QVectorPath(pts, 4, 0, QVectorPath::RectangleHint | QVectorPath::ImplicitClose)
127 {
128 set(r);
129 }
130 inline QRectVectorPath()
131 : QVectorPath(pts, 4, 0, QVectorPath::RectangleHint | QVectorPath::ImplicitClose)
132 { }
133
134 qreal pts[8];
135};
136
137#ifndef QT_NO_DEBUG_STREAM
138QDebug Q_GUI_EXPORT &operator<<(QDebug &, const QVectorPath &path);
139#endif
140
141class QPixmapFilter;
142
143class Q_GUI_EXPORT QPaintEngineEx : public QPaintEngine
144{
145 Q_DECLARE_PRIVATE(QPaintEngineEx)
146public:
147 QPaintEngineEx();
148
149 virtual QPainterState *createState(QPainterState *orig) const;
150
151 virtual void draw(const QVectorPath &path);
152 virtual void fill(const QVectorPath &path, const QBrush &brush) = 0;
153 virtual void stroke(const QVectorPath &path, const QPen &pen);
154
155 virtual void clip(const QVectorPath &path, Qt::ClipOperation op) = 0;
156 virtual void clip(const QRect &rect, Qt::ClipOperation op);
157 virtual void clip(const QRegion &region, Qt::ClipOperation op);
158 virtual void clip(const QPainterPath &path, Qt::ClipOperation op);
159
160 virtual void clipEnabledChanged() = 0;
161 virtual void penChanged() = 0;
162 virtual void brushChanged() = 0;
163 virtual void brushOriginChanged() = 0;
164 virtual void opacityChanged() = 0;
165 virtual void compositionModeChanged() = 0;
166 virtual void renderHintsChanged() = 0;
167 virtual void transformChanged() = 0;
168
169 virtual void fillRect(const QRectF &rect, const QBrush &brush);
170 virtual void fillRect(const QRectF &rect, const QColor &color);
171
172 virtual void drawRoundedRect(const QRectF &rect, qreal xrad, qreal yrad, Qt::SizeMode mode);
173
174 virtual void drawRects(const QRect *rects, int rectCount);
175 virtual void drawRects(const QRectF *rects, int rectCount);
176
177 virtual void drawLines(const QLine *lines, int lineCount);
178 virtual void drawLines(const QLineF *lines, int lineCount);
179
180 virtual void drawEllipse(const QRectF &r);
181 virtual void drawEllipse(const QRect &r);
182
183 virtual void drawPath(const QPainterPath &path);
184
185 virtual void drawPoints(const QPointF *points, int pointCount);
186 virtual void drawPoints(const QPoint *points, int pointCount);
187
188 virtual void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode);
189 virtual void drawPolygon(const QPoint *points, int pointCount, PolygonDrawMode mode);
190
191 virtual void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) = 0;
192 virtual void drawPixmap(const QPointF &pos, const QPixmap &pm);
193
194 virtual void drawImage(const QRectF &r, const QImage &pm, const QRectF &sr,
195 Qt::ImageConversionFlags flags = Qt::AutoColor) = 0;
196 virtual void drawImage(const QPointF &pos, const QImage &image);
197
198 virtual void drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s);
199
200 virtual void drawPixmapFragments(const QPainter::PixmapFragment *fragments, int fragmentCount, const QPixmap &pixmap,
201 QFlags<QPainter::PixmapFragmentHint> hints);
202
203 virtual void updateState(const QPaintEngineState &state);
204
205 virtual void drawStaticTextItem(QStaticTextItem *) = 0;
206
207 virtual void setState(QPainterState *s);
208 inline QPainterState *state() { return static_cast<QPainterState *>(QPaintEngine::state); }
209 inline const QPainterState *state() const { return static_cast<const QPainterState *>(QPaintEngine::state); }
210
211 virtual void sync() {}
212
213 virtual void beginNativePainting() {}
214 virtual void endNativePainting() {}
215
216 // Return a pixmap filter of "type" that can render the parameters
217 // in "prototype". The returned filter is owned by the engine and
218 // will be destroyed when the engine is destroyed. The "prototype"
219 // allows the engine to pick different filters based on the parameters
220 // that will be requested, and not just the "type".
221 virtual QPixmapFilter *pixmapFilter(int /*type*/, const QPixmapFilter * /*prototype*/) { return 0; }
222
223 // These flags are needed in the implementation of paint buffers.
224 enum Flags
225 {
226 DoNotEmulate = 0x01, // If set, QPainter will not wrap this engine in an emulation engine.
227 IsEmulationEngine = 0x02 // If set, this object is a QEmulationEngine.
228 };
229 virtual uint flags() const {return 0;}
230
231protected:
232 QPaintEngineEx(QPaintEngineExPrivate &data);
233};
234
235class Q_GUI_EXPORT QPaintEngineExPrivate : public QPaintEnginePrivate
236{
237 Q_DECLARE_PUBLIC(QPaintEngineEx)
238public:
239 QPaintEngineExPrivate();
240 ~QPaintEngineExPrivate();
241
242 void replayClipOperations();
243 bool hasClipOperations() const;
244
245 QStroker stroker;
246 QDashStroker dasher;
247 StrokeHandler *strokeHandler;
248 QStrokerOps *activeStroker;
249 QPen strokerPen;
250
251 QRect exDeviceRect;
252};
253
254inline uint QVectorPath::polygonFlags(QPaintEngine::PolygonDrawMode mode) {
255 switch (mode) {
256 case QPaintEngine::ConvexMode: return ConvexPolygonHint | ImplicitClose;
257 case QPaintEngine::OddEvenMode: return PolygonHint | OddEvenFill | ImplicitClose;
258 case QPaintEngine::WindingMode: return PolygonHint | WindingFill | ImplicitClose;
259 case QPaintEngine::PolylineMode: return PolygonHint;
260 default: return 0;
261 }
262}
263
264QT_END_NAMESPACE
265
266QT_END_HEADER
267
268#endif
Note: See TracBrowser for help on using the repository browser.