diff options
author | Tobias Koenig <tobias.koenig@kdab.com> | 2016-01-20 14:59:37 +0100 |
---|---|---|
committer | Tobias Koenig <tobias.koenig@kdab.com> | 2016-01-20 14:34:29 +0000 |
commit | 5d921dda57bff431487e6f1d64ef5111d464655d (patch) | |
tree | e312220e9ddec92315de30b9dbc3570ea216c879 /src/render/backend | |
parent | 30152f710ab459c203d3b59d2d0c364af365f92f (diff) |
Port FrameGraphManager away from QResourceManager
Change-Id: I7399008adb0f612c78738f58f168fa38cf6ae845
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src/render/backend')
-rw-r--r-- | src/render/backend/managers.cpp | 73 | ||||
-rw-r--r-- | src/render/backend/managers_p.h | 16 | ||||
-rw-r--r-- | src/render/backend/render-backend.pri | 1 | ||||
-rw-r--r-- | src/render/backend/renderer.cpp | 5 |
4 files changed, 86 insertions, 9 deletions
diff --git a/src/render/backend/managers.cpp b/src/render/backend/managers.cpp new file mode 100644 index 000000000..e59db7402 --- /dev/null +++ b/src/render/backend/managers.cpp @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "managers_p.h" + +#include <Qt3DRender/private/framegraphnode_p.h> + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { +namespace Render { + +bool FrameGraphManager::containsNode(const Qt3DCore::QNodeId &id) const +{ + return m_nodes.contains(id); +} + +void FrameGraphManager::appendNode(FrameGraphNode *node) +{ + m_nodes.insert(node->peerUuid(), node); +} + +FrameGraphNode* FrameGraphManager::lookupNode(const Qt3DCore::QNodeId &id) const +{ + const QHash<Qt3DCore::QNodeId, FrameGraphNode*>::const_iterator it = m_nodes.find(id); + if (it == m_nodes.end()) + return Q_NULLPTR; + else + return *it; +} + +void FrameGraphManager::releaseNode(const Qt3DCore::QNodeId &id) +{ + delete m_nodes.take(id); +} + +} // namespace Render +} // namespace Qt3DRender + +QT_END_NAMESPACE diff --git a/src/render/backend/managers_p.h b/src/render/backend/managers_p.h index e3b9cb9d7..a1f228339 100644 --- a/src/render/backend/managers_p.h +++ b/src/render/backend/managers_p.h @@ -135,14 +135,20 @@ public: EntityManager() {} }; -class FrameGraphManager : public Qt3DCore::QResourceManager< - FrameGraphNode *, - Qt3DCore::QNodeId, - 8, - Qt3DCore::ArrayAllocatingPolicy> +class FrameGraphNode; + +class Q_AUTOTEST_EXPORT FrameGraphManager { public: FrameGraphManager() {} + + bool containsNode(const Qt3DCore::QNodeId &id) const; + void appendNode(FrameGraphNode *node); + FrameGraphNode* lookupNode(const Qt3DCore::QNodeId &id) const; + void releaseNode(const Qt3DCore::QNodeId &id); + +private: + QHash<Qt3DCore::QNodeId, FrameGraphNode*> m_nodes; }; class LayerManager : public Qt3DCore::QResourceManager< diff --git a/src/render/backend/render-backend.pri b/src/render/backend/render-backend.pri index b6c4a77a5..0b7efa5e7 100644 --- a/src/render/backend/render-backend.pri +++ b/src/render/backend/render-backend.pri @@ -43,6 +43,7 @@ SOURCES += \ $$PWD/rendertarget.cpp \ $$PWD/renderattachment.cpp \ $$PWD/attachmentpack.cpp \ + $$PWD/managers.cpp \ $$PWD/platformsurfacefilter.cpp \ $$PWD/cameralens.cpp \ $$PWD/entity.cpp \ diff --git a/src/render/backend/renderer.cpp b/src/render/backend/renderer.cpp index e6bf0cf86..c9a5b5b0f 100644 --- a/src/render/backend/renderer.cpp +++ b/src/render/backend/renderer.cpp @@ -413,10 +413,7 @@ void Renderer::setFrameGraphRoot(const Qt3DCore::QNodeId fgRootId) Render::FrameGraphNode *Renderer::frameGraphRoot() const { - FrameGraphNode **fgRoot = m_nodesManager->lookupResource<FrameGraphNode*, FrameGraphManager>(m_frameGraphRootUuid); - if (fgRoot != Q_NULLPTR) - return *fgRoot; - return Q_NULLPTR; + return m_nodesManager->frameGraphManager()->lookupNode(m_frameGraphRootUuid); } // QAspectThread context |