1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QQUICKSHAPECURVERENDERER_P_H
#define QQUICKSHAPECURVERENDERER_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists for the convenience
// of a number of Qt sources files. This header file may change from
// version to version without notice, or even be removed.
//
// We mean it.
//
#include <QtQuickShapes/private/qquickshapesglobal_p.h>
#include <QtQuickShapes/private/qquickshape_p_p.h>
#include <QtQuick/private/qquadpath_p.h>
#include <QtQuick/private/qsgcurveabstractnode_p.h>
#include <QtQuick/private/qsggradientcache_p.h>
#include <qsgnode.h>
#include <qsggeometry.h>
#include <qsgmaterial.h>
#include <qsgrendererinterface.h>
#include <qsgtexture.h>
#include <QtCore/qrunnable.h>
#include <QtGui/private/qtriangulator_p.h>
#include <QtQuick/private/qsgcurvefillnode_p.h>
QT_BEGIN_NAMESPACE
class QQuickShapeCurveRenderer : public QQuickAbstractPathRenderer
{
public:
QQuickShapeCurveRenderer(QQuickItem *)
: m_rootNode(nullptr)
{ }
~QQuickShapeCurveRenderer() override;
void beginSync(int totalCount, bool *countChanged) override;
void setPath(int index, const QQuickPath *path) override;
void setStrokeColor(int index, const QColor &color) override;
void setStrokeWidth(int index, qreal w) override;
void setFillColor(int index, const QColor &color) override;
void setFillRule(int index, QQuickShapePath::FillRule fillRule) override;
void setJoinStyle(int index, QQuickShapePath::JoinStyle joinStyle, int miterLimit) override;
void setCapStyle(int index, QQuickShapePath::CapStyle capStyle) override;
void setStrokeStyle(int index, QQuickShapePath::StrokeStyle strokeStyle,
qreal dashOffset, const QVector<qreal> &dashPattern) override;
void setFillGradient(int index, QQuickShapeGradient *gradient) override;
void endSync(bool async) override;
void setAsyncCallback(void (*)(void *), void *) override;
Flags flags() const override { return Flags{}; }
void updateNode() override;
void setRootNode(QSGNode *node);
using NodeList = QVector<QSGCurveAbstractNode *>;
enum DirtyFlag
{
PathDirty = 0x01,
FillDirty = 0x02,
StrokeDirty = 0x04,
UniformsDirty = 0x08
};
enum DebugVisualizationOption {
NoDebug = 0,
DebugCurves = 0x01,
DebugWireframe = 0x02
};
Q_QUICKSHAPES_PRIVATE_EXPORT static int debugVisualization();
Q_QUICKSHAPES_PRIVATE_EXPORT static void setDebugVisualization(int options);
private:
struct PathData {
bool isFillVisible() const { return fillColor.alpha() > 0 || gradientType != QGradient::NoGradient; }
bool isStrokeVisible() const
{
return validPenWidth && pen.color().alpha() > 0 && pen.style() != Qt::NoPen;
}
QGradient::Type gradientType = QGradient::NoGradient;
QSGGradientCache::GradientDesc gradient;
QPainterPath originalPath;
QQuadPath path;
QQuadPath fillPath;
QQuadPath strokePath;
QColor fillColor;
Qt::FillRule fillRule = Qt::OddEvenFill;
QPen pen;
int m_dirty = 0;
bool validPenWidth = true;
bool convexConcaveResolved = false;
NodeList fillNodes;
NodeList fillDebugNodes;
NodeList strokeNodes;
NodeList strokeDebugNodes;
};
void deleteAndClear(NodeList *nodeList);
NodeList addFillNodes(const PathData &pathData, NodeList *debugNodes);
NodeList addTriangulatingStrokerNodes(const PathData &pathData, NodeList *debugNodes);
NodeList addCurveStrokeNodes(const PathData &pathData, NodeList *debugNodes);
QSGNode *m_rootNode;
QVector<PathData> m_paths;
static int debugVisualizationFlags;
};
QT_END_NAMESPACE
#endif // QQUICKSHAPECURVERENDERER_P_H
|