summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean Harmer <sean.harmer@kdab.com>2016-01-15 20:02:27 +0000
committerSean Harmer <sean.harmer@kdab.com>2016-01-15 20:02:27 +0000
commit6dac744d17dca5664a308a21e8dba3765cf8a8a3 (patch)
treedae1aa28424b82e8e8172f54313af376385ac0ff
parent78ad6123fb4f8597eb936e2c4b1636d307df4ecc (diff)
parent8b820e8f93c851c08941a4eead519588d2135c3d (diff)
Merge branch '5.6' into dev
Conflicts: examples/qt3d/qgltf/main.qml Change-Id: I03d4cc679a7812fb114461609e481d43a0bc5390
-rw-r--r--config.tests/assimp/assimp.pro6
-rw-r--r--examples/qt3d/qgltf/Scene.qml (renamed from examples/qt3d/qgltf/Wine.qml)45
-rw-r--r--examples/qt3d/qgltf/main.qml19
-rw-r--r--examples/qt3d/qgltf/qgltf.pro9
-rw-r--r--examples/qt3d/qgltf/qgltf_example.qrc2
-rw-r--r--src/3rdparty/assimp/assimp_dependency.pri11
-rw-r--r--src/core/resources/qresourcemanager.cpp18
-rw-r--r--src/core/resources/qresourcemanager_p.h56
-rw-r--r--src/input/backend/qabstractphysicaldevicebackendnode.h2
-rw-r--r--src/input/frontend/qabstractphysicaldevice.h4
-rw-r--r--src/input/frontend/qkeyboardcontroller.cpp4
-rw-r--r--src/input/frontend/qkeyboardcontroller.h4
-rw-r--r--src/input/frontend/qmousecontroller.cpp4
-rw-r--r--src/input/frontend/qmousecontroller.h4
-rw-r--r--src/plugins/sceneparsers/assimp/assimp.pro11
-rw-r--r--src/plugins/sceneparsers/sceneparsers.pro2
-rw-r--r--src/quick3d/imports/scene3d/scene3ditem.cpp65
-rw-r--r--src/quick3d/imports/scene3d/scene3ditem_p.h1
-rw-r--r--tests/auto/core/core.pro1
-rw-r--r--tests/auto/core/listresourcesmanager/listresourcesmanager.pro7
-rw-r--r--tests/auto/core/listresourcesmanager/tst_listresourcesmanager.cpp434
-rw-r--r--tests/auto/input/commons/testdevice.h4
-rw-r--r--tools/qgltf/qgltf.cpp12
-rw-r--r--tools/qgltf/qgltf.pro19
24 files changed, 115 insertions, 629 deletions
diff --git a/config.tests/assimp/assimp.pro b/config.tests/assimp/assimp.pro
index 5f022ced4..920c451c4 100644
--- a/config.tests/assimp/assimp.pro
+++ b/config.tests/assimp/assimp.pro
@@ -1,8 +1,8 @@
SOURCES += main.cpp
-LIBS += -lassimp
-
-unix {
+unix:!contains(QT_CONFIG, no-pkg-config) {
CONFIG += link_pkgconfig
PKGCONFIG += assimp
+} else {
+ LIBS += -lassimp
}
diff --git a/examples/qt3d/qgltf/Wine.qml b/examples/qt3d/qgltf/Scene.qml
index b24e9de3f..e6d0e7dd8 100644
--- a/examples/qt3d/qgltf/Wine.qml
+++ b/examples/qt3d/qgltf/Scene.qml
@@ -40,21 +40,34 @@ import Qt3D.Render 2.0
Entity {
id: root
- property vector3d position: Qt.vector3d(0, 0, 0)
- property real angleX: 0
- property real angleY: 0
- property real angleZ: 0
- property real scale: 1
+ Entity {
+ components: [
+ Transform {
+ translation: Qt.vector3d(-30, 0, 0)
+ rotation: fromEulerAngles(-90, 180, 0)
+ },
+ SceneLoader {
+ source: "qrc:/models/test_scene.qgltf"
+ }
+ ]
+ }
- components: [
- Transform {
- translation: root.position
- rotation: fromEulerAngles(root.angleX, root.angleY, root.angleZ)
- scale: root.scale
- },
- SceneLoader
- {
- source: "qrc:/models/wine.qgltf"
- }
- ]
+ Entity {
+ components: [
+ SceneLoader {
+ source: "qrc:/models/toyplane.qgltf"
+ }
+ ]
+ }
+
+ Entity {
+ components: [
+ Transform {
+ translation: Qt.vector3d(0, -20, 0)
+ },
+ SceneLoader {
+ source: "qrc:/models/trefoil.qgltf"
+ }
+ ]
+ }
}
diff --git a/examples/qt3d/qgltf/main.qml b/examples/qt3d/qgltf/main.qml
index f1b9403c0..99e1bb930 100644
--- a/examples/qt3d/qgltf/main.qml
+++ b/examples/qt3d/qgltf/main.qml
@@ -58,23 +58,12 @@ Entity {
}
components: FrameGraph {
- activeFrameGraph : Viewport {
- CameraSelector {
- camera: camera
- ClearBuffer {
- buffers: ClearBuffer.ColorDepthBuffer
- SortMethod {
- criteria: [
- SortCriterion { sort: SortCriterion.BackToFront }
- ]
- }
- }
- }
+ activeFrameGraph: ForwardRenderer {
+ clearColor: Qt.rgba(0, 0.5, 1, 1)
+ camera: camera
}
}
- Wine {
- id: wineRack
- position: Qt.vector3d(-60.0, 0.0, 0.0)
+ Scene {
}
}
diff --git a/examples/qt3d/qgltf/qgltf.pro b/examples/qt3d/qgltf/qgltf.pro
index 3ba543ec5..61361b0e6 100644
--- a/examples/qt3d/qgltf/qgltf.pro
+++ b/examples/qt3d/qgltf/qgltf.pro
@@ -11,10 +11,13 @@ SOURCES += \
OTHER_FILES += \
main.qml \
- Wine.qml
+ Scene.qml
-QT3D_MODELS = ../exampleresources/assets/gltf/wine/wine.dae
-QGLTF_PARAMS = -g
+QT3D_MODELS = ../exampleresources/assets/test_scene.dae \
+ ../exampleresources/assets/obj/toyplane.obj \
+ ../exampleresources/assets/obj/trefoil.obj
+
+QGLTF_PARAMS = -b -S
load(qgltf)
RESOURCES += \
diff --git a/examples/qt3d/qgltf/qgltf_example.qrc b/examples/qt3d/qgltf/qgltf_example.qrc
index 0da7ea21f..72868031a 100644
--- a/examples/qt3d/qgltf/qgltf_example.qrc
+++ b/examples/qt3d/qgltf/qgltf_example.qrc
@@ -1,6 +1,6 @@
<RCC>
<qresource prefix="/">
<file>main.qml</file>
- <file>Wine.qml</file>
+ <file>Scene.qml</file>
</qresource>
</RCC>
diff --git a/src/3rdparty/assimp/assimp_dependency.pri b/src/3rdparty/assimp/assimp_dependency.pri
new file mode 100644
index 000000000..4fe0df54e
--- /dev/null
+++ b/src/3rdparty/assimp/assimp_dependency.pri
@@ -0,0 +1,11 @@
+config_assimp:!if(cross_compile:host_build) {
+ unix:!contains(QT_CONFIG, no-pkg-config) {
+ CONFIG += link_pkgconfig
+ PKGCONFIG_PRIVATE += assimp
+ } else {
+ LIBS += -lassimp
+ }
+ return()
+} else {
+ include(assimp.pri)
+}
diff --git a/src/core/resources/qresourcemanager.cpp b/src/core/resources/qresourcemanager.cpp
index 5ece6a03f..8af1d5d5d 100644
--- a/src/core/resources/qresourcemanager.cpp
+++ b/src/core/resources/qresourcemanager.cpp
@@ -65,24 +65,6 @@
released
\sa QResourceManager
- \sa ListAllocatingPolicy
-*/
-
-/*!
- \class Qt3DCore::ListAllocatingPolicy
- \inmodule Qt3DCore
- \since 5.5
-
- \brief Allocates resources in a list.
-
- It is best to use it when you don't need to iterate over an entire set of resources, in which
- case ArrayAllocatingPolicy is faster. It can store a non predefined amount of resources, though
- there might not be enough handles at some point, depending on the INDEXBITS used.
- It's main use case is to manage resources that are accessed in an independent manner from other
- resources of the same type.
-
- \sa QResourceManager
- \sa ArrayAllocatingPolicy
*/
/*!
diff --git a/src/core/resources/qresourcemanager_p.h b/src/core/resources/qresourcemanager_p.h
index 5f094881d..47f067409 100644
--- a/src/core/resources/qresourcemanager_p.h
+++ b/src/core/resources/qresourcemanager_p.h
@@ -286,62 +286,6 @@ private:
};
-template <typename T, uint INDEXBITS>
-class ListAllocatingPolicy
-{
-public:
- ListAllocatingPolicy()
- {
- }
-
- T* allocateResource()
- {
- int idx;
- T *newT;
- if (!m_freeEntries.isEmpty()) {
- idx = m_freeEntries.takeFirst();
- m_resourcesEntries[idx] = T();
- newT = &m_resourcesEntries[idx];
- }
- else {
- m_resourcesEntries.append(T());
- idx = m_resourcesEntries.size() - 1;
- newT = &m_resourcesEntries.last();
- }
- // If elements are added to the list, we're not sure the address
- // that was returned here for previous elements stays valid
- m_resourcesToIndices[newT] = idx;
- return newT;
- }
-
- void releaseResource(T *r)
- {
- if (m_resourcesToIndices.contains(r)) {
- performCleanup(r, Int2Type<QResourceInfo<T>::needsCleanup>());
- m_freeEntries.append(m_resourcesToIndices.take(r));
- }
- }
-
- void reset()
- {
- m_resourcesEntries.clear();
- m_resourcesToIndices.clear();
- }
-
-private:
- QList<T> m_resourcesEntries;
- QHash<T*, int> m_resourcesToIndices;
- QList<int> m_freeEntries;
-
- void performCleanup(T *r, Int2Type<true>)
- {
- r->cleanup();
- }
-
- void performCleanup(T *, Int2Type<false>)
- {}
-};
-
template <typename T, typename C, uint INDEXBITS = 16,
template <typename, uint> class AllocatingPolicy = ArrayAllocatingPolicy,
template <class> class LockingPolicy = NonLockingPolicy
diff --git a/src/input/backend/qabstractphysicaldevicebackendnode.h b/src/input/backend/qabstractphysicaldevicebackendnode.h
index 1d7ef21bd..3846d1a1e 100644
--- a/src/input/backend/qabstractphysicaldevicebackendnode.h
+++ b/src/input/backend/qabstractphysicaldevicebackendnode.h
@@ -56,7 +56,7 @@ class QT3DINPUTSHARED_EXPORT QAbstractPhysicalDeviceBackendNode : public Qt3DCor
public:
explicit QAbstractPhysicalDeviceBackendNode(QBackendNode::Mode mode);
void updateFromPeer(Qt3DCore::QNode *peer) Q_DECL_OVERRIDE;
- void cleanup();
+ virtual void cleanup();
void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) Q_DECL_OVERRIDE;
void setInputAspect(QInputAspect *aspect);
diff --git a/src/input/frontend/qabstractphysicaldevice.h b/src/input/frontend/qabstractphysicaldevice.h
index 915042edc..8056a195b 100644
--- a/src/input/frontend/qabstractphysicaldevice.h
+++ b/src/input/frontend/qabstractphysicaldevice.h
@@ -62,8 +62,8 @@ public:
virtual QStringList axisNames() const = 0;
virtual QStringList buttonNames() const = 0;
- virtual int axisIdentifier(const QString &name) = 0;
- virtual int buttonIdentifier(const QString &name) = 0;
+ virtual int axisIdentifier(const QString &name) const = 0;
+ virtual int buttonIdentifier(const QString &name) const = 0;
void addAxisSetting(QAxisSetting *axisSetting);
void removeAxisSetting(QAxisSetting *axisSetting);
diff --git a/src/input/frontend/qkeyboardcontroller.cpp b/src/input/frontend/qkeyboardcontroller.cpp
index 77b54c7fa..09ff52066 100644
--- a/src/input/frontend/qkeyboardcontroller.cpp
+++ b/src/input/frontend/qkeyboardcontroller.cpp
@@ -258,13 +258,13 @@ QStringList QKeyboardController::buttonNames() const
return d->m_keyNames;
}
-int QKeyboardController::axisIdentifier(const QString &name)
+int QKeyboardController::axisIdentifier(const QString &name) const
{
Q_UNUSED(name);
return 0;
}
-int QKeyboardController::buttonIdentifier(const QString &name)
+int QKeyboardController::buttonIdentifier(const QString &name) const
{
Q_D(const QKeyboardController);
return d->m_keyMap.value(name, 0);
diff --git a/src/input/frontend/qkeyboardcontroller.h b/src/input/frontend/qkeyboardcontroller.h
index aafbd3e57..e929629d9 100644
--- a/src/input/frontend/qkeyboardcontroller.h
+++ b/src/input/frontend/qkeyboardcontroller.h
@@ -62,8 +62,8 @@ public:
int buttonCount() const Q_DECL_FINAL;
QStringList axisNames() const Q_DECL_FINAL;
QStringList buttonNames() const Q_DECL_FINAL;
- int axisIdentifier(const QString &name) Q_DECL_FINAL;
- int buttonIdentifier(const QString &name) Q_DECL_FINAL;
+ int axisIdentifier(const QString &name) const Q_DECL_FINAL;
+ int buttonIdentifier(const QString &name) const Q_DECL_FINAL;
protected:
QKeyboardController(QKeyboardControllerPrivate &dd, QNode *parent = 0);
diff --git a/src/input/frontend/qmousecontroller.cpp b/src/input/frontend/qmousecontroller.cpp
index a8e3cbc61..30b200629 100644
--- a/src/input/frontend/qmousecontroller.cpp
+++ b/src/input/frontend/qmousecontroller.cpp
@@ -107,7 +107,7 @@ QStringList QMouseController::buttonNames() const
<< QStringLiteral("Center");
}
-int QMouseController::axisIdentifier(const QString &name)
+int QMouseController::axisIdentifier(const QString &name) const
{
if (name == QStringLiteral("X"))
return X;
@@ -116,7 +116,7 @@ int QMouseController::axisIdentifier(const QString &name)
return -1;
}
-int QMouseController::buttonIdentifier(const QString &name)
+int QMouseController::buttonIdentifier(const QString &name) const
{
if (name == QStringLiteral("Left"))
return Left;
diff --git a/src/input/frontend/qmousecontroller.h b/src/input/frontend/qmousecontroller.h
index 8a03d7e14..3773c652c 100644
--- a/src/input/frontend/qmousecontroller.h
+++ b/src/input/frontend/qmousecontroller.h
@@ -72,8 +72,8 @@ public:
int buttonCount() const Q_DECL_FINAL;
QStringList axisNames() const Q_DECL_FINAL;
QStringList buttonNames() const Q_DECL_FINAL;
- int axisIdentifier(const QString &name) Q_DECL_FINAL;
- int buttonIdentifier(const QString &name) Q_DECL_FINAL;
+ int axisIdentifier(const QString &name) const Q_DECL_FINAL;
+ int buttonIdentifier(const QString &name) const Q_DECL_FINAL;
float sensitivity() const;
diff --git a/src/plugins/sceneparsers/assimp/assimp.pro b/src/plugins/sceneparsers/assimp/assimp.pro
index 215941071..3660b1f6d 100644
--- a/src/plugins/sceneparsers/assimp/assimp.pro
+++ b/src/plugins/sceneparsers/assimp/assimp.pro
@@ -5,16 +5,7 @@ PLUGIN_TYPE = sceneparsers
PLUGIN_CLASS_NAME = AssimpParserPlugin
load(qt_plugin)
-config_assimp {
- LIBS += -lassimp
-
- unix {
- CONFIG += link_pkgconfig
- PKGCONFIG_PRIVATE += assimp
- }
-} else {
- include(../../../3rdparty/assimp/assimp.pri)
-}
+include(../../../3rdparty/assimp/assimp_dependency.pri)
HEADERS += \
assimphelpers.h \
diff --git a/src/plugins/sceneparsers/sceneparsers.pro b/src/plugins/sceneparsers/sceneparsers.pro
index 9271659db..ccb7a96aa 100644
--- a/src/plugins/sceneparsers/sceneparsers.pro
+++ b/src/plugins/sceneparsers/sceneparsers.pro
@@ -1,3 +1,5 @@
TEMPLATE = subdirs
+# QNX is not supported, and Linux GCC 4.9 on ARM chokes on the assimp
+# sources (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66964).
config_assimp|!cross_compile: SUBDIRS += assimp
SUBDIRS += gltf
diff --git a/src/quick3d/imports/scene3d/scene3ditem.cpp b/src/quick3d/imports/scene3d/scene3ditem.cpp
index 2e55c52ee..ef839ae87 100644
--- a/src/quick3d/imports/scene3d/scene3ditem.cpp
+++ b/src/quick3d/imports/scene3d/scene3ditem.cpp
@@ -96,8 +96,9 @@ class Scene3DSGNode;
\li The window is closed
- \li Scene3DItem is notified via itemChange() and calls shutdown() on Scene3DRenderer,
- which performs the necessary cleanups in the QSGRenderThread (destroys DebugLogger ...).
+ \li This triggers the windowsChanged signal which the Scene3DRenderer
+ uses to perform the necessary cleanups in the QSGRenderThread (destroys
+ DebugLogger ...) with the shutdown slot (queued connection).
\li The destroyed signal of the window is also connected to the
Scene3DRenderer. When triggered in the context of the main thread, the
@@ -162,6 +163,7 @@ public:
Q_CHECK_PTR(m_item->window());
QObject::connect(m_item->window(), &QQuickWindow::beforeRendering, this, &Scene3DRenderer::render, Qt::DirectConnection);
+ QObject::connect(m_item, &QQuickItem::windowChanged, this, &Scene3DRenderer::onWindowChangedQueued, Qt::QueuedConnection);
ContextSaver saver;
@@ -213,12 +215,37 @@ public:
void synchronize();
- // Executed in the QtQuick render thread.
- void shutdown();
-
public Q_SLOTS:
void render();
+ // Executed in the QtQuick render thread.
+ void shutdown()
+ {
+ qCDebug(Scene3D) << Q_FUNC_INFO << QThread::currentThread();
+
+ // Set to null so that subsequent calls to render
+ // would return early
+ m_item = Q_NULLPTR;
+
+ // Shutdown the Renderer Aspect while the OpenGL context
+ // is still valid
+ if (m_renderAspect)
+ m_renderAspect->renderShutdown();
+ }
+
+ // SGThread
+ void onWindowChangedQueued(QQuickWindow *w)
+ {
+ if (w == Q_NULLPTR) {
+ qCDebug(Scene3D) << Q_FUNC_INFO << QThread::currentThread();
+ shutdown();
+ // Will only trigger something with the Loader case
+ // The window closed cases is handled by the window's destroyed
+ // signal
+ QMetaObject::invokeMethod(m_cleaner, "cleanup");
+ }
+ }
+
private:
Scene3DItem *m_item; // Will be released by the QQuickWindow/QML Engine
Qt3DCore::QAspectEngine *m_aspectEngine; // Will be released by the Scene3DRendererCleaner
@@ -538,15 +565,6 @@ void Scene3DItem::setMultisample(bool enable)
}
}
-void Scene3DItem::itemChange(ItemChange change, const ItemChangeData& value)
-{
- // Are we being removed from the scene?
- if (change == QQuickItem::ItemSceneChange && value.window == Q_NULLPTR)
- m_renderer->shutdown();
-
- QQuickItem::itemChange(change, value);
-}
-
QSGNode *Scene3DItem::updatePaintNode(QSGNode *node, QQuickItem::UpdatePaintNodeData *)
{
// If the node already exists
@@ -576,25 +594,6 @@ void Scene3DRenderer::synchronize()
m_multisample = m_item->multisample();
}
-void Scene3DRenderer::shutdown()
-{
- qCDebug(Scene3D) << Q_FUNC_INFO << QThread::currentThread();
-
- // Set to null so that subsequent calls to render
- // would return early
- m_item = Q_NULLPTR;
-
- // Shutdown the Renderer Aspect while the OpenGL context
- // is still valid
- if (m_renderAspect)
- m_renderAspect->renderShutdown();
-
- // Will only trigger something with the Loader case
- // The window closed cases is handled by the window's destroyed
- // signal
- QMetaObject::invokeMethod(m_cleaner, "cleanup");
-}
-
void Scene3DRenderer::setSGNode(Scene3DSGNode *node) Q_DECL_NOEXCEPT
{
m_node = node;
diff --git a/src/quick3d/imports/scene3d/scene3ditem_p.h b/src/quick3d/imports/scene3d/scene3ditem_p.h
index 1b9335203..edb0b7b00 100644
--- a/src/quick3d/imports/scene3d/scene3ditem_p.h
+++ b/src/quick3d/imports/scene3d/scene3ditem_p.h
@@ -93,7 +93,6 @@ private Q_SLOTS:
void applyRootEntityChange();
private:
- void itemChange(ItemChange change, const ItemChangeData& value);
QSGNode *updatePaintNode(QSGNode *node, UpdatePaintNodeData *nodeData) Q_DECL_OVERRIDE;
QStringList m_aspects;
diff --git a/tests/auto/core/core.pro b/tests/auto/core/core.pro
index d33b97edc..e76a7d856 100644
--- a/tests/auto/core/core.pro
+++ b/tests/auto/core/core.pro
@@ -4,7 +4,6 @@ SUBDIRS = \
handle \
handlemanager \
arrayresourcesmanager \
- listresourcesmanager \
qcircularbuffer \
qboundedcircularbuffer \
nodes \
diff --git a/tests/auto/core/listresourcesmanager/listresourcesmanager.pro b/tests/auto/core/listresourcesmanager/listresourcesmanager.pro
deleted file mode 100644
index ab1ea78db..000000000
--- a/tests/auto/core/listresourcesmanager/listresourcesmanager.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-TARGET = tst_listresourcesmanager
-CONFIG += testcase
-TEMPLATE = app
-
-SOURCES += tst_listresourcesmanager.cpp
-
-QT += testlib 3dcore 3dcore-private
diff --git a/tests/auto/core/listresourcesmanager/tst_listresourcesmanager.cpp b/tests/auto/core/listresourcesmanager/tst_listresourcesmanager.cpp
deleted file mode 100644
index 5cbbe97bd..000000000
--- a/tests/auto/core/listresourcesmanager/tst_listresourcesmanager.cpp
+++ /dev/null
@@ -1,434 +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 <QtTest/QtTest>
-#include <QList>
-#include <Qt3DCore/private/qhandle_p.h>
-#include <Qt3DCore/private/qresourcemanager_p.h>
-
-class tst_ListResourcesManager : public QObject
-{
- Q_OBJECT
-public:
- tst_ListResourcesManager() {}
- ~tst_ListResourcesManager() {}
-
-private slots:
- void createResourcesManager();
- void acquireResources();
- void getResources();
- void registerResourcesResize();
- void removeResource();
- void resetResource();
- void lookupResource();
- void releaseResource();
- void heavyDutyMultiThreadedAccess();
- void heavyDutyMultiThreadedAccessRelease();
- void maximumNumberOfResources();
-};
-
-class tst_ListResource
-{
-public:
- tst_ListResource() : m_value(0)
- {}
-
- QAtomicInt m_value;
-};
-
-typedef Qt3DCore::QHandle<tst_ListResource> tHandle;
-typedef Qt3DCore::QHandle<tst_ListResource, 4> tHandle4;
-typedef Qt3DCore::QHandle<tst_ListResource, 8> tHandle8;
-typedef Qt3DCore::QHandle<tst_ListResource, 16> tHandle16;
-
-void tst_ListResourcesManager::createResourcesManager()
-{
- Qt3DCore::QResourceManager<tst_ListResource, int, 16, Qt3DCore::ListAllocatingPolicy> manager16;
- Qt3DCore::QResourceManager<tst_ListResource, int, 4, Qt3DCore::ListAllocatingPolicy> manager4;
- Qt3DCore::QResourceManager<tst_ListResource, int, 8, Qt3DCore::ListAllocatingPolicy> manager8;
-
- QVERIFY(manager16.maxResourcesEntries() == 65535);
- QVERIFY(manager8.maxResourcesEntries() == 255);
- QVERIFY(manager4.maxResourcesEntries() == 15);
-}
-
-/*!
- * Check that the handles returned when a registering resources
- * have a correct index and counter.
- */
-void tst_ListResourcesManager::acquireResources()
-{
- Qt3DCore::QResourceManager<tst_ListResource, int, 4, Qt3DCore::ListAllocatingPolicy> manager;
-
- QList<tHandle4> handles;
-
- for (int i = 0; i < 5; i++) {
- handles << manager.acquire();
- }
-
- for (uint i = 0; i < 5; i++) {
- QVERIFY(handles.at(i).index() == i);
- QVERIFY(handles.at(i).counter() == 1);
- }
-}
-
-/*!
- * Test that values can be properly retrieved.
- */
-void tst_ListResourcesManager::getResources()
-{
-
- Qt3DCore::QResourceManager<tst_ListResource, int, 8, Qt3DCore::ListAllocatingPolicy> manager;
- QList<tst_ListResource *> resources;
- QList<tHandle8> handles;
-
- for (int i = 0; i < 5; i++) {
- handles << manager.acquire();
- }
-
- for (uint i = 0; i < 5; i++) {
- QVERIFY(handles.at(i).index() == i);
- QVERIFY(handles.at(i).counter() == 1);
- resources << manager.data(handles.at(i));
- QVERIFY(resources.at(i) != Q_NULLPTR);
- resources.at(i)->m_value = i;
- }
-
- for (int i = 0; i < 5; i++)
- QVERIFY(manager.data(handles.at(i))->m_value == i);
-
- // Check that an invalid resource returns NULL
- tHandle8 iHandle;
- QVERIFY(manager.data(iHandle) == Q_NULLPTR);
-
-}
-
-/*!
- * Test that when a resize of the data vectors in the manager occurs,
- * everything behaves correctly.
- */
-void tst_ListResourcesManager::registerResourcesResize()
-{
- Qt3DCore::QResourceManager<tst_ListResource, int, 16, Qt3DCore::ListAllocatingPolicy> manager;
- QList<tHandle16> handles;
-
- for (uint i = 0; i < 2; i++) {
- handles << manager.acquire();
- manager.data(handles.at(i))->m_value = i + 2;
- }
-
- for (uint i = 0; i < 5; i++) {
- handles << manager.acquire();
- manager.data(handles.at(i + 2))->m_value = i + 2 + 5;
- }
-
- for (int i = 0; i < 7; i++) {
- QVERIFY(handles.at(i).index() == static_cast<uint>(i));
- QVERIFY(handles.at(i).counter() == 1);
- if (i < 2)
- QVERIFY(manager.data(handles.at(i))->m_value == i + 2);
- else
- QVERIFY(manager.data(handles.at(i))->m_value == i + 5);
- }
-}
-
-/*!
- * Checks for the removal of resources.
- */
-void tst_ListResourcesManager::removeResource()
-{
- Qt3DCore::QResourceManager<tst_ListResource, int, 16, Qt3DCore::ListAllocatingPolicy> manager;
-
- QList<tst_ListResource *> resources;
- QList<tHandle> handles;
-
- for (int i = 0; i < 32; i++) {
- handles << manager.acquire();
- resources << manager.data(handles.at(i));
- }
-
- manager.release(handles.at(2));
- QVERIFY(manager.data(handles.at(2)) == Q_NULLPTR);
- // Triggers QASSERT so commented
-// manager.release(handles.at(2));
-
- tHandle nHandle = manager.acquire();
- QVERIFY(manager.data(nHandle) != Q_NULLPTR);
-}
-
-/*!
- * Checks that reset behaves correctly.
- */
-void tst_ListResourcesManager::resetResource()
-{
- Qt3DCore::QResourceManager<tst_ListResource, int, 16, Qt3DCore::ListAllocatingPolicy> manager;
-
- QList<tst_ListResource *> resources;
- QList<tHandle16> handles;
-
- for (int i = 0; i < 5; i++) {
- handles << manager.acquire();
- resources << manager.data(handles.at(i));
- resources.at(i)->m_value = 4;
- }
- manager.reset();
- for (uint i = 0; i < 5; i++) {
- QVERIFY(manager.data(handles.at(i)) == Q_NULLPTR);
- }
- handles.clear();
- for (uint i = 0; i < 5; i++)
- handles << manager.acquire();
-
- for (uint i = 0; i < 5; i++) {
- QVERIFY(handles.at(i).index() == i);
- QVERIFY(handles.at(i).counter() == 1);
- QVERIFY(manager.data(handles.at(i))->m_value != 4);
- }
-}
-
-void tst_ListResourcesManager::lookupResource()
-{
- Qt3DCore::QResourceManager<tst_ListResource, uint, 16, Qt3DCore::ListAllocatingPolicy> manager;
-
- QList<tst_ListResource *> resources;
- QList<tHandle16> handles;
-
- for (int i = 0; i < 5; i++) {
- handles << manager.acquire();
- resources << manager.data(handles.at(i));
- resources.at(i)->m_value = 4;
- }
-
- tHandle16 t = manager.lookupHandle(2);
- QVERIFY(t.handle() == 0);
- QVERIFY(manager.data(t) == Q_NULLPTR);
- tst_ListResource *resource = manager.getOrCreateResource(2);
- QVERIFY(resource != Q_NULLPTR);
- t = manager.lookupHandle(2);
- QVERIFY(manager.data(t) == manager.lookupResource(2));
- QVERIFY(t == manager.getOrAcquireHandle(2));
- QVERIFY(resource == manager.getOrCreateResource(2));
- QVERIFY(manager.data(t) == resource);
-}
-
-void tst_ListResourcesManager::releaseResource()
-{
- Qt3DCore::QResourceManager<tst_ListResource, uint, 16, Qt3DCore::ListAllocatingPolicy> manager;
- QList<tst_ListResource *> resources;
-
- for (int i = 0; i < 5; i++) {
- resources << manager.getOrCreateResource(i);
- }
-
- for (int i = 0; i < 5; i++) {
- QVERIFY(resources.at(i) == manager.lookupResource(i));
- }
-
- for (int i = 0; i < 5; i++) {
- manager.releaseResource(i);
- QVERIFY(manager.lookupResource(i) == Q_NULLPTR);
- }
-}
-
-class tst_Thread : public QThread
-{
- Q_OBJECT
-public:
-
- typedef Qt3DCore::QResourceManager<tst_ListResource,
- int,
- 16,
- Qt3DCore::ListAllocatingPolicy,
- Qt3DCore::ObjectLevelLockingPolicy> Manager;
-
- tst_Thread() : QThread()
- {
- }
-
- void setManager(Manager *manager)
- {
- m_manager = manager;
- }
-
- // QThread interface
-protected:
- void run()
- {
- int i = 0;
- int max = tHandle16::maxIndex();
- while (i < max) {
- tst_ListResource *r = m_manager->getOrCreateResource(i);
- i++;
- QVERIFY(r != Q_NULLPTR);
- r->m_value.fetchAndAddOrdered(+1);
- }
- qDebug() << QThread::currentThread() << "Done";
- }
-
- Manager *m_manager;
-};
-
-
-void tst_ListResourcesManager::heavyDutyMultiThreadedAccess()
-{
- tst_Thread::Manager *manager = new tst_Thread::Manager();
-
- QList<tst_Thread *> threads;
-
- int iterations = 8;
- int max = tHandle16::maxIndex();
-
- for (int i = 0; i < iterations; i++) {
- tst_Thread *thread = new tst_Thread();
- thread->setManager(manager);
- threads << thread;
- }
-
- for (int i = 0; i < iterations; i++) {
- threads[i]->start();
- }
-
- for (int i = 0; i < iterations; i++) {
- threads[i]->wait();
- }
-
- for (int i = 0; i < max; i++) {
- QVERIFY(manager->lookupResource(i) != Q_NULLPTR);
- QVERIFY(manager->lookupResource(i)->m_value = iterations);
- }
-
- qDeleteAll(threads);
- delete manager;
-}
-
-class tst_Thread2 : public QThread
-{
- Q_OBJECT
-public:
-
- typedef Qt3DCore::QResourceManager<tst_ListResource,
- int,
- 16,
- Qt3DCore::ListAllocatingPolicy,
- Qt3DCore::ObjectLevelLockingPolicy> Manager;
-
- tst_Thread2(int releaseAbove = 7)
- : QThread()
- , m_releaseAbove(releaseAbove)
- {
- }
-
- void setManager(Manager *manager)
- {
- m_manager = manager;
- }
-
- // QThread interface
-protected:
- void run()
- {
- int i = 0;
- int max = tHandle::maxIndex();
- while (i < max) {
- tst_ListResource *r = m_manager->getOrCreateResource(i);
- QVERIFY(r != Q_NULLPTR);
- int oldValue = r->m_value.fetchAndAddOrdered(+1);
- if (oldValue == m_releaseAbove)
- m_manager->releaseResource(i);
- i++;
- }
- qDebug() << QThread::currentThread() << "Done";
- }
-
- Manager *m_manager;
- int m_releaseAbove;
-};
-
-void tst_ListResourcesManager::heavyDutyMultiThreadedAccessRelease()
-{
- tst_Thread2::Manager *manager = new tst_Thread2::Manager();
-
- QList<tst_Thread2 *> threads;
-
- int iterations = 8;
- int max = tHandle16::maxIndex();
-
- for (int u = 0; u < 2; u++) {
-
- for (int i = 0; i < iterations; i++) {
- tst_Thread2 *thread = new tst_Thread2();
- thread->setManager(manager);
- threads << thread;
- }
-
- for (int i = 0; i < iterations; i++) {
- threads[i]->start();
- }
-
- for (int i = 0; i < iterations; i++) {
- threads[i]->wait();
- }
-
- for (int i = 0; i < max; i++) {
- QVERIFY(manager->lookupResource(i) == Q_NULLPTR);
- }
-
- qDeleteAll(threads);
- threads.clear();
- }
-
- delete manager;
-}
-
-void tst_ListResourcesManager::maximumNumberOfResources()
-{
- Qt3DCore::QResourceManager<tst_ListResource, uint, 16, Qt3DCore::ListAllocatingPolicy> manager;
-
- QList<tst_ListResource *> resources;
- QList<tHandle16> handles;
-
- QCOMPARE(tHandle16::maxIndex(), (uint)manager.maxResourcesEntries());
-
- for (int i = 0; i < manager.maxResourcesEntries(); i++) {
- handles << manager.acquire();
- resources << manager.data(handles.at(i));
- resources.at(i)->m_value = 4;
- }
-}
-
-QTEST_APPLESS_MAIN(tst_ListResourcesManager)
-
-#include "tst_listresourcesmanager.moc"
diff --git a/tests/auto/input/commons/testdevice.h b/tests/auto/input/commons/testdevice.h
index d04130cfc..b8e048a86 100644
--- a/tests/auto/input/commons/testdevice.h
+++ b/tests/auto/input/commons/testdevice.h
@@ -54,8 +54,8 @@ public:
int buttonCount() const Q_DECL_FINAL { return 0; }
QStringList axisNames() const Q_DECL_FINAL { return QStringList(); }
QStringList buttonNames() const Q_DECL_FINAL { return QStringList(); }
- int axisIdentifier(const QString &name) Q_DECL_FINAL { Q_UNUSED(name) return 0; }
- int buttonIdentifier(const QString &name) Q_DECL_FINAL { Q_UNUSED(name) return 0; }
+ int axisIdentifier(const QString &name) const Q_DECL_FINAL { Q_UNUSED(name) return 0; }
+ int buttonIdentifier(const QString &name) const Q_DECL_FINAL { Q_UNUSED(name) return 0; }
protected:
void copy(const Qt3DCore::QNode *ref) Q_DECL_FINAL
diff --git a/tools/qgltf/qgltf.cpp b/tools/qgltf/qgltf.cpp
index 02de0224b..cd6f23280 100644
--- a/tools/qgltf/qgltf.cpp
+++ b/tools/qgltf/qgltf.cpp
@@ -2458,6 +2458,14 @@ void GltfExporter::save(const QString &inputFilename)
qDebug() << "Done\n";
}
+static const char *description =
+ "qgltf uses Assimp to import a variety of 3D model formats "
+ "and export it into fast-to-load, optimized glTF "
+ "assets embedded into Qt resource files.\n\n"
+ "Note: this tool should typically not be invoked directly. Instead, "
+ "let qmake manage it based on QT3D_MODELS in the .pro file.\n\n"
+ "For standard Qt 3D usage the recommended options are -b -S.";
+
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
@@ -2467,6 +2475,7 @@ int main(int argc, char **argv)
QCommandLineParser cmdLine;
cmdLine.addHelpOption();
cmdLine.addVersionOption();
+ cmdLine.setApplicationDescription(QString::fromUtf8(description));
QCommandLineOption outDirOpt(QStringLiteral("d"), QStringLiteral("Place all output data into <dir>"), QStringLiteral("dir"));
cmdLine.addOption(outDirOpt);
QCommandLineOption binOpt(QStringLiteral("b"), QStringLiteral("Store binary JSON data in the .qgltf file"));
@@ -2517,6 +2526,9 @@ int main(int argc, char **argv)
QDir().mkpath(opts.outDir);
}
+ if (cmdLine.positionalArguments().isEmpty())
+ cmdLine.showHelp();
+
AssimpImporter importer;
GltfExporter exporter(&importer);
foreach (const QString &fn, cmdLine.positionalArguments()) {
diff --git a/tools/qgltf/qgltf.pro b/tools/qgltf/qgltf.pro
index b6aa6f048..a61607204 100644
--- a/tools/qgltf/qgltf.pro
+++ b/tools/qgltf/qgltf.pro
@@ -3,23 +3,6 @@ option(host_build)
SOURCES = qgltf.cpp
-config_assimp:!cross_compile {
- !contains(QT_CONFIG, no-pkg-config) {
- CONFIG += link_pkgconfig
- PKGCONFIG_PRIVATE += assimp
- } else {
- LIBS += -lassimp
- }
-} else {
- # Fix for using bootstrap module on OSX outside of qtbase
- contains(QT_CONFIG, qt_framework) {
- # Add framework headers directly to make bootstrap lib work
- INCLUDEPATH += $$QT.core.libs/QtCore.framework/Headers
- # Extend framework search path to make #include <QtCore/*> work
- QMAKE_CXXFLAGS += -F$$QT.core.libs
- }
-
- include(../../src/3rdparty/assimp/assimp.pri)
-}
+include(../../src/3rdparty/assimp/assimp_dependency.pri)
load(qt_tool)