summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2019-09-17 09:45:06 +0200
committerPaul Lemire <paul.lemire@kdab.com>2019-09-19 22:03:54 +0200
commit0ae1f63069f524d75f814000410ffa8e8f1890b4 (patch)
tree47ca4d3a015f7a846f447ce70187e6fa80b425da
parent29bf6a68c01ad95bd57c34512901a474252be972 (diff)
Update QFrameGraphNode to use direct sync
Change-Id: Ied19e2d25372795f3a70309540e7f84f6ae4f4a3 Reviewed-by: Mike Krus <mike.krus@kdab.com>
-rw-r--r--src/render/framegraph/framegraphnode.cpp21
-rw-r--r--src/render/framegraph/framegraphnode_p.h2
-rw-r--r--src/render/framegraph/qframegraphnode.cpp5
-rw-r--r--src/render/frontend/qrenderaspect.cpp2
4 files changed, 29 insertions, 1 deletions
diff --git a/src/render/framegraph/framegraphnode.cpp b/src/render/framegraph/framegraphnode.cpp
index 458d96d4b..093213b78 100644
--- a/src/render/framegraph/framegraphnode.cpp
+++ b/src/render/framegraph/framegraphnode.cpp
@@ -66,6 +66,7 @@ FrameGraphNode::~FrameGraphNode()
{
}
+// TO DO: Remove once all FG nodes have been converted to direct sync
void FrameGraphNode::initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change)
{
// Set up the parent child relationship and enabled state
@@ -129,6 +130,7 @@ QVector<FrameGraphNode *> FrameGraphNode::children() const
return children;
}
+// TO DO: Remove once all FG nodes have been converted to direct sync
void FrameGraphNode::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
{
switch (e->type()) {
@@ -156,6 +158,25 @@ void FrameGraphNode::cleanup()
setParentId({});
}
+void FrameGraphNode::syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime)
+{
+ Q_UNUSED(firstTime);
+ const QFrameGraphNode *node = qobject_cast<const QFrameGraphNode *>(frontEnd);
+
+ const auto parentId = Qt3DCore::qIdForNode(node->parentFrameGraphNode());
+ if (parentId != m_parentId) {
+ setParentId(parentId);
+ // TO DO: Check if FrameGraphDirty wouldn't be enough here
+ markDirty(AbstractRenderer::AllDirty);
+ }
+
+ if (node->isEnabled() != d_func()->m_enabled) {
+ d_func()->m_enabled = node->isEnabled();
+ markDirty(AbstractRenderer::FrameGraphDirty);
+ }
+}
+
+
} // namespace Render
} // namespace Qt3DRender
diff --git a/src/render/framegraph/framegraphnode_p.h b/src/render/framegraph/framegraphnode_p.h
index 3edd4f57d..aa07877a1 100644
--- a/src/render/framegraph/framegraphnode_p.h
+++ b/src/render/framegraph/framegraphnode_p.h
@@ -123,6 +123,8 @@ public:
void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) override;
+ void syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime) override;
+
protected:
FrameGraphNode(FrameGraphNodeType nodeType, QBackendNode::Mode mode = QBackendNode::ReadOnly);
void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) override;
diff --git a/src/render/framegraph/qframegraphnode.cpp b/src/render/framegraph/qframegraphnode.cpp
index d52b728a8..aa7767e0b 100644
--- a/src/render/framegraph/qframegraphnode.cpp
+++ b/src/render/framegraph/qframegraphnode.cpp
@@ -258,6 +258,7 @@ Qt3DCore::QNodeCreatedChangeBasePtr QFrameGraphNode::createNodeCreationChange()
void QFrameGraphNode::onParentChanged(QObject *)
{
+ // TO DO: Remove once all node have been converted to use direct sync
const auto parentID = parentFrameGraphNode() ? parentFrameGraphNode()->id() : Qt3DCore::QNodeId();
auto parentChange = Qt3DCore::QPropertyUpdatedChangePtr::create(id());
parentChange->setPropertyName("parentFrameGraphUpdated");
@@ -265,6 +266,10 @@ void QFrameGraphNode::onParentChanged(QObject *)
const bool blocked = blockNotifications(false);
notifyObservers(parentChange);
blockNotifications(blocked);
+
+ // Direct sync update request
+ Q_D(QFrameGraphNode);
+ d->update();
}
} // namespace Qt3DRender
diff --git a/src/render/frontend/qrenderaspect.cpp b/src/render/frontend/qrenderaspect.cpp
index f33af9ebd..3ed5d2d6b 100644
--- a/src/render/frontend/qrenderaspect.cpp
+++ b/src/render/frontend/qrenderaspect.cpp
@@ -295,7 +295,7 @@ void QRenderAspectPrivate::registerBackendTypes()
q->registerBackendType<QShaderImage>(QSharedPointer<Render::NodeFunctor<Render::ShaderImage, Render::ShaderImageManager>>::create(m_renderer));
// Framegraph
- q->registerBackendType<QFrameGraphNode>(QSharedPointer<Render::FrameGraphNodeFunctor<Render::FrameGraphNode, QFrameGraphNode> >::create(m_renderer));
+ q->registerBackendType<QFrameGraphNode, true>(QSharedPointer<Render::FrameGraphNodeFunctor<Render::FrameGraphNode, QFrameGraphNode> >::create(m_renderer));
q->registerBackendType<QCameraSelector>(QSharedPointer<Render::FrameGraphNodeFunctor<Render::CameraSelector, QCameraSelector> >::create(m_renderer));
q->registerBackendType<QClearBuffers>(QSharedPointer<Render::FrameGraphNodeFunctor<Render::ClearBuffers, QClearBuffers> >::create(m_renderer));
q->registerBackendType<QDispatchCompute>(QSharedPointer<Render::FrameGraphNodeFunctor<Render::DispatchCompute, QDispatchCompute> >::create(m_renderer));