summaryrefslogtreecommitdiffstats
path: root/src/render/jobs
diff options
context:
space:
mode:
authorSean Harmer <sean.harmer@kdab.com>2015-09-18 18:04:22 +0100
committerPaul Lemire <paul.lemire@kdab.com>2015-10-13 12:13:09 +0000
commitb6756277908e1d8e15dd3e35da72c42569494152 (patch)
tree237ea333015f4479f9fbafd4184b89789983a304 /src/render/jobs
parent9c1281f56317bfb8c050d0c464a5a1da1ca885bd (diff)
Final batch of file moves for now
Change-Id: I0c9e83e3142e6b083feb2cbcabcc4279de64b95b Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src/render/jobs')
-rw-r--r--src/render/jobs/framecleanupjob.cpp76
-rw-r--r--src/render/jobs/framecleanupjob_p.h73
-rw-r--r--src/render/jobs/framepreparationjob.cpp95
-rw-r--r--src/render/jobs/framepreparationjob_p.h74
-rw-r--r--src/render/jobs/jobs.pri25
-rw-r--r--src/render/jobs/loadbufferjob.cpp72
-rw-r--r--src/render/jobs/loadbufferjob_p.h74
-rw-r--r--src/render/jobs/loadgeometryjob.cpp68
-rw-r--r--src/render/jobs/loadgeometryjob_p.h74
-rw-r--r--src/render/jobs/loadscenejob.cpp76
-rw-r--r--src/render/jobs/loadscenejob_p.h76
-rw-r--r--src/render/jobs/loadtexturedatajob.cpp132
-rw-r--r--src/render/jobs/loadtexturedatajob_p.h75
-rw-r--r--src/render/jobs/renderviewjob.cpp82
-rw-r--r--src/render/jobs/renderviewjob_p.h95
-rw-r--r--src/render/jobs/renderviewjobutils.cpp441
-rw-r--r--src/render/jobs/renderviewjobutils_p.h149
-rw-r--r--src/render/jobs/updateboundingvolumejob.cpp116
-rw-r--r--src/render/jobs/updateboundingvolumejob_p.h70
-rw-r--r--src/render/jobs/updateworldtransformjob.cpp98
-rw-r--r--src/render/jobs/updateworldtransformjob_p.h70
21 files changed, 2111 insertions, 0 deletions
diff --git a/src/render/jobs/framecleanupjob.cpp b/src/render/jobs/framecleanupjob.cpp
new file mode 100644
index 000000000..7d6df11b4
--- /dev/null
+++ b/src/render/jobs/framecleanupjob.cpp
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** 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 "framecleanupjob_p.h"
+#include <private/renderer_p.h>
+#include <private/entity_p.h>
+#include <private/shaderdata_p.h>
+#include <private/managers_p.h>
+#include <private/texturedatamanager_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+namespace Render {
+
+FrameCleanupJob::FrameCleanupJob(Renderer *renderer)
+ : m_renderer(renderer)
+{
+}
+
+FrameCleanupJob::~FrameCleanupJob()
+{
+}
+
+void FrameCleanupJob::run()
+{
+ // set each ShaderData to not need an update
+ Q_FOREACH (const Qt3D::QNodeId &id, ShaderData::updatedShaderDataList()) {
+ ShaderData *shaderData = m_renderer->shaderDataManager()->lookupResource(id);
+ if (shaderData != Q_NULLPTR)
+ shaderData->clearUpdate();
+ }
+ ShaderData::clearShaderDataList();
+
+ // Cleanup texture handles
+ TextureDataManager *textureDataManager = m_renderer->textureDataManager();
+ textureDataManager->cleanup();
+}
+
+} // namespace Render
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
diff --git a/src/render/jobs/framecleanupjob_p.h b/src/render/jobs/framecleanupjob_p.h
new file mode 100644
index 000000000..c0afc13d5
--- /dev/null
+++ b/src/render/jobs/framecleanupjob_p.h
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** 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 QT3DRENDER_RENDER_FRAMECLEANUPJOB_H
+#define QT3DRENDER_RENDER_FRAMECLEANUPJOB_H
+
+#include <Qt3DCore/qaspectjob.h>
+#include <Qt3DRenderer/qt3drenderer_global.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+namespace Render {
+
+class Renderer;
+class Entity;
+
+class FrameCleanupJob : public Qt3D::QAspectJob
+{
+public:
+ explicit FrameCleanupJob(Renderer *renderer);
+ ~FrameCleanupJob();
+
+protected:
+ void run() Q_DECL_FINAL;
+
+private:
+ Renderer *m_renderer;
+};
+
+typedef QSharedPointer<FrameCleanupJob> FrameCleanupJobPtr;
+
+} // namespace Render
+
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
+
+#endif // QT3DRENDER_RENDER_FRAMECLEANUPJOB_H
diff --git a/src/render/jobs/framepreparationjob.cpp b/src/render/jobs/framepreparationjob.cpp
new file mode 100644
index 000000000..8b98fb54d
--- /dev/null
+++ b/src/render/jobs/framepreparationjob.cpp
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** 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 "framepreparationjob_p.h"
+#include <Qt3DRenderer/private/renderer_p.h>
+#include <Qt3DRenderer/private/entity_p.h>
+#include <Qt3DRenderer/private/shaderdata_p.h>
+#include <Qt3DRenderer/sphere.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+namespace Render {
+
+FramePreparationJob::FramePreparationJob(Entity *root)
+ : m_root(root)
+{
+}
+
+FramePreparationJob::~FramePreparationJob()
+{
+
+}
+
+void FramePreparationJob::run()
+{
+ parseNodeTree(m_root);
+}
+
+void FramePreparationJob::parseNodeTree(Entity *node)
+{
+ // Initialize worldBoundingVolume if Mesh associated
+ Qt3DRender::Render::GeometryRenderer *mesh = Q_NULLPTR;
+ if ((node->localBoundingVolume()->isNull())
+ && (mesh = node->renderComponent<GeometryRenderer>()) != Q_NULLPTR) {
+ // if (!mesh->meshDataHandle().isNull()) {
+ // Qt3DRender::QMeshData *meshData = mesh->meshData();
+ // if (meshData != Q_NULLPTR) {
+ // const QAxisAlignedBoundingBox box = meshData->boundingBox();
+ // node->localBoundingVolume()->setCenter(box.center());
+ // const QVector3D &radii = box.radii();
+ // node->localBoundingVolume()->setRadius(qMax(radii.x(), qMax(radii.y(), radii.z())));
+ // }
+ // }
+ // TO DO: Make that work with the GeometryRenderer
+ }
+
+ // Update transform properties in ShaderData
+ QList<ShaderData *> shadersData = node->renderComponents<ShaderData>();
+ Q_FOREACH (ShaderData *r, shadersData) {
+ r->updateTransformedProperties(*node->worldTransform());
+ }
+
+ // Traverse children
+ Q_FOREACH (Entity *child, node->children())
+ parseNodeTree(child);
+}
+
+} // namespace Render
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
diff --git a/src/render/jobs/framepreparationjob_p.h b/src/render/jobs/framepreparationjob_p.h
new file mode 100644
index 000000000..cc5c7feef
--- /dev/null
+++ b/src/render/jobs/framepreparationjob_p.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** 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 QT3DRENDER_RENDER_FRAMEPREPARATIONJOB_H
+#define QT3DRENDER_RENDER_FRAMEPREPARATIONJOB_H
+
+#include <Qt3DCore/qaspectjob.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+namespace Render {
+
+class Renderer;
+class Entity;
+
+class FramePreparationJob : public Qt3D::QAspectJob
+{
+public:
+ FramePreparationJob(Entity *root);
+ ~FramePreparationJob();
+
+protected:
+ void run() Q_DECL_FINAL;
+
+private:
+ void parseNodeTree(Entity *node);
+
+ Entity *m_root;
+};
+
+typedef QSharedPointer<FramePreparationJob> FramePreparationJobPtr;
+
+} // namespace Render
+
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
+
+#endif // QT3DRENDER_RENDER_FRAMEPREPARATIONJOB_H
diff --git a/src/render/jobs/jobs.pri b/src/render/jobs/jobs.pri
new file mode 100644
index 000000000..2c9b93a4e
--- /dev/null
+++ b/src/render/jobs/jobs.pri
@@ -0,0 +1,25 @@
+INCLUDEPATH += $$PWD
+
+HEADERS += \
+ $$PWD/updateworldtransformjob_p.h \
+ $$PWD/updateboundingvolumejob_p.h \
+ $$PWD/renderviewjob_p.h \
+ $$PWD/renderviewjobutils_p.h \
+ $$PWD/loadscenejob_p.h \
+ $$PWD/framecleanupjob_p.h \
+ $$PWD/framepreparationjob_p.h \
+ $$PWD/loadtexturedatajob_p.h \
+ $$PWD/loadbufferjob_p.h \
+ $$PWD/loadgeometryjob_p.h
+
+SOURCES += \
+ $$PWD/updateworldtransformjob.cpp \
+ $$PWD/updateboundingvolumejob.cpp \
+ $$PWD/renderviewjob.cpp \
+ $$PWD/renderviewjobutils.cpp \
+ $$PWD/loadscenejob.cpp \
+ $$PWD/framecleanupjob.cpp \
+ $$PWD/framepreparationjob.cpp \
+ $$PWD/loadtexturedatajob.cpp \
+ $$PWD/loadbufferjob.cpp \
+ $$PWD/loadgeometryjob.cpp
diff --git a/src/render/jobs/loadbufferjob.cpp b/src/render/jobs/loadbufferjob.cpp
new file mode 100644
index 000000000..4feb07358
--- /dev/null
+++ b/src/render/jobs/loadbufferjob.cpp
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Paul Lemire
+** 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 "loadbufferjob_p.h"
+#include <Qt3DRenderer/private/buffer_p.h>
+#include <Qt3DRenderer/private/buffermanager_p.h>
+#include <Qt3DRenderer/private/renderer_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+namespace Render {
+
+
+LoadBufferJob::LoadBufferJob(const HBuffer &handle)
+ : QAspectJob()
+ , m_handle(handle)
+ , m_renderer(Q_NULLPTR)
+{
+}
+
+LoadBufferJob::~LoadBufferJob()
+{
+}
+
+void LoadBufferJob::run()
+{
+ // Let's leave it for the moment until this has been properly tested
+ qDebug() << Q_FUNC_INFO;
+ Buffer *buffer = m_renderer->bufferManager()->data(m_handle);
+ buffer->executeFunctor();
+}
+
+} // namespace Render
+
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
diff --git a/src/render/jobs/loadbufferjob_p.h b/src/render/jobs/loadbufferjob_p.h
new file mode 100644
index 000000000..7ad43a8a0
--- /dev/null
+++ b/src/render/jobs/loadbufferjob_p.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Paul Lemire
+** 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 QT3DRENDER_RENDER_LOADBUFFERJOB_H
+#define QT3DRENDER_RENDER_LOADBUFFERJOB_H
+
+#include <QSharedPointer>
+#include <Qt3DCore/qaspectjob.h>
+#include <Qt3DRenderer/private/handle_types_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+namespace Render {
+
+class Renderer;
+
+class LoadBufferJob : public Qt3D::QAspectJob
+{
+public:
+ explicit LoadBufferJob(const HBuffer &handle);
+ ~LoadBufferJob();
+
+ void setRenderer(Renderer *renderer) { m_renderer = renderer; }
+
+protected:
+ void run() Q_DECL_OVERRIDE;
+ HBuffer m_handle;
+ Renderer *m_renderer;
+};
+
+typedef QSharedPointer<LoadBufferJob> LoadBufferJobPtr;
+
+} // namespace Render
+
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
+
+#endif // QT3DRENDER_RENDER_LOADBUFFERJOB_H
diff --git a/src/render/jobs/loadgeometryjob.cpp b/src/render/jobs/loadgeometryjob.cpp
new file mode 100644
index 000000000..695e32dc1
--- /dev/null
+++ b/src/render/jobs/loadgeometryjob.cpp
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Paul Lemire
+** 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 "loadgeometryjob_p.h"
+#include <Qt3DRenderer/private/renderer_p.h>
+#include <Qt3DRenderer/private/geometryrenderermanager_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+namespace Render {
+
+LoadGeometryJob::LoadGeometryJob(const HGeometryRenderer &handle)
+ : QAspectJob()
+ , m_handle(handle)
+{
+}
+
+LoadGeometryJob::~LoadGeometryJob()
+{
+}
+
+void LoadGeometryJob::run()
+{
+ GeometryRenderer *geometryRenderer = m_renderer->geometryRendererManager()->data(m_handle);
+ if (geometryRenderer != Q_NULLPTR)
+ geometryRenderer->executeFunctor();
+}
+
+} // namespace Render
+
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
diff --git a/src/render/jobs/loadgeometryjob_p.h b/src/render/jobs/loadgeometryjob_p.h
new file mode 100644
index 000000000..493b1b694
--- /dev/null
+++ b/src/render/jobs/loadgeometryjob_p.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Paul Lemire
+** 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 QT3DRENDER_RENDER_LOADGEOMETRYJOB_H
+#define QT3DRENDER_RENDER_LOADGEOMETRYJOB_H
+
+#include <QSharedPointer>
+#include <Qt3DCore/qaspectjob.h>
+#include <Qt3DRenderer/private/handle_types_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+namespace Render {
+
+class Renderer;
+
+class LoadGeometryJob : public Qt3D::QAspectJob
+{
+public:
+ explicit LoadGeometryJob(const HGeometryRenderer &handle);
+ ~LoadGeometryJob();
+
+ void setRenderer(Renderer *renderer) { m_renderer = renderer; }
+
+protected:
+ void run() Q_DECL_OVERRIDE;
+ HGeometryRenderer m_handle;
+ Renderer *m_renderer;
+};
+
+typedef QSharedPointer<LoadGeometryJob> LoadGeometryJobPtr;
+
+} // namespace Render
+
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
+
+#endif // QT3DRENDER_RENDER_LOADGEOMETRYJOB_H
diff --git a/src/render/jobs/loadscenejob.cpp b/src/render/jobs/loadscenejob.cpp
new file mode 100644
index 000000000..6ceda73da
--- /dev/null
+++ b/src/render/jobs/loadscenejob.cpp
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** 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 "loadscenejob_p.h"
+#include <private/renderer_p.h>
+#include <private/scenemanager_p.h>
+#include <Qt3DCore/qentity.h>
+#include <Qt3DRenderer/private/abstractsceneparser_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+namespace Render {
+
+LoadSceneJob::LoadSceneJob(const QUrl &source, const Qt3D::QNodeId &m_sceneComponent)
+ : QAspectJob()
+ , m_renderer(Q_NULLPTR)
+ , m_source(source)
+ , m_sceneComponent(m_sceneComponent)
+{
+}
+
+void LoadSceneJob::run()
+{
+ Qt3D::QEntity *sceneTree = m_renderer->sceneManager()->sceneTreeFromSource(m_source);
+ if (sceneTree == Q_NULLPTR) {
+ Q_FOREACH (AbstractSceneParser *parser, m_renderer->sceneParsers()) {
+ if (parser->isExtensionSupported(m_source)) {
+ parser->setSource(m_source);
+ sceneTree = parser->scene();
+ m_renderer->sceneManager()->addLoadedSceneTree(m_source, sceneTree);
+ }
+ }
+ }
+ // set clone of sceneTree in sceneComponent
+ Scene *scene = m_renderer->sceneManager()->lookupResource(m_sceneComponent);
+ scene->setSceneSubtree(sceneTree);
+}
+
+} // namespace Render
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
diff --git a/src/render/jobs/loadscenejob_p.h b/src/render/jobs/loadscenejob_p.h
new file mode 100644
index 000000000..d4831d7ed
--- /dev/null
+++ b/src/render/jobs/loadscenejob_p.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** 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 QT3DRENDER_RENDER_LOADSCENEJOB_H
+#define QT3DRENDER_RENDER_LOADSCENEJOB_H
+
+#include <Qt3DCore/qaspectjob.h>
+#include <Qt3DCore/qnodeid.h>
+#include <QSharedPointer>
+#include <QUrl>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+namespace Render {
+
+class Renderer;
+
+class LoadSceneJob : public Qt3D::QAspectJob
+{
+public:
+ explicit LoadSceneJob(const QUrl &source, const Qt3D::QNodeId &sceneComponent);
+ void setRenderer(Renderer *renderer) { m_renderer = renderer; }
+
+protected:
+ void run() Q_DECL_OVERRIDE;
+
+private:
+ Renderer *m_renderer;
+ QUrl m_source;
+ Qt3D::QNodeId m_sceneComponent;
+};
+
+typedef QSharedPointer<LoadSceneJob> LoadSceneJobPtr;
+
+} // namespace Render
+
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
+
+#endif // LOADSCENEJOB_H
diff --git a/src/render/jobs/loadtexturedatajob.cpp b/src/render/jobs/loadtexturedatajob.cpp
new file mode 100644
index 000000000..2dadcd69e
--- /dev/null
+++ b/src/render/jobs/loadtexturedatajob.cpp
@@ -0,0 +1,132 @@
+/****************************************************************************
+**
+** 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 "loadtexturedatajob_p.h"
+#include <Qt3DRenderer/private/renderer_p.h>
+#include <Qt3DRenderer/private/managers_p.h>
+#include <Qt3DRenderer/private/texturedatamanager_p.h>
+#include <QThread>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+namespace Render {
+
+LoadTextureDataJob::LoadTextureDataJob(const Qt3D::QNodeId &textureId)
+ : m_textureId(textureId)
+{
+}
+
+LoadTextureDataJob::~LoadTextureDataJob()
+{
+}
+
+void LoadTextureDataJob::run()
+{
+ qCDebug(Jobs) << "Entering" << Q_FUNC_INFO << QThread::currentThread();
+
+ Texture *txt = m_renderer->textureManager()->lookupResource(m_textureId);
+
+ if (txt != Q_NULLPTR) {
+ // Load update each TextureImage
+ Q_FOREACH (HTextureImage texImgHandle, txt->textureImages()) {
+ TextureImage *texImg = m_renderer->textureImageManager()->data(texImgHandle);
+ if (texImg != Q_NULLPTR && texImg->isDirty() && !texImg->dataFunctor().isNull()) {
+ QTextureDataFunctorPtr functor = texImg->dataFunctor();
+ HTextureData textureDataHandle;
+ TexImageData *data = Q_NULLPTR;
+
+ // scoped for locker
+ {
+ QMutexLocker locker(m_renderer->textureDataManager()->mutex());
+ // We don't want to take the chance of having two jobs uploading the same functor
+ // because of sync issues
+ textureDataHandle = m_renderer->textureDataManager()->textureDataFromFunctor(functor);
+
+ // Texture data handle isn't null == there's already a matching TextureData
+ if (!textureDataHandle.isNull()) {
+ data = m_renderer->textureDataManager()->data(textureDataHandle);
+ } else {
+ TexImageDataPtr dataPtr = functor->operator ()();
+ if (dataPtr.isNull()) {
+ qCDebug(Jobs) << Q_FUNC_INFO << "Texture has no raw data";
+ } else {
+ // Save the TexImageDataPtr with it's functor as a key
+ textureDataHandle = m_renderer->textureDataManager()->acquire();
+ data = m_renderer->textureDataManager()->data(textureDataHandle);
+ *data = *(dataPtr.data());
+ m_renderer->textureDataManager()->addTextureDataForFunctor(textureDataHandle, functor);
+ }
+ }
+
+ // Update HTextureImage Functor to release TextureData when needed
+ m_renderer->textureDataManager()->assignFunctorToTextureImage(functor, texImgHandle);
+ }
+
+ // Set texture size of texture if the first layer / level / face has a valid size
+ // otherwise assume the size was set on the texture itself
+ if (texImg->layer() == 0 && texImg->mipmapLevel() == 0 &&
+ texImg->face() == QAbstractTextureProvider::CubeMapPositiveX) {
+
+ if (data == Q_NULLPTR) {
+ qWarning() << "Texture data is null, texture data failed to load";
+ } else {
+ // Set the size of the texture based on the layer 0 / level 0
+ // if the functor provides something valid. Otherwise we assume the texture
+ // already has the correct size
+ if (data->width() != -1 && data->height() != -1 && data->depth() != -1) {
+ txt->setSize(data->width(), data->height(), data->depth());
+ }
+ // Set the format of the texture if the texture format is set to Automatic
+ if (txt->format() == QAbstractTextureProvider::Automatic) {
+ txt->setFormat(static_cast<QAbstractTextureProvider::TextureFormat>(data->format()));
+ }
+ }
+ }
+ // Set the textureDataHandle on the texture image
+ texImg->setTextureDataHandle(textureDataHandle);
+ }
+ }
+ // Tell the renderer to reload the TextureImage for the Texture
+ // next frame
+ txt->requestTextureDataUpdate();
+ }
+}
+
+} // namespace Render
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
diff --git a/src/render/jobs/loadtexturedatajob_p.h b/src/render/jobs/loadtexturedatajob_p.h
new file mode 100644
index 000000000..15b32c79b
--- /dev/null
+++ b/src/render/jobs/loadtexturedatajob_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 QT3DRENDER_RENDER_LOADTEXTUREDATAJOB_H
+#define QT3DRENDER_RENDER_LOADTEXTUREDATAJOB_H
+
+#include <Qt3DCore/qnodeid.h>
+#include <Qt3DCore/qaspectjob.h>
+#include <Qt3DRenderer/qtextureimage.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+namespace Render {
+
+class Renderer;
+
+class LoadTextureDataJob : public Qt3D::QAspectJob
+{
+public:
+ LoadTextureDataJob(const Qt3D::QNodeId &textureId);
+ ~LoadTextureDataJob();
+ inline void setRenderer(Renderer *renderer) { m_renderer = renderer; }
+
+protected:
+ void run() Q_DECL_FINAL;
+
+private:
+ Qt3D::QNodeId m_textureId;
+ Renderer *m_renderer;
+};
+
+typedef QSharedPointer<LoadTextureDataJob> LoadTextureDataJobPtr;
+
+} // namespace Render
+
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
+
+#endif // QT3DRENDER_RENDER_LOADTEXTUREDATAJOB_H
diff --git a/src/render/jobs/renderviewjob.cpp b/src/render/jobs/renderviewjob.cpp
new file mode 100644
index 000000000..962bcaaa7
--- /dev/null
+++ b/src/render/jobs/renderviewjob.cpp
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** 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 "renderviewjob_p.h"
+
+#include <Qt3DRenderer/private/renderview_p.h>
+#include <Qt3DRenderer/private/renderer_p.h>
+#include <Qt3DRenderer/private/renderviewjobutils_p.h>
+#include <Qt3DRenderer/private/renderlogging_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+namespace Render {
+
+void RenderViewJob::run()
+{
+ qCDebug(Jobs) << Q_FUNC_INFO << m_index;
+
+ // Create a RenderView object
+ // The RenderView are created from a QFrameAllocator stored in the current Thread local storage
+
+ Qt3D::QFrameAllocator *currentFrameAllocator = m_renderer->currentFrameAllocator();
+ RenderView *renderView = currentFrameAllocator->allocate<RenderView>();
+
+ // RenderView should allocate heap resources using only the currentFrameAllocator
+ renderView->setAllocator(currentFrameAllocator);
+ renderView->setRenderer(m_renderer);
+ renderView->setSurfaceSize(m_surfaceSize);
+
+ // Populate the renderview's configuration from the framegraph
+ setRenderViewConfigFromFrameGraphLeafNode(renderView, m_fgLeaf);
+
+ // Build RenderCommand should perform the culling as we have no way to determine
+ // if a child has a mesh in the view frustum while its parent isn't contained in it.
+ if (!renderView->noDraw())
+ renderView->buildRenderCommands(m_renderer->renderSceneRoot());
+
+ // Sorts RenderCommand
+ renderView->sort();
+
+ // Enqueue our fully populated RenderView with the RenderThread
+ m_renderer->enqueueRenderView(renderView, m_index);
+}
+
+} // namespace Render
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
diff --git a/src/render/jobs/renderviewjob_p.h b/src/render/jobs/renderviewjob_p.h
new file mode 100644
index 000000000..281928500
--- /dev/null
+++ b/src/render/jobs/renderviewjob_p.h
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** 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 QT3DRENDER_RENDER_RENDERVIEWJOB_H
+#define QT3DRENDER_RENDER_RENDERVIEWJOB_H
+
+#include <Qt3DCore/qaspectjob.h>
+#include <Qt3DCore/qframeallocator.h>
+#include <QThreadStorage>
+#include <QSize>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+namespace Render {
+
+class Renderer;
+class FrameGraphNode;
+
+class RenderViewJob : public Qt3D::QAspectJob
+{
+public:
+ RenderViewJob()
+ : m_renderer(0)
+ , m_fgLeaf(0)
+ , m_index(0)
+ {}
+
+ inline void setRenderer(Renderer *renderer) { m_renderer = renderer; }
+ inline void setSurfaceSize(const QSize &size) { m_surfaceSize = size; }
+
+ inline void setFrameGraphLeafNode(FrameGraphNode *fgLeaf)
+ {
+ m_fgLeaf = fgLeaf;
+ }
+
+ // Sets the position in the queue of RenderViews that the
+ // RenderView generated by this job should be inserted. This is
+ // used to ensure that for example a RenderView for creating
+ // a shadow map texture is submitted before the RenderView that
+ // contains commands making use of the shadow map
+ inline void setSubmitOrderIndex(int index) { m_index = index; }
+
+protected:
+ void run() Q_DECL_OVERRIDE;
+
+private:
+ Renderer *m_renderer;
+ QSize m_surfaceSize;
+ FrameGraphNode *m_fgLeaf;
+ int m_index;
+};
+
+typedef QSharedPointer<RenderViewJob> RenderViewJobPtr;
+
+} // namespace Render
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
+
+#endif // QT3DRENDER_RENDER_RENDERVIEWJOB_H
diff --git a/src/render/jobs/renderviewjobutils.cpp b/src/render/jobs/renderviewjobutils.cpp
new file mode 100644
index 000000000..9cf472549
--- /dev/null
+++ b/src/render/jobs/renderviewjobutils.cpp
@@ -0,0 +1,441 @@
+/****************************************************************************
+**
+** 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 "renderviewjobutils_p.h"
+#include "renderlogging_p.h"
+
+#include <Qt3DRenderer/qopenglfilter.h>
+#include <Qt3DRenderer/sphere.h>
+#include <Qt3DRenderer/qshaderdata.h>
+
+#include <Qt3DRenderer/private/cameraselectornode_p.h>
+#include <Qt3DRenderer/private/clearbuffer_p.h>
+#include <Qt3DRenderer/private/layerfilternode_p.h>
+#include <Qt3DRenderer/private/managers_p.h>
+#include <Qt3DRenderer/private/effect_p.h>
+#include <Qt3DRenderer/private/renderpassfilternode_p.h>
+#include <Qt3DRenderer/private/renderstateset_p.h>
+#include <Qt3DRenderer/private/rendertargetselectornode_p.h>
+#include <Qt3DRenderer/private/renderview_p.h>
+#include <Qt3DRenderer/private/sortmethod_p.h>
+#include <Qt3DRenderer/private/techniquefilternode_p.h>
+#include <Qt3DRenderer/private/viewportnode_p.h>
+#include <Qt3DRenderer/private/shadervariables_p.h>
+#include <Qt3DRenderer/private/managers_p.h>
+#include <Qt3DRenderer/private/shaderdata_p.h>
+#include <Qt3DRenderer/private/statesetnode_p.h>
+
+QT_BEGIN_NAMESPACE
+
+using namespace Qt3D;
+
+namespace Qt3DRender {
+namespace Render {
+
+/*!
+ \internal
+ Walks up the framegraph tree from \a fgLeaf and builds up as much state
+ as possible and populates \a rv. For cases where we can't get the specific state
+ (e.g. because it depends upon more than just the framegraph) we store the data from
+ the framegraph that will be needed to later when the rest of the data becomes available
+*/
+void setRenderViewConfigFromFrameGraphLeafNode(RenderView *rv, const FrameGraphNode *fgLeaf)
+{
+ // The specific RenderPass to be used is also dependent upon the Effect and TechniqueFilter
+ // which is referenced by the Material which is referenced by the RenderMesh. So we can
+ // only store the filter info in the RenderView structure and use it to do the resolving
+ // when we build the RenderCommand list.
+ const Renderer *renderer = rv->renderer();
+ const FrameGraphNode *node = fgLeaf;
+
+ while (node) {
+ FrameGraphNode::FrameGraphNodeType type = node->nodeType();
+ if (node->isEnabled())
+ switch (type) {
+ case FrameGraphNode::CameraSelector:
+ // Can be set only once and we take camera nearest to the leaf node
+ if (!rv->renderCamera()) {
+ const CameraSelector *cameraSelector = static_cast<const CameraSelector *>(node);
+ Entity *camNode = renderer->renderNodesManager()->lookupResource(cameraSelector->cameraUuid());
+ if (camNode) {
+ CameraLens *lens = camNode->renderComponent<CameraLens>();
+ if (lens && lens->isEnabled()) {
+ rv->setRenderCamera(lens);
+ rv->setViewMatrix(*camNode->worldTransform());
+ rv->setEyePosition(camNode->worldBoundingVolume()->center());
+ }
+ }
+ break;
+ }
+
+ case FrameGraphNode::LayerFilter: // Can be set multiple times in the tree
+ rv->appendLayerFilter(static_cast<const LayerFilterNode *>(node)->layers());
+ break;
+
+ case FrameGraphNode::RenderPassFilter:
+ // Can be set once
+ // TODO: Amalgamate all render pass filters from leaf to root
+ if (!rv->renderPassFilter())
+ rv->setRenderPassFilter(static_cast<const RenderPassFilter *>(node));
+ break;
+
+ case FrameGraphNode::RenderTarget: {
+ // Can be set once and we take render target nearest to the leaf node
+ const RenderTargetSelector *targetSelector = static_cast<const RenderTargetSelector *>(node);
+ QNodeId renderTargetUid = targetSelector->renderTargetUuid();
+ HTarget renderTargetHandle = renderer->renderTargetManager()->lookupHandle(renderTargetUid);
+ if (rv->renderTargetHandle().isNull()) {
+ rv->setRenderTargetHandle(renderTargetHandle);
+
+ RenderTarget *renderTarget = renderer->renderTargetManager()->data(renderTargetHandle);
+ if (renderTarget) {
+ // Add renderTarget Handle and build renderCommand AttachmentPack
+
+ // Copy draw buffers list
+ rv->setDrawBuffers(targetSelector->drawBuffers());
+
+ // Copy attachments
+ Q_FOREACH (const QNodeId &attachmentId, renderTarget->renderAttachments()) {
+ RenderAttachment *attachment = renderer->attachmentManager()->lookupResource(attachmentId);
+ if (attachment)
+ rv->addRenderAttachment(attachment->attachment());
+ }
+
+ }
+ }
+ break;
+ }
+
+ case FrameGraphNode::ClearBuffer:
+ rv->setClearBuffer(static_cast<const ClearBuffer *>(node)->type());
+ break;
+
+ case FrameGraphNode::TechniqueFilter:
+ // Can be set once
+ // TODO Amalgamate all technique filters from leaf to root
+ if (rv->techniqueFilter())
+ rv->setTechniqueFilter(static_cast<const TechniqueFilter *>(node));
+ break;
+
+ case FrameGraphNode::Viewport: {
+ // If the Viewport has already been set in a lower node
+ // Make it so that the new viewport is actually
+ // a subregion relative to that of the parent viewport
+ const ViewportNode *vpNode = static_cast<const ViewportNode *>(node);
+ rv->setViewport(computeViewport(rv->viewport(), vpNode));
+
+ // We take the clear color from the viewport node nearest the leaf
+ if (!rv->clearColor().isValid())
+ rv->setClearColor(vpNode->clearColor());
+ break;
+ }
+
+ case FrameGraphNode::SortMethod: {
+ const Render::SortMethod *sortMethod = static_cast<const Render::SortMethod *>(node);
+ rv->addSortCriteria(sortMethod->criteria());
+ break;
+ }
+
+ case FrameGraphNode::SubtreeSelector:
+ // Has no meaning here. SubtreeSelector was used
+ // in a prior step to build the list of RenderViewJobs
+ break;
+
+ case FrameGraphNode::StateSet: {
+ const Render::StateSetNode *rStateSet = static_cast<const Render::StateSetNode *>(node);
+ // Create global RenderStateSet for renderView if no stateSet was set before
+ RenderStateSet *stateSet = rv->stateSet();
+ if (stateSet == Q_NULLPTR) {
+ stateSet = rv->allocator()->allocate<RenderStateSet>();
+ rv->setStateSet(stateSet);
+ }
+
+ // Add renderstates to stateset
+ const QList<RenderState *> &states = rStateSet->renderStates();
+ Q_FOREACH (RenderState *renderState, states)
+ stateSet->addState(renderState);
+
+ break;
+ }
+
+ case FrameGraphNode::NoDraw: {
+ rv->setNoDraw(true);
+ break;
+ }
+
+ default:
+ // Should never get here
+ qCWarning(Backend) << "Unhandled FrameGraphNode type";
+ }
+
+ node = node->parent();
+ }
+}
+
+/*!
+ \internal
+ Searches the \a renderer for the best matching Technique from
+ \a effect specified by the \a renderView.
+*/
+Technique *findTechniqueForEffect(Renderer *renderer,
+ RenderView *renderView,
+ Effect *effect)
+{
+ if (!effect)
+ return Q_NULLPTR;
+
+ // Iterate through the techniques in the effect
+ Q_FOREACH (const QNodeId &techniqueId, effect->techniques()) {
+ Technique *technique = renderer->techniqueManager()->lookupResource(techniqueId);
+
+ if (!technique)
+ continue;
+
+ // We need to be sure the renderer is still running <=> still has a GraphicsContext
+ if (renderer->isRunning() && *renderer->contextInfo() == *technique->openGLFilter()) {
+
+ // If no techniqueFilter is present, we return the technique as it satisfies OpenGL version
+ const TechniqueFilter *techniqueFilter = renderView->techniqueFilter();
+ bool foundMatch = (techniqueFilter == Q_NULLPTR || techniqueFilter->filters().isEmpty());
+ if (foundMatch)
+ return technique;
+
+ // There is a technique filter so we need to check for a technique with suitable criteria.
+ // Check for early bail out if the technique doesn't have sufficient number of criteria and
+ // can therefore never satisfy the filter
+ if (technique->annotations().size() < techniqueFilter->filters().size())
+ continue;
+
+ // Iterate through the filter criteria and for each one search for a criteria on the
+ // technique that satisfies it
+ Q_FOREACH (const QNodeId &filterAnnotationId, techniqueFilter->filters()) {
+ foundMatch = false;
+ Annotation *filterAnnotation = renderer->criterionManager()->lookupResource(filterAnnotationId);
+
+ Q_FOREACH (const QNodeId &techniqueAnnotationId, technique->annotations()) {
+ Annotation *techniqueAnnotation = renderer->criterionManager()->lookupResource(techniqueAnnotationId);
+ if ((foundMatch = (*techniqueAnnotation == *filterAnnotation)))
+ break;
+ }
+
+ if (!foundMatch) {
+ // No match for TechniqueFilter criterion in any of the technique's criteria.
+ // So no way this can match. Don't bother checking the rest of the criteria.
+ break;
+ }
+ }
+
+ if (foundMatch)
+ return technique; // All criteria matched - we have a winner!
+ }
+ }
+
+ // We failed to find a suitable technique to use :(
+ return Q_NULLPTR;
+}
+
+
+RenderRenderPassList findRenderPassesForTechnique(Renderer *renderer,
+ RenderView *renderView,
+ Technique *technique)
+{
+ Q_ASSERT(renderer);
+ Q_ASSERT(technique);
+
+ RenderRenderPassList passes;
+ Q_FOREACH (const QNodeId &passId, technique->renderPasses()) {
+ RenderPass *renderPass = renderer->renderPassManager()->lookupResource(passId);
+
+ if (renderPass) {
+ const RenderPassFilter *passFilter = renderView->renderPassFilter();
+ bool foundMatch = (!passFilter || passFilter->filters().size() == 0);
+
+ // A pass filter is present so we need to check for matching criteria
+ if (!foundMatch && renderPass->annotations().size() >= passFilter->filters().size()) {
+
+ // Iterate through the filter criteria and look for render passes with criteria that satisfy them
+ Q_FOREACH (const QNodeId &filterAnnotationId, passFilter->filters()) {
+ foundMatch = false;
+ Annotation *filterAnnotation = renderer->criterionManager()->lookupResource(filterAnnotationId);
+
+ Q_FOREACH (const QNodeId &passAnnotationId, renderPass->annotations()) {
+ Annotation *passAnnotation = renderer->criterionManager()->lookupResource(passAnnotationId);
+ if ((foundMatch = (*passAnnotation == *filterAnnotation)))
+ break;
+ }
+
+ if (!foundMatch) {
+ // No match for criterion in any of the render pass' criteria
+ break;
+ }
+ }
+ }
+
+ if (foundMatch) {
+ // Found a renderpass that satisfies our needs. Add it in order
+ passes << renderPass;
+ }
+ }
+ }
+
+ return passes;
+}
+
+
+ParameterInfoList::iterator findParamInfo(ParameterInfoList *params, const QString &name)
+{
+ ParameterInfoList::iterator it = std::lower_bound(params->begin(), params->end(), name);
+ if (it != params->end() && it->name != name)
+ return params->end();
+ return it;
+}
+
+void addParametersForIds(ParameterInfoList *params, ParameterManager *manager,
+ const QList<Qt3D::QNodeId> &parameterIds)
+{
+ Q_FOREACH (const QNodeId &paramId, parameterIds) {
+ Parameter *param = manager->lookupResource(paramId);
+ if (param != Q_NULLPTR) {
+ ParameterInfoList::iterator it = std::lower_bound(params->begin(), params->end(), param->name());
+ if (it == params->end() || it->name != param->name())
+ params->insert(it, ParameterInfo(param->name(), param->value()));
+ }
+ }
+}
+
+void parametersFromMaterialEffectTechnique(ParameterInfoList *infoList,
+ ParameterManager *manager,
+ Material *material,
+ Effect *effect,
+ Technique *technique)
+{
+ // The parameters are taken in the following priority order:
+ //
+ // 1) Material
+ // 2) Technique
+ // 3) Effect
+ //
+ // That way a user can override defaults in Effect's and Techniques on a
+ // object manner and a Technique can override global defaults from the Effect.
+ parametersFromParametersProvider(infoList, manager, material);
+ parametersFromParametersProvider(infoList, manager, technique);
+ parametersFromParametersProvider(infoList, manager, effect);
+}
+
+RenderStateSet *buildRenderStateSet(const QList<RenderState*> &states, QFrameAllocator *allocator)
+{
+ RenderStateSet *stateSet = allocator->allocate<RenderStateSet>();
+
+ Q_FOREACH (RenderState *renderState, states) {
+ stateSet->addState(renderState);
+ }
+
+ return stateSet;
+}
+
+namespace {
+
+const QString blockArray = QStringLiteral("[%1]");
+const int qNodeIdTypeId = qMetaTypeId<QNodeId>();
+
+}
+
+UniformBlockValueBuilder::UniformBlockValueBuilder()
+ : shaderDataManager(Q_NULLPTR)
+{
+}
+
+UniformBlockValueBuilder::~UniformBlockValueBuilder()
+{
+}
+
+void UniformBlockValueBuilder::buildActiveUniformNameValueMapHelper(const QString &blockName, const QString &qmlPropertyName, const QVariant &value)
+{
+ // In the end, values are either scalar or a scalar array
+ // Composed elements (structs, structs array) are simplified into simple scalars
+ if (value.userType() == QMetaType::QVariantList) { // Array
+ QVariantList list = value.value<QVariantList>();
+ if (list.at(0).userType() == qNodeIdTypeId) { // Array of struct qmlPropertyName[i].structMember
+ for (int i = 0; i < list.size(); ++i) {
+ if (list.at(i).userType() == qNodeIdTypeId) {
+ ShaderData *subShaderData = shaderDataManager->lookupResource(list.at(i).value<QNodeId>());
+ if (subShaderData)
+ buildActiveUniformNameValueMapStructHelper(subShaderData,
+ blockName + QStringLiteral(".") + qmlPropertyName + blockArray.arg(i),
+ QStringLiteral(""));
+ }
+ }
+ } else { // Array of scalar/vec qmlPropertyName[0]
+ QString varName = blockName + QStringLiteral(".") + qmlPropertyName + QStringLiteral("[0]");
+ if (uniforms.contains(varName)) {
+ qCDebug(Shaders) << "UBO array member " << varName << " set for update";
+ activeUniformNamesToValue.insert(varName, value);
+ }
+ }
+ } else if (value.userType() == qNodeIdTypeId) { // Struct qmlPropertyName.structMember
+ ShaderData *rSubShaderData = shaderDataManager->lookupResource(value.value<QNodeId>());
+ if (rSubShaderData)
+ buildActiveUniformNameValueMapStructHelper(rSubShaderData,
+ blockName,
+ qmlPropertyName);
+ } else { // Scalar / Vec
+ QString varName = blockName + QStringLiteral(".") + qmlPropertyName;
+ if (uniforms.contains(varName)) {
+ qCDebug(Shaders) << "UBO scalar member " << varName << " set for update";
+ activeUniformNamesToValue.insert(varName, value);
+ }
+ }
+}
+
+void UniformBlockValueBuilder::buildActiveUniformNameValueMapStructHelper(ShaderData *rShaderData, const QString &blockName, const QString &qmlPropertyName)
+{
+ const QHash<QString, QVariant> &properties = updatedPropertiesOnly ? rShaderData->updatedProperties() : rShaderData->properties();
+ QHash<QString, QVariant>::const_iterator it = properties.begin();
+ const QHash<QString, QVariant>::const_iterator end = properties.end();
+
+ while (it != end) {
+ QString prefix = qmlPropertyName.isEmpty() ? QStringLiteral("") : QStringLiteral(".");
+ buildActiveUniformNameValueMapHelper(blockName + prefix + qmlPropertyName,
+ it.key(),
+ it.value());
+ ++it;
+ }
+}
+
+} // namespace Render
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
diff --git a/src/render/jobs/renderviewjobutils_p.h b/src/render/jobs/renderviewjobutils_p.h
new file mode 100644
index 000000000..3e362b39c
--- /dev/null
+++ b/src/render/jobs/renderviewjobutils_p.h
@@ -0,0 +1,149 @@
+/****************************************************************************
+**
+** 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 QT3DRENDER_RENDERVIEWJOBUTILS_P_H
+#define QT3DRENDER_RENDERVIEWJOBUTILS_P_H
+
+#include <Qt3DRenderer/qt3drenderer_global.h>
+#include <Qt3DCore/qnodeid.h>
+#include <QtCore/qhash.h>
+#include <QtCore/qvariant.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3D {
+class QFrameAllocator;
+}
+
+namespace Qt3DRender {
+namespace Render {
+
+class FrameGraphNode;
+class ParameterManager;
+class Effect;
+class Entity;
+class Material;
+class RenderPass;
+class RenderStateSet;
+class Technique;
+class RenderView;
+class Renderer;
+class ShaderDataManager;
+struct ShaderUniform;
+class ShaderData;
+class RenderState;
+
+Q_AUTOTEST_EXPORT void setRenderViewConfigFromFrameGraphLeafNode(RenderView *rv,
+ const FrameGraphNode *fgLeaf);
+
+Q_AUTOTEST_EXPORT Technique *findTechniqueForEffect(Renderer *renderer,
+ RenderView *renderView,
+ Effect *effect);
+
+typedef QVarLengthArray<RenderPass*, 4> RenderRenderPassList;
+Q_AUTOTEST_EXPORT RenderRenderPassList findRenderPassesForTechnique(Renderer *renderer,
+ RenderView *renderView,
+ Technique *technique);
+
+struct ParameterInfo
+{
+ ParameterInfo(const QString &name = QString(), const QVariant &value = QVariant())
+ : name(name)
+ , value(value)
+ {}
+
+ QString name;
+ QVariant value;
+
+ bool operator<(const QString &otherName) const
+ {
+ return name < otherName;
+ }
+};
+
+typedef QVarLengthArray<ParameterInfo, 16> ParameterInfoList;
+
+Q_AUTOTEST_EXPORT void parametersFromMaterialEffectTechnique(ParameterInfoList *infoList,
+ ParameterManager *manager,
+ Material *material,
+ Effect *effect,
+ Technique *technique);
+
+Q_AUTOTEST_EXPORT void addParametersForIds(ParameterInfoList *params, ParameterManager *manager,
+ const QList<Qt3D::QNodeId> &parameterIds);
+
+template<class T>
+void parametersFromParametersProvider(ParameterInfoList *infoList,
+ ParameterManager *manager,
+ T *pass)
+{
+ if (pass)
+ addParametersForIds(infoList, manager, pass->parameters());
+}
+
+Q_AUTOTEST_EXPORT ParameterInfoList::iterator findParamInfo(ParameterInfoList *infoList,
+ const QString &name);
+
+Q_AUTOTEST_EXPORT RenderStateSet *buildRenderStateSet(const QList<RenderState*> &states,
+ Qt3D::QFrameAllocator *allocator);
+
+
+struct Q_AUTOTEST_EXPORT UniformBlockValueBuilder
+{
+ UniformBlockValueBuilder();
+ ~UniformBlockValueBuilder();
+
+ void buildActiveUniformNameValueMapHelper(const QString &blockName,
+ const QString &qmlPropertyName,
+ const QVariant &value);
+ void buildActiveUniformNameValueMapStructHelper(ShaderData *rShaderData,
+ const QString &blockName,
+ const QString &qmlPropertyName = QString());
+
+ bool updatedPropertiesOnly;
+ QHash<QString, ShaderUniform> uniforms;
+ QHash<QString, QVariant> activeUniformNamesToValue;
+ ShaderDataManager *shaderDataManager;
+};
+
+} // namespace Render
+} // namespace Qt3DRender
+
+Q_DECLARE_TYPEINFO(Qt3DRender::Render::ParameterInfo, Q_MOVABLE_TYPE);
+
+QT_END_NAMESPACE
+
+#endif // QT3DRENDER_RENDERVIEWJOBUTILS_P_H
diff --git a/src/render/jobs/updateboundingvolumejob.cpp b/src/render/jobs/updateboundingvolumejob.cpp
new file mode 100644
index 000000000..3c8f47262
--- /dev/null
+++ b/src/render/jobs/updateboundingvolumejob.cpp
@@ -0,0 +1,116 @@
+/****************************************************************************
+**
+** 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 "updateboundingvolumejob_p.h"
+
+#include <Qt3DRenderer/private/renderer_p.h>
+#include <Qt3DRenderer/private/entity_p.h>
+#include <Qt3DRenderer/private/renderlogging_p.h>
+#include <sphere.h>
+
+#include <QElapsedTimer>
+#include <QStack>
+#include <QThread>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+namespace Render {
+
+namespace {
+
+void expandWorldBoundingVolume(Qt3DRender::Render::Entity *node)
+{
+ Qt3DRender::Render::Entity *currentNode = node;
+ QStack<int> childIndexStack;
+ forever {
+
+ // Find left most leaf node of currentNode
+ while (!currentNode && !currentNode->children().isEmpty()) {
+ childIndexStack.push(1);
+ currentNode = currentNode->children().first();
+ }
+
+ if (!currentNode || !currentNode->parent())
+ return;
+
+ // Initialize parent bounding volume to be equal to that of the first child
+ Qt3DRender::Render::Entity *parentNode = currentNode->parent();
+ Qt3DRender::Sphere *parentBoundingVolume = parentNode->worldBoundingVolume();
+ *(parentBoundingVolume) = *(currentNode->worldBoundingVolume());
+
+ // Expand the parent bounding volume by each of remaining the siblings
+ QVector<Entity *> siblings = parentNode->children();
+ const int siblingCount = siblings.count();
+ for (int i = 1; i < siblingCount; ++i) {
+ Qt3DRender::Sphere *siblingBoundingVolume = siblings.at(i)->worldBoundingVolume();
+ parentBoundingVolume->expandToContain(*siblingBoundingVolume);
+ }
+
+ // Move to parent's next sibling
+ childIndexStack.pop();
+ currentNode = Q_NULLPTR;
+ if (!childIndexStack.empty() && parentNode->parent()) {
+ const int nextSiblingIndex = childIndexStack.top()++;
+ QVector<Entity *> parentSiblings = parentNode->parent()->children();
+ if (nextSiblingIndex < parentSiblings.size())
+ currentNode = parentSiblings.at(nextSiblingIndex);
+ }
+ }
+}
+
+}
+
+UpdateBoundingVolumeJob::UpdateBoundingVolumeJob(Entity *node)
+ : m_node(node)
+{
+}
+
+void UpdateBoundingVolumeJob::run()
+{
+ // Expand the bounding volumes of each node that has children by the
+ // bounding volumes of the children
+
+ // TODO: Implement this using a parallel_for
+ qCDebug(Jobs) << "Entering" << Q_FUNC_INFO << QThread::currentThread();
+ expandWorldBoundingVolume(m_node);
+ qCDebug(Jobs) << "Exiting" << Q_FUNC_INFO << QThread::currentThread();
+}
+
+} // namespace Render
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
diff --git a/src/render/jobs/updateboundingvolumejob_p.h b/src/render/jobs/updateboundingvolumejob_p.h
new file mode 100644
index 000000000..a26a1906b
--- /dev/null
+++ b/src/render/jobs/updateboundingvolumejob_p.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** 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 QT3DRENDER_RENDER_UPDATEBOUNDINGVOLUMEJOB_H
+#define QT3DRENDER_RENDER_UPDATEBOUNDINGVOLUMEJOB_H
+
+#include <Qt3DCore/qaspectjob.h>
+
+#include <QSharedPointer>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+namespace Render {
+
+class Entity;
+
+class UpdateBoundingVolumeJob : public Qt3D::QAspectJob
+{
+public:
+ explicit UpdateBoundingVolumeJob(Entity *m_node);
+
+protected:
+ void run() Q_DECL_OVERRIDE;
+
+private:
+ Entity *m_node;
+};
+
+typedef QSharedPointer<UpdateBoundingVolumeJob> UpdateBoundingVolumeJobPtr;
+
+} // namespace Render
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
+
+#endif // QT3DRENDER_RENDER_UPDATEBOUNDINGVOLUMEJOB_H
diff --git a/src/render/jobs/updateworldtransformjob.cpp b/src/render/jobs/updateworldtransformjob.cpp
new file mode 100644
index 000000000..20c58511c
--- /dev/null
+++ b/src/render/jobs/updateworldtransformjob.cpp
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** 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 "updateworldtransformjob_p.h"
+
+#include <Qt3DRenderer/private/renderer_p.h>
+#include <Qt3DRenderer/private/entity_p.h>
+#include <sphere.h>
+#include <Qt3DRenderer/private/transform_p.h>
+#include <Qt3DRenderer/private/renderlogging_p.h>
+#include <QThread>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+namespace Render {
+
+namespace {
+
+void updateWorldTransformAndBounds(Qt3DRender::Render::Entity *node, const QMatrix4x4 &parentTransform)
+{
+ QMatrix4x4 worldTransform(parentTransform);
+ Transform *nodeTransform = node->renderComponent<Transform>();
+ if (nodeTransform != Q_NULLPTR && nodeTransform->isEnabled())
+ worldTransform = worldTransform * nodeTransform->transformMatrix();
+
+ *(node->worldTransform()) = worldTransform;
+ *(node->worldBoundingVolume()) = node->localBoundingVolume()->transformed(worldTransform);
+
+ Q_FOREACH (Qt3DRender::Render::Entity *child, node->children())
+ updateWorldTransformAndBounds(child, worldTransform);
+}
+
+}
+
+UpdateWorldTransformJob::UpdateWorldTransformJob(Entity *node)
+ : Qt3D::QAspectJob()
+ , m_node(node)
+{
+}
+
+void UpdateWorldTransformJob::run()
+{
+ // Iterate over each level of hierarchy in our scene
+ // and update each node's world transform from its
+ // local transform and its parent's world transform
+
+ // TODO: Parallelise this on each level using a parallel_for
+ // implementation.
+
+ qCDebug(Jobs) << "Entering" << Q_FUNC_INFO << QThread::currentThread();
+
+ QMatrix4x4 parentTransform;
+ Entity *parent = m_node->parent();
+ if (parent != Q_NULLPTR)
+ parentTransform = *(parent->worldTransform());
+ updateWorldTransformAndBounds(m_node, parentTransform);
+
+ qCDebug(Jobs) << "Exiting" << Q_FUNC_INFO << QThread::currentThread();
+}
+
+} // namespace Render
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
diff --git a/src/render/jobs/updateworldtransformjob_p.h b/src/render/jobs/updateworldtransformjob_p.h
new file mode 100644
index 000000000..81559cf42
--- /dev/null
+++ b/src/render/jobs/updateworldtransformjob_p.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** 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 QT3DRENDER_RENDER_UPDATEWORLDTRANSFORMJOB_H
+#define QT3DRENDER_RENDER_UPDATEWORLDTRANSFORMJOB_H
+
+#include <Qt3DCore/qaspectjob.h>
+
+#include <QSharedPointer>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+namespace Render {
+
+class Entity;
+
+class UpdateWorldTransformJob : public Qt3D::QAspectJob
+{
+public:
+ explicit UpdateWorldTransformJob(Entity *node);
+
+protected:
+ void run() Q_DECL_OVERRIDE;
+
+private:
+ Entity *m_node;
+};
+
+typedef QSharedPointer<UpdateWorldTransformJob> UpdateWorldTransformJobPtr;
+
+} // namespace Render
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
+
+#endif // QT3DRENDER_RENDER_UPDATEWORLDTRANSFORMJOB_H