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