Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qquickshapecurverenderer_p.h
Go to the documentation of this file.
1// Copyright (C) 2022 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 QQUICKSHAPECURVERENDERER_P_H
5#define QQUICKSHAPECURVERENDERER_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 for the convenience
12// of a number of Qt sources files. This header file may change from
13// version to 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_p.h>
20#include <QtQuick/private/qquadpath_p.h>
21#include <QtQuick/private/qsgcurveabstractnode_p.h>
22#include <QtQuick/private/qsggradientcache_p.h>
23#include <qsgnode.h>
24#include <qsggeometry.h>
25#include <qsgmaterial.h>
27#include <qsgtexture.h>
28#include <QtCore/qrunnable.h>
29#include <QRunnable>
30
31#include <QtGui/private/qtriangulator_p.h>
32#include <QtQuick/private/qsgcurvefillnode_p.h>
33
35
37
38class Q_QUICKSHAPES_EXPORT QQuickShapeCurveRenderer : public QQuickAbstractPathRenderer
39{
40public:
45
46 void beginSync(int totalCount, bool *countChanged) override;
47 void setPath(int index, const QQuickPath *path) override;
48 void setPath(int index, const QPainterPath &path, QQuickShapePath::PathHints pathHints = {});
49 void setStrokeColor(int index, const QColor &color) override;
50 void setStrokeWidth(int index, qreal w) override;
51 void setFillColor(int index, const QColor &color) override;
52 void setFillRule(int index, QQuickShapePath::FillRule fillRule) override;
53 void setJoinStyle(int index, QQuickShapePath::JoinStyle joinStyle, int miterLimit) override;
54 void setCapStyle(int index, QQuickShapePath::CapStyle capStyle) override;
55 void setStrokeStyle(int index, QQuickShapePath::StrokeStyle strokeStyle,
56 qreal dashOffset, const QVector<qreal> &dashPattern) override;
57 void setFillGradient(int index, QQuickShapeGradient *gradient) override;
58 void setFillTransform(int index, const QSGTransform &transform) override;
59 void endSync(bool async) override;
60 void setAsyncCallback(void (*)(void *), void *) override;
61 Flags flags() const override { return SupportsAsync; }
62
63 void updateNode() override;
64
65 void setRootNode(QSGNode *node);
66
67 using NodeList = QVector<QSGCurveAbstractNode *>;
68
70 {
71 PathDirty = 0x01,
72 FillDirty = 0x02,
73 StrokeDirty = 0x04,
74 UniformsDirty = 0x08
75 };
76
78 NoDebug = 0,
79 DebugCurves = 0x01,
80 DebugWireframe = 0x02
81 };
82
83 static int debugVisualization();
84 static void setDebugVisualization(int options);
85
86private:
87 struct PathData {
88
89 bool isFillVisible() const { return fillColor.alpha() > 0 || gradientType != QGradient::NoGradient; }
90
91 bool isStrokeVisible() const
92 {
93 return validPenWidth && pen.color().alpha() > 0 && pen.style() != Qt::NoPen;
94 }
95
98 QSGTransform fillTransform;
99 QColor fillColor;
100 Qt::FillRule fillRule = Qt::OddEvenFill;
101 QPen pen;
102 bool validPenWidth = true;
103 int m_dirty = 0;
104 QQuickShapePath::PathHints pathHints;
105
106 QPainterPath originalPath;
108 QQuadPath fillPath;
109 QQuadPath strokePath;
110
111 NodeList fillNodes;
112 NodeList strokeNodes;
113
114 QQuickShapeCurveRunnable *currentRunner = nullptr;
115 };
116
117 void createRunner(PathData *pathData);
118 void maybeUpdateAsyncItem();
119
120 static void processPath(PathData *pathData);
121 static NodeList addFillNodes(const PathData &pathData);
122 static NodeList addTriangulatingStrokerNodes(const PathData &pathData);
123 static NodeList addCurveStrokeNodes(const PathData &pathData);
124
125 void solveIntersections(QQuadPath &path);
126 QQuickItem *m_item;
127 QSGNode *m_rootNode = nullptr;
128 QVector<PathData> m_paths;
129 void (*m_asyncCallback)(void *) = nullptr;
130 void *m_asyncCallbackData = nullptr;
131 static int debugVisualizationFlags;
132
134};
135
137{
139
140public:
141 void run() override;
142
143 bool isAsync = false;
144 bool isDone = false;
145 bool orphaned = false;
146
147 // input / output
148 QQuickShapeCurveRenderer::PathData pathData;
149
152};
153
155
156#endif // QQUICKSHAPECURVERENDERER_P_H
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
Type
Specifies the type of gradient.
Definition qbrush.h:138
@ NoGradient
Definition qbrush.h:142
\inmodule QtCore
Definition qobject.h:103
\inmodule QtGui
\inmodule QtGui
Definition qpen.h:28
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
Definition qquickitem.h:63
QVector< QSGCurveAbstractNode * > NodeList
QQuickShapeCurveRenderer::PathData pathData
void done(QQuickShapeCurveRunnable *self)
void run() override
Implement this pure virtual function in your subclass.
\inmodule QtCore
Definition qrunnable.h:18
\group qtquick-scenegraph-nodes \title Qt Quick Scene Graph Node classes
Definition qsgnode.h:37
Combined button and popup list for selecting options.
@ NoPen
@ OddEvenFill
std::vector< Node > NodeList
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
Flags
GLfloat GLfloat GLfloat w
[0]
GLuint index
[2]
GLuint color
[2]
GLuint GLenum GLenum transform
GLsizei const GLchar *const * path
static void setCapStyle(int cap_style, GC gc)
#define Q_OBJECT
#define Q_SIGNALS
double qreal
Definition qtypes.h:187
QGraphicsItem * item