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 QVECTORPATH_P_H
43 #define QVECTORPATH_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>
58 #include <private/qpaintengine_p.h>
59 #include <private/qstroker_p.h>
60 #include <private/qpainter_p.h>
71 typedef void (*qvectorpath_cache_cleanup)(QPaintEngineEx *engine, void *data);
77 class Q_GUI_EXPORT QVectorPath
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,
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,
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...
103 // Shape rendering specifiers...
104 OddEvenFill = 0x1000,
105 WindingFill = 0x2000,
106 ImplicitClose = 0x4000
109 // ### Falcon: introduca a struct XY for points so lars is not so confused...
110 QVectorPath(const qreal *points,
112 const QPainterPath::ElementType *elements = 0,
113 uint hints = ArbitraryShapeHint)
114 : m_elements(elements),
123 QRectF controlPointRect() const;
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; }
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; }
133 inline void makeCacheable() const { m_hints |= ShouldUseCacheHint; m_cache = 0; }
134 inline uint hints() const { return m_hints; }
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; }
140 inline int elementCount() const { return m_count; }
141 inline const QPainterPath convertToPainterPath() const;
143 static inline uint polygonFlags(QPaintEngine::PolygonDrawMode mode);
146 QPaintEngineEx *engine;
148 qvectorpath_cache_cleanup cleanup;
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;
157 if (e->engine == engine)
166 Q_DISABLE_COPY(QVectorPath)
168 const QPainterPath::ElementType *m_elements;
169 const qreal *m_points;
172 mutable uint m_hints;
173 mutable QRealRect m_cp_rect;
175 mutable CacheEntry *m_cache;
178 Q_GUI_EXPORT const QVectorPath &qtVectorPathForPath(const QPainterPath &path);