1 /****************************************************************************
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the QtGui module of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
42 #ifndef QPAINTENGINE_X11_P_H
43 #define QPAINTENGINE_X11_P_H
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.
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"
64 typedef unsigned long Picture;
68 class QX11PaintEnginePrivate;
70 class QXRenderTessellator;
77 class QX11PaintEngine : public QPaintEngine
79 Q_DECLARE_PRIVATE(QX11PaintEngine)
84 bool begin(QPaintDevice *pdev);
87 void updateState(const QPaintEngineState &state);
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);
96 void drawLines(const QLine *lines, int lineCount);
97 void drawLines(const QLineF *lines, int lineCount);
99 void drawRects(const QRect *rects, int rectCount);
100 void drawRects(const QRectF *rects, int rectCount);
102 void drawPoints(const QPoint *points, int pointCount);
103 void drawPoints(const QPointF *points, int pointCount);
105 void drawEllipse(const QRect &r);
106 void drawEllipse(const QRectF &r);
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); }
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);
119 virtual Qt::HANDLE handle() const;
120 inline Type type() const { return QPaintEngine::X11; }
122 QPainter::RenderHints supportedRenderHints() const;
125 QX11PaintEngine(QX11PaintEnginePrivate &dptr);
127 void drawXLFD(const QPointF &p, const QTextItemInt &si);
128 #ifndef QT_NO_FONTCONFIG
129 void drawFreetype(const QPointF &p, const QTextItemInt &si);
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 *);
138 Q_DISABLE_COPY(QX11PaintEngine)
141 class QX11PaintEnginePrivate : public QPaintEnginePrivate
143 Q_DECLARE_PUBLIC(QX11PaintEngine)
145 QX11PaintEnginePrivate()
153 txop = QTransform::TxNone;
154 has_clipping = false;
157 #ifndef QT_NO_XRENDER
167 void fillPolygon_translated(const QPointF *points, int pointCount, GCMode gcMode,
168 QPaintEngine::PolygonDrawMode mode);
169 void fillPolygon_dev(const QPointF *points, int pointCount, GCMode gcMode,
170 QPaintEngine::PolygonDrawMode mode);
171 void fillPath(const QPainterPath &path, GCMode gcmode, bool transform);
172 void strokePolygon_dev(const QPointF *points, int pointCount, bool close);
173 void strokePolygon_translated(const QPointF *points, int pointCount, bool close);
174 void setupAdaptedOrigin(const QPoint &p);
175 void resetAdaptedOrigin();
176 void decidePathFallback() {
177 use_path_fallback = has_alpha_brush
181 || (render_hints & QPainter::Antialiasing);
183 void decideCoordAdjust() {
184 adjust_coords = !(render_hints & QPainter::Antialiasing)
186 || (has_alpha_brush && has_pen && !has_alpha_pen)
187 || (cpen.style() > Qt::SolidLine));
189 void clipPolygon_dev(const QPolygonF &poly, QPolygonF *clipped_poly);
190 void systemStateChanged();
197 #if !defined (QT_NO_XRENDER)
199 Qt::HANDLE current_brush;
200 QPixmap bitmap_texture;
201 int composition_mode;
214 uint has_complex_xform : 1;
215 uint has_scaling_xform : 1;
216 uint has_non_scaling_xform : 1;
217 uint has_custom_pen : 1;
218 uint use_path_fallback : 1;
219 uint adjust_coords : 1;
220 uint has_clipping : 1;
221 uint adapted_brush_origin : 1;
222 uint adapted_pen_origin : 1;
225 uint has_texture : 1;
226 uint has_alpha_texture : 1;
227 uint has_pattern : 1;
228 uint has_alpha_pen : 1;
229 uint has_alpha_brush : 1;
232 const QX11Info *xinfo;
234 QTransform::TransformationType txop;
236 QPolygonClipper<qt_float_point, qt_float_point, float> polygonClipper;
238 int xlibMaxLinePoints;
239 #ifndef QT_NO_XRENDER
240 QXRenderTessellator *tessellator;
246 #endif // QPAINTENGINE_X11_P_H