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
qsgnode.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 QSGNODE_H
5#define QSGNODE_H
6
7#include <QtCore/qlist.h>
8#include <QtQuick/qsggeometry.h>
9#include <QtGui/QMatrix4x4>
10
11#include <float.h>
12
14
15#ifndef QT_NO_DEBUG
16#define QSG_RUNTIME_DESCRIPTION
17#endif
18
20class QSGRenderer;
21
22class QSGNode;
23class QSGRootNode;
24class QSGGeometryNode;
26class QSGClipNode;
27class QSGNodePrivate;
30
31namespace QSGBatchRenderer {
32 class Renderer;
33 class Updater;
34}
35
36class Q_QUICK_EXPORT QSGNode
37{
38public:
48
49 enum Flag {
50 // Lower 16 bites reserved for general node
51 OwnedByParent = 0x0001,
52 UsePreprocess = 0x0002,
53
54 // 0x00ff0000 bits reserved for node subclasses
55
56 // QSGBasicGeometryNode
57 OwnsGeometry = 0x00010000,
58 OwnsMaterial = 0x00020000,
59 OwnsOpaqueMaterial = 0x00040000,
60
61 // Uppermost 8 bits are reserved for internal use.
62 IsVisitableNode = 0x01000000
63#ifdef Q_QDOC
64 , InternalReserved = 0x01000000
65#endif
66 };
68
70 DirtySubtreeBlocked = 0x0080,
71 DirtyMatrix = 0x0100,
72 DirtyNodeAdded = 0x0400,
73 DirtyNodeRemoved = 0x0800,
74 DirtyGeometry = 0x1000,
75 DirtyMaterial = 0x2000,
76 DirtyOpacity = 0x4000,
77
78 DirtyForceUpdate = 0x8000,
79
80 DirtyUsePreprocess = UsePreprocess,
81
82 DirtyPropagationMask = DirtyMatrix
83 | DirtyNodeAdded
84 | DirtyOpacity
85 | DirtyForceUpdate
86
87 };
88 Q_DECLARE_FLAGS(DirtyState, DirtyStateBit)
89
90 QSGNode();
91 virtual ~QSGNode();
92
93 QSGNode *parent() const { return m_parent; }
94
95 void removeChildNode(QSGNode *node);
96 void removeAllChildNodes();
97 void prependChildNode(QSGNode *node);
98 void appendChildNode(QSGNode *node);
99 void insertChildNodeBefore(QSGNode *node, QSGNode *before);
100 void insertChildNodeAfter(QSGNode *node, QSGNode *after);
101 void reparentChildNodesTo(QSGNode *newParent);
102
103 int childCount() const;
104 QSGNode *childAtIndex(int i) const;
105 QSGNode *firstChild() const { return m_firstChild; }
106 QSGNode *lastChild() const { return m_lastChild; }
107 QSGNode *nextSibling() const { return m_nextSibling; }
108 QSGNode* previousSibling() const { return m_previousSibling; }
109
110 inline NodeType type() const { return m_type; }
111
113 void markDirty(DirtyState bits);
114 QT_DEPRECATED DirtyState dirtyState() const { return { }; }
115
116 virtual bool isSubtreeBlocked() const;
117
118 Flags flags() const { return m_nodeFlags; }
119 void setFlag(Flag, bool = true);
120 void setFlags(Flags, bool = true);
121
122 virtual void preprocess() { }
123
124protected:
125 QSGNode(NodeType type);
126 QSGNode(QSGNodePrivate &dd, NodeType type);
127
128private:
129 friend class QSGRootNode;
131 friend class QSGRenderer;
132
133 void init();
134 void destroy();
135
136 QSGNode *m_parent = nullptr;
137 NodeType m_type = BasicNodeType;
138 QSGNode *m_firstChild = nullptr;
139 QSGNode *m_lastChild = nullptr;
140 QSGNode *m_nextSibling = nullptr;
141 QSGNode *m_previousSibling = nullptr;
142 int m_subtreeRenderableCount = 0;
143
144 Flags m_nodeFlags;
145
146protected:
147 friend class QSGNodePrivate;
148
149 QScopedPointer<QSGNodePrivate> d_ptr;
150};
151
152void Q_QUICK_EXPORT qsgnode_set_description(QSGNode *node, const QString &description);
153
154class Q_QUICK_EXPORT QSGBasicGeometryNode : public QSGNode
155{
156public:
157 ~QSGBasicGeometryNode() override;
158
159 void setGeometry(QSGGeometry *geometry);
160 const QSGGeometry *geometry() const { return m_geometry; }
161 QSGGeometry *geometry() { return m_geometry; }
162
163 const QMatrix4x4 *matrix() const { return m_matrix; }
164 const QSGClipNode *clipList() const { return m_clip_list; }
165
166 void setRendererMatrix(const QMatrix4x4 *m) { m_matrix = m; }
167 void setRendererClipList(const QSGClipNode *c) { m_clip_list = c; }
168
169protected:
170 QSGBasicGeometryNode(NodeType type);
172
173private:
174 friend class QSGNodeUpdater;
175
176 QSGGeometry *m_geometry;
177
178 Q_DECL_UNUSED_MEMBER int m_reserved_start_index;
179 Q_DECL_UNUSED_MEMBER int m_reserved_end_index;
180
181 const QMatrix4x4 *m_matrix;
182 const QSGClipNode *m_clip_list;
183};
184
185class QSGMaterial;
186
187class Q_QUICK_EXPORT QSGGeometryNode : public QSGBasicGeometryNode
188{
189public:
191 ~QSGGeometryNode() override;
192
193 void setMaterial(QSGMaterial *material);
194 QSGMaterial *material() const { return m_material; }
195
196 void setOpaqueMaterial(QSGMaterial *material);
197 QSGMaterial *opaqueMaterial() const { return m_opaque_material; }
198
199 QSGMaterial *activeMaterial() const;
200
201 void setRenderOrder(int order);
202 int renderOrder() const { return m_render_order; }
203
204 void setInheritedOpacity(qreal opacity);
205 qreal inheritedOpacity() const { return m_opacity; }
206
207protected:
209
210private:
211 friend class QSGNodeUpdater;
212
213 int m_render_order = 0;
214 QSGMaterial *m_material = nullptr;
215 QSGMaterial *m_opaque_material = nullptr;
216
217 qreal m_opacity = 1;
218};
219
220class Q_QUICK_EXPORT QSGClipNode : public QSGBasicGeometryNode
221{
222public:
223 QSGClipNode();
224 ~QSGClipNode() override;
225
226 void setIsRectangular(bool rectHint);
227 bool isRectangular() const { return m_is_rectangular; }
228
229 void setClipRect(const QRectF &);
230 QRectF clipRect() const { return m_clip_rect; }
231
232private:
233 uint m_is_rectangular : 1;
234 uint m_reserved : 31;
235
236 QRectF m_clip_rect;
237};
238
239
240class Q_QUICK_EXPORT QSGTransformNode : public QSGNode
241{
242public:
244 ~QSGTransformNode() override;
245
246 void setMatrix(const QMatrix4x4 &matrix);
247 const QMatrix4x4 &matrix() const { return m_matrix; }
248
249 void setCombinedMatrix(const QMatrix4x4 &matrix);
250 const QMatrix4x4 &combinedMatrix() const { return m_combined_matrix; }
251
252private:
253 QMatrix4x4 m_matrix;
254 QMatrix4x4 m_combined_matrix;
255};
256
257
258class Q_QUICK_EXPORT QSGRootNode : public QSGNode
259{
260public:
261 QSGRootNode();
262 ~QSGRootNode() override;
263
264private:
265 void notifyNodeChange(QSGNode *node, DirtyState state);
266
268 friend class QSGNode;
269 friend class QSGGeometryNode;
270
271 QList<QSGAbstractRenderer *> m_renderers;
272};
273
274
275class Q_QUICK_EXPORT QSGOpacityNode : public QSGNode
276{
277public:
279 ~QSGOpacityNode() override;
280
281 void setOpacity(qreal opacity);
282 qreal opacity() const { return m_opacity; }
283
284 void setCombinedOpacity(qreal opacity);
285 qreal combinedOpacity() const { return m_combined_opacity; }
286
287 bool isSubtreeBlocked() const override;
288
289private:
290 qreal m_opacity = 1;
291 qreal m_combined_opacity = 1;
292};
293
294class Q_QUICK_EXPORT QSGNodeVisitor {
295public:
296 virtual ~QSGNodeVisitor();
297
298protected:
301 virtual void enterClipNode(QSGClipNode *) {}
302 virtual void leaveClipNode(QSGClipNode *) {}
307 virtual void visitNode(QSGNode *n);
308 virtual void visitChildren(QSGNode *n);
309};
310
311#ifndef QT_NO_DEBUG_STREAM
312Q_QUICK_EXPORT QDebug operator<<(QDebug, const QSGNode *n);
313Q_QUICK_EXPORT QDebug operator<<(QDebug, const QSGGeometryNode *n);
314Q_QUICK_EXPORT QDebug operator<<(QDebug, const QSGTransformNode *n);
315Q_QUICK_EXPORT QDebug operator<<(QDebug, const QSGOpacityNode *n);
316Q_QUICK_EXPORT QDebug operator<<(QDebug, const QSGRootNode *n);
317
318#endif
319
320Q_DECLARE_OPERATORS_FOR_FLAGS(QSGNode::DirtyState)
321Q_DECLARE_OPERATORS_FOR_FLAGS(QSGNode::Flags)
322
324
325#endif // QSGNODE_H
\inmodule QtCore
The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space.
Definition qmatrix4x4.h:25
\inmodule QtCore\reentrant
Definition qrect.h:484
QSGAbstractRenderer gives access to the scene graph nodes and rendering.
The QSGBasicGeometryNode class serves as a baseclass for geometry based nodes.
Definition qsgnode.h:155
const QSGClipNode * clipList() const
Will be set during rendering to contain the clip of the geometry for that rendering pass.
Definition qsgnode.h:164
const QSGGeometry * geometry() const
Returns this node's geometry.
Definition qsgnode.h:160
QSGGeometry * geometry()
Returns this node's geometry.
Definition qsgnode.h:161
void setRendererClipList(const QSGClipNode *c)
Definition qsgnode.h:167
void setRendererMatrix(const QMatrix4x4 *m)
Definition qsgnode.h:166
const QMatrix4x4 * matrix() const
Will be set during rendering to contain transformation of the geometry for that rendering pass.
Definition qsgnode.h:163
The QSGClipNode class implements the clipping functionality in the scene graph.
Definition qsgnode.h:221
bool isRectangular() const
Returns if this clip node has a rectangular clip.
Definition qsgnode.h:227
QRectF clipRect() const
Returns the clip rect of this node.
Definition qsgnode.h:230
The QSGGeometryNode class is used for all rendered content in the scene graph.
Definition qsgnode.h:188
qreal inheritedOpacity() const
Set during rendering to specify the inherited opacity for that rendering pass.
Definition qsgnode.h:205
QSGMaterial * opaqueMaterial() const
Returns the opaque material of the QSGGeometryNode.
Definition qsgnode.h:197
QSGMaterial * material() const
Returns the material of the QSGGeometryNode.
Definition qsgnode.h:194
int renderOrder() const
Returns the render order of this geometry node.
Definition qsgnode.h:202
The QSGGeometry class provides low-level storage for graphics primitives in the \l{Qt Quick Scene Gra...
Definition qsggeometry.h:15
The QSGMaterial class encapsulates rendering state for a shader program.
Definition qsgmaterial.h:15
static QString description(const QSGNode *node)
Definition qsgnode_p.h:34
The QSGNodeVisitor class is a helper class for traversing the scene graph.
Definition qsgnode.h:294
virtual void enterOpacityNode(QSGOpacityNode *)
Definition qsgnode.h:305
virtual void leaveGeometryNode(QSGGeometryNode *)
Definition qsgnode.h:304
virtual void enterTransformNode(QSGTransformNode *)
Definition qsgnode.h:299
virtual void leaveTransformNode(QSGTransformNode *)
Definition qsgnode.h:300
virtual void leaveOpacityNode(QSGOpacityNode *)
Definition qsgnode.h:306
virtual void leaveClipNode(QSGClipNode *)
Definition qsgnode.h:302
virtual void enterClipNode(QSGClipNode *)
Definition qsgnode.h:301
virtual void enterGeometryNode(QSGGeometryNode *)
Definition qsgnode.h:303
\group qtquick-scenegraph-nodes \title Qt Quick Scene Graph Node classes
Definition qsgnode.h:37
QSGNode * nextSibling() const
Returns the node after this in the parent's list of children.
Definition qsgnode.h:107
Flags flags() const
Returns the set of flags for this node.
Definition qsgnode.h:118
DirtyStateBit
Used in QSGNode::markDirty() to indicate how the scene graph has changed.
Definition qsgnode.h:69
QSGNode * previousSibling() const
Returns the node before this in the parent's list of children.
Definition qsgnode.h:108
Flag
The QSGNode::Flag enum describes flags on the QSGNode.
Definition qsgnode.h:49
QT_DEPRECATED DirtyState dirtyState() const
Definition qsgnode.h:114
QSGNode * lastChild() const
Returns the last child of this node.
Definition qsgnode.h:106
NodeType
Can be used to figure out the type of node.
Definition qsgnode.h:39
@ BasicNodeType
Definition qsgnode.h:40
@ TransformNodeType
Definition qsgnode.h:42
@ RootNodeType
Definition qsgnode.h:45
@ GeometryNodeType
Definition qsgnode.h:41
@ ClipNodeType
Definition qsgnode.h:43
@ OpacityNodeType
Definition qsgnode.h:44
QSGNode * parent() const
Returns the parent node of this node.
Definition qsgnode.h:93
QSGNode * firstChild() const
Returns the first child of this node.
Definition qsgnode.h:105
NodeType type() const
Returns the type of this node.
Definition qsgnode.h:110
QT_DEPRECATED void clearDirty()
Definition qsgnode.h:112
virtual void preprocess()
Override this function to do processing on the node before it is rendered.
Definition qsgnode.h:122
QScopedPointer< QSGNodePrivate > d_ptr
Definition qsgnode.h:149
The QSGOpacityNode class is used to change opacity of nodes.
Definition qsgnode.h:276
qreal opacity() const
Returns this opacity node's opacity.
Definition qsgnode.h:282
qreal combinedOpacity() const
Returns this node's accumulated opacity.
Definition qsgnode.h:285
The renderer class is the abstract baseclass used for rendering the QML scene graph.
The QSGRootNode is the toplevel root of any scene graph.
Definition qsgnode.h:259
The QSGTransformNode class implements transformations in the scene graph.
Definition qsgnode.h:241
const QMatrix4x4 & combinedMatrix() const
Set during rendering to the combination of all parent matrices for that rendering pass.
Definition qsgnode.h:250
const QMatrix4x4 & matrix() const
Returns this transform node's matrix.
Definition qsgnode.h:247
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
else opt state
[0]
Combined button and popup list for selecting options.
#define Q_DECL_UNUSED_MEMBER
#define Q_DECLARE_FLAGS(Flags, Enum)
Definition qflags.h:174
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
Definition qflags.h:194
Flags
static void setMatrix(libinput_device *dev)
const GLfloat * m
GLenum type
GLfloat n
const GLubyte * c
GLuint GLenum matrix
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const void * bits
GLfixed GLfixed GLint GLint order
void Q_QUICK_EXPORT qsgnode_set_description(QSGNode *node, const QString &description)
Definition qsgnode.cpp:641
Q_QUICK_EXPORT QDebug operator<<(QDebug, const QSGNode *n)
Definition qsgnode.cpp:1556
#define QT_DEPRECATED
static QT_BEGIN_NAMESPACE void init(QTextBoundaryFinder::BoundaryType type, QStringView str, QCharAttributes *attributes)
unsigned int uint
Definition qtypes.h:34
double qreal
Definition qtypes.h:187