5#ifndef QQUICKSHAPECURVERENDERER_P_H
6#define QQUICKSHAPECURVERENDERER_P_H
19#include <QtQuickShapes/private/qquickshapesglobal_p.h>
20#include <QtQuickShapes/private/qquickshape_p_p.h>
21#include <QtQuick/private/qquadpath_p.h>
22#include <QtQuick/private/qsgcurveabstractnode_p.h>
23#include <QtQuick/private/qsggradientcache_p.h>
25#include <qsggeometry.h>
26#include <qsgmaterial.h>
27#include <qsgrendererinterface.h>
28#include <qsgtexture.h>
29#include <QtCore/qrunnable.h>
32#include <QtGui/private/qtriangulator_p.h>
33#include <QtQuick/private/qsgcurvefillnode_p.h>
42 QQuickShapeCurveRenderer(QQuickItem *item)
45 ~QQuickShapeCurveRenderer() override;
47 void beginSync(
int totalCount,
bool *countChanged) override;
48 void setPath(
int index,
const QPainterPath &path, QQuickShapePath::PathHints pathHints = {}) override;
49 void setStrokeColor(
int index,
const QColor &color) override;
50 void setStrokeWidth(
int index, qreal w) override;
51 void setCosmeticStroke(
int index,
bool c) override;
52 void setFillColor(
int index,
const QColor &color) override;
53 void setFillRule(
int index, QQuickShapePath::FillRule fillRule) override;
54 void setJoinStyle(
int index, QQuickShapePath::JoinStyle joinStyle,
int miterLimit) override;
55 void setCapStyle(
int index, QQuickShapePath::CapStyle capStyle) override;
56 void setStrokeStyle(
int index, QQuickShapePath::StrokeStyle strokeStyle,
57 qreal dashOffset,
const QList<qreal> &dashPattern) override;
58 void setFillGradient(
int index, QQuickShapeGradient *gradient) override;
59 void setFillTextureProvider(
int index, QQuickItem *textureProviderItem) override;
60 void setFillTransform(
int index,
const QSGTransform &transform) override;
61 void endSync(
bool async) override;
62 void setAsyncCallback(
void (*)(
void *),
void *) override;
63 Flags flags()
const override {
return SupportsAsync; }
64 void handleSceneChange(QQuickWindow *window) override;
66 void updateNode() override;
68 void setRootNode(QSGNode *node);
69 void clearNodeReferences();
71 using NodeList = QList<QSGCurveAbstractNode *>;
81 enum DebugVisualizationOption {
87 static int debugVisualization();
88 static void setDebugVisualization(
int options);
93 bool isFillVisible()
const
95 return gradientType != QGradient::NoGradient
96 || fillTextureProviderItem !=
nullptr
97 || fillColor.alpha() > 0;
100 bool isStrokeVisible()
const
102 return validPenWidth && pen.color().alpha() > 0 && pen.style() != Qt::NoPen;
105 QGradient::Type gradientType = QGradient::NoGradient;
106 QSGGradientCache::GradientDesc gradient;
107 QSGTransform fillTransform;
109 Qt::FillRule fillRule = Qt::OddEvenFill;
111 bool validPenWidth =
true;
113 QQuickShapePath::PathHints pathHints;
115 QPainterPath originalPath;
120 NodeList strokeNodes;
122 QQuickShapeCurveRunnable *currentRunner =
nullptr;
123 QQuickItem *fillTextureProviderItem =
nullptr;
126 void setUpRunner(PathData *pathData);
127 void maybeUpdateAsyncItem();
129 static void processPath(PathData *pathData);
130 static NodeList addFillNodes(
const QQuadPath &path);
131 static NodeList addTriangulatingStrokerNodes(
const QQuadPath &path,
const QPen &pen);
132 static NodeList addCurveStrokeNodes(
const QQuadPath &path,
const QPen &pen);
135 QSGNode *m_rootNode =
nullptr;
136 QList<PathData> m_paths;
137 QList<PathData> m_removedPaths;
138 void (*m_asyncCallback)(
void *) =
nullptr;
139 void *m_asyncCallbackData =
nullptr;
140 static int debugVisualizationFlags;
142 friend class QQuickShapeCurveRunnable;
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 ~QQuickAbstractPathRenderer()
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
QSGMaterialType * type() const override
This function is called by the scene graph to query an identifier that is unique to the QSGMaterialSh...
QQuickShapeConicalGradientMaterial(QQuickShapeGenericStrokeFillNode *node)
int compare(const QSGMaterial *other) const override
Compares this material to other and returns 0 if they are equal; -1 if this material should sort befo...
QSGMaterialShader * createShader(QSGRendererInterface::RenderMode renderMode) const override
This function returns a new instance of a the QSGMaterialShader implementation used to render geometr...
QQuickShapeGenericStrokeFillNode * node() const
void updateSampledImage(RenderState &state, int binding, QSGTexture **texture, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override
This function is called by the scene graph to prepare use of sampled images in the shader,...
bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override
This function is called by the scene graph to get the contents of the shader program's uniform buffer...
QQuickShapeConicalGradientRhiShader(int viewCount)
void run() override
Implement this pure virtual function in your subclass.
bool supportsElementIndexUint
QQuickShapeGenericRenderer::Color4ub fillColor
QQuickShapeGenericRenderer::VertexContainerType fillVertices
QQuickShapeGenericRenderer::IndexContainerType fillIndices
static QSGMaterial * createLinearGradient(QQuickWindow *window, QQuickShapeGenericStrokeFillNode *node)
static QSGMaterial * createTextureFill(QQuickWindow *window, QQuickShapeGenericStrokeFillNode *node)
static QSGMaterial * createConicalGradient(QQuickWindow *window, QQuickShapeGenericStrokeFillNode *node)
static QSGMaterial * createVertexColor(QQuickWindow *window)
static QSGMaterial * createRadialGradient(QQuickWindow *window, QQuickShapeGenericStrokeFillNode *node)
QQuickShapeGenericStrokeFillNode * m_fillNode
QQuickShapeGenericStrokeFillNode * m_strokeNode
QQuickShapeGenericNode * m_next
void setAsyncCallback(void(*)(void *), void *) override
void setFillGradient(int index, QQuickShapeGradient *gradient) override
void setStrokeStyle(int index, QQuickShapePath::StrokeStyle strokeStyle, qreal dashOffset, const QList< qreal > &dashPattern) override
QQuickShapeGenericRenderer(QQuickItem *item)
void setFillTransform(int index, const QSGTransform &transform) override
QList< quint32 > IndexContainerType
void setCosmeticStroke(int index, bool c) override
static void triangulateFill(const QPainterPath &path, const Color4ub &fillColor, VertexContainerType *fillVertices, IndexContainerType *fillIndices, QSGGeometry::Type *indexType, bool supportsElementIndexUint, qreal triangulationScale)
QList< QSGGeometry::ColoredPoint2D > VertexContainerType
void setPath(int index, const QPainterPath &path, QQuickShapePath::PathHints pathHints={}) override
void setStrokeColor(int index, const QColor &color) override
void setFillRule(int index, QQuickShapePath::FillRule fillRule) override
void setFillTextureProvider(int index, QQuickItem *textureProviderItem) override
void setFillColor(int index, const QColor &color) override
void setTriangulationScale(int index, qreal scale) override
void setJoinStyle(int index, QQuickShapePath::JoinStyle joinStyle, int miterLimit) override
void setStrokeWidth(int index, qreal w) override
~QQuickShapeGenericRenderer()
void setRootNode(QQuickShapeGenericNode *node)
QList< QSGGeometry::TexturedPoint2D > TexturedVertexContainerType
void handleSceneChange(QQuickWindow *window) override
void beginSync(int totalCount, bool *countChanged) override
void setCapStyle(int index, QQuickShapePath::CapStyle capStyle) override
Flags flags() const override
static void triangulateStroke(const QPainterPath &path, const QPen &pen, const Color4ub &strokeColor, VertexContainerType *strokeVertices, const QSize &clipSize, qreal triangulationScale)
void updateNode() override
void endSync(bool async) override
QSGGradientCache::GradientDesc m_fillGradient
void preprocess() override
Override this function to do processing on the node before it is rendered.
QSGTransform m_fillTransform
QSGTextureProvider * m_fillTextureProvider
void activateMaterial(QQuickWindow *window, Material m)
QQuickShapeLinearGradientMaterial(QQuickShapeGenericStrokeFillNode *node)
QSGMaterialShader * createShader(QSGRendererInterface::RenderMode renderMode) const override
This function returns a new instance of a the QSGMaterialShader implementation used to render geometr...
int compare(const QSGMaterial *other) const override
Compares this material to other and returns 0 if they are equal; -1 if this material should sort befo...
QSGMaterialType * type() const override
This function is called by the scene graph to query an identifier that is unique to the QSGMaterialSh...
QQuickShapeGenericStrokeFillNode * node() const
void updateSampledImage(RenderState &state, int binding, QSGTexture **texture, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override
This function is called by the scene graph to prepare use of sampled images in the shader,...
QQuickShapeLinearGradientRhiShader(int viewCount)
bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override
This function is called by the scene graph to get the contents of the shader program's uniform buffer...
QQuickShapeGenericStrokeFillNode * node() const
QQuickShapeRadialGradientMaterial(QQuickShapeGenericStrokeFillNode *node)
QSGMaterialType * type() const override
This function is called by the scene graph to query an identifier that is unique to the QSGMaterialSh...
QSGMaterialShader * createShader(QSGRendererInterface::RenderMode renderMode) const override
This function returns a new instance of a the QSGMaterialShader implementation used to render geometr...
int compare(const QSGMaterial *other) const override
Compares this material to other and returns 0 if they are equal; -1 if this material should sort befo...
bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override
This function is called by the scene graph to get the contents of the shader program's uniform buffer...
QQuickShapeRadialGradientRhiShader(int viewCount)
void updateSampledImage(RenderState &state, int binding, QSGTexture **texture, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override
This function is called by the scene graph to prepare use of sampled images in the shader,...
RenderingFlags flags() const override
QRectF rect() const override
void releaseResources() override
This function is called when all custom graphics resources allocated by this node have to be freed im...
~QQuickShapeSoftwareRenderNode()
void render(const RenderState *state) override
This function is called by the renderer and should paint this node with directly invoking commands vi...
QQuickShapeSoftwareRenderNode(QQuickShape *item)
StateFlags changedStates() const override
This function should return a mask where each bit represents graphics states changed by the \l render...
void setPath(int index, const QPainterPath &path, QQuickShapePath::PathHints pathHints={}) override
void setStrokeColor(int index, const QColor &color) override
void setJoinStyle(int index, QQuickShapePath::JoinStyle joinStyle, int miterLimit) override
void setFillColor(int index, const QColor &color) override
void setTriangulationScale(int index, qreal scale) override
void handleSceneChange(QQuickWindow *window) override
void endSync(bool async) override
void setNode(QQuickShapeSoftwareRenderNode *node)
void setFillTextureProvider(int index, QQuickItem *textureProviderItem) override
void beginSync(int totalCount, bool *countChanged) override
void setCapStyle(int index, QQuickShapePath::CapStyle capStyle) override
void setStrokeStyle(int index, QQuickShapePath::StrokeStyle strokeStyle, qreal dashOffset, const QList< qreal > &dashPattern) override
void setCosmeticStroke(int index, bool c) override
void setFillGradient(int index, QQuickShapeGradient *gradient) override
void updateNode() override
void setFillRule(int index, QQuickShapePath::FillRule fillRule) override
void setStrokeWidth(int index, qreal w) override
void setFillTransform(int index, const QSGTransform &transform) override
QQuickShapeGenericRenderer::Color4ub strokeColor
QQuickShapeGenericRenderer::VertexContainerType strokeVertices
QQuickShapeTextureFillMaterial(QQuickShapeGenericStrokeFillNode *node)
void setDummyTexture(QSGPlainTexture *texture)
QSGMaterialShader * createShader(QSGRendererInterface::RenderMode renderMode) const override
This function returns a new instance of a the QSGMaterialShader implementation used to render geometr...
int compare(const QSGMaterial *other) const override
Compares this material to other and returns 0 if they are equal; -1 if this material should sort befo...
QSGPlainTexture * dummyTexture() const
QQuickShapeGenericStrokeFillNode * node() const
~QQuickShapeTextureFillMaterial() override
QSGMaterialType * type() const override
This function is called by the scene graph to query an identifier that is unique to the QSGMaterialSh...
QQuickShapeTextureFillRhiShader(int viewCount)
bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override
This function is called by the scene graph to get the contents of the shader program's uniform buffer...
void updateSampledImage(RenderState &state, int binding, QSGTexture **texture, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override
This function is called by the scene graph to prepare use of sampled images in the shader,...
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)
QList< qreal > dashPattern
QSGTransform fillTransform
QQuickShapeStrokeFillParams()
QQuickShapeGradient * fillGradient