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
qsgnodeupdater.cpp
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#include "qsgnodeupdater_p.h"
5#include "qsgnode.h"
6#include "qsgrendernode_p.h"
7
9
10// #define QSG_UPDATER_DEBUG
11
13 : m_combined_matrix_stack(64)
14 , m_opacity_stack(64)
15 , m_current_clip(nullptr)
16 , m_force_update(0)
17{
19}
20
24
26{
27 m_current_clip = nullptr;
29
30 Q_ASSERT(m_opacity_stack.size() == 1); // The one we added in the constructr...
32
33 visitNode(n);
34}
35
36
48{
49 while (node != root && node != nullptr) {
50 if (node->isSubtreeBlocked())
51 return true;
52 node = node->parent();
53 }
54 return false;
55}
56
57
59{
60#ifdef QSG_UPDATER_DEBUG
61 qDebug() << "enter transform:" << t << "force=" << m_force_update;
62#endif
63
64 if (!t->matrix().isIdentity()) {
66 t->setCombinedMatrix(*m_combined_matrix_stack.last() * t->matrix());
67 } else {
68 t->setCombinedMatrix(t->matrix());
69 }
70 m_combined_matrix_stack.add(&t->combinedMatrix());
71 } else {
73 t->setCombinedMatrix(*m_combined_matrix_stack.last());
74 } else {
75 t->setCombinedMatrix(QMatrix4x4());
76 }
77 }
78}
79
80
82{
83#ifdef QSG_UPDATER_DEBUG
84 qDebug() << "leave transform:" << t;
85#endif
86
87 if (!t->matrix().isIdentity()) {
89 }
90
91}
92
93
95{
96#ifdef QSG_UPDATER_DEBUG
97 qDebug() << "enter clip:" << c;
98#endif
99
101 c->m_clip_list = m_current_clip;
103}
104
105
107{
108#ifdef QSG_UPDATER_DEBUG
109 qDebug() << "leave clip:" << c;
110#endif
111
112 m_current_clip = c->m_clip_list;
113}
114
115
117{
118#ifdef QSG_UPDATER_DEBUG
119 qDebug() << "enter geometry:" << g;
120#endif
121
123 g->m_clip_list = m_current_clip;
124 g->setInheritedOpacity(m_opacity_stack.last());
125}
126
128{
129#ifdef QSG_UPDATER_DEBUG
130 qDebug() << "leave geometry" << g;
131#else
132 Q_UNUSED(g);
133#endif
134}
135
137{
138#ifdef QSG_UPDATER_DEBUG
139 qDebug() << "enter render:" << r;
140#endif
141
144 rd->m_clip_list = m_current_clip;
145 rd->m_opacity = m_opacity_stack.last();
146}
147
149{
150#ifdef QSG_UPDATER_DEBUG
151 qDebug() << "leave render" << r;
152#else
153 Q_UNUSED(r);
154#endif
155}
156
158{
159 qreal opacity = m_opacity_stack.last() * o->opacity();
160 o->setCombinedOpacity(opacity);
161 m_opacity_stack.add(opacity);
162
163#ifdef QSG_UPDATER_DEBUG
164 qDebug() << "enter opacity" << o;
165#endif
166}
167
169{
170#ifdef QSG_UPDATER_DEBUG
171 qDebug() << "leave opacity" << o;
172#endif
173 if (o->flags() & QSGNode::DirtyOpacity)
175
177}
178
180{
181 for (QSGNode *c = n->firstChild(); c; c = c->nextSibling())
182 visitNode(c);
183}
184
186{
187#ifdef QSG_UPDATER_DEBUG
188 qDebug() << "enter:" << n;
189#endif
190
191 if (!m_force_update)
192 return;
193 if (n->isSubtreeBlocked())
194 return;
195
196 switch (n->type()) {
198 QSGTransformNode *t = static_cast<QSGTransformNode *>(n);
202 break; }
204 QSGGeometryNode *g = static_cast<QSGGeometryNode *>(n);
208 break; }
210 QSGRenderNode *r = static_cast<QSGRenderNode *>(n);
214 break; }
216 QSGClipNode *c = static_cast<QSGClipNode *>(n);
220 break; }
222 QSGOpacityNode *o = static_cast<QSGOpacityNode *>(n);
226 break; }
227 default:
229 break;
230 }
231}
232
void add(const Type &t)
qsizetype size() const
Type & last()
bool isEmpty() const
void pop_back()
The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space.
Definition qmatrix4x4.h:25
The QSGClipNode class implements the clipping functionality in the scene graph.
Definition qsgnode.h:221
The QSGGeometryNode class is used for all rendered content in the scene graph.
Definition qsgnode.h:188
void leaveGeometryNode(QSGGeometryNode *)
void enterRenderNode(QSGRenderNode *)
QDataBuffer< qreal > m_opacity_stack
void visitNode(QSGNode *n)
void enterOpacityNode(QSGOpacityNode *o)
virtual bool isNodeBlocked(QSGNode *n, QSGNode *root) const
Returns true if node is has something that blocks it in the chain from node to root doing a full stat...
const QSGClipNode * m_current_clip
virtual ~QSGNodeUpdater()
void enterGeometryNode(QSGGeometryNode *)
void enterClipNode(QSGClipNode *c)
void leaveClipNode(QSGClipNode *c)
virtual void enterTransformNode(QSGTransformNode *)
QDataBuffer< const QMatrix4x4 * > m_combined_matrix_stack
virtual void updateStates(QSGNode *n)
void leaveRenderNode(QSGRenderNode *)
virtual void leaveTransformNode(QSGTransformNode *)
void visitChildren(QSGNode *n)
void leaveOpacityNode(QSGOpacityNode *o)
\group qtquick-scenegraph-nodes \title Qt Quick Scene Graph Node classes
Definition qsgnode.h:37
@ DirtyOpacity
Definition qsgnode.h:76
virtual bool isSubtreeBlocked() const
Returns whether this node and its subtree is available for use.
Definition qsgnode.cpp:325
@ TransformNodeType
Definition qsgnode.h:42
@ GeometryNodeType
Definition qsgnode.h:41
@ RenderNodeType
Definition qsgnode.h:46
@ 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
The QSGOpacityNode class is used to change opacity of nodes.
Definition qsgnode.h:276
static QSGRenderNodePrivate * get(QSGRenderNode *node)
The QSGRenderNode class represents a set of custom rendering commands targeting the graphics API that...
The QSGTransformNode class implements transformations in the scene graph.
Definition qsgnode.h:241
Combined button and popup list for selecting options.
#define qDebug
[1]
Definition qlogging.h:164
GLboolean r
[2]
GLboolean GLboolean g
GLfloat n
const GLubyte * c
GLdouble GLdouble t
Definition qopenglext.h:243
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
#define Q_UNUSED(x)
double qreal
Definition qtypes.h:187
QRandomGenerator64 rd
[10]
QObject::connect nullptr