Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qvectorpath_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QVECTORPATH_P_H
5#define QVECTORPATH_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtGui/private/qtguiglobal_p.h>
19#include <QtGui/qpaintengine.h>
20
21#include <private/qpaintengine_p.h>
22#include <private/qstroker_p.h>
23#include <private/qpainter_p.h>
24
25
27
28
29class QPaintEngineEx;
30
32
33struct QRealRect {
35};
36
37class Q_GUI_EXPORT QVectorPath
38{
39public:
40 enum Hint {
41 // Shape hints, in 0x000000ff, access using shape()
42 AreaShapeMask = 0x0001, // shape covers an area
43 NonConvexShapeMask = 0x0002, // shape is not convex
44 CurvedShapeMask = 0x0004, // shape contains curves...
45 LinesShapeMask = 0x0008,
46 RectangleShapeMask = 0x0010,
47 ShapeMask = 0x001f,
48
49 // Shape hints merged into basic shapes..
50 LinesHint = LinesShapeMask,
51 RectangleHint = AreaShapeMask | RectangleShapeMask,
52 EllipseHint = AreaShapeMask | CurvedShapeMask,
53 ConvexPolygonHint = AreaShapeMask,
54 PolygonHint = AreaShapeMask | NonConvexShapeMask,
55 RoundedRectHint = AreaShapeMask | CurvedShapeMask,
56 ArbitraryShapeHint = AreaShapeMask | NonConvexShapeMask | CurvedShapeMask,
57
58 // Other hints
59 IsCachedHint = 0x0100, // Set if the cache hint is set
60 ShouldUseCacheHint = 0x0200, // Set if the path should be cached when possible..
61 ControlPointRect = 0x0400, // Set if the control point rect has been calculated...
62
63 // Shape rendering specifiers...
64 OddEvenFill = 0x1000,
65 WindingFill = 0x2000,
66 ImplicitClose = 0x4000,
67 ExplicitOpen = 0x8000
68 };
69
70 // ### Falcon: introduca a struct XY for points so lars is not so confused...
72 int count,
73 const QPainterPath::ElementType *elements = nullptr,
74 uint hints = ArbitraryShapeHint)
75 : m_elements(elements),
76 m_points(points),
77 m_count(count),
78 m_hints(hints)
79 {
80 }
81
83
84 QRectF controlPointRect() const;
85
86 inline Hint shape() const { return (Hint) (m_hints & ShapeMask); }
87 inline bool isConvex() const { return (m_hints & NonConvexShapeMask) == 0; }
88 inline bool isCurved() const { return m_hints & CurvedShapeMask; }
89
90 inline bool isCacheable() const { return m_hints & ShouldUseCacheHint; }
91 inline bool hasImplicitClose() const { return m_hints & ImplicitClose; }
92 inline bool hasExplicitOpen() const { return m_hints & ExplicitOpen; }
93 inline bool hasWindingFill() const { return m_hints & WindingFill; }
94
95 inline void makeCacheable() const { m_hints |= ShouldUseCacheHint; m_cache = nullptr; }
96 inline uint hints() const { return m_hints; }
97
98 inline const QPainterPath::ElementType *elements() const { return m_elements; }
99 inline const qreal *points() const { return m_points; }
100 inline bool isEmpty() const { return m_points == nullptr; }
101
102 inline int elementCount() const { return m_count; }
103 inline const QPainterPath convertToPainterPath() const;
104
106 {
107 switch (mode) {
108 case QPaintEngine::ConvexMode: return ConvexPolygonHint | ImplicitClose;
109 case QPaintEngine::OddEvenMode: return PolygonHint | OddEvenFill | ImplicitClose;
110 case QPaintEngine::WindingMode: return PolygonHint | WindingFill | ImplicitClose;
111 case QPaintEngine::PolylineMode: return PolygonHint | ExplicitOpen;
112 default: return 0;
113 }
114 }
115
122
123 CacheEntry *addCacheData(QPaintEngineEx *engine, void *data, qvectorpath_cache_cleanup cleanup) const;
125 Q_ASSERT(m_hints & ShouldUseCacheHint);
126 CacheEntry *e = m_cache;
127 while (e) {
128 if (e->engine == engine)
129 return e;
130 e = e->next;
131 }
132 return nullptr;
133 }
134
135 template <typename T> static inline bool isRect(const T *pts, int elementCount) {
136 return (elementCount == 5 // 5-point polygon, check for closed rect
137 && pts[0] == pts[8] && pts[1] == pts[9] // last point == first point
138 && pts[0] == pts[6] && pts[2] == pts[4] // x values equal
139 && pts[1] == pts[3] && pts[5] == pts[7] // y values equal...
140 && pts[0] < pts[4] && pts[1] < pts[5]
141 ) ||
142 (elementCount == 4 // 4-point polygon, check for unclosed rect
143 && pts[0] == pts[6] && pts[2] == pts[4] // x values equal
144 && pts[1] == pts[3] && pts[5] == pts[7] // y values equal...
145 && pts[0] < pts[4] && pts[1] < pts[5]
146 );
147 }
148
149 inline bool isRect() const
150 {
151 const QPainterPath::ElementType * const types = elements();
152
153 return (shape() == QVectorPath::RectangleHint)
154 || (isRect(points(), elementCount())
159 }
160
161
162private:
163 Q_DISABLE_COPY_MOVE(QVectorPath)
164
165 const QPainterPath::ElementType *m_elements;
166 const qreal *m_points;
167 const int m_count;
168
169 mutable uint m_hints;
170 mutable QRealRect m_cp_rect;
171
172 mutable CacheEntry *m_cache;
173};
174
175Q_GUI_EXPORT const QVectorPath &qtVectorPathForPath(const QPainterPath &path);
176
178
179#endif
PolygonDrawMode
\value OddEvenMode The polygon should be drawn using OddEven fill rule.
\inmodule QtGui
ElementType
This enum describes the types of elements used to connect vertices in subpaths.
\inmodule QtCore\reentrant
Definition qrect.h:484
bool isRect() const
bool isConvex() const
QVectorPath(const qreal *points, int count, const QPainterPath::ElementType *elements=nullptr, uint hints=ArbitraryShapeHint)
static bool isRect(const T *pts, int elementCount)
uint hints() const
static uint polygonFlags(QPaintEngine::PolygonDrawMode mode)
bool isCacheable() const
bool isCurved() const
const QPainterPath::ElementType * elements() const
void makeCacheable() const
bool isEmpty() const
bool hasWindingFill() const
bool hasImplicitClose() const
const qreal * points() const
CacheEntry * lookupCacheData(QPaintEngineEx *engine) const
Hint shape() const
int elementCount() const
bool hasExplicitOpen() const
Combined button and popup list for selecting options.
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
GLenum mode
GLsizei GLenum GLenum * types
GLenum GLenum GLsizei count
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLfixed GLfixed GLint GLint GLfixed points
GLsizei const GLchar *const * path
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
static const QTextHtmlElement elements[Html_NumElements]
unsigned int uint
Definition qtypes.h:34
double qreal
Definition qtypes.h:187
Q_GUI_EXPORT const QVectorPath & qtVectorPathForPath(const QPainterPath &path)
void(* qvectorpath_cache_cleanup)(QPaintEngineEx *engine, void *data)
QJSEngine engine
[0]
QPaintEngineEx * engine
qvectorpath_cache_cleanup cleanup