summaryrefslogtreecommitdiffstats
path: root/src/render/framegraph
diff options
context:
space:
mode:
Diffstat (limited to 'src/render/framegraph')
-rw-r--r--src/render/framegraph/qframegraphnode.cpp37
-rw-r--r--src/render/framegraph/qframegraphnode_p.h5
-rw-r--r--src/render/framegraph/qframegraphnodecreatedchange.cpp3
-rw-r--r--src/render/framegraph/qframegraphnodecreatedchange_p.h11
4 files changed, 54 insertions, 2 deletions
diff --git a/src/render/framegraph/qframegraphnode.cpp b/src/render/framegraph/qframegraphnode.cpp
index 0a60edef7..9acfd1209 100644
--- a/src/render/framegraph/qframegraphnode.cpp
+++ b/src/render/framegraph/qframegraphnode.cpp
@@ -41,6 +41,12 @@
#include "qframegraphnode_p.h"
#include <Qt3DRender/qframegraphnodecreatedchange.h>
+#include <Qt3DCore/QNode>
+
+#include <QQueue>
+
+using namespace Qt3DCore;
+
QT_BEGIN_NAMESPACE
namespace Qt3DRender {
@@ -190,7 +196,10 @@ QFrameGraphNode::~QFrameGraphNode()
}
/*!
- Returns a pointer to the parent.
+ Returns a pointer to the parent frame graph node.
+
+ If the parent of this node is not a frame graph node,
+ this method will recursively look for a parent node that is a frame graph node.
*/
QFrameGraphNode *QFrameGraphNode::parentFrameGraphNode() const
{
@@ -205,6 +214,32 @@ QFrameGraphNode *QFrameGraphNode::parentFrameGraphNode() const
return parentFGNode;
}
+/*!
+ \internal
+ * Returns a list of the children that are frame graph nodes.
+ * If this function encounters a child node that is not a frame graph node,
+ * it will go through the children of the child node and look for frame graph nodes.
+ * If any of these are not frame graph nodes, they will be further searched as
+ * if they were direct children of this node.
+ */
+QVector<QFrameGraphNode *> QFrameGraphNodePrivate::childFrameGraphNodes() const
+{
+ Q_Q(const QFrameGraphNode);
+ QVector<QFrameGraphNode *> result;
+ QQueue<QNode *> queue;
+ queue.append(q->childNodes().toList());
+ result.reserve(queue.size());
+ while (!queue.isEmpty()) {
+ auto *child = queue.dequeue();
+ auto *childFGNode = qobject_cast<QFrameGraphNode *>(child);
+ if (childFGNode != nullptr)
+ result.push_back(childFGNode);
+ else
+ queue.append(child->childNodes().toList());
+ }
+ return result;
+}
+
/*! \internal */
QFrameGraphNode::QFrameGraphNode(QFrameGraphNodePrivate &dd, QNode *parent)
: QNode(dd, parent)
diff --git a/src/render/framegraph/qframegraphnode_p.h b/src/render/framegraph/qframegraphnode_p.h
index 00cc53626..c03017638 100644
--- a/src/render/framegraph/qframegraphnode_p.h
+++ b/src/render/framegraph/qframegraphnode_p.h
@@ -65,9 +65,12 @@ class QFrameGraphNodePrivate : public Qt3DCore::QNodePrivate
{
public:
QFrameGraphNodePrivate();
+ QVector<QFrameGraphNode *> childFrameGraphNodes() const;
+
+ static QFrameGraphNodePrivate *get(QFrameGraphNode *node) { return node->d_func(); }
+ static const QFrameGraphNodePrivate *get(const QFrameGraphNode *node) { return node->d_func(); }
Q_DECLARE_PUBLIC(QFrameGraphNode)
- QList<QFrameGraphNode *> m_fgChildren;
};
} // namespace Qt3DRender
diff --git a/src/render/framegraph/qframegraphnodecreatedchange.cpp b/src/render/framegraph/qframegraphnodecreatedchange.cpp
index ef51d5228..464c98bc3 100644
--- a/src/render/framegraph/qframegraphnodecreatedchange.cpp
+++ b/src/render/framegraph/qframegraphnodecreatedchange.cpp
@@ -36,7 +36,9 @@
#include "qframegraphnodecreatedchange.h"
#include "qframegraphnodecreatedchange_p.h"
+
#include <Qt3DRender/qframegraphnode.h>
+#include <Qt3DRender/private/qframegraphnode_p.h>
QT_BEGIN_NAMESPACE
@@ -45,6 +47,7 @@ namespace Qt3DRender {
QFrameGraphNodeCreatedChangeBasePrivate::QFrameGraphNodeCreatedChangeBasePrivate(const QFrameGraphNode *node)
: Qt3DCore::QNodeCreatedChangeBasePrivate(node)
, m_parentFrameGraphNodeId(Qt3DCore::qIdForNode(node->parentFrameGraphNode()))
+ , m_childFrameGraphNodeIds(Qt3DCore::qIdsForNodes(QFrameGraphNodePrivate::get(node)->childFrameGraphNodes()))
{
}
diff --git a/src/render/framegraph/qframegraphnodecreatedchange_p.h b/src/render/framegraph/qframegraphnodecreatedchange_p.h
index 9aa396b8f..c0437afc5 100644
--- a/src/render/framegraph/qframegraphnodecreatedchange_p.h
+++ b/src/render/framegraph/qframegraphnodecreatedchange_p.h
@@ -49,6 +49,7 @@
//
#include <Qt3DCore/private/qnodecreatedchange_p.h>
+#include <Qt3DRender/qframegraphnodecreatedchange.h>
QT_BEGIN_NAMESPACE
@@ -62,6 +63,16 @@ public:
QFrameGraphNodeCreatedChangeBasePrivate(const QFrameGraphNode *node);
Qt3DCore::QNodeId m_parentFrameGraphNodeId;
+ Qt3DCore::QNodeIdVector m_childFrameGraphNodeIds;
+
+ static QFrameGraphNodeCreatedChangeBasePrivate *get(QFrameGraphNodeCreatedChangeBase *change)
+ {
+ return change->d_func();
+ }
+ static const QFrameGraphNodeCreatedChangeBasePrivate *get(const QFrameGraphNodeCreatedChangeBase *change)
+ {
+ return change->d_func();
+ }
};
} // Qt3DRender