Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
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// Qt-Security score:significant reason:default
4
5#ifndef QQUICKSHAPE_P_P_H
6#define QQUICKSHAPE_P_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtQuickShapes/private/qquickshapesglobal_p.h>
20#include <QtQuickShapes/private/qquickshape_p.h>
21#include <private/qquickitem_p.h>
22#include <private/qsgtransform_p.h>
23#include <QPainterPath>
24#include <QColor>
25#include <QBrush>
26#include <QElapsedTimer>
27#if QT_CONFIG(opengl)
28# include <private/qopenglcontext_p.h>
29#endif
31
32class QSGPlainTexture;
33class QRhi;
34
36{
37public:
38 enum Flag {
40 };
41 Q_DECLARE_FLAGS(Flags, Flag)
43
45
46 // Gui thread
47 virtual void beginSync(int totalCount, bool *countChanged) = 0;
48 virtual void endSync(bool async) = 0;
49 virtual void setAsyncCallback(void (*)(void *), void *) { }
50 virtual Flags flags() const { return {}; }
51 virtual void setPath(int index, const QQuickPath *path);
52 virtual void setPath(int index, const QPainterPath &path, QQuickShapePath::PathHints pathHints = {}) = 0;
53
54 virtual void setStrokeColor(int index, const QColor &color) = 0;
55 virtual void setStrokeWidth(int index, qreal w) = 0;
56 virtual void setCosmeticStroke(int index, bool c) = 0;
57 virtual void setJoinStyle(int index, QQuickShapePath::JoinStyle joinStyle, int miterLimit) = 0;
58 virtual void setCapStyle(int index, QQuickShapePath::CapStyle capStyle) = 0;
59 virtual void setStrokeStyle(int index, QQuickShapePath::StrokeStyle strokeStyle,
60 qreal dashOffset, const QList<qreal> &dashPattern) = 0;
61
62 virtual void setFillColor(int index, const QColor &color) = 0;
63 virtual void setFillRule(int index, QQuickShapePath::FillRule fillRule) = 0;
64 virtual void setFillGradient(int index, QQuickShapeGradient *gradient) = 0;
65 virtual void setStrokeGradient(int index, QQuickShapeGradient *gradient) = 0;
66 virtual void setFillTextureProvider(int index, QQuickItem *textureProviderItem) = 0;
67 virtual void setFillTransform(int index, const QSGTransform &transform) = 0;
68 virtual void setTriangulationScale(int, qreal) { }
69 virtual void setVisible(int index, bool visible) = 0;
70 virtual void handleSceneChange(QQuickWindow *window) = 0;
71
72 // Render thread, with gui blocked
73 virtual void updateNode() = 0;
74};
75
76Q_DECLARE_OPERATORS_FOR_FLAGS(QQuickAbstractPathRenderer::Flags)
77
78inline void QQuickAbstractPathRenderer::setPath(int index, const QQuickPath *path)
79{
80 QQuickShapePath::PathHints hints;
81 QPainterPath newPath = path ? path->path() : QPainterPath();
82 if (const auto *shapePath = qobject_cast<const QQuickShapePath *>(path)) {
83 hints = shapePath->pathHints();
84 if (shapePath->hasTrim()) {
85 const QQuickShapeTrim *trim = const_cast<QQuickShapePath *>(shapePath)->trim();
86 newPath = path->path().trimmed(trim->start(), trim->end(), trim->offset());
87 }
88 }
89 setPath(index, newPath, hints);
90}
91
114
115class Q_QUICKSHAPES_EXPORT QQuickShapePathPrivate : public QQuickPathPrivate
116{
117 Q_DECLARE_PUBLIC(QQuickShapePath)
118
119public:
120 enum Dirty {
121 DirtyPath = 0x01,
122 DirtyStrokeColor = 0x02,
123 DirtyStrokeWidth = 0x04,
124 DirtyFillColor = 0x08,
125 DirtyFillRule = 0x10,
126 DirtyStyle = 0x20,
127 DirtyDash = 0x40,
128 DirtyFillGradient = 0x80,
129 DirtyFillTransform = 0x100,
130 DirtyFillItem = 0x200,
131 DirtyTrim = 0x400,
132 DirtyStrokeGradient = 0x800,
133 DirtyVisible = 0x1000,
134
135 DirtyAll = 0x1FFF
136 };
137
138 QQuickShapePathPrivate();
139
140 void _q_pathChanged();
141 void _q_fillGradientChanged();
142 void _q_strokeGradientChanged();
143 void _q_fillItemDestroyed();
144
145 void handleSceneChange();
146
147 void writeToDebugStream(QDebug &debug) const override;
148
149 static QQuickShapePathPrivate *get(QQuickShapePath *p) { return p->d_func(); }
150
151 int dirty;
152 QQuickShapeStrokeFillParams sfp;
153 QQuickShapePath::PathHints pathHints;
154};
155
156class Q_QUICKSHAPES_EXPORT QQuickShapePrivate : public QQuickItemPrivate
157{
158 Q_DECLARE_PUBLIC(QQuickShape)
159
160public:
161 QQuickShapePrivate();
162 ~QQuickShapePrivate();
163
164 void init();
165
166 QQuickShape::RendererType selectRendererType();
167 void createRenderer();
168 QSGNode *createNode();
169 void sync();
170
171 void _q_shapePathChanged();
172 void setStatus(QQuickShape::Status newStatus);
173 void handleSceneChange(QQuickWindow *w);
174
175 static QQuickShapePrivate *get(QQuickShape *item) { return item->d_func(); }
176
177 static void asyncShapeReady(void *data);
178
179 qreal getImplicitWidth() const override;
180 qreal getImplicitHeight() const override;
181
182 int effectRefCount;
183 QList<QQuickShapePath *> sp;
184 QElapsedTimer syncTimer;
185 QQuickAbstractPathRenderer *renderer = nullptr;
186 int syncTimingTotalDirty = 0;
187 int syncTimeCounter = 0;
188 QQuickShape::Status status = QQuickShape::Null;
189 QQuickShape::RendererType rendererType = QQuickShape::UnknownRenderer;
190 QQuickShape::RendererType preferredType = QQuickShape::UnknownRenderer;
191 QQuickShape::ContainsMode containsMode = QQuickShape::BoundingRectContains;
192 QQuickShape::FillMode fillMode = QQuickShape::NoResize;
193 QQuickShape::HAlignment horizontalAlignment = QQuickShape::AlignLeft;
194 QQuickShape::VAlignment verticalAlignment = QQuickShape::AlignTop;
195
196 bool spChanged = false;
197 bool rendererChanged = false;
198 bool async = false;
199 bool enableVendorExts = false;
200 bool syncTimingActive = false;
201 qreal triangulationScale = 1.0;
202};
203
204QT_END_NAMESPACE
205
206#endif
virtual void setVisible(int index, bool visible)=0
virtual void setFillTextureProvider(int index, QQuickItem *textureProviderItem)=0
virtual void beginSync(int totalCount, bool *countChanged)=0
virtual void setStrokeColor(int index, const QColor &color)=0
virtual void setPath(int index, const QPainterPath &path, QQuickShapePath::PathHints pathHints={})=0
virtual void setAsyncCallback(void(*)(void *), void *)
virtual Flags flags() const
virtual void setCapStyle(int index, QQuickShapePath::CapStyle capStyle)=0
virtual void setStrokeStyle(int index, QQuickShapePath::StrokeStyle strokeStyle, qreal dashOffset, const QList< qreal > &dashPattern)=0
virtual void setFillGradient(int index, QQuickShapeGradient *gradient)=0
virtual void setFillColor(int index, const QColor &color)=0
virtual void setCosmeticStroke(int index, bool c)=0
virtual void setPath(int index, const QQuickPath *path)
virtual void setTriangulationScale(int, qreal)
virtual void setFillRule(int index, QQuickShapePath::FillRule fillRule)=0
virtual void setStrokeWidth(int index, qreal w)=0
virtual void setFillTransform(int index, const QSGTransform &transform)=0
virtual void endSync(bool async)=0
virtual void updateNode()=0
virtual void handleSceneChange(QQuickWindow *window)=0
virtual void setStrokeGradient(int index, QQuickShapeGradient *gradient)=0
virtual void setJoinStyle(int index, QQuickShapePath::JoinStyle joinStyle, int miterLimit)=0
Combined button and popup list for selecting options.
QT_BEGIN_NAMESPACE Q_STATIC_LOGGING_CATEGORY(lcSynthesizedIterableAccess, "qt.iterable.synthesized", QtWarningMsg)
static void initResources()
static void vpe_clear(QQmlListProperty< QObject > *property)
static void vpe_append(QQmlListProperty< QObject > *property, QObject *obj)
Q_GHS_KEEP_REFERENCE(QQuickShapes_initializeModule)
QQuickShapeGradient * strokeGradient
QQuickShapeGradient * fillGradient