summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2015-07-31 12:47:00 +0200
committerSean Harmer <sean.harmer@kdab.com>2015-08-07 00:12:02 +0000
commita585e4b2670f7bfc3d44a731472c9f7fb9ca6698 (patch)
treecebba6e14ebd4f7938d8d7fa31097410d6da917c
parentd8ac5a77916934da196a69dad92624abd1aa0ab3 (diff)
RenderGeometry backend node for QGeometry
Change-Id: I4586e26e9785b29e2128e3c4d40895122306346e Reviewed-by: Paul Lemire <paul.lemire@kdab.com> Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
-rw-r--r--src/render/backend/render-backend.pri6
-rw-r--r--src/render/backend/rendergeometry.cpp111
-rw-r--r--src/render/backend/rendergeometry_p.h75
3 files changed, 190 insertions, 2 deletions
diff --git a/src/render/backend/render-backend.pri b/src/render/backend/render-backend.pri
index 20450cb25..b3fa20da2 100644
--- a/src/render/backend/render-backend.pri
+++ b/src/render/backend/render-backend.pri
@@ -53,7 +53,8 @@ HEADERS += \
$$PWD/rendertextureimage_p.h \
$$PWD/vsyncframeadvanceservice_p.h \
$$PWD/renderbuffer_p.h \
- $$PWD/renderattribute_p.h
+ $$PWD/renderattribute_p.h \
+ $$PWD/rendergeometry_p.h
SOURCES += \
$$PWD/qrenderaspect.cpp \
@@ -97,4 +98,5 @@ SOURCES += \
$$PWD/rendertextureimage.cpp \
$$PWD/vsyncframeadvanceservice.cpp \
$$PWD/renderbuffer.cpp \
- $$PWD/renderattribute.cpp
+ $$PWD/renderattribute.cpp \
+ $$PWD/rendergeometry.cpp
diff --git a/src/render/backend/rendergeometry.cpp b/src/render/backend/rendergeometry.cpp
new file mode 100644
index 000000000..5ca72a10f
--- /dev/null
+++ b/src/render/backend/rendergeometry.cpp
@@ -0,0 +1,111 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 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 "rendergeometry_p.h"
+#include <Qt3DCore/qscenepropertychange.h>
+#include <Qt3DCore/qabstractattribute.h>
+#include <Qt3DRenderer/qgeometry.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3D {
+
+namespace Render {
+
+RenderGeometry::RenderGeometry()
+ : QBackendNode(ReadOnly)
+ , m_geometryDirty(false)
+{
+}
+
+RenderGeometry::~RenderGeometry()
+{
+}
+
+void RenderGeometry::cleanup()
+{
+ m_attributes.clear();
+ m_geometryDirty = false;
+}
+
+void RenderGeometry::updateFromPeer(QNode *peer)
+{
+ QGeometry *geometry = static_cast<QGeometry *>(peer);
+ if (geometry != Q_NULLPTR) {
+ m_attributes.reserve(geometry->attributes().size());
+ Q_FOREACH (QAbstractAttribute *attribute, geometry->attributes())
+ m_attributes.push_back(attribute->id());
+ m_geometryDirty = true;
+ }
+}
+
+void RenderGeometry::sceneChangeEvent(const QSceneChangePtr &e)
+{
+ QScenePropertyChangePtr propertyChange = qSharedPointerCast<QScenePropertyChange>(e);
+ QByteArray propertyName = propertyChange->propertyName();
+
+ switch (e->type()) {
+ case NodeAdded: {
+ if (propertyName == QByteArrayLiteral("attribute")) {
+ m_attributes.push_back(propertyChange->value().value<QNodeId>());
+ m_geometryDirty = true;
+ }
+ break;
+ }
+
+ case NodeRemoved: {
+ if (propertyName == QByteArrayLiteral("attribute")) {
+ m_attributes.removeOne(propertyChange->value().value<QNodeId>());
+ m_geometryDirty = true;
+ }
+ break;
+ }
+
+ default:
+ break;
+ }
+}
+
+void RenderGeometry::unsetDirty()
+{
+ m_geometryDirty = false;
+}
+
+} // Render
+
+} // Qt3D
+
+QT_END_NAMESPACE
diff --git a/src/render/backend/rendergeometry_p.h b/src/render/backend/rendergeometry_p.h
new file mode 100644
index 000000000..636cba773
--- /dev/null
+++ b/src/render/backend/rendergeometry_p.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 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_RENDERGEOMETRY_H
+#define QT3D_RENDER_RENDERGEOMETRY_H
+
+#include <Qt3DCore/qbackendnode.h>
+
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3D {
+
+namespace Render {
+
+class Q_AUTOTEST_EXPORT RenderGeometry : public QBackendNode
+{
+public:
+ RenderGeometry();
+ ~RenderGeometry();
+
+ void cleanup();
+
+ void updateFromPeer(QNode *peer) Q_DECL_OVERRIDE;
+ void sceneChangeEvent(const QSceneChangePtr &e) Q_DECL_OVERRIDE;
+
+ inline QVector<QNodeId> attributes() const { return m_attributes; }
+ inline bool isDirty() const { return m_geometryDirty; }
+ void unsetDirty();
+
+private:
+ QVector<QNodeId> m_attributes;
+ bool m_geometryDirty;
+};
+
+} // Render
+
+} // Qt3D
+
+QT_END_NAMESPACE
+
+#endif // QT3D_RENDER_RENDERGEOMETRY_H