Detailed Description
The QSGNode class is the base class for all nodes in the scene graph.
The QSGNode class can be used as a child container. Children are added with the appendChildNode(), prependChildNode(), insertChildNodeBefore() and insertChildNodeAfter(). Ordering of nodes is important as geometry nodes will be rendered in the order they are added to the scene graph. Actually, the scene may reorder nodes freely, but the resulting visual order is still guaranteed.
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, etc. 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(), e.g. 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 its 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.
Warning: Anything related to QSGNode should happen on the scene graph rendering thread.
Member Function Documentation
QSGNode::QSGNode()
QSGNode::QSGNode(NodeType type) [protected]
QSGNode::~QSGNode() [virtual]
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.
QSGNode * QSGNode::childAtIndex(int i) const
int QSGNode::childCount() const
void QSGNode::clearDirty()
DirtyState QSGNode::dirtyState() const
QSGNode * QSGNode::firstChild() const
Flags QSGNode::flags() const
See also setFlags().
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.
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.
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.
QSGNode * QSGNode::lastChild() const
void QSGNode::markDirty(DirtyState bits)
Marks this node with the states in flags as dirty.
When a node is marked dirty, it recursively mark the parent chain as dirty and notify all connected renderers that the has dirty states.
QSGNode * QSGNode::nextSibling() const
QSGNode * QSGNode::parent() const
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.
void QSGNode::preprocess() [virtual]
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.
The preprocess function is called before the update pass that propegates opacity and transformations through the scene graph. That means that functions like QSGOpacityNode::combinedOpacity() and QSGTransformNode::combinedMatrix() will not contain up-to-date values. If such values are changed during the preprocess, these changes will be propegated through the scene graph before it 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.
QSGNode * QSGNode::previousSibling() const
void QSGNode::removeAllChildNodes()
Removes all child nodes from this node's list of children.
void QSGNode::removeChildNode(QSGNode * node)
Removes node from this node's list of children.
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().
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().
NodeType QSGNode::type() const