1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** Contact: Qt Software Information ([email protected])
|
---|
5 | **
|
---|
6 | ** This file is part of the QtGui module of the Qt Toolkit.
|
---|
7 | **
|
---|
8 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
9 | ** Commercial Usage
|
---|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
11 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
12 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
13 | ** a written agreement between you and Nokia.
|
---|
14 | **
|
---|
15 | ** GNU Lesser General Public License Usage
|
---|
16 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
17 | ** General Public License version 2.1 as published by the Free Software
|
---|
18 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
19 | ** packaging of this file. Please review the following information to
|
---|
20 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
21 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
22 | **
|
---|
23 | ** In addition, as a special exception, Nokia gives you certain
|
---|
24 | ** additional rights. These rights are described in the Nokia Qt LGPL
|
---|
25 | ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
|
---|
26 | ** 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 are unsure which license is appropriate for your use, please
|
---|
37 | ** contact the sales department at [email protected].
|
---|
38 | ** $QT_END_LICENSE$
|
---|
39 | **
|
---|
40 | ****************************************************************************/
|
---|
41 |
|
---|
42 | #ifndef QPAINTENGINE_X11_P_H
|
---|
43 | #define QPAINTENGINE_X11_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/qregion.h"
|
---|
58 | #include "QtGui/qpen.h"
|
---|
59 | #include "QtCore/qpoint.h"
|
---|
60 | #include "private/qpaintengine_p.h"
|
---|
61 | #include "private/qpainter_p.h"
|
---|
62 | #include "private/qpolygonclipper_p.h"
|
---|
63 |
|
---|
64 | typedef unsigned long Picture;
|
---|
65 |
|
---|
66 | QT_BEGIN_NAMESPACE
|
---|
67 |
|
---|
68 | class QX11PaintEnginePrivate;
|
---|
69 | class QFontEngineFT;
|
---|
70 | class QXRenderTessellator;
|
---|
71 |
|
---|
72 | struct qt_float_point
|
---|
73 | {
|
---|
74 | qreal x, y;
|
---|
75 | };
|
---|
76 |
|
---|
77 | class QX11PaintEngine : public QPaintEngine
|
---|
78 | {
|
---|
79 | Q_DECLARE_PRIVATE(QX11PaintEngine)
|
---|
80 | public:
|
---|
81 | QX11PaintEngine();
|
---|
82 | ~QX11PaintEngine();
|
---|
83 |
|
---|
84 | bool begin(QPaintDevice *pdev);
|
---|
85 | bool end();
|
---|
86 |
|
---|
87 | void updateState(const QPaintEngineState &state);
|
---|
88 |
|
---|
89 | void updatePen(const QPen &pen);
|
---|
90 | void updateBrush(const QBrush &brush, const QPointF &pt);
|
---|
91 | void updateRenderHints(QPainter::RenderHints hints);
|
---|
92 | void updateFont(const QFont &font);
|
---|
93 | void updateMatrix(const QTransform &matrix);
|
---|
94 | void updateClipRegion_dev(const QRegion ®ion, Qt::ClipOperation op);
|
---|
95 |
|
---|
96 | void drawLines(const QLine *lines, int lineCount);
|
---|
97 | void drawLines(const QLineF *lines, int lineCount);
|
---|
98 |
|
---|
99 | void drawRects(const QRect *rects, int rectCount);
|
---|
100 | void drawRects(const QRectF *rects, int rectCount);
|
---|
101 |
|
---|
102 | void drawPoints(const QPoint *points, int pointCount);
|
---|
103 | void drawPoints(const QPointF *points, int pointCount);
|
---|
104 |
|
---|
105 | void drawEllipse(const QRect &r);
|
---|
106 | void drawEllipse(const QRectF &r);
|
---|
107 |
|
---|
108 | virtual void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode);
|
---|
109 | inline void drawPolygon(const QPoint *points, int pointCount, PolygonDrawMode mode)
|
---|
110 | { QPaintEngine::drawPolygon(points, pointCount, mode); }
|
---|
111 |
|
---|
112 | void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr);
|
---|
113 | void drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s);
|
---|
114 | void drawPath(const QPainterPath &path);
|
---|
115 | void drawTextItem(const QPointF &p, const QTextItem &textItem);
|
---|
116 | void drawImage(const QRectF &r, const QImage &img, const QRectF &sr,
|
---|
117 | Qt::ImageConversionFlags flags = Qt::AutoColor);
|
---|
118 |
|
---|
119 | virtual Qt::HANDLE handle() const;
|
---|
120 | inline Type type() const { return QPaintEngine::X11; }
|
---|
121 |
|
---|
122 | QPainter::RenderHints supportedRenderHints() const;
|
---|
123 |
|
---|
124 | protected:
|
---|
125 | QX11PaintEngine(QX11PaintEnginePrivate &dptr);
|
---|
126 |
|
---|
127 | void drawXLFD(const QPointF &p, const QTextItemInt &si);
|
---|
128 | #ifndef QT_NO_FONTCONFIG
|
---|
129 | void drawFreetype(const QPointF &p, const QTextItemInt &si);
|
---|
130 | #endif
|
---|
131 |
|
---|
132 | friend class QPixmap;
|
---|
133 | friend class QFontEngineBox;
|
---|
134 | friend Q_GUI_EXPORT GC qt_x11_get_pen_gc(QPainter *);
|
---|
135 | friend Q_GUI_EXPORT GC qt_x11_get_brush_gc(QPainter *);
|
---|
136 |
|
---|
137 | private:
|
---|
138 | Q_DISABLE_COPY(QX11PaintEngine)
|
---|
139 | };
|
---|
140 |
|
---|
141 | class QX11PaintEnginePrivate : public QPaintEnginePrivate
|
---|
142 | {
|
---|
143 | Q_DECLARE_PUBLIC(QX11PaintEngine)
|
---|
144 | public:
|
---|
145 | QX11PaintEnginePrivate()
|
---|
146 | {
|
---|
147 | scrn = -1;
|
---|
148 | hd = 0;
|
---|
149 | picture = 0;
|
---|
150 | gc = gc_brush = 0;
|
---|
151 | dpy = 0;
|
---|
152 | xinfo = 0;
|
---|
153 | txop = QTransform::TxNone;
|
---|
154 | has_clipping = false;
|
---|
155 | render_hints = 0;
|
---|
156 | #ifndef QT_NO_XRENDER
|
---|
157 | tessellator = 0;
|
---|
158 | #endif
|
---|
159 | }
|
---|
160 | enum GCMode {
|
---|
161 | PenGC,
|
---|
162 | BrushGC
|
---|
163 | };
|
---|
164 |
|
---|
165 | void init();
|
---|
166 | void fillPolygon_translated(const QPointF *points, int pointCount, GCMode gcMode,
|
---|
167 | QPaintEngine::PolygonDrawMode mode);
|
---|
168 | void fillPolygon_dev(const QPointF *points, int pointCount, GCMode gcMode,
|
---|
169 | QPaintEngine::PolygonDrawMode mode);
|
---|
170 | void fillPath(const QPainterPath &path, GCMode gcmode, bool transform);
|
---|
171 | void strokePolygon_dev(const QPointF *points, int pointCount, bool close);
|
---|
172 | void strokePolygon_translated(const QPointF *points, int pointCount, bool close);
|
---|
173 | void setupAdaptedOrigin(const QPoint &p);
|
---|
174 | void resetAdaptedOrigin();
|
---|
175 | void decidePathFallback() {
|
---|
176 | use_path_fallback = has_alpha_brush
|
---|
177 | || has_alpha_pen
|
---|
178 | || has_custom_pen
|
---|
179 | || has_complex_xform
|
---|
180 | || (render_hints & QPainter::Antialiasing);
|
---|
181 | }
|
---|
182 | void decideCoordAdjust() {
|
---|
183 | adjust_coords = !(render_hints & QPainter::Antialiasing)
|
---|
184 | && (has_alpha_pen
|
---|
185 | || (has_alpha_brush && has_pen && !has_alpha_pen)
|
---|
186 | || (cpen.style() > Qt::SolidLine));
|
---|
187 | }
|
---|
188 | void clipPolygon_dev(const QPolygonF &poly, QPolygonF *clipped_poly);
|
---|
189 | void systemStateChanged();
|
---|
190 |
|
---|
191 | Display *dpy;
|
---|
192 | int scrn;
|
---|
193 | int pdev_depth;
|
---|
194 | Qt::HANDLE hd;
|
---|
195 | QPixmap brush_pm;
|
---|
196 | #if !defined (QT_NO_XRENDER)
|
---|
197 | Qt::HANDLE picture;
|
---|
198 | Qt::HANDLE current_brush;
|
---|
199 | QPixmap bitmap_texture;
|
---|
200 | int composition_mode;
|
---|
201 | #else
|
---|
202 | Qt::HANDLE picture;
|
---|
203 | #endif
|
---|
204 | GC gc;
|
---|
205 | GC gc_brush;
|
---|
206 |
|
---|
207 | QPen cpen;
|
---|
208 | QBrush cbrush;
|
---|
209 | QRegion crgn;
|
---|
210 | QTransform matrix;
|
---|
211 | qreal opacity;
|
---|
212 |
|
---|
213 | uint has_complex_xform : 1;
|
---|
214 | uint has_scaling_xform : 1;
|
---|
215 | uint has_non_scaling_xform : 1;
|
---|
216 | uint has_custom_pen : 1;
|
---|
217 | uint use_path_fallback : 1;
|
---|
218 | uint adjust_coords : 1;
|
---|
219 | uint has_clipping : 1;
|
---|
220 | uint adapted_brush_origin : 1;
|
---|
221 | uint adapted_pen_origin : 1;
|
---|
222 | uint has_pen : 1;
|
---|
223 | uint has_brush : 1;
|
---|
224 | uint has_texture : 1;
|
---|
225 | uint has_alpha_texture : 1;
|
---|
226 | uint has_pattern : 1;
|
---|
227 | uint has_alpha_pen : 1;
|
---|
228 | uint has_alpha_brush : 1;
|
---|
229 | uint render_hints;
|
---|
230 |
|
---|
231 | const QX11Info *xinfo;
|
---|
232 | QPointF bg_origin;
|
---|
233 | QTransform::TransformationType txop;
|
---|
234 | qreal xform_scale;
|
---|
235 | QPolygonClipper<qt_float_point, qt_float_point, float> polygonClipper;
|
---|
236 |
|
---|
237 | int xlibMaxLinePoints;
|
---|
238 | #ifndef QT_NO_XRENDER
|
---|
239 | QXRenderTessellator *tessellator;
|
---|
240 | #endif
|
---|
241 | };
|
---|
242 |
|
---|
243 | QT_END_NAMESPACE
|
---|
244 |
|
---|
245 | #endif // QPAINTENGINE_X11_P_H
|
---|