summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2015-03-31 11:26:36 +0200
committerPaul Lemire <paul.lemire@kdab.com>2015-05-10 12:25:31 +0000
commit90ba9328495574f8fbd745fb9825bf02e8c2f28d (patch)
treee09d595f381781a85674f9494af71eba70f42623
parentb43e70b9dde614a91d6c9f993c3b444cd113e4e2 (diff)
FrameGraph: allow the FrameGraph tree to contain any kind of Nodes
Change-Id: Ib5a6ea27610dfad3352adacd57c8f0f02c97f31f Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
-rw-r--r--src/quick3d/imports/render/qt3dquick3drenderplugin.cpp3
-rw-r--r--src/quick3d/quick3drenderer/items/items.pri2
-rw-r--r--src/quick3d/quick3drenderer/items/quick3dframegraphitem.cpp100
-rw-r--r--src/quick3d/quick3drenderer/items/quick3dframegraphitem.h79
-rw-r--r--src/render/backend/framegraph/framegraphnode_p.h5
-rw-r--r--src/render/frontend/framegraph-components/qframegraphnode.cpp42
-rw-r--r--src/render/frontend/framegraph-components/qframegraphnode.h5
7 files changed, 16 insertions, 220 deletions
diff --git a/src/quick3d/imports/render/qt3dquick3drenderplugin.cpp b/src/quick3d/imports/render/qt3dquick3drenderplugin.cpp
index a2b2fc705..6c690b9fa 100644
--- a/src/quick3d/imports/render/qt3dquick3drenderplugin.cpp
+++ b/src/quick3d/imports/render/qt3dquick3drenderplugin.cpp
@@ -97,7 +97,6 @@
#include <Qt3DQuickRenderer/quick3dtexture.h>
#include <Qt3DQuickRenderer/private/shaderpropertyparser_p.h>
#include <Qt3DQuickRenderer/quick3drenderpass.h>
-#include <Qt3DQuickRenderer/quick3dframegraphitem.h>
#include <Qt3DQuickRenderer/quick3dsortmethod.h>
#include <Qt3DQuickRenderer/quick3dparameter.h>
#include <Qt3DQuickRenderer/quick3dshaderdata.h>
@@ -205,7 +204,7 @@ void Qt3DQuick3DRenderPlugin::registerTypes(const char *uri)
qmlRegisterExtendedType<Qt3D::QViewport, Qt3D::Render::Quick::Quick3DViewport>(uri, 2, 0, "Viewport");
qmlRegisterExtendedType<Qt3D::QRenderTargetSelector, Qt3D::Render::Quick::Quick3DRenderTargetSelector>(uri, 2, 0, "RenderTargetSelector");
qmlRegisterType<Qt3D::QClearBuffer>(uri, 2, 0, "ClearBuffer");
- qmlRegisterExtendedUncreatableType<Qt3D::QFrameGraphNode, Qt3D::Render::Quick::Quick3DFrameGraphItem>(uri, 2, 0, "FrameGraphNode", QStringLiteral("FrameGraphNode is a base class"));
+ qmlRegisterUncreatableType<Qt3D::QFrameGraphNode>(uri, 2, 0, "FrameGraphNode", QStringLiteral("FrameGraphNode is a base class"));
qmlRegisterExtendedType<Qt3D::QStateSet, Qt3D::Render::Quick::Quick3DStateSet>(uri, 2, 0, "StateSet");
qmlRegisterType<Qt3D::QNoDraw>(uri, 2, 0, "NoDraw");
qmlRegisterType<Qt3D::QFrameGraph>(uri, 2, 0, "FrameGraph");
diff --git a/src/quick3d/quick3drenderer/items/items.pri b/src/quick3d/quick3drenderer/items/items.pri
index 014ab0b38..35fa140d3 100644
--- a/src/quick3d/quick3drenderer/items/items.pri
+++ b/src/quick3d/quick3drenderer/items/items.pri
@@ -10,7 +10,6 @@ HEADERS += \
$$PWD/shaderpropertyparser_p.h \
$$PWD/quick3dtexture.h \
$$PWD/quick3drenderpass.h \
- $$PWD/quick3dframegraphitem.h \
$$PWD/quick3dsortmethod.h \
$$PWD/quick3dparameter_p.h \
$$PWD/quick3dparameter.h \
@@ -31,7 +30,6 @@ SOURCES += \
$$PWD/shaderpropertyparser.cpp \
$$PWD/quick3dtexture.cpp \
$$PWD/quick3drenderpass.cpp \
- $$PWD/quick3dframegraphitem.cpp \
$$PWD/quick3dsortmethod.cpp \
$$PWD/quick3dparameter.cpp \
$$PWD/quick3dshaderdata.cpp \
diff --git a/src/quick3d/quick3drenderer/items/quick3dframegraphitem.cpp b/src/quick3d/quick3drenderer/items/quick3dframegraphitem.cpp
deleted file mode 100644
index c2c53b83b..000000000
--- a/src/quick3d/quick3drenderer/items/quick3dframegraphitem.cpp
+++ /dev/null
@@ -1,100 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 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 "quick3dframegraphitem.h"
-
-QT_BEGIN_NAMESPACE
-
-namespace Qt3D {
-
-namespace Render {
-
-namespace Quick {
-
-Quick3DFrameGraphItem::Quick3DFrameGraphItem(QObject *parent)
- : QObject(parent)
-{
-}
-
-QQmlListProperty<QFrameGraphNode> Quick3DFrameGraphItem::frameGraphChildrenList()
-{
- return QQmlListProperty<QFrameGraphNode>(this, 0,
- &Quick3DFrameGraphItem::apprendFrameGraphItem,
- &Quick3DFrameGraphItem::frameGraphItemsCount,
- &Quick3DFrameGraphItem::frameGraphItemAt,
- &Quick3DFrameGraphItem::clearFrameGraphItemList);
-}
-
-void Quick3DFrameGraphItem::apprendFrameGraphItem(QQmlListProperty<QFrameGraphNode> *list, QFrameGraphNode *item)
-{
- Quick3DFrameGraphItem *fg = qobject_cast<Quick3DFrameGraphItem *>(list->object);
- if (fg)
- return fg->parentFrameGraphItem()->appendFrameGraphNode(item);
-}
-
-QFrameGraphNode *Quick3DFrameGraphItem::frameGraphItemAt(QQmlListProperty<QFrameGraphNode> *list, int index)
-{
- Quick3DFrameGraphItem *fg = qobject_cast<Quick3DFrameGraphItem *>(list->object);
- if (fg)
- return fg->parentFrameGraphItem()->frameGraphChildren().at(index);
- return Q_NULLPTR;
-}
-
-int Quick3DFrameGraphItem::frameGraphItemsCount(QQmlListProperty<QFrameGraphNode> *list)
-{
- Quick3DFrameGraphItem *fg = qobject_cast<Quick3DFrameGraphItem *>(list->object);
- if (fg)
- return fg->parentFrameGraphItem()->frameGraphChildren().count();
- return -1;
-}
-
-void Quick3DFrameGraphItem::clearFrameGraphItemList(QQmlListProperty<QFrameGraphNode> *list)
-{
- Quick3DFrameGraphItem *fg = qobject_cast<Quick3DFrameGraphItem *>(list->object);
- if (fg) {
- Q_FOREACH (QFrameGraphNode *item, fg->parentFrameGraphItem()->frameGraphChildren())
- fg->parentFrameGraphItem()->removeFrameGraphNode(item);
- }
-}
-
-} // Quick
-
-} // Render
-
-} // Qt3D
-
-QT_END_NAMESPACE
-
diff --git a/src/quick3d/quick3drenderer/items/quick3dframegraphitem.h b/src/quick3d/quick3drenderer/items/quick3dframegraphitem.h
deleted file mode 100644
index 56cdf4afb..000000000
--- a/src/quick3d/quick3drenderer/items/quick3dframegraphitem.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 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$
-**
-****************************************************************************/
-
-#ifndef QT3D_RENDER_QUICK_QUICK3DFRAMEGRAPHITEM_H
-#define QT3D_RENDER_QUICK_QUICK3DFRAMEGRAPHITEM_H
-
-#include <Qt3DQuickRenderer/qt3dquickrenderer_global.h>
-#include <Qt3DRenderer/qframegraphnode.h>
-#include <QQmlListProperty>
-
-QT_BEGIN_NAMESPACE
-
-namespace Qt3D {
-
-namespace Render {
-
-namespace Quick {
-
-class QT3DQUICKRENDERERSHARED_EXPORT Quick3DFrameGraphItem : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(QQmlListProperty<Qt3D::QFrameGraphNode> frameGraphChildren READ frameGraphChildrenList)
- Q_CLASSINFO("DefaultProperty", "frameGraphChildren")
-
-public:
- explicit Quick3DFrameGraphItem(QObject *parent = 0);
-
- inline QFrameGraphNode *parentFrameGraphItem() const { return qobject_cast<QFrameGraphNode *>(parent()); }
- QQmlListProperty<QFrameGraphNode> frameGraphChildrenList();
-
-private:
- static void apprendFrameGraphItem(QQmlListProperty<QFrameGraphNode> *list, QFrameGraphNode *item);
- static QFrameGraphNode *frameGraphItemAt(QQmlListProperty<QFrameGraphNode> *list, int index);
- static int frameGraphItemsCount(QQmlListProperty<QFrameGraphNode> *list);
- static void clearFrameGraphItemList(QQmlListProperty<QFrameGraphNode> *list);
-};
-
-} // Quick
-
-} // Render
-
-} // Qt3D
-
-QT_END_NAMESPACE
-
-#endif // QT3D_RENDER_QUICK_QUICK3DFRAMEGRAPHITEM_H
diff --git a/src/render/backend/framegraph/framegraphnode_p.h b/src/render/backend/framegraph/framegraphnode_p.h
index d05408125..b17401ede 100644
--- a/src/render/backend/framegraph/framegraphnode_p.h
+++ b/src/render/backend/framegraph/framegraphnode_p.h
@@ -145,8 +145,9 @@ protected:
backend->setFrameGraphManager(m_manager);
backend->setHandle(handle);
backend->setPeer(f);
- if (qobject_cast<QFrameGraphNode *>(n->parentNode()))
- backend->setParentHandle(m_manager->lookupHandle(n->parentNode()->id()));
+ QFrameGraphNode *parentFGNode = static_cast<QFrameGraphNode *>(n)->parentFrameGraphNode();
+ if (parentFGNode)
+ backend->setParentHandle(m_manager->lookupHandle(parentFGNode->id()));
return backend;
}
return static_cast<Backend *>(*m_manager->data(handle));
diff --git a/src/render/frontend/framegraph-components/qframegraphnode.cpp b/src/render/frontend/framegraph-components/qframegraphnode.cpp
index d3cf5f835..fadf049b8 100644
--- a/src/render/frontend/framegraph-components/qframegraphnode.cpp
+++ b/src/render/frontend/framegraph-components/qframegraphnode.cpp
@@ -62,48 +62,28 @@ QFrameGraphNodePrivate::QFrameGraphNodePrivate(QFrameGraphNode *qq)
{
}
-void QFrameGraphNode::copy(const QNode *ref)
-{
- QNode::copy(ref);
- const QFrameGraphNode *refNode = static_cast<const QFrameGraphNode *>(ref);
- Q_FOREACH (QFrameGraphNode *fgChild, refNode->d_func()->m_fgChildren)
- appendFrameGraphNode(qobject_cast<QFrameGraphNode *>(QNode::clone(fgChild)));
-
-}
-
QFrameGraphNode::QFrameGraphNode(QNode *parent)
: QNode(*new QFrameGraphNodePrivate(this), parent)
{
}
-/*! \internal */
-QFrameGraphNode::QFrameGraphNode(QFrameGraphNodePrivate &dd, QNode *parent)
- : QNode(dd, parent)
+QFrameGraphNode *QFrameGraphNode::parentFrameGraphNode() const
{
-}
+ QFrameGraphNode *parentFGNode = Q_NULLPTR;
+ QNode *parentN = parentNode();
-void QFrameGraphNode::appendFrameGraphNode(QFrameGraphNode *item)
-{
- Q_D(QFrameGraphNode);
- if (!d->m_fgChildren.contains(item)) {
- if (!item->parent())
- item->setParent(this);
- d->m_fgChildren.append(item);
+ while (parentN) {
+ if ((parentFGNode = qobject_cast<QFrameGraphNode *>(parentN)) != Q_NULLPTR)
+ break;
+ parentN = parentN->parentNode();
}
+ return parentFGNode;
}
-void QFrameGraphNode::removeFrameGraphNode(QFrameGraphNode *item)
-{
- Q_D(QFrameGraphNode);
- if (!d->m_fgChildren.contains(item)) {
- d->m_fgChildren.removeOne(item);
- }
-}
-
-QList<QFrameGraphNode *> QFrameGraphNode::frameGraphChildren() const
+/*! \internal */
+QFrameGraphNode::QFrameGraphNode(QFrameGraphNodePrivate &dd, QNode *parent)
+ : QNode(dd, parent)
{
- Q_D(const QFrameGraphNode);
- return d->m_fgChildren;
}
/*!
diff --git a/src/render/frontend/framegraph-components/qframegraphnode.h b/src/render/frontend/framegraph-components/qframegraphnode.h
index b6f8bf1f4..7fb5e4dfa 100644
--- a/src/render/frontend/framegraph-components/qframegraphnode.h
+++ b/src/render/frontend/framegraph-components/qframegraphnode.h
@@ -54,16 +54,13 @@ class QT3DRENDERERSHARED_EXPORT QFrameGraphNode : public QNode
public:
explicit QFrameGraphNode(QNode *parent = 0);
- void appendFrameGraphNode(QFrameGraphNode *item);
- void removeFrameGraphNode(QFrameGraphNode *item);
- QList<QFrameGraphNode *> frameGraphChildren() const;
+ QFrameGraphNode *parentFrameGraphNode() const;
bool isEnabled() const;
void setEnabled(bool enabled);
protected:
QFrameGraphNode(QFrameGraphNodePrivate &dd, QNode *parent = 0);
- void copy(const QNode *ref) Q_DECL_OVERRIDE;
Q_SIGNALS:
void enabledChanged();