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
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 <private/qquickitem_p.h>
21#include <private/qsgtransform_p.h>
22#include <QPainterPath>
23#include <QColor>
24#include <QBrush>
25#include <QElapsedTimer>
26#if QT_CONFIG(opengl)
27# include <private/qopenglcontext_p.h>
28#endif
30
31class QSGPlainTexture;
32class QRhi;
33
35{
36public:
37 enum Flag {
39 };
40 Q_DECLARE_FLAGS(Flags, Flag)
42
44
45 // Gui thread
46 virtual void beginSync(int totalCount, bool *countChanged) = 0;
47 virtual void endSync(bool async) = 0;
48 virtual void setAsyncCallback(void (*)(void *), void *) { }
49 virtual Flags flags() const { return {}; }
50 virtual void setPath(int index, const QQuickPath *path);
51 virtual void setPath(int index, const QPainterPath &path, QQuickShapePath::PathHints pathHints = {}) = 0;
52 virtual void setStrokeColor(int index, const QColor &color) = 0;
53 virtual void setStrokeWidth(int index, qreal w) = 0;
54 virtual void setCosmeticStroke(int index, bool c) = 0;
55 virtual void setFillColor(int index, const QColor &color) = 0;
56 virtual void setFillRule(int index, QQuickShapePath::FillRule fillRule) = 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 QVector<qreal> &dashPattern) = 0;
61 virtual void setFillGradient(int index, QQuickShapeGradient *gradient) = 0;
62 virtual void setFillTextureProvider(int index, QQuickItem *textureProviderItem) = 0;
63 virtual void setFillTransform(int index, const QSGTransform &transform) = 0;
64 virtual void setTriangulationScale(qreal) { }
65 virtual void handleSceneChange(QQuickWindow *window) = 0;
66
67 // Render thread, with gui blocked
68 virtual void updateNode() = 0;
69};
70
71Q_DECLARE_OPERATORS_FOR_FLAGS(QQuickAbstractPathRenderer::Flags)
72
73inline void QQuickAbstractPathRenderer::setPath(int index, const QQuickPath *path)
74{
75 QQuickShapePath::PathHints hints;
76 QPainterPath newPath = path ? path->path() : QPainterPath();
77 if (const auto *shapePath = qobject_cast<const QQuickShapePath *>(path)) {
78 hints = shapePath->pathHints();
79 if (shapePath->hasTrim()) {
80 const QQuickShapeTrim *trim = const_cast<QQuickShapePath *>(shapePath)->trim();
81 newPath = path->path().trimmed(trim->start(), trim->end(), trim->offset());
82 }
83 }
84 setPath(index, newPath, hints);
85}
86
107
108class Q_QUICKSHAPES_EXPORT QQuickShapePathPrivate : public QQuickPathPrivate
109{
110 Q_DECLARE_PUBLIC(QQuickShapePath)
111
112public:
113 enum Dirty {
114 DirtyPath = 0x01,
115 DirtyStrokeColor = 0x02,
116 DirtyStrokeWidth = 0x04,
117 DirtyFillColor = 0x08,
118 DirtyFillRule = 0x10,
119 DirtyStyle = 0x20,
120 DirtyDash = 0x40,
121 DirtyFillGradient = 0x80,
122 DirtyFillTransform = 0x100,
123 DirtyFillItem = 0x200,
124 DirtyTrim = 0x400,
125
126 DirtyAll = 0x7FF
127 };
128
129 QQuickShapePathPrivate();
130
131 void _q_pathChanged();
132 void _q_fillGradientChanged();
133 void _q_fillItemDestroyed();
134
135 void handleSceneChange();
136
137 void writeToDebugStream(QDebug &debug) const override;
138
139 static QQuickShapePathPrivate *get(QQuickShapePath *p) { return p->d_func(); }
140
141 int dirty;
142 QQuickShapeStrokeFillParams sfp;
143 QQuickShapePath::PathHints pathHints;
144};
145
146class Q_QUICKSHAPES_EXPORT QQuickShapePrivate : public QQuickItemPrivate
147{
148 Q_DECLARE_PUBLIC(QQuickShape)
149
150public:
151 QQuickShapePrivate();
152 ~QQuickShapePrivate();
153
154 void init();
155
156 QQuickShape::RendererType selectRendererType();
157 void createRenderer();
158 QSGNode *createNode();
159 void sync();
160
161 void _q_shapePathChanged();
162 void setStatus(QQuickShape::Status newStatus);
163 void handleSceneChange(QQuickWindow *w);
164
165 static QQuickShapePrivate *get(QQuickShape *item) { return item->d_func(); }
166
167 static void asyncShapeReady(void *data);
168
169 qreal getImplicitWidth() const override;
170 qreal getImplicitHeight() const override;
171
172 int effectRefCount;
173 QVector<QQuickShapePath *> sp;
174 QElapsedTimer syncTimer;
175 QQuickAbstractPathRenderer *renderer = nullptr;
176 int syncTimingTotalDirty = 0;
177 int syncTimeCounter = 0;
178 QQuickShape::Status status = QQuickShape::Null;
179 QQuickShape::RendererType rendererType = QQuickShape::UnknownRenderer;
180 QQuickShape::RendererType preferredType = QQuickShape::UnknownRenderer;
181 QQuickShape::ContainsMode containsMode = QQuickShape::BoundingRectContains;
182 QQuickShape::FillMode fillMode = QQuickShape::NoResize;
183 QQuickShape::HAlignment horizontalAlignment = QQuickShape::AlignLeft;
184 QQuickShape::VAlignment verticalAlignment = QQuickShape::AlignTop;
185
186 bool spChanged = false;
187 bool rendererChanged = false;
188 bool async = false;
189 bool enableVendorExts = false;
190 bool syncTimingActive = false;
191 qreal triangulationScale = 1.0;
192};
193
194QT_END_NAMESPACE
195
196#endif
virtual void setTriangulationScale(qreal)
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 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 setCosmeticStroke(int index, bool c)=0
virtual void setPath(int index, const QQuickPath *path)
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 setJoinStyle(int index, QQuickShapePath::JoinStyle joinStyle, int miterLimit)=0
Q_STATIC_LOGGING_CATEGORY(lcAccessibilityCore, "qt.accessibility.core")
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 * fillGradient