author | Eckhart Koeppen <eckhart.koppen@nokia.com> |
Wed, 21 Apr 2010 20:15:53 +0300 | |
branch | RCL_3 |
changeset 14 | c0432d11811c |
parent 4 | 3b1da2848fc7 |
child 30 | 5dc02b23752f |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 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 QPAINTER_P_H |
|
43 |
#define QPAINTER_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/qbrush.h" |
|
57 |
#include "QtGui/qfont.h" |
|
58 |
#include "QtGui/qpen.h" |
|
59 |
#include "QtGui/qregion.h" |
|
60 |
#include "QtGui/qmatrix.h" |
|
61 |
#include "QtGui/qpainter.h" |
|
62 |
#include "QtGui/qpainterpath.h" |
|
63 |
#include "QtGui/qpaintengine.h" |
|
64 |
#include <QtCore/qhash.h> |
|
65 |
||
66 |
#include <private/qpen_p.h> |
|
67 |
||
68 |
QT_BEGIN_NAMESPACE |
|
69 |
||
70 |
class QPaintEngine; |
|
71 |
class QEmulationPaintEngine; |
|
72 |
class QPaintEngineEx; |
|
73 |
||
74 |
struct QTLWExtra; |
|
75 |
||
76 |
struct DataPtrContainer { |
|
77 |
void *ptr; |
|
78 |
}; |
|
79 |
||
80 |
inline void *data_ptr(const QTransform &t) { return (DataPtrContainer *) &t; } |
|
81 |
inline bool qtransform_fast_equals(const QTransform &a, const QTransform &b) { return data_ptr(a) == data_ptr(b); } |
|
82 |
||
83 |
// QPen inline functions... |
|
84 |
inline QPen::DataPtr &data_ptr(const QPen &p) { return const_cast<QPen &>(p).data_ptr(); } |
|
85 |
inline bool qpen_fast_equals(const QPen &a, const QPen &b) { return data_ptr(a) == data_ptr(b); } |
|
86 |
inline QBrush qpen_brush(const QPen &p) { return data_ptr(p)->brush; } |
|
87 |
inline qreal qpen_widthf(const QPen &p) { return data_ptr(p)->width; } |
|
88 |
inline Qt::PenStyle qpen_style(const QPen &p) { return data_ptr(p)->style; } |
|
89 |
inline Qt::PenCapStyle qpen_capStyle(const QPen &p) { return data_ptr(p)->capStyle; } |
|
90 |
inline Qt::PenJoinStyle qpen_joinStyle(const QPen &p) { return data_ptr(p)->joinStyle; } |
|
91 |
||
92 |
// QBrush inline functions... |
|
93 |
inline QBrush::DataPtr &data_ptr(const QBrush &p) { return const_cast<QBrush &>(p).data_ptr(); } |
|
94 |
inline bool qbrush_fast_equals(const QBrush &a, const QBrush &b) { return data_ptr(a) == data_ptr(b); } |
|
95 |
inline Qt::BrushStyle qbrush_style(const QBrush &b) { return data_ptr(b)->style; } |
|
96 |
inline const QColor &qbrush_color(const QBrush &b) { return data_ptr(b)->color; } |
|
97 |
inline bool qbrush_has_transform(const QBrush &b) { return data_ptr(b)->transform.type() > QTransform::TxNone; } |
|
98 |
||
99 |
class QPainterClipInfo |
|
100 |
{ |
|
101 |
public: |
|
102 |
enum ClipType { RegionClip, PathClip, RectClip, RectFClip }; |
|
103 |
||
104 |
QPainterClipInfo(const QPainterPath &p, Qt::ClipOperation op, const QTransform &m) : |
|
105 |
clipType(PathClip), matrix(m), operation(op), path(p) { } |
|
106 |
||
107 |
QPainterClipInfo(const QRegion &r, Qt::ClipOperation op, const QTransform &m) : |
|
108 |
clipType(RegionClip), matrix(m), operation(op), region(r) { } |
|
109 |
||
110 |
QPainterClipInfo(const QRect &r, Qt::ClipOperation op, const QTransform &m) : |
|
111 |
clipType(RectClip), matrix(m), operation(op), rect(r) { } |
|
112 |
||
113 |
QPainterClipInfo(const QRectF &r, Qt::ClipOperation op, const QTransform &m) : |
|
114 |
clipType(RectFClip), matrix(m), operation(op), rectf(r) { } |
|
115 |
||
116 |
ClipType clipType; |
|
117 |
QTransform matrix; |
|
118 |
Qt::ClipOperation operation; |
|
119 |
QPainterPath path; |
|
120 |
QRegion region; |
|
121 |
QRect rect; |
|
122 |
QRectF rectf; |
|
123 |
||
124 |
// ### |
|
125 |
// union { |
|
126 |
// QRegionData *d; |
|
127 |
// QPainterPathPrivate *pathData; |
|
128 |
||
129 |
// struct { |
|
130 |
// int x, y, w, h; |
|
131 |
// } rectData; |
|
132 |
// struct { |
|
133 |
// qreal x, y, w, h; |
|
134 |
// } rectFData; |
|
135 |
// }; |
|
136 |
||
137 |
}; |
|
138 |
||
139 |
||
140 |
class Q_GUI_EXPORT QPainterState : public QPaintEngineState |
|
141 |
{ |
|
142 |
public: |
|
143 |
QPainterState(); |
|
144 |
QPainterState(const QPainterState *s); |
|
145 |
virtual ~QPainterState(); |
|
146 |
void init(QPainter *p); |
|
147 |
||
148 |
QPointF brushOrigin; |
|
149 |
QFont font; |
|
150 |
QFont deviceFont; |
|
151 |
QPen pen; |
|
152 |
QBrush brush; |
|
153 |
QBrush bgBrush; // background brush |
|
154 |
QRegion clipRegion; |
|
155 |
QPainterPath clipPath; |
|
156 |
Qt::ClipOperation clipOperation; |
|
157 |
QPainter::RenderHints renderHints; |
|
158 |
QList<QPainterClipInfo> clipInfo; // ### Make me smaller and faster to copy around... |
|
159 |
QTransform worldMatrix; // World transformation matrix, not window and viewport |
|
160 |
QTransform matrix; // Complete transformation matrix, |
|
161 |
QTransform redirectionMatrix; |
|
162 |
int wx, wy, ww, wh; // window rectangle |
|
163 |
int vx, vy, vw, vh; // viewport rectangle |
|
164 |
qreal opacity; |
|
165 |
||
166 |
uint WxF:1; // World transformation |
|
167 |
uint VxF:1; // View transformation |
|
168 |
uint clipEnabled:1; |
|
169 |
||
170 |
Qt::BGMode bgMode; |
|
171 |
QPainter *painter; |
|
172 |
Qt::LayoutDirection layoutDirection; |
|
173 |
QPainter::CompositionMode composition_mode; |
|
174 |
uint emulationSpecifier; |
|
175 |
uint changeFlags; |
|
176 |
}; |
|
177 |
||
178 |
struct QPainterDummyState |
|
179 |
{ |
|
180 |
QFont font; |
|
181 |
QPen pen; |
|
182 |
QBrush brush; |
|
183 |
QTransform transform; |
|
184 |
}; |
|
185 |
||
186 |
class QPainterPrivate |
|
187 |
{ |
|
188 |
Q_DECLARE_PUBLIC(QPainter) |
|
189 |
public: |
|
190 |
QPainterPrivate(QPainter *painter) |
|
191 |
: q_ptr(painter), d_ptrs(0), state(0), dummyState(0), txinv(0), inDestructor(false), d_ptrs_size(0), |
|
192 |
refcount(1), device(0), original_device(0), helper_device(0), engine(0), emulationEngine(0), |
|
193 |
extended(0) |
|
194 |
{ |
|
195 |
} |
|
196 |
||
197 |
~QPainterPrivate(); |
|
198 |
||
199 |
QPainter *q_ptr; |
|
200 |
QPainterPrivate **d_ptrs; |
|
201 |
||
202 |
QPainterState *state; |
|
203 |
QVector<QPainterState*> states; |
|
204 |
||
205 |
mutable QPainterDummyState *dummyState; |
|
206 |
||
207 |
QTransform invMatrix; |
|
208 |
uint txinv:1; |
|
209 |
uint inDestructor : 1; |
|
210 |
uint d_ptrs_size; |
|
211 |
uint refcount; |
|
212 |
||
213 |
enum DrawOperation { StrokeDraw = 0x1, |
|
214 |
FillDraw = 0x2, |
|
215 |
StrokeAndFillDraw = 0x3 |
|
216 |
}; |
|
217 |
||
218 |
QPainterDummyState *fakeState() const { |
|
219 |
if (!dummyState) |
|
220 |
dummyState = new QPainterDummyState(); |
|
221 |
return dummyState; |
|
222 |
} |
|
223 |
||
224 |
void updateEmulationSpecifier(QPainterState *s); |
|
225 |
void updateStateImpl(QPainterState *state); |
|
226 |
void updateState(QPainterState *state); |
|
227 |
||
228 |
void draw_helper(const QPainterPath &path, DrawOperation operation = StrokeAndFillDraw); |
|
229 |
void drawStretchedGradient(const QPainterPath &path, DrawOperation operation); |
|
230 |
void drawOpaqueBackground(const QPainterPath &path, DrawOperation operation); |
|
231 |
||
232 |
void updateMatrix(); |
|
233 |
void updateInvMatrix(); |
|
234 |
||
235 |
int rectSubtraction() const { |
|
236 |
return state->pen.style() != Qt::NoPen && state->pen.width() == 0 ? 1 : 0; |
|
237 |
} |
|
238 |
||
239 |
void checkEmulation(); |
|
240 |
||
241 |
QTransform viewTransform() const; |
|
242 |
static bool attachPainterPrivate(QPainter *q, QPaintDevice *pdev); |
|
243 |
void detachPainterPrivate(QPainter *q); |
|
244 |
||
245 |
QPaintDevice *device; |
|
246 |
QPaintDevice *original_device; |
|
247 |
QPaintDevice *helper_device; |
|
248 |
QPaintEngine *engine; |
|
249 |
QEmulationPaintEngine *emulationEngine; |
|
250 |
QPaintEngineEx *extended; |
|
251 |
QBrush colorBrush; // for fill with solid color |
|
252 |
}; |
|
253 |
||
254 |
Q_GUI_EXPORT void qt_draw_helper(QPainterPrivate *p, const QPainterPath &path, QPainterPrivate::DrawOperation operation); |
|
255 |
||
256 |
QString qt_generate_brush_key(const QBrush &brush); |
|
257 |
||
258 |
QT_END_NAMESPACE |
|
259 |
||
260 |
#endif // QPAINTER_P_H |