Make QRegion not need to be friends with QVector
[profile/ivi/qtbase.git] / src / gui / painting / qpaintengineex_p.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
16 **
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
20 **
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
28 **
29 ** Other Usage
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
32 **
33 **
34 **
35 **
36 **
37 **
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
58 #include <private/qpaintengine_p.h>
59 #include <private/qstroker_p.h>
60 #include <private/qpainter_p.h>
61 #include <private/qvectorpath_p.h>
62
63
64 QT_BEGIN_HEADER
65
66 QT_BEGIN_NAMESPACE
67
68
69 class QPainterState;
70 class QPaintEngineExPrivate;
71 class QStaticTextItem;
72 struct StrokeHandler;
73
74 #ifndef QT_NO_DEBUG_STREAM
75 QDebug Q_GUI_EXPORT &operator<<(QDebug &, const QVectorPath &path);
76 #endif
77
78 class QPixmapFilter;
79
80 class Q_GUI_EXPORT QPaintEngineEx : public QPaintEngine
81 {
82     Q_DECLARE_PRIVATE(QPaintEngineEx)
83 public:
84     QPaintEngineEx();
85
86     virtual QPainterState *createState(QPainterState *orig) const;
87
88     virtual void draw(const QVectorPath &path);
89     virtual void fill(const QVectorPath &path, const QBrush &brush) = 0;
90     virtual void stroke(const QVectorPath &path, const QPen &pen);
91
92     virtual void clip(const QVectorPath &path, Qt::ClipOperation op) = 0;
93     virtual void clip(const QRect &rect, Qt::ClipOperation op);
94     virtual void clip(const QRegion &region, Qt::ClipOperation op);
95     virtual void clip(const QPainterPath &path, Qt::ClipOperation op);
96
97     virtual void clipEnabledChanged() = 0;
98     virtual void penChanged() = 0;
99     virtual void brushChanged() = 0;
100     virtual void brushOriginChanged() = 0;
101     virtual void opacityChanged() = 0;
102     virtual void compositionModeChanged() = 0;
103     virtual void renderHintsChanged() = 0;
104     virtual void transformChanged() = 0;
105
106     virtual void fillRect(const QRectF &rect, const QBrush &brush);
107     virtual void fillRect(const QRectF &rect, const QColor &color);
108
109     virtual void drawRoundedRect(const QRectF &rect, qreal xrad, qreal yrad, Qt::SizeMode mode);
110
111     virtual void drawRects(const QRect *rects, int rectCount);
112     virtual void drawRects(const QRectF *rects, int rectCount);
113
114     virtual void drawLines(const QLine *lines, int lineCount);
115     virtual void drawLines(const QLineF *lines, int lineCount);
116
117     virtual void drawEllipse(const QRectF &r);
118     virtual void drawEllipse(const QRect &r);
119
120     virtual void drawPath(const QPainterPath &path);
121
122     virtual void drawPoints(const QPointF *points, int pointCount);
123     virtual void drawPoints(const QPoint *points, int pointCount);
124
125     virtual void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode);
126     virtual void drawPolygon(const QPoint *points, int pointCount, PolygonDrawMode mode);
127
128     virtual void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) = 0;
129     virtual void drawPixmap(const QPointF &pos, const QPixmap &pm);
130
131     virtual void drawImage(const QRectF &r, const QImage &pm, const QRectF &sr,
132                            Qt::ImageConversionFlags flags = Qt::AutoColor) = 0;
133     virtual void drawImage(const QPointF &pos, const QImage &image);
134
135     virtual void drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s);
136
137     virtual void drawPixmapFragments(const QPainter::PixmapFragment *fragments, int fragmentCount, const QPixmap &pixmap,
138                                      QFlags<QPainter::PixmapFragmentHint> hints);
139
140     virtual void updateState(const QPaintEngineState &state);
141
142     virtual void drawStaticTextItem(QStaticTextItem *);
143
144     virtual void setState(QPainterState *s);
145     inline QPainterState *state() { return static_cast<QPainterState *>(QPaintEngine::state); }
146     inline const QPainterState *state() const { return static_cast<const QPainterState *>(QPaintEngine::state); }
147
148     virtual void sync() {}
149
150     virtual void beginNativePainting() {}
151     virtual void endNativePainting() {}
152
153     // Return a pixmap filter of "type" that can render the parameters
154     // in "prototype".  The returned filter is owned by the engine and
155     // will be destroyed when the engine is destroyed.  The "prototype"
156     // allows the engine to pick different filters based on the parameters
157     // that will be requested, and not just the "type".
158     virtual QPixmapFilter *pixmapFilter(int /*type*/, const QPixmapFilter * /*prototype*/) { return 0; }
159
160     // These flags are needed in the implementation of paint buffers.
161     enum Flags
162     {
163         DoNotEmulate = 0x01,        // If set, QPainter will not wrap this engine in an emulation engine.
164         IsEmulationEngine = 0x02    // If set, this object is a QEmulationEngine.
165     };
166     virtual uint flags() const {return 0;}
167     virtual bool supportsTransformations(QFontEngine *fontEngine, const QTransform &m) const;
168     virtual bool shouldDrawCachedGlyphs(QFontEngine *fontEngine, const QTransform &m) const;
169
170 protected:
171     QPaintEngineEx(QPaintEngineExPrivate &data);
172 };
173
174 class Q_GUI_EXPORT QPaintEngineExPrivate : public QPaintEnginePrivate
175 {
176     Q_DECLARE_PUBLIC(QPaintEngineEx)
177 public:
178     QPaintEngineExPrivate();
179     ~QPaintEngineExPrivate();
180
181     void replayClipOperations();
182     bool hasClipOperations() const;
183
184     QStroker stroker;
185     QDashStroker dasher;
186     StrokeHandler *strokeHandler;
187     QStrokerOps *activeStroker;
188     QPen strokerPen;
189
190     QRect exDeviceRect;
191 };
192
193 QT_END_NAMESPACE
194
195 QT_END_HEADER
196
197 #endif