QSGNode Class

The QSGNode class is the base class for all nodes in the scene graph. More...

Header: #include <QSGNode>
qmake: QT += quick
Inherited By:

QSGBasicGeometryNode, QSGOpacityNode, QSGRenderNode, and QSGTransformNode

Public Types

enum DirtyStateBit { DirtyMatrix, DirtyNodeAdded, DirtyNodeRemoved, DirtyGeometry, DirtyMaterial, …, DirtySubtreeBlocked }
enum Flag { OwnedByParent, UsePreprocess, OwnsGeometry, OwnsMaterial, OwnsOpaqueMaterial, InternalReserved }
enum NodeType { BasicNodeType, GeometryNodeType, TransformNodeType, ClipNodeType, OpacityNodeType, RenderNodeType }

Detailed Description

The QSGNode class can be used as a child container. Children are added with the appendChildNode(), prependChildNode(), insertChildNodeBefore() and insertChildNodeAfter(). The order of nodes is important as geometry nodes are rendered according to their ordering in the scene graph.

The scene graph nodes contains a mechanism to describe which parts of the scene has changed. This includes the combined matrices, accumulated opacity, changes to the node hierarchy, and so on. This information can be used for optimizations inside the scene graph renderer. For the renderer to properly render the nodes, it is important that users call QSGNode::markDirty() with the correct flags when nodes are changed. Most of the functions on the node classes will implicitly call markDirty(). For example, QSGNode::appendChildNode() will call markDirty() passing in QSGNode::DirtyNodeAdded.

If nodes change every frame, the preprocess() function can be used to apply changes to a node for every frame it is rendered. The use of preprocess() must be explicitly enabled by setting the QSGNode::UsePreprocess flag on the node.

The virtual isSubtreeBlocked() function can be used to disable a subtree all together. Nodes in a blocked subtree will not be preprocessed() and not rendered.

Note: All classes with QSG prefix should be used solely on the scene graph's rendering thread. See Scene Graph and Rendering for more information.

Member Type Documentation

enum QSGNode::DirtyStateBit

Used in QSGNode::markDirty() to indicate how the scene graph has changed.

ConstantValueDescription
QSGNode::DirtyMatrix0x0100The matrix in a QSGTransformNode has changed.
QSGNode::DirtyNodeAdded0x0400A node was added.
QSGNode::DirtyNodeRemoved0x0800A node was removed.
QSGNode::DirtyGeometry0x1000The geometry of a QSGGeometryNode has changed.
QSGNode::DirtyMaterial0x2000The material of a QSGGeometryNode has changed.
QSGNode::DirtyOpacity0x4000The opacity of a QSGOpacityNode has changed.
QSGNode::DirtySubtreeBlocked0x0080The subtree has been blocked.

See also QSGNode::markDirty().

enum QSGNode::Flag

The QSGNode::Flag enum describes flags on the QSGNode

ConstantValueDescription
QSGNode::OwnedByParent0x0001The node is owned by its parent and will be deleted when the parent is deleted.
QSGNode::UsePreprocess0x0002The node's virtual preprocess() function will be called before rendering starts.
QSGNode::OwnsGeometry0x00010000Only valid for QSGGeometryNode and QSGClipNode. The node has ownership over the QSGGeometry instance and will delete it when the node is destroyed or a geometry is assigned.
QSGNode::OwnsMaterial0x00020000Only valid for QSGGeometryNode. The node has ownership over the material and will delete it when the node is destroyed or a material is assigned.
QSGNode::OwnsOpaqueMaterial0x00040000Only valid for QSGGeometryNode. The node has ownership over the opaque material and will delete it when the node is destroyed or a material is assigned.
QSGNode::InternalReserved0x01000000Reserved for internal use.

enum QSGNode::NodeType

Can be used to figure out the type of node.

ConstantValueDescription
QSGNode::BasicNodeType0The type of QSGNode
QSGNode::GeometryNodeType1The type of QSGGeometryNode
QSGNode::TransformNodeType2The type of QSGTransformNode
QSGNode::ClipNodeType3The type of QSGClipNode
QSGNode::OpacityNodeType4The type of QSGOpacityNode
QSGNode::RenderNodeType6The type of QSGRenderNode

See also type().