diff options
author | Michael Brasser <mbrasser@ford.com> | 2019-08-06 12:09:06 -0500 |
---|---|---|
committer | Michael Brasser <mbrasser@ford.com> | 2019-08-14 09:16:21 -0500 |
commit | 3dcc9719808a77ab644921df38ea82c268ea7a97 (patch) | |
tree | e3ee5cfa2bae3424286028d4ad3bfd4f4b37dccb /src/render/framegraph | |
parent | 3cdd4e12eb25757bb5711977ecf7ede419c44dd1 (diff) |
Add SubtreeEnabler frame graph node
SubtreeEnabler allows easy enabling and disabling of
frame graph subtrees.
[ChangeLog] Added SubtreeEnabler to allow easing enabling
and disabling of frame graph subtrees.
Change-Id: Ibd4dd305c41b2985225311a0cc49675e60a3727f
Reviewed-by: Mike Krus <mike.krus@kdab.com>
Diffstat (limited to 'src/render/framegraph')
-rw-r--r-- | src/render/framegraph/framegraph.pri | 8 | ||||
-rw-r--r-- | src/render/framegraph/framegraphnode_p.h | 2 | ||||
-rw-r--r-- | src/render/framegraph/framegraphvisitor.cpp | 6 | ||||
-rw-r--r-- | src/render/framegraph/qsubtreeenabler.cpp | 113 | ||||
-rw-r--r-- | src/render/framegraph/qsubtreeenabler.h | 65 | ||||
-rw-r--r-- | src/render/framegraph/subtreeenabler.cpp | 57 | ||||
-rw-r--r-- | src/render/framegraph/subtreeenabler_p.h | 74 |
7 files changed, 318 insertions, 7 deletions
diff --git a/src/render/framegraph/framegraph.pri b/src/render/framegraph/framegraph.pri index 1489c2659..e833d4590 100644 --- a/src/render/framegraph/framegraph.pri +++ b/src/render/framegraph/framegraph.pri @@ -66,7 +66,9 @@ HEADERS += \ $$PWD/setfence_p.h \ $$PWD/waitfence_p.h \ $$PWD/qnopicking.h \ - $$PWD/nopicking_p.h + $$PWD/nopicking_p.h \ + $$PWD/qsubtreeenabler.h \ + $$PWD/subtreeenabler_p.h SOURCES += \ $$PWD/cameraselectornode.cpp \ @@ -114,4 +116,6 @@ SOURCES += \ $$PWD/setfence.cpp \ $$PWD/waitfence.cpp \ $$PWD/qnopicking.cpp \ - $$PWD/nopicking.cpp + $$PWD/nopicking.cpp \ + $$PWD/qsubtreeenabler.cpp \ + $$PWD/subtreeenabler.cpp diff --git a/src/render/framegraph/framegraphnode_p.h b/src/render/framegraph/framegraphnode_p.h index 420abce56..3edd4f57d 100644 --- a/src/render/framegraph/framegraphnode_p.h +++ b/src/render/framegraph/framegraphnode_p.h @@ -90,7 +90,7 @@ public: Viewport, ClearBuffers, SortMethod, - SubtreeSelector, + SubtreeEnabler, StateSet, NoDraw, FrustumCulling, diff --git a/src/render/framegraph/framegraphvisitor.cpp b/src/render/framegraph/framegraphvisitor.cpp index cd8b08219..5ccad87e1 100644 --- a/src/render/framegraph/framegraphvisitor.cpp +++ b/src/render/framegraph/framegraphvisitor.cpp @@ -74,10 +74,8 @@ QVector<FrameGraphNode *> FrameGraphVisitor::traverse(FrameGraphNode *root) void FrameGraphVisitor::visit(Render::FrameGraphNode *node) { - // TO DO: check if node is a subtree selector - // in which case, we only visit the subtrees returned - // by the selector functor and not all the children - // as we would otherwise do + if (node->nodeType() == Render::FrameGraphNode::SubtreeEnabler && !node->isEnabled()) + return; // Recurse to children (if we have any), otherwise if this is a leaf node, // initiate a rendering from the current camera diff --git a/src/render/framegraph/qsubtreeenabler.cpp b/src/render/framegraph/qsubtreeenabler.cpp new file mode 100644 index 000000000..5355b6fbd --- /dev/null +++ b/src/render/framegraph/qsubtreeenabler.cpp @@ -0,0 +1,113 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Ford Motor Company +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <Qt3DRender/qsubtreeenabler.h> +#include <Qt3DRender/private/qframegraphnode_p.h> + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender +{ + +/*! + \class Qt3DRender::QSubtreeEnabler + \inmodule Qt3DRender + \brief Enables or disables entire subtrees of framegraph nodes. + \since 5.14 + + While QFrameGraphNodes can be individually enabled and disabled via the + \c enabled property, this can become tedious when an entire path + needs to be turned on or off. QSubtreeEnabler is a convenience node + that makes this use case trivial, allowing all of its children to be + controlled by a single switch. + + QSubtreeEnabler is enabled by default. +*/ + +/*! + \qmltype SubtreeEnabler + \inqmlmodule Qt3D.Render + \since 5.14 + \instantiates Qt3DRender::QSubtreeEnabler + \inherits FrameGraphNode + \brief Enables or disables entire subtrees of frame graph nodes. + + While FrameGraphNodes can be individually enabled and disabled via the + \c enabled property, this can become tedious when an entire path + needs to be turned on or off. SubtreeEnabler is a convenience node + that makes this use case trivial, allowing all of its children to be + controlled by a single switch. + + For example, the following simplified frame graph includes a subtree for + debug rendering that can easily be enabled only when debugging. + + \qml + RenderSurfaceSelector { + ClearBuffers { + Viewport { + CameraSelector {} + } + } + + SubtreeEnabler { + enabled: showDebugView + Viewport { + CameraSelector { + RenderPassFilter {} + } + } + } + } + \endqml + + SubtreeEnabler is enabled by default. + */ + +QSubtreeEnabler::QSubtreeEnabler(Qt3DCore::QNode *parent) + : QFrameGraphNode(*new QFrameGraphNodePrivate, parent) +{ +} + +QSubtreeEnabler::~QSubtreeEnabler() +{ +} + +} //Qt3DRender + +QT_END_NAMESPACE diff --git a/src/render/framegraph/qsubtreeenabler.h b/src/render/framegraph/qsubtreeenabler.h new file mode 100644 index 000000000..bb62dd170 --- /dev/null +++ b/src/render/framegraph/qsubtreeenabler.h @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Ford Motor Company +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QT3DRENDER_QSUBTREEENABLER_H +#define QT3DRENDER_QSUBTREEENABLER_H + +#include <Qt3DRender/QFrameGraphNode> + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender +{ + +class Q_3DRENDERSHARED_EXPORT QSubtreeEnabler : public QFrameGraphNode +{ + Q_OBJECT +public: + explicit QSubtreeEnabler(Qt3DCore::QNode *parent = nullptr); + ~QSubtreeEnabler(); + +private: + void *m_reserved; +}; + +} //Qt3DRender + +QT_END_NAMESPACE + +#endif // QT3DRENDER_QSUBTREEENABLER_H diff --git a/src/render/framegraph/subtreeenabler.cpp b/src/render/framegraph/subtreeenabler.cpp new file mode 100644 index 000000000..e4b4e4ba7 --- /dev/null +++ b/src/render/framegraph/subtreeenabler.cpp @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Ford Motor Company +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "subtreeenabler_p.h" + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { + +namespace Render { + +SubtreeEnabler::SubtreeEnabler() + : FrameGraphNode(FrameGraphNode::SubtreeEnabler) +{ +} + +} //Render + +} //Qt3DRender + +QT_END_NAMESPACE diff --git a/src/render/framegraph/subtreeenabler_p.h b/src/render/framegraph/subtreeenabler_p.h new file mode 100644 index 000000000..22782da12 --- /dev/null +++ b/src/render/framegraph/subtreeenabler_p.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Ford Motor Company +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef SUBTREEENABLER_P_H +#define SUBTREEENABLER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <Qt3DRender/private/framegraphnode_p.h> + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { + +namespace Render { + +class Q_AUTOTEST_EXPORT SubtreeEnabler : public FrameGraphNode +{ +public: + SubtreeEnabler(); +}; + +} //Render + +} //Qt3DRender + +QT_END_NAMESPACE + +#endif // SUBTREEENABLER_P_H |