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 QPAINTENGINEEX_P_H
43 #define QPAINTENGINEEX_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/qdrawutil.h>
59 #include <private/qpaintengine_p.h>
60 #include <private/qstroker_p.h>
61 #include <private/qpainter_p.h>
62 #include <private/qvectorpath_p.h>
72 class QPaintEngineExPrivate;
73 class QStaticTextItem;
78 inline void set(const QRect &r) {
83 // We will assume normalized for later...
89 class QRectVectorPath : public QVectorPath {
91 inline void set(const QRect &r) {
93 qreal right = r.x() + r.width();
95 qreal bottom = r.y() + r.height();
106 inline void set(const QRectF &r) {
108 qreal right = r.x() + r.width();
110 qreal bottom = r.y() + r.height();
120 inline QRectVectorPath(const QRect &r)
121 : QVectorPath(pts, 4, 0, QVectorPath::RectangleHint | QVectorPath::ImplicitClose)
125 inline QRectVectorPath(const QRectF &r)
126 : QVectorPath(pts, 4, 0, QVectorPath::RectangleHint | QVectorPath::ImplicitClose)
130 inline QRectVectorPath()
131 : QVectorPath(pts, 4, 0, QVectorPath::RectangleHint | QVectorPath::ImplicitClose)
137 #ifndef QT_NO_DEBUG_STREAM
138 QDebug Q_GUI_EXPORT &operator<<(QDebug &, const QVectorPath &path);
143 class Q_GUI_EXPORT QPaintEngineEx : public QPaintEngine
145 Q_DECLARE_PRIVATE(QPaintEngineEx)
149 virtual QPainterState *createState(QPainterState *orig) const;
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);
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 ®ion, Qt::ClipOperation op);
158 virtual void clip(const QPainterPath &path, Qt::ClipOperation op);
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;
169 virtual void fillRect(const QRectF &rect, const QBrush &brush);
170 virtual void fillRect(const QRectF &rect, const QColor &color);
172 virtual void drawRoundedRect(const QRectF &rect, qreal xrad, qreal yrad, Qt::SizeMode mode);
174 virtual void drawRects(const QRect *rects, int rectCount);
175 virtual void drawRects(const QRectF *rects, int rectCount);
177 virtual void drawLines(const QLine *lines, int lineCount);
178 virtual void drawLines(const QLineF *lines, int lineCount);
180 virtual void drawEllipse(const QRectF &r);
181 virtual void drawEllipse(const QRect &r);
183 virtual void drawPath(const QPainterPath &path);
185 virtual void drawPoints(const QPointF *points, int pointCount);
186 virtual void drawPoints(const QPoint *points, int pointCount);
188 virtual void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode);
189 virtual void drawPolygon(const QPoint *points, int pointCount, PolygonDrawMode mode);
191 virtual void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) = 0;
192 virtual void drawPixmap(const QPointF &pos, const QPixmap &pm);
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);
198 virtual void drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s);
200 virtual void drawPixmapFragments(const QPainter::PixmapFragment *fragments, int fragmentCount, const QPixmap &pixmap,
201 QFlags<QPainter::PixmapFragmentHint> hints);
203 virtual void updateState(const QPaintEngineState &state);
205 virtual void drawStaticTextItem(QStaticTextItem *);
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); }
211 virtual void sync() {}
213 virtual void beginNativePainting() {}
214 virtual void endNativePainting() {}
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; }
223 // These flags are needed in the implementation of paint buffers.
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.
229 virtual uint flags() const {return 0;}
230 virtual bool supportsTransformations(qreal pixelSize, const QTransform &m) const;
231 virtual bool shouldDrawCachedGlyphs(qreal pixelSize, const QTransform &m) const;
234 QPaintEngineEx(QPaintEngineExPrivate &data);
237 class Q_GUI_EXPORT QPaintEngineExPrivate : public QPaintEnginePrivate
239 Q_DECLARE_PUBLIC(QPaintEngineEx)
241 QPaintEngineExPrivate();
242 ~QPaintEngineExPrivate();
244 void replayClipOperations();
245 bool hasClipOperations() const;
249 StrokeHandler *strokeHandler;
250 QStrokerOps *activeStroker;
256 inline uint QVectorPath::polygonFlags(QPaintEngine::PolygonDrawMode mode) {
258 case QPaintEngine::ConvexMode: return ConvexPolygonHint | ImplicitClose;
259 case QPaintEngine::OddEvenMode: return PolygonHint | OddEvenFill | ImplicitClose;
260 case QPaintEngine::WindingMode: return PolygonHint | WindingFill | ImplicitClose;
261 case QPaintEngine::PolylineMode: return PolygonHint;