Qt 4.8
qvectorpath_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 QVECTORPATH_P_H
43 #define QVECTORPATH_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 
62 
64 
66 
67 QT_MODULE(Gui)
68 
69 class QPaintEngineEx;
70 
71 typedef void (*qvectorpath_cache_cleanup)(QPaintEngineEx *engine, void *data);
72 
73 struct QRealRect {
74  qreal x1, y1, x2, y2;
75 };
76 
78 {
79 public:
80  enum Hint {
81  // Shape hints, in 0x000000ff, access using shape()
82  AreaShapeMask = 0x0001, // shape covers an area
83  NonConvexShapeMask = 0x0002, // shape is not convex
84  CurvedShapeMask = 0x0004, // shape contains curves...
85  LinesShapeMask = 0x0008,
86  RectangleShapeMask = 0x0010,
87  ShapeMask = 0x001f,
88 
89  // Shape hints merged into basic shapes..
90  LinesHint = LinesShapeMask,
91  RectangleHint = AreaShapeMask | RectangleShapeMask,
92  EllipseHint = AreaShapeMask | CurvedShapeMask,
93  ConvexPolygonHint = AreaShapeMask,
94  PolygonHint = AreaShapeMask | NonConvexShapeMask,
95  RoundedRectHint = AreaShapeMask | CurvedShapeMask,
96  ArbitraryShapeHint = AreaShapeMask | NonConvexShapeMask | CurvedShapeMask,
97 
98  // Other hints
99  IsCachedHint = 0x0100, // Set if the cache hint is set
100  ShouldUseCacheHint = 0x0200, // Set if the path should be cached when possible..
101  ControlPointRect = 0x0400, // Set if the control point rect has been calculated...
102 
103  // Shape rendering specifiers...
104  OddEvenFill = 0x1000,
105  WindingFill = 0x2000,
106  ImplicitClose = 0x4000
107  };
108 
109  // ### Falcon: introduca a struct XY for points so lars is not so confused...
110  QVectorPath(const qreal *points,
111  int count,
113  uint hints = ArbitraryShapeHint)
114  : m_elements(elements),
115  m_points(points),
116  m_count(count),
117  m_hints(hints)
118  {
119  }
120 
121  ~QVectorPath();
122 
123  QRectF controlPointRect() const;
124 
125  inline Hint shape() const { return (Hint) (m_hints & ShapeMask); }
126  inline bool isConvex() const { return (m_hints & NonConvexShapeMask) == 0; }
127  inline bool isCurved() const { return m_hints & CurvedShapeMask; }
128 
129  inline bool isCacheable() const { return m_hints & ShouldUseCacheHint; }
130  inline bool hasImplicitClose() const { return m_hints & ImplicitClose; }
131  inline bool hasWindingFill() const { return m_hints & WindingFill; }
132 
133  inline void makeCacheable() const { m_hints |= ShouldUseCacheHint; m_cache = 0; }
134  inline uint hints() const { return m_hints; }
135 
136  inline const QPainterPath::ElementType *elements() const { return m_elements; }
137  inline const qreal *points() const { return m_points; }
138  inline bool isEmpty() const { return m_points == 0; }
139 
140  inline int elementCount() const { return m_count; }
141  inline const QPainterPath convertToPainterPath() const;
142 
143  static inline uint polygonFlags(QPaintEngine::PolygonDrawMode mode);
144 
145  struct CacheEntry {
147  void *data;
150  };
151 
152  CacheEntry *addCacheData(QPaintEngineEx *engine, void *data, qvectorpath_cache_cleanup cleanup) const;
153  inline CacheEntry *lookupCacheData(QPaintEngineEx *engine) const {
154  Q_ASSERT(m_hints & ShouldUseCacheHint);
155  CacheEntry *e = m_cache;
156  while (e) {
157  if (e->engine == engine)
158  return e;
159  e = e->next;
160  }
161  return 0;
162  }
163 
164 
165 private:
167 
168  const QPainterPath::ElementType *m_elements;
169  const qreal *m_points;
170  const int m_count;
171 
172  mutable uint m_hints;
173  mutable QRealRect m_cp_rect;
174 
175  mutable CacheEntry *m_cache;
176 };
177 
179 
181 
183 
184 #endif
ElementType
This enum describes the types of elements used to connect vertices in subpaths.
Definition: qpainterpath.h:70
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
int elementCount() const
bool isEmpty() const
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
bool isCurved() const
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:67
#define Q_GUI_EXPORT
Definition: qglobal.h:1450
#define Q_DISABLE_COPY(Class)
Disables the use of copy constructors and assignment operators for the given Class.
Definition: qglobal.h:2523
void(* qvectorpath_cache_cleanup)(QPaintEngineEx *engine, void *data)
Definition: qvectorpath_p.h:71
bool isCacheable() const
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
const QPainterPath::ElementType * elements() const
void makeCacheable() const
QPaintEngineEx * engine
#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
CacheEntry * lookupCacheData(QPaintEngineEx *engine) const
static const char * data(const QByteArray &arr)
unsigned int uint
Definition: qglobal.h:996
Q_GUI_EXPORT const QVectorPath & qtVectorPathForPath(const QPainterPath &path)
bool hasWindingFill() const
uint hints() const
qvectorpath_cache_cleanup cleanup
const qreal * points() const
static void cleanup()
Definition: qpicture.cpp:1508
bool isConvex() const
bool hasImplicitClose() const
static const QTextHtmlElement elements[Html_NumElements]
QVectorPath(const qreal *points, int count, const QPainterPath::ElementType *elements=0, uint hints=ArbitraryShapeHint)
#define QT_END_HEADER
Definition: qglobal.h:137
Hint shape() const