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
qquickshapegenericrenderer_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 QQUICKSHAPEGENERICRENDERER_P_H
5#define QQUICKSHAPEGENERICRENDERER_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/qsggradientcache_p.h>
21#include <qsgnode.h>
22#include <qsggeometry.h>
23#include <qsgmaterial.h>
25#include <qsgtexture.h>
26#include <QtCore/qrunnable.h>
27
29
34
36{
37public:
38 enum Dirty {
41 DirtyColor = 0x04,
44 DirtyList = 0x20 // only for accDirty
45 };
46
48 : m_item(item),
50 m_rootNode(nullptr),
51 m_accDirty(0),
52 m_asyncCallback(nullptr),
53 m_asyncCallbackData(nullptr)
54 { }
56
57 void beginSync(int totalCount, bool *countChanged) override;
58 void setPath(int index, const QQuickPath *path) override;
59 void setStrokeColor(int index, const QColor &color) override;
60 void setStrokeWidth(int index, qreal w) override;
61 void setFillColor(int index, const QColor &color) override;
62 void setFillRule(int index, QQuickShapePath::FillRule fillRule) override;
63 void setJoinStyle(int index, QQuickShapePath::JoinStyle joinStyle, int miterLimit) override;
64 void setCapStyle(int index, QQuickShapePath::CapStyle capStyle) override;
66 qreal dashOffset, const QVector<qreal> &dashPattern) override;
67 void setFillGradient(int index, QQuickShapeGradient *gradient) override;
68 void setFillTransform(int index, const QSGTransform &transform) override;
69 void setTriangulationScale(qreal scale) override;
70 void endSync(bool async) override;
71 void setAsyncCallback(void (*)(void *), void *) override;
72 Flags flags() const override { return SupportsAsync; }
73
74 void updateNode() override;
75
77
78 struct Color4ub { unsigned char r, g, b, a; };
79 typedef QVector<QSGGeometry::ColoredPoint2D> VertexContainerType;
80 typedef QVector<quint32> IndexContainerType;
81
82 static void triangulateFill(const QPainterPath &path,
83 const Color4ub &fillColor,
84 VertexContainerType *fillVertices,
85 IndexContainerType *fillIndices,
86 QSGGeometry::Type *indexType,
87 bool supportsElementIndexUint,
88 qreal triangulationScale);
89 static void triangulateStroke(const QPainterPath &path,
90 const QPen &pen,
91 const Color4ub &strokeColor,
92 VertexContainerType *strokeVertices,
93 const QSize &clipSize,
94 qreal triangulationScale);
95
96private:
97 void maybeUpdateAsyncItem();
98
99 struct ShapePathData {
100 float strokeWidth;
101 QPen pen;
102 Color4ub strokeColor = { uchar(0), uchar(0), uchar(0), uchar(0) };
103 Color4ub fillColor = { uchar(0), uchar(0), uchar(0), uchar(0) };
104 Qt::FillRule fillRule;
106 FillGradientType fillGradientActive;
108 QSGTransform fillTransform;
109 VertexContainerType fillVertices;
110 IndexContainerType fillIndices;
111 QSGGeometry::Type indexType;
112 VertexContainerType strokeVertices;
113 int syncDirty;
114 int effectiveDirty = 0;
115 QQuickShapeFillRunnable *pendingFill = nullptr;
116 QQuickShapeStrokeRunnable *pendingStroke = nullptr;
117 };
118
119 void updateShadowDataInNode(ShapePathData *d, QQuickShapeGenericStrokeFillNode *n);
120 void updateFillNode(ShapePathData *d, QQuickShapeGenericNode *node);
121 void updateStrokeNode(ShapePathData *d, QQuickShapeGenericNode *node);
122
123 QQuickItem *m_item;
125 QQuickShapeGenericNode *m_rootNode;
126 QVector<ShapePathData> m_sp;
127 int m_accDirty;
128 void (*m_asyncCallback)(void *);
129 void *m_asyncCallbackData;
130 float m_triangulationScale = 1.0;
131};
132
156
179
203
211
220
222{
223public:
225
227 QSGMaterial *oldMaterial) override;
229 QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
230
231private:
232 QSGTransform m_fillTransform;
233 QVector2D m_gradA;
234 QVector2D m_gradB;
235};
236
238{
239public:
241 : m_node(node)
242 {
243 // Passing RequiresFullMatrix is essential in order to prevent the
244 // batch renderer from baking in simple, translate-only transforms into
245 // the vertex data. The shader will rely on the fact that
246 // vertexCoord.xy is the Shape-space coordinate and so no modifications
247 // are welcome.
249 }
250
251 QSGMaterialType *type() const override;
252 int compare(const QSGMaterial *other) const override;
254
255 QQuickShapeGenericStrokeFillNode *node() const { return m_node; }
256
257private:
259};
260
262{
263public:
265
267 QSGMaterial *oldMaterial) override;
269 QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
270
271private:
272 QSGTransform m_fillTransform;
273 QVector2D m_focalPoint;
274 QVector2D m_focalToCenter;
275 float m_centerRadius;
276 float m_focalRadius;
277};
278
280{
281public:
287
288 QSGMaterialType *type() const override;
289 int compare(const QSGMaterial *other) const override;
291
292 QQuickShapeGenericStrokeFillNode *node() const { return m_node; }
293
294private:
296};
297
299{
300public:
302
304 QSGMaterial *oldMaterial) override;
306 QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
307
308private:
309 QSGTransform m_fillTransform;
310 QVector2D m_centerPoint;
311 float m_angle;
312};
313
315{
316public:
322
323 QSGMaterialType *type() const override;
324 int compare(const QSGMaterial *other) const override;
326
327 QQuickShapeGenericStrokeFillNode *node() const { return m_node; }
328
329private:
331};
332
334
335#endif // QQUICKSHAPEGENERICRENDERER_P_H
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
Definition qlist.h:75
\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
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...
QQuickShapeGenericRenderer::Color4ub fillColor
QQuickShapeGenericRenderer::VertexContainerType fillVertices
QQuickShapeGenericRenderer::IndexContainerType fillIndices
void done(QQuickShapeFillRunnable *self)
void run() override
Implement this pure virtual function in your subclass.
static QSGMaterial * createLinearGradient(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
void setAsyncCallback(void(*)(void *), void *) override
void setTriangulationScale(qreal scale) override
void setFillGradient(int index, QQuickShapeGradient *gradient) override
void setFillTransform(int index, const QSGTransform &transform) override
static void triangulateFill(const QPainterPath &path, const Color4ub &fillColor, VertexContainerType *fillVertices, IndexContainerType *fillIndices, QSGGeometry::Type *indexType, bool supportsElementIndexUint, qreal triangulationScale)
void setStrokeColor(int index, const QColor &color) override
void setFillRule(int index, QQuickShapePath::FillRule fillRule) override
void setFillColor(int index, const QColor &color) override
QVector< QSGGeometry::ColoredPoint2D > VertexContainerType
void setJoinStyle(int index, QQuickShapePath::JoinStyle joinStyle, int miterLimit) override
void setStrokeWidth(int index, qreal w) override
void setRootNode(QQuickShapeGenericNode *node)
void beginSync(int totalCount, bool *countChanged) override
void setCapStyle(int index, QQuickShapePath::CapStyle capStyle) override
static void triangulateStroke(const QPainterPath &path, const QPen &pen, const Color4ub &strokeColor, VertexContainerType *strokeVertices, const QSize &clipSize, qreal triangulationScale)
void setStrokeStyle(int index, QQuickShapePath::StrokeStyle strokeStyle, qreal dashOffset, const QVector< qreal > &dashPattern) override
void setPath(int index, const QQuickPath *path) override
QSGGradientCache::GradientDesc m_fillGradient
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,...
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...
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,...
QQuickShapeGenericRenderer::Color4ub strokeColor
QQuickShapeGenericRenderer::VertexContainerType strokeVertices
void done(QQuickShapeStrokeRunnable *self)
void run() override
Implement this pure virtual function in your subclass.
\qmltype Window \instantiates QQuickWindow \inqmlmodule QtQuick
\inmodule QtCore
Definition qrunnable.h:18
The QSGGeometryNode class is used for all rendered content in the scene graph.
Definition qsgnode.h:188
Type
Specifies the component type in the vertex data.
Definition qsggeometry.h:43
Encapsulates the current rendering state during a call to QSGMaterialShader::updateUniformData() and ...
The QSGMaterialShader class represents a graphics API independent shader program.
The QSGMaterial class encapsulates rendering state for a shader program.
Definition qsgmaterial.h:15
void setFlag(Flags flags, bool on=true)
Sets the flags flags on this material if on is true; otherwise clears the attribute.
\group qtquick-scenegraph-nodes \title Qt Quick Scene Graph Node classes
Definition qsgnode.h:37
An interface providing access to some of the graphics API specific internals of the scenegraph.
RenderMode
\value RenderMode2D Normal 2D rendering \value RenderMode2DNoDepthBuffer Normal 2D rendering with dep...
GraphicsApi
\value Unknown An unknown graphics API is in use \value Software The Qt Quick 2D Renderer is in use \...
\inmodule QtQuick
Definition qsgtexture.h:20
\inmodule QtCore
Definition qsize.h:25
The QVector2D class represents a vector or vertex in 2D space.
Definition qvectornd.h:31
else opt state
[0]
Combined button and popup list for selecting options.
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
const GLfloat * m
GLfloat GLfloat GLfloat w
[0]
GLuint index
[2]
GLuint color
[2]
GLenum GLuint texture
GLfloat n
GLuint GLenum GLenum transform
GLsizei const GLchar *const * path
GLenum GLenum GLenum GLenum GLenum scale
#define Q_OBJECT
#define Q_SIGNALS
unsigned char uchar
Definition qtypes.h:32
double qreal
Definition qtypes.h:187
QObject::connect nullptr
QSharedPointer< T > other(t)
[5]
QGraphicsItem * item
aWidget window() -> setWindowTitle("New Window Title")
[2]
The QSGMaterialType class is used as a unique type token in combination with QSGMaterial.