Qt 4.8
qpaintengineex_p.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
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 #include <QtGui/qdrawutil.h>
58 
59 #include <private/qpaintengine_p.h>
60 #include <private/qstroker_p.h>
61 #include <private/qpainter_p.h>
62 #include <private/qvectorpath_p.h>
63 
64 
66 
68 
69 QT_MODULE(Gui)
70 
71 class QPainterState;
73 class QStaticTextItem;
74 struct StrokeHandler;
75 
76 struct QIntRect {
77  int x1, y1, x2, y2;
78  inline void set(const QRect &r) {
79  x1 = r.x();
80  y1 = r.y();
81  x2 = r.right() + 1;
82  y2 = r.bottom() + 1;
83  // We will assume normalized for later...
84  Q_ASSERT(x2 >= x1);
85  Q_ASSERT(y2 >= y1);
86  }
87 };
88 
89 class QRectVectorPath : public QVectorPath {
90 public:
91  inline void set(const QRect &r) {
92  qreal left = r.x();
93  qreal right = r.x() + r.width();
94  qreal top = r.y();
95  qreal bottom = r.y() + r.height();
96  pts[0] = left;
97  pts[1] = top;
98  pts[2] = right;
99  pts[3] = top;
100  pts[4] = right;
101  pts[5] = bottom;
102  pts[6] = left;
103  pts[7] = bottom;
104  }
105 
106  inline void set(const QRectF &r) {
107  qreal left = r.x();
108  qreal right = r.x() + r.width();
109  qreal top = r.y();
110  qreal bottom = r.y() + r.height();
111  pts[0] = left;
112  pts[1] = top;
113  pts[2] = right;
114  pts[3] = top;
115  pts[4] = right;
116  pts[5] = bottom;
117  pts[6] = left;
118  pts[7] = bottom;
119  }
120  inline QRectVectorPath(const QRect &r)
121  : QVectorPath(pts, 4, 0, QVectorPath::RectangleHint | QVectorPath::ImplicitClose)
122  {
123  set(r);
124  }
125  inline QRectVectorPath(const QRectF &r)
126  : QVectorPath(pts, 4, 0, QVectorPath::RectangleHint | QVectorPath::ImplicitClose)
127  {
128  set(r);
129  }
131  : QVectorPath(pts, 4, 0, QVectorPath::RectangleHint | QVectorPath::ImplicitClose)
132  { }
133 
134  qreal pts[8];
135 };
136 
137 #ifndef QT_NO_DEBUG_STREAM
139 #endif
140 
141 class QPixmapFilter;
142 
144 {
146 public:
147  QPaintEngineEx();
148 
149  virtual QPainterState *createState(QPainterState *orig) const;
150 
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);
154 
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 &region, Qt::ClipOperation op);
158  virtual void clip(const QPainterPath &path, Qt::ClipOperation op);
159 
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;
168 
169  virtual void fillRect(const QRectF &rect, const QBrush &brush);
170  virtual void fillRect(const QRectF &rect, const QColor &color);
171 
172  virtual void drawRoundedRect(const QRectF &rect, qreal xrad, qreal yrad, Qt::SizeMode mode);
173 
174  virtual void drawRects(const QRect *rects, int rectCount);
175  virtual void drawRects(const QRectF *rects, int rectCount);
176 
177  virtual void drawLines(const QLine *lines, int lineCount);
178  virtual void drawLines(const QLineF *lines, int lineCount);
179 
180  virtual void drawEllipse(const QRectF &r);
181  virtual void drawEllipse(const QRect &r);
182 
183  virtual void drawPath(const QPainterPath &path);
184 
185  virtual void drawPoints(const QPointF *points, int pointCount);
186  virtual void drawPoints(const QPoint *points, int pointCount);
187 
188  virtual void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode);
189  virtual void drawPolygon(const QPoint *points, int pointCount, PolygonDrawMode mode);
190 
191  virtual void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) = 0;
192  virtual void drawPixmap(const QPointF &pos, const QPixmap &pm);
193 
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);
197 
198  virtual void drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s);
199 
200  virtual void drawPixmapFragments(const QPainter::PixmapFragment *fragments, int fragmentCount, const QPixmap &pixmap,
201  QPainter::PixmapFragmentHints hints);
202  virtual void drawPixmapFragments(const QRectF *targetRects, const QRectF *sourceRects, int fragmentCount, const QPixmap &pixmap,
203  QPainter::PixmapFragmentHints hints);
204 
205  virtual void updateState(const QPaintEngineState &state);
206 
207  virtual void drawStaticTextItem(QStaticTextItem *);
208 
209  virtual void setState(QPainterState *s);
210  inline QPainterState *state() { return static_cast<QPainterState *>(QPaintEngine::state); }
211  inline const QPainterState *state() const { return static_cast<const QPainterState *>(QPaintEngine::state); }
212 
213  virtual void sync() {}
214 
215  virtual void beginNativePainting() {}
216  virtual void endNativePainting() {}
217 
218  // Return a pixmap filter of "type" that can render the parameters
219  // in "prototype". The returned filter is owned by the engine and
220  // will be destroyed when the engine is destroyed. The "prototype"
221  // allows the engine to pick different filters based on the parameters
222  // that will be requested, and not just the "type".
223  virtual QPixmapFilter *pixmapFilter(int /*type*/, const QPixmapFilter * /*prototype*/) { return 0; }
224 
225  // These flags are needed in the implementation of paint buffers.
226  enum Flags
227  {
228  DoNotEmulate = 0x01, // If set, QPainter will not wrap this engine in an emulation engine.
229  IsEmulationEngine = 0x02 // If set, this object is a QEmulationEngine.
230  };
231  virtual uint flags() const {return 0;}
232  virtual bool supportsTransformations(qreal pixelSize, const QTransform &m) const;
233 
234 protected:
236 };
237 
239 {
241 public:
244 
245  void replayClipOperations();
246  bool hasClipOperations() const;
247 
253 
255 };
256 
258  switch (mode) {
259  case QPaintEngine::ConvexMode: return ConvexPolygonHint | ImplicitClose;
260  case QPaintEngine::OddEvenMode: return PolygonHint | OddEvenFill | ImplicitClose;
261  case QPaintEngine::WindingMode: return PolygonHint | WindingFill | ImplicitClose;
262  case QPaintEngine::PolylineMode: return PolygonHint;
263  default: return 0;
264  }
265 }
266 
268 
270 
271 #endif
The QDebug class provides an output stream for debugging information.
Definition: qdebug.h:62
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
double qreal
Definition: qglobal.h:1193
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
#define QT_MODULE(x)
Definition: qglobal.h:2783
The QLine class provides a two-dimensional vector using integer precision.
Definition: qline.h:57
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:67
QPaintEngineState * state
Definition: qpaintengine.h:239
#define Q_GUI_EXPORT
Definition: qglobal.h:1450
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
QRectVectorPath(const QRectF &r)
virtual uint flags() const
virtual void beginNativePainting()
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QPen class defines how a QPainter should draw lines and outlines of shapes.
Definition: qpen.h:64
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
const QPainterState * state() const
The QLineF class provides a two-dimensional vector using floating point precision.
Definition: qline.h:212
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
virtual QPixmapFilter * pixmapFilter(int, const QPixmapFilter *)
virtual void endNativePainting()
static float pixelSize(const QFontDef &request, int dpi)
Definition: qfont_win.cpp:80
static void drawRects(const T *rects, int n, const QTransform &transform, IDirectFBSurface *surface)
static uint polygonFlags(QPaintEngine::PolygonDrawMode mode)
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
static const char * data(const QByteArray &arr)
unsigned int uint
Definition: qglobal.h:996
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
The QPaintEngine class provides an abstract definition of how QPainter draws to a given device on a g...
Definition: qpaintengine.h:90
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
QDebug Q_GUI_EXPORT & operator<<(QDebug &, const QVectorPath &path)
QStrokerOps * activeStroker
#define Q_DECLARE_PUBLIC(Class)
Definition: qglobal.h:2477
This class is used in conjunction with the QPainter::drawPixmapFragments() function to specify how a ...
Definition: qpainter.h:103
The QPixmapFilter class provides the basic functionality for pixmap filter classes.
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
QRectVectorPath(const QRect &r)
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
StrokeHandler * strokeHandler
static void drawPoints(const T *points, int n, const QTransform &transform, IDirectFBSurface *surface)
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
The QPaintEngineState class provides information about the active paint engine&#39;s current state...
Definition: qpaintengine.h:289
virtual void sync()
#define Q_DECLARE_PRIVATE(Class)
Definition: qglobal.h:2467
SizeMode
Definition: qnamespace.h:1187
static void drawLines(const T *lines, int n, const QTransform &transform, IDirectFBSurface *surface)
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
#define QT_END_HEADER
Definition: qglobal.h:137
QPainterState * state()
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65
ClipOperation
Definition: qnamespace.h:1495