diff options
author | Paul Lemire <paul.lemire@kdab.com> | 2019-09-18 08:38:54 +0200 |
---|---|---|
committer | Paul Lemire <paul.lemire@kdab.com> | 2019-09-20 15:54:10 +0200 |
commit | e915e062668155436eaf7dce461f31b0058d77c5 (patch) | |
tree | b580b687e1855aca2d472d2acfe75f42e8153719 | |
parent | 86dfa6f8fea866928bef729d159586578412a46c (diff) |
QFrameGraphNode: remove message sync left overs
Change-Id: I798111ea9e2fda76e40c1588c18d6e7e80d34ab7
Reviewed-by: Mike Krus <mike.krus@kdab.com>
-rw-r--r-- | src/render/framegraph/framegraphnode.cpp | 32 | ||||
-rw-r--r-- | src/render/framegraph/framegraphnode_p.h | 3 | ||||
-rw-r--r-- | src/render/framegraph/qframegraphnode.cpp | 9 | ||||
-rw-r--r-- | tests/auto/render/framegraphnode/framegraphnode.pro | 1 | ||||
-rw-r--r-- | tests/auto/render/framegraphnode/tst_framegraphnode.cpp | 39 |
5 files changed, 19 insertions, 65 deletions
diff --git a/src/render/framegraph/framegraphnode.cpp b/src/render/framegraph/framegraphnode.cpp index c30b155e8..93531fd7d 100644 --- a/src/render/framegraph/framegraphnode.cpp +++ b/src/render/framegraph/framegraphnode.cpp @@ -66,15 +66,6 @@ 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 - const auto creationChange = qSharedPointerCast<QFrameGraphNodeCreatedChangeBase>(change); - setParentId(creationChange->parentFrameGraphNodeId()); - markDirty(AbstractRenderer::FrameGraphDirty); -} - void FrameGraphNode::setFrameGraphManager(FrameGraphManager *manager) { if (m_manager != manager) @@ -130,29 +121,6 @@ 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()) { - - case Qt3DCore::PropertyUpdated: { - Qt3DCore::QPropertyUpdatedChangePtr propertyChange = qSharedPointerCast<Qt3DCore::QPropertyUpdatedChange>(e); - if (propertyChange->propertyName() == QByteArrayLiteral("enabled")) { - d_func()->m_enabled = propertyChange->value().toBool(); - markDirty(AbstractRenderer::FrameGraphDirty); - } else if (propertyChange->propertyName() == QByteArrayLiteral("parentFrameGraphUpdated")) { - auto newParent = propertyChange->value().value<Qt3DCore::QNodeId>(); - setParentId(newParent); - markDirty(AbstractRenderer::AllDirty); - } - break; - } - default: - markDirty(AbstractRenderer::AllDirty); - break; - } -} - void FrameGraphNode::cleanup() { setParentId({}); diff --git a/src/render/framegraph/framegraphnode_p.h b/src/render/framegraph/framegraphnode_p.h index aa07877a1..846dc8060 100644 --- a/src/render/framegraph/framegraphnode_p.h +++ b/src/render/framegraph/framegraphnode_p.h @@ -121,13 +121,10 @@ public: void cleanup(); - 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; private: FrameGraphNodeType m_nodeType; diff --git a/src/render/framegraph/qframegraphnode.cpp b/src/render/framegraph/qframegraphnode.cpp index aa7767e0b..1ef81a081 100644 --- a/src/render/framegraph/qframegraphnode.cpp +++ b/src/render/framegraph/qframegraphnode.cpp @@ -258,15 +258,6 @@ 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"); - parentChange->setValue(QVariant::fromValue(parentID)); - const bool blocked = blockNotifications(false); - notifyObservers(parentChange); - blockNotifications(blocked); - // Direct sync update request Q_D(QFrameGraphNode); d->update(); diff --git a/tests/auto/render/framegraphnode/framegraphnode.pro b/tests/auto/render/framegraphnode/framegraphnode.pro index 577bc9775..f47fc1866 100644 --- a/tests/auto/render/framegraphnode/framegraphnode.pro +++ b/tests/auto/render/framegraphnode/framegraphnode.pro @@ -8,3 +8,4 @@ CONFIG += testcase SOURCES += tst_framegraphnode.cpp include(../commons/commons.pri) +include(../../core/common/common.pri) diff --git a/tests/auto/render/framegraphnode/tst_framegraphnode.cpp b/tests/auto/render/framegraphnode/tst_framegraphnode.cpp index 22bd872dc..4ad1ce6f5 100644 --- a/tests/auto/render/framegraphnode/tst_framegraphnode.cpp +++ b/tests/auto/render/framegraphnode/tst_framegraphnode.cpp @@ -33,6 +33,7 @@ #include <Qt3DCore/qpropertyupdatedchange.h> #include <Qt3DCore/private/qnodecreatedchangegenerator_p.h> #include "testrenderer.h" +#include "qbackendnodetester.h" class MyFrameGraphNode : public Qt3DRender::Render::FrameGraphNode { @@ -52,12 +53,12 @@ public: {} }; -class tst_FrameGraphNode : public QObject +class tst_FrameGraphNode : public Qt3DCore::QBackendNodeTester { Q_OBJECT public: tst_FrameGraphNode(QObject *parent = nullptr) - : QObject(parent) + : Qt3DCore::QBackendNodeTester(parent) {} ~tst_FrameGraphNode() @@ -216,10 +217,9 @@ private Q_SLOTS: void checkSceneChangeEvents() { // GIVEN - const Qt3DCore::QNodeId fgNode1Id = Qt3DCore::QNodeId::createId(); - - Qt3DRender::Render::FrameGraphNode *backendFGNode = new MyFrameGraphNode(); + Qt3DRender::QFrameGraphNode *frontendFGNode = new MyQFrameGraphNode(); Qt3DRender::QFrameGraphNode *frontendFGChild = new MyQFrameGraphNode(); + Qt3DRender::Render::FrameGraphNode *backendFGNode = new MyFrameGraphNode(); Qt3DRender::Render::FrameGraphNode *backendFGChild = new MyFrameGraphNode(); QScopedPointer<Qt3DRender::Render::FrameGraphManager> manager(new Qt3DRender::Render::FrameGraphManager()); @@ -229,44 +229,41 @@ private Q_SLOTS: backendFGNode->setRenderer(&renderer); backendFGChild->setRenderer(&renderer); - setIdInternal(backendFGNode, fgNode1Id); + setIdInternal(backendFGNode, frontendFGNode->id()); setIdInternal(backendFGChild, frontendFGChild->id()); - manager->appendNode(fgNode1Id, backendFGNode); + manager->appendNode(frontendFGNode->id(), backendFGNode); manager->appendNode(frontendFGChild->id(), backendFGChild); backendFGNode->setFrameGraphManager(manager.data()); backendFGChild->setFrameGraphManager(manager.data()); - - // To geneate the type_info in the QNodePrivate of frontendFGChild - Qt3DCore::QNodeCreatedChangeGenerator generator(frontendFGChild); + simulateInitializationSync(frontendFGNode, backendFGNode); + simulateInitializationSync(frontendFGChild, backendFGChild); QCOMPARE(backendFGNode->childrenIds().size(), 0); { // WHEN - renderer.clearDirtyBits(0); - const auto change = Qt3DCore::QPropertyUpdatedChangePtr::create(frontendFGChild->id()); - change->setPropertyName("parentFrameGraphUpdated"); - change->setValue(QVariant::fromValue(fgNode1Id)); - backendFGChild->sceneChangeEvent(change); + renderer.clearDirtyBits(Qt3DRender::Render::AbstractRenderer::AllDirty); + frontendFGChild->setParent(frontendFGNode); + backendFGChild->syncFromFrontEnd(frontendFGChild, false); // THEN QCOMPARE(backendFGNode->childrenIds().size(), 1); - QCOMPARE(backendFGChild->parentId(), fgNode1Id); + QCOMPARE(backendFGChild->parentId(), frontendFGNode->id()); + QVERIFY(renderer.dirtyBits() & Qt3DRender::Render::AbstractRenderer::FrameGraphDirty); } { // WHEN - renderer.clearDirtyBits(0); - const auto change = Qt3DCore::QPropertyUpdatedChangePtr::create(frontendFGChild->id()); - change->setPropertyName("parentFrameGraphUpdated"); - change->setValue(QVariant::fromValue(Qt3DCore::QNodeId())); - backendFGChild->sceneChangeEvent(change); + renderer.clearDirtyBits(Qt3DRender::Render::AbstractRenderer::AllDirty); + frontendFGChild->setParent(Q_NODE_NULLPTR); + backendFGChild->syncFromFrontEnd(frontendFGChild, false); // THEN QCOMPARE(backendFGNode->childrenIds().size(), 0); QVERIFY(backendFGChild->parentId().isNull()); + QVERIFY(renderer.dirtyBits() & Qt3DRender::Render::AbstractRenderer::FrameGraphDirty); } } |