Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qquickshape_p_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 QQUICKSHAPE_P_P_H
5#define QQUICKSHAPE_P_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 <QtQuickShapes/private/qquickshapesglobal_p.h>
19#include <QtQuickShapes/private/qquickshape_p.h>
20#include <QtQuick/private/qquickitem_p.h>
21#include <QPainterPath>
22#include <QColor>
23#include <QBrush>
24#include <QElapsedTimer>
25#if QT_CONFIG(opengl)
26# include <private/qopenglcontext_p.h>
27#endif
29
30class QSGPlainTexture;
31class QRhi;
32
34{
35public:
36 enum Flag {
37 SupportsAsync = 0x01
38 };
40
42 struct GradientDesc { // can fully describe a linear/radial/conical gradient
45 QPointF a; // start (L) or center point (R/C)
46 QPointF b; // end (L) or focal point (R)
47 qreal v0; // center radius (R) or start angle (C)
48 qreal v1; // focal radius (R)
49 };
50
52
53 // Gui thread
54 virtual void beginSync(int totalCount, bool *countChanged) = 0;
55 virtual void endSync(bool async) = 0;
56 virtual void setAsyncCallback(void (*)(void *), void *) { }
57 virtual Flags flags() const { return {}; }
58 virtual void setPath(int index, const QQuickPath *path) = 0;
59 virtual void setStrokeColor(int index, const QColor &color) = 0;
60 virtual void setStrokeWidth(int index, qreal w) = 0;
61 virtual void setFillColor(int index, const QColor &color) = 0;
62 virtual void setFillRule(int index, QQuickShapePath::FillRule fillRule) = 0;
63 virtual void setJoinStyle(int index, QQuickShapePath::JoinStyle joinStyle, int miterLimit) = 0;
64 virtual void setCapStyle(int index, QQuickShapePath::CapStyle capStyle) = 0;
65 virtual void setStrokeStyle(int index, QQuickShapePath::StrokeStyle strokeStyle,
66 qreal dashOffset, const QVector<qreal> &dashPattern) = 0;
67 virtual void setFillGradient(int index, QQuickShapeGradient *gradient) = 0;
68 virtual void setTriangulationScale(qreal) { }
69
70 // Render thread, with gui blocked
71 virtual void updateNode() = 0;
72};
73
74Q_DECLARE_OPERATORS_FOR_FLAGS(QQuickAbstractPathRenderer::Flags)
75
77{
79
91};
92
93class Q_QUICKSHAPES_PRIVATE_EXPORT QQuickShapePathPrivate : public QQuickPathPrivate
94{
95 Q_DECLARE_PUBLIC(QQuickShapePath)
96
97public:
98 enum Dirty {
99 DirtyPath = 0x01,
100 DirtyStrokeColor = 0x02,
101 DirtyStrokeWidth = 0x04,
102 DirtyFillColor = 0x08,
103 DirtyFillRule = 0x10,
104 DirtyStyle = 0x20,
105 DirtyDash = 0x40,
106 DirtyFillGradient = 0x80,
107
108 DirtyAll = 0xFF
109 };
110
112
114 void _q_fillGradientChanged();
115
116 static QQuickShapePathPrivate *get(QQuickShapePath *p) { return p->d_func(); }
117
118 int dirty;
120};
121
123{
124 Q_DECLARE_PUBLIC(QQuickShape)
125
126public:
129
131 void createRenderer();
133 void sync();
134
135 void _q_shapePathChanged();
136 void setStatus(QQuickShape::Status newStatus);
137
138 static QQuickShapePrivate *get(QQuickShape *item) { return item->d_func(); }
139
140 static void asyncShapeReady(void *data);
141
152 bool spChanged = false;
153 bool rendererChanged = false;
154 bool async = false;
155 bool enableVendorExts = false;
156 bool syncTimingActive = false;
158};
159
161{
164 { }
168 {
169 return spread == other.spread && stops == other.stops;
170 }
171};
172
173inline size_t qHash(const QQuickShapeGradientCacheKey &v, size_t seed = 0)
174{
175 size_t h = seed + v.spread;
176 for (int i = 0; i < 3 && i < v.stops.size(); ++i)
177 h += v.stops[i].second.rgba();
178 return h;
179}
180
182{
183public:
187
188private:
190};
191
193
194#endif
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
\inmodule QtCore
\inmodule QtCore
Definition qhash.h:818
\inmodule QtCore\reentrant
Definition qpoint.h:214
virtual void setPath(int index, const QQuickPath *path)=0
virtual void setTriangulationScale(qreal)
virtual void beginSync(int totalCount, bool *countChanged)=0
virtual void setStrokeColor(int index, const QColor &color)=0
virtual void setStrokeStyle(int index, QQuickShapePath::StrokeStyle strokeStyle, qreal dashOffset, const QVector< qreal > &dashPattern)=0
virtual void setAsyncCallback(void(*)(void *), void *)
virtual Flags flags() const
virtual void setCapStyle(int index, QQuickShapePath::CapStyle capStyle)=0
virtual void setFillGradient(int index, QQuickShapeGradient *gradient)=0
virtual void setFillColor(int index, const QColor &color)=0
virtual void setFillRule(int index, QQuickShapePath::FillRule fillRule)=0
virtual void setStrokeWidth(int index, qreal w)=0
virtual void endSync(bool async)=0
virtual void updateNode()=0
virtual void setJoinStyle(int index, QQuickShapePath::JoinStyle joinStyle, int miterLimit)=0
QSGTexture * get(const QQuickShapeGradientCacheKey &grad)
static QQuickShapeGradientCache * cacheForRhi(QRhi *rhi)
QQuickShapeStrokeFillParams sfp
static QQuickShapePathPrivate * get(QQuickShapePath *p)
QQuickShape::RendererType rendererType
QVector< QQuickShapePath * > sp
QQuickShapePrivate()
Renders a path.
static QQuickShapePrivate * get(QQuickShape *item)
void setStatus(QQuickShape::Status newStatus)
QElapsedTimer syncTimer
QQuickShape::Status status
QQuickAbstractPathRenderer * renderer
QQuickShape::RendererType preferredType
static void asyncShapeReady(void *data)
QQuickShape::ContainsMode containsMode
QQuickShape::RendererType selectRendererType()
\inmodule QtGui
Definition qrhi.h:1767
\group qtquick-scenegraph-nodes \title Qt Quick Scene Graph Node classes
Definition qsgnode.h:37
\inmodule QtQuick
Definition qsgtexture.h:20
Combined button and popup list for selecting options.
#define Q_DECLARE_FLAGS(Flags, Enum)
Definition qflags.h:174
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
Definition qflags.h:194
Flags
GLsizei const GLfloat * v
[13]
GLfloat GLfloat GLfloat w
[0]
GLuint index
[2]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLfloat GLfloat GLfloat GLfloat h
GLsizei const GLchar *const * path
GLfloat GLfloat p
[1]
size_t qHash(const QQuickShapeGradientCacheKey &v, size_t seed=0)
static Q_CONSTINIT QBasicAtomicInteger< unsigned > seed
Definition qrandom.cpp:196
double qreal
Definition qtypes.h:92
QSharedPointer< T > other(t)
[5]
QGraphicsItem * item
QQuickShapeGradient::SpreadMode spread
bool operator==(const QQuickShapeGradientCacheKey &other) const
QQuickShapeGradient::SpreadMode spread
QQuickShapeGradientCacheKey(const QGradientStops &stops, QQuickShapeGradient::SpreadMode spread)
QQuickShapePath::JoinStyle joinStyle
QQuickShapePath::FillRule fillRule
QQuickShapePath::CapStyle capStyle
QQuickShapePath::StrokeStyle strokeStyle
QQuickShapeGradient * fillGradient