diff options
author | Paul Lemire <paul.lemire@kdab.com> | 2019-09-17 13:54:50 +0200 |
---|---|---|
committer | Paul Lemire <paul.lemire@kdab.com> | 2019-09-20 14:26:04 +0200 |
commit | b27d2684e765b4cd49d985e23768a9199e72a509 (patch) | |
tree | 983e513e87eb9187204675259b9cf82a7342f25e /src/render/framegraph | |
parent | c11cc7dfa5b9b0766bd1c42c7b8ba0ab021a68a8 (diff) |
Update QSortPolicy to use direct sync
Change-Id: I8d79c5eab413479a665aa3e7f4576a715547f58e
Reviewed-by: Mike Krus <mike.krus@kdab.com>
Diffstat (limited to 'src/render/framegraph')
-rw-r--r-- | src/render/framegraph/qsortpolicy.cpp | 3 | ||||
-rw-r--r-- | src/render/framegraph/sortpolicy.cpp | 29 | ||||
-rw-r--r-- | src/render/framegraph/sortpolicy_p.h | 4 |
3 files changed, 15 insertions, 21 deletions
diff --git a/src/render/framegraph/qsortpolicy.cpp b/src/render/framegraph/qsortpolicy.cpp index 6f852afbd..c8e3d23c5 100644 --- a/src/render/framegraph/qsortpolicy.cpp +++ b/src/render/framegraph/qsortpolicy.cpp @@ -178,7 +178,10 @@ void QSortPolicy::setSortTypes(const QVector<SortType> &sortTypes) if (sortTypes != d->m_sortTypes) { d->m_sortTypes = sortTypes; emit sortTypesChanged(sortTypes); + + const bool wasBlocked = blockNotifications(true); emit sortTypesChanged(sortTypesInt()); + blockNotifications(wasBlocked); } } diff --git a/src/render/framegraph/sortpolicy.cpp b/src/render/framegraph/sortpolicy.cpp index b81d1f6cb..3c7975945 100644 --- a/src/render/framegraph/sortpolicy.cpp +++ b/src/render/framegraph/sortpolicy.cpp @@ -53,18 +53,19 @@ SortPolicy::SortPolicy() { } -void SortPolicy::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) +void SortPolicy::syncFromFrontEnd(const QNode *frontEnd, bool firstTime) { - if (e->type() == Qt3DCore::PropertyUpdated) { - Qt3DCore::QPropertyUpdatedChangePtr propertyChange = qSharedPointerCast<Qt3DCore::QPropertyUpdatedChange>(e); - if (propertyChange->propertyName() == QByteArrayLiteral("sortTypes")) { - auto sortTypesInt = propertyChange->value().value<QVector<int>>(); - m_sortTypes.clear(); - transformVector(sortTypesInt, m_sortTypes); - markDirty(AbstractRenderer::FrameGraphDirty); - } + const QSortPolicy *node = qobject_cast<const QSortPolicy *>(frontEnd); + if (!node) + return; + + FrameGraphNode::syncFromFrontEnd(frontEnd, firstTime); + + const auto sortTypes = node->sortTypes(); + if (sortTypes != m_sortTypes) { + m_sortTypes = sortTypes; + markDirty(AbstractRenderer::FrameGraphDirty); } - FrameGraphNode::sceneChangeEvent(e); } QVector<QSortPolicy::SortType> SortPolicy::sortTypes() const @@ -72,14 +73,6 @@ QVector<QSortPolicy::SortType> SortPolicy::sortTypes() const return m_sortTypes; } -void SortPolicy::initializeFromPeer(const QNodeCreatedChangeBasePtr &change) -{ - FrameGraphNode::initializeFromPeer(change); - const auto typedChange = qSharedPointerCast<Qt3DCore::QNodeCreatedChange<QSortPolicyData>>(change); - const QSortPolicyData &data = typedChange->data; - m_sortTypes = data.sortTypes; -} - } // namepace Render } // namespace Qt3DRender diff --git a/src/render/framegraph/sortpolicy_p.h b/src/render/framegraph/sortpolicy_p.h index ef928af7b..8d572ead7 100644 --- a/src/render/framegraph/sortpolicy_p.h +++ b/src/render/framegraph/sortpolicy_p.h @@ -65,13 +65,11 @@ class Q_AUTOTEST_EXPORT SortPolicy : public FrameGraphNode public: SortPolicy(); - void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) override; + void syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime) override; QVector<Qt3DRender::QSortPolicy::SortType> sortTypes() const; private: - void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) final; - QVector<Qt3DRender::QSortPolicy::SortType> m_sortTypes; }; |