Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
QSGNode Class Reference

\group qtquick-scenegraph-nodes \title Qt Quick Scene Graph Node classes More...

#include <qsgnode.h>

+ Inheritance diagram for QSGNode:
+ Collaboration diagram for QSGNode:

Public Types

enum  NodeType {
  BasicNodeType , GeometryNodeType , TransformNodeType , ClipNodeType ,
  OpacityNodeType , RootNodeType , RenderNodeType
}
 Can be used to figure out the type of node. More...
 
enum  Flag {
  OwnedByParent = 0x0001 , UsePreprocess = 0x0002 , OwnsGeometry = 0x00010000 , OwnsMaterial = 0x00020000 ,
  OwnsOpaqueMaterial = 0x00040000 , IsVisitableNode = 0x01000000
}
 The QSGNode::Flag enum describes flags on the QSGNode. More...
 
enum  DirtyStateBit {
  DirtySubtreeBlocked = 0x0080 , DirtyMatrix = 0x0100 , DirtyNodeAdded = 0x0400 , DirtyNodeRemoved = 0x0800 ,
  DirtyGeometry = 0x1000 , DirtyMaterial = 0x2000 , DirtyOpacity = 0x4000 , DirtyForceUpdate = 0x8000 ,
  DirtyUsePreprocess = UsePreprocess , DirtyPropagationMask
}
 Used in QSGNode::markDirty() to indicate how the scene graph has changed. More...
 

Public Member Functions

 QSGNode ()
 Constructs a new node.
 
virtual ~QSGNode ()
 Destroys the node.
 
QSGNodeparent () const
 Returns the parent node of this node.
 
void removeChildNode (QSGNode *node)
 Removes node from this node's list of children.
 
void removeAllChildNodes ()
 Removes all child nodes from this node's list of children.
 
void prependChildNode (QSGNode *node)
 Prepends node to this node's the list of children.
 
void appendChildNode (QSGNode *node)
 Appends node to this node's list of children.
 
void insertChildNodeBefore (QSGNode *node, QSGNode *before)
 Inserts node to this node's list of children before the node specified with before.
 
void insertChildNodeAfter (QSGNode *node, QSGNode *after)
 Inserts node to this node's list of children after the node specified with after.
 
void reparentChildNodesTo (QSGNode *newParent)
 
int childCount () const
 Returns the number of child nodes.
 
QSGNodechildAtIndex (int i) const
 Returns the child at index i.
 
QSGNodefirstChild () const
 Returns the first child of this node.
 
QSGNodelastChild () const
 Returns the last child of this node.
 
QSGNodenextSibling () const
 Returns the node after this in the parent's list of children.
 
QSGNodepreviousSibling () const
 Returns the node before this in the parent's list of children.
 
NodeType type () const
 Returns the type of this node.
 
QT_DEPRECATED void clearDirty ()
 
void markDirty (DirtyState bits)
 Notifies all connected renderers that the node has dirty bits.
 
QT_DEPRECATED DirtyState dirtyState () const
 
virtual bool isSubtreeBlocked () const
 Returns whether this node and its subtree is available for use.
 
Flags flags () const
 Returns the set of flags for this node.
 
void setFlag (Flag, bool=true)
 Sets the flag f on this node if enabled is true; otherwise clears the flag.
 
void setFlags (Flags, bool=true)
 Sets the flags f on this node if enabled is true; otherwise clears the flags.
 
virtual void preprocess ()
 Override this function to do processing on the node before it is rendered.
 

Protected Member Functions

 QSGNode (NodeType type)
 Constructs a new node with the given node type.
 
 QSGNode (QSGNodePrivate &dd, NodeType type)
 Constructs a new node with the given node type.
 

Protected Attributes

QScopedPointer< QSGNodePrivated_ptr
 

Friends

class QSGRootNode
 
class QSGBatchRenderer::Renderer
 
class QSGRenderer
 
class QSGNodePrivate
 

Detailed Description

\group qtquick-scenegraph-nodes \title Qt Quick Scene Graph Node classes

Nodes that can be used as part of the scene graph.

This page lists the nodes in \l {Qt Quick}'s \l {scene graph}{Qt Quick Scene Graph}.

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

\inmodule QtQuick

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 contain a mechanism that describes which parts of the scene have 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 \l {Scene Graph and Rendering} for more information.

Definition at line 36 of file qsgnode.h.

Member Enumeration Documentation

◆ DirtyStateBit

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

\value DirtyMatrix The matrix in a QSGTransformNode has changed. \value DirtyNodeAdded A node was added. \value DirtyNodeRemoved A node was removed. \value DirtyGeometry The geometry of a QSGGeometryNode has changed. \value DirtyMaterial The material of a QSGGeometryNode has changed. \value DirtyOpacity The opacity of a QSGOpacityNode has changed. \value DirtySubtreeBlocked The subtree has been blocked.

\omitvalue DirtyForceUpdate \omitvalue DirtyUsePreprocess \omitvalue DirtyPropagationMask

See also
QSGNode::markDirty()
Enumerator
DirtySubtreeBlocked 
DirtyMatrix 
DirtyNodeAdded 
DirtyNodeRemoved 
DirtyGeometry 
DirtyMaterial 
DirtyOpacity 
DirtyForceUpdate 
DirtyUsePreprocess 
DirtyPropagationMask 

Definition at line 69 of file qsgnode.h.

◆ Flag

The QSGNode::Flag enum describes flags on the QSGNode.

\value OwnedByParent The node is owned by its parent and will be deleted when the parent is deleted. \value UsePreprocess The node's virtual preprocess() function will be called before rendering starts. \value OwnsGeometry Only 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. \value OwnsMaterial Only valid for QSGGeometryNode. The node has ownership over the material and will delete it when the node is destroyed or a material is assigned. \value OwnsOpaqueMaterial Only 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. \value InternalReserved Reserved for internal use.

\omitvalue IsVisitableNode

Enumerator
OwnedByParent 
UsePreprocess 
OwnsGeometry 
OwnsMaterial 
OwnsOpaqueMaterial 
IsVisitableNode 

Definition at line 49 of file qsgnode.h.

◆ NodeType

Can be used to figure out the type of node.

\value BasicNodeType The type of QSGNode \value GeometryNodeType The type of QSGGeometryNode \value TransformNodeType The type of QSGTransformNode \value ClipNodeType The type of QSGClipNode \value OpacityNodeType The type of QSGOpacityNode \value RenderNodeType The type of QSGRenderNode

\omitvalue RootNodeType

See also
type()
Enumerator
BasicNodeType 
GeometryNodeType 
TransformNodeType 
ClipNodeType 
OpacityNodeType 
RootNodeType 
RenderNodeType 

Definition at line 39 of file qsgnode.h.

Constructor & Destructor Documentation

◆ QSGNode() [1/3]

QSGNode::QSGNode ( )

Constructs a new node.

Definition at line 209 of file qsgnode.cpp.

◆ ~QSGNode()

QSGNode::~QSGNode ( )
virtual

Destroys the node.

Every child of this node that has the flag QSGNode::OwnedByParent set, will also be deleted.

Definition at line 280 of file qsgnode.cpp.

◆ QSGNode() [2/3]

QSGNode::QSGNode ( NodeType type)
protected

Constructs a new node with the given node type.

Definition at line 220 of file qsgnode.cpp.

◆ QSGNode() [3/3]

QSGNode::QSGNode ( QSGNodePrivate & dd,
NodeType type )
protected

Constructs a new node with the given node type.

Definition at line 238 of file qsgnode.cpp.

Member Function Documentation

◆ appendChildNode()

void QSGNode::appendChildNode ( QSGNode * node)

Appends node to this node's list of children.

Ordering of nodes is important as geometry nodes will be rendered in the order they are added to the scene graph.

Definition at line 396 of file qsgnode.cpp.

◆ childAtIndex()

QSGNode * QSGNode::childAtIndex ( int i) const

Returns the child at index i.

Children are stored internally as a linked list, so iterating over the children via the index is suboptimal.

Definition at line 566 of file qsgnode.cpp.

◆ childCount()

int QSGNode::childCount ( ) const

Returns the number of child nodes.

Definition at line 554 of file qsgnode.cpp.

◆ clearDirty()

QT_DEPRECATED void QSGNode::clearDirty ( )
inline

Definition at line 112 of file qsgnode.h.

◆ dirtyState()

QT_DEPRECATED DirtyState QSGNode::dirtyState ( ) const
inline

Definition at line 114 of file qsgnode.h.

◆ firstChild()

QSGNode * QSGNode::firstChild ( ) const
inline

Returns the first child of this node.

The children are stored in a linked list.

Definition at line 105 of file qsgnode.h.

◆ flags()

Flags QSGNode::flags ( ) const
inline

Returns the set of flags for this node.

Definition at line 118 of file qsgnode.h.

◆ insertChildNodeAfter()

void QSGNode::insertChildNodeAfter ( QSGNode * node,
QSGNode * after )

Inserts node to this node's list of children after the node specified with after.

Ordering of nodes is important as geometry nodes will be rendered in the order they are added to the scene graph.

Definition at line 465 of file qsgnode.cpp.

◆ insertChildNodeBefore()

void QSGNode::insertChildNodeBefore ( QSGNode * node,
QSGNode * before )

Inserts node to this node's list of children before the node specified with before.

Ordering of nodes is important as geometry nodes will be rendered in the order they are added to the scene graph.

Definition at line 429 of file qsgnode.cpp.

◆ isSubtreeBlocked()

bool QSGNode::isSubtreeBlocked ( ) const
virtual

Returns whether this node and its subtree is available for use.

Blocked subtrees will not get their dirty states updated and they will not be rendered.

The QSGOpacityNode will return a blocked subtree when accumulated opacity is 0, for instance.

Reimplemented in QSGOpacityNode.

Definition at line 323 of file qsgnode.cpp.

◆ lastChild()

QSGNode * QSGNode::lastChild ( ) const
inline

Returns the last child of this node.

The children are stored as a linked list.

Definition at line 106 of file qsgnode.h.

◆ markDirty()

void QSGNode::markDirty ( DirtyState bits)

Notifies all connected renderers that the node has dirty bits.

Definition at line 622 of file qsgnode.cpp.

◆ nextSibling()

QSGNode * QSGNode::nextSibling ( ) const
inline

Returns the node after this in the parent's list of children.

The children are stored as a linked list.

Definition at line 107 of file qsgnode.h.

◆ parent()

QSGNode * QSGNode::parent ( ) const
inline

Returns the parent node of this node.

Definition at line 93 of file qsgnode.h.

◆ prependChildNode()

void QSGNode::prependChildNode ( QSGNode * node)

Prepends node to this node's the list of children.

Ordering of nodes is important as geometry nodes will be rendered in the order they are added to the scene graph.

Definition at line 365 of file qsgnode.cpp.

◆ preprocess()

virtual void QSGNode::preprocess ( )
inlinevirtual

Override this function to do processing on the node before it is rendered.

Preprocessing needs to be explicitly enabled by setting the flag QSGNode::UsePreprocess. The flag needs to be set before the node is added to the scene graph and will cause the preprocess() function to be called for every frame the node is rendered.

Warning
Beware of deleting nodes while they are being preprocessed. It is possible, with a small performance hit, to delete a single node during its own preprocess call. Deleting a subtree which has nodes that also use preprocessing may result in a segmentation fault. This is done for performance reasons.

Reimplemented in QQuickShapeGenericStrokeFillNode, QSGBasicInternalImageNode, QSGCurveFillNode, QSGCurveGlyphNode, QSGDefaultGlyphNode, QSGDistanceFieldGlyphNode, QSGOpenVGInternalImageNode, QSGRhiShaderEffectNode, QSGSoftwareInternalImageNode, and SGFramebufferObjectNode.

Definition at line 122 of file qsgnode.h.

◆ previousSibling()

QSGNode * QSGNode::previousSibling ( ) const
inline

Returns the node before this in the parent's list of children.

The children are stored as a linked list.

Definition at line 108 of file qsgnode.h.

◆ removeAllChildNodes()

void QSGNode::removeAllChildNodes ( )

Removes all child nodes from this node's list of children.

Definition at line 525 of file qsgnode.cpp.

◆ removeChildNode()

void QSGNode::removeChildNode ( QSGNode * node)

Removes node from this node's list of children.

Definition at line 498 of file qsgnode.cpp.

◆ reparentChildNodesTo()

void QSGNode::reparentChildNodesTo ( QSGNode * newParent)

Reparents all nodes of this node to newParent.

Definition at line 545 of file qsgnode.cpp.

◆ setFlag()

void QSGNode::setFlag ( Flag f,
bool enabled = true )

Sets the flag f on this node if enabled is true; otherwise clears the flag.

See also
flags()

Definition at line 584 of file qsgnode.cpp.

◆ setFlags()

void QSGNode::setFlags ( Flags f,
bool enabled = true )

Sets the flags f on this node if enabled is true; otherwise clears the flags.

See also
flags()

Definition at line 603 of file qsgnode.cpp.

◆ type()

NodeType QSGNode::type ( ) const
inline

Returns the type of this node.

The node type must be one of the predefined types defined in QSGNode::NodeType and can safely be used to cast to the corresponding class.

Definition at line 110 of file qsgnode.h.

Friends And Related Symbol Documentation

◆ QSGBatchRenderer::Renderer

friend class QSGBatchRenderer::Renderer
friend

Definition at line 130 of file qsgnode.h.

◆ QSGNodePrivate

friend class QSGNodePrivate
friend

Definition at line 147 of file qsgnode.h.

◆ QSGRenderer

friend class QSGRenderer
friend

Definition at line 131 of file qsgnode.h.

◆ QSGRootNode

friend class QSGRootNode
friend

Definition at line 129 of file qsgnode.h.

Member Data Documentation

◆ d_ptr

QScopedPointer<QSGNodePrivate> QSGNode::d_ptr
protected

Definition at line 149 of file qsgnode.h.


The documentation for this class was generated from the following files: