diff options
36 files changed, 645 insertions, 48 deletions
diff --git a/src/plugins/renderplugins/scene2d/scene2d.pro b/src/plugins/renderplugins/scene2d/scene2d.pro index dbf9c3e36..4f7ae6ea9 100644 --- a/src/plugins/renderplugins/scene2d/scene2d.pro +++ b/src/plugins/renderplugins/scene2d/scene2d.pro @@ -1,17 +1,15 @@ TARGET = scene2d -QT += core-private 3dcore 3dcore-private 3drender 3drender-private 3dextras 3dquickrender 3dquickrender-private +QT += core-private 3dcore 3dcore-private 3drender 3drender-private 3dextras 3dquickscene2d 3dquickscene2d-private # Qt3D is free of Q_FOREACH - make sure it stays that way: DEFINES += QT_NO_FOREACH HEADERS += \ scene2dplugin.h -# scene2dnode_p.h SOURCES += \ main.cpp \ scene2dplugin.cpp -# scene2dnode.cpp DISTFILES += \ scene2dplugin.json diff --git a/src/plugins/renderplugins/scene2d/scene2dplugin.cpp b/src/plugins/renderplugins/scene2d/scene2dplugin.cpp index 5621858ea..83e002473 100644 --- a/src/plugins/renderplugins/scene2d/scene2dplugin.cpp +++ b/src/plugins/renderplugins/scene2d/scene2dplugin.cpp @@ -40,7 +40,7 @@ #include "scene2dplugin.h" #include <Qt3DRender/qrenderaspect.h> -#include <Qt3DQuickRender/qscene2d.h> +#include <Qt3DQuickScene2D/qscene2d.h> QT_BEGIN_NAMESPACE diff --git a/src/quick3d/imports/render/qt3dquick3drenderplugin.cpp b/src/quick3d/imports/render/qt3dquick3drenderplugin.cpp index f162e3d2b..b151d1b39 100644 --- a/src/quick3d/imports/render/qt3dquick3drenderplugin.cpp +++ b/src/quick3d/imports/render/qt3dquick3drenderplugin.cpp @@ -109,7 +109,6 @@ #include <Qt3DRender/qbuffercapture.h> #include <Qt3DRender/qmemorybarrier.h> -#include <Qt3DQuickRender/qscene2d.h> #include <Qt3DQuickRender/private/quick3dlayerfilter_p.h> #include <Qt3DQuickRender/private/quick3dtechnique_p.h> #include <Qt3DQuickRender/private/quick3dmaterial_p.h> @@ -285,9 +284,6 @@ void Qt3DQuick3DRenderPlugin::registerTypes(const char *uri) qmlRegisterType<Qt3DRender::QSeamlessCubemap>(uri, 2, 0, "SeamlessCubemap"); qmlRegisterType<Qt3DRender::QStencilOperation>(uri, 2, 0, "StencilOperation"); qmlRegisterType<Qt3DRender::QStencilMask>(uri, 2, 0, "StencilMask"); - - // Scene2D - Qt3DRender::Quick::registerType<Qt3DRender::Quick::QScene2D>("QScene2D", "Qt3D.Render/Scene2D", uri, 2, 9, "Scene2D"); } QT_END_NAMESPACE diff --git a/src/quick3d/imports/scene2d/importsscene2d.pro b/src/quick3d/imports/scene2d/importsscene2d.pro new file mode 100644 index 000000000..13ccf7818 --- /dev/null +++ b/src/quick3d/imports/scene2d/importsscene2d.pro @@ -0,0 +1,19 @@ +CXX_MODULE = qml +TARGET = qtquickscene2dplugin +TARGETPATH = QtQuick/Scene2D +IMPORT_VERSION = 2.0 + +QT += qml quick 3dcore 3drender 3drender-private 3dinput 3dlogic 3dquickscene2d + +# Qt3D is free of Q_FOREACH - make sure it stays that way: +DEFINES += QT_NO_FOREACH + +HEADERS += \ + qtquickscene2dplugin.h \ + +SOURCES += \ + qtquickscene2dplugin.cpp \ + +OTHER_FILES += qmldir + +load(qml_plugin) diff --git a/src/quick3d/imports/scene2d/qmldir b/src/quick3d/imports/scene2d/qmldir new file mode 100644 index 000000000..2e807f1e6 --- /dev/null +++ b/src/quick3d/imports/scene2d/qmldir @@ -0,0 +1,3 @@ +module QtQuick.Scene2D +plugin qtquickscene2dplugin +classname QtQuickScene2DPlugin diff --git a/src/quick3d/imports/scene2d/qtquickscene2dplugin.cpp b/src/quick3d/imports/scene2d/qtquickscene2dplugin.cpp new file mode 100644 index 000000000..44ca596d3 --- /dev/null +++ b/src/quick3d/imports/scene2d/qtquickscene2dplugin.cpp @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** 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 "qtquickscene2dplugin.h" + +#include <Qt3DQuickScene2D/qscene2d.h> +#include <private/qrenderaspect_p.h> + +QT_BEGIN_NAMESPACE + +static void initScene2dPlugin() +{ + Qt3DRender::QRenderAspectPrivate::configurePlugin("scene2d"); +} + +Q_COREAPP_STARTUP_FUNCTION(initScene2dPlugin) + +void QtQuickScene2DPlugin::registerTypes(const char *uri) +{ + qmlRegisterType<Qt3DRender::Quick::QScene2D>(uri, 2, 9, "Scene2D"); +} + +QT_END_NAMESPACE diff --git a/src/quick3d/imports/scene2d/qtquickscene2dplugin.h b/src/quick3d/imports/scene2d/qtquickscene2dplugin.h new file mode 100644 index 000000000..c9318673f --- /dev/null +++ b/src/quick3d/imports/scene2d/qtquickscene2dplugin.h @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** 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 QTQUICKSCENE2DPLUGIN_H +#define QTQUICKSCENE2DPLUGIN_H + +#include <QtQml/qqmlextensionplugin.h> + +static void initResources() +{ +#ifdef QT_STATIC + Q_INIT_RESOURCE(qmake_QtQuick_Scene2D); +#endif +} + +QT_BEGIN_NAMESPACE + +class QtQuickScene2DPlugin : public QQmlExtensionPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) +public: + QtQuickScene2DPlugin(QObject *parent = 0) : QQmlExtensionPlugin(parent) { initResources(); } + void registerTypes(const char *uri) Q_DECL_OVERRIDE; +}; + +QT_END_NAMESPACE + +#endif // QTQUICKSCENE2DPLUGIN_H diff --git a/src/quick3d/quick3drender/quick3drender.pro b/src/quick3d/quick3drender/quick3drender.pro index b1b904e12..88d7a9556 100644 --- a/src/quick3d/quick3drender/quick3drender.pro +++ b/src/quick3d/quick3drender/quick3drender.pro @@ -14,19 +14,16 @@ gcov { SOURCES += \ qt3dquickrender_global.cpp \ - qt3dquickrendernodefactory.cpp \ - qt3dquickrender_logging.cpp + qt3dquickrendernodefactory.cpp HEADERS += \ qt3dquickrendernodefactory_p.h \ qt3dquickrender_global_p.h \ - qt3dquickrender_global.h \ - qt3dquickrender_logging_p.h + qt3dquickrender_global.h # otherwise mingw headers do not declare common functions like ::strcasecmp win32-g++*:QMAKE_CXXFLAGS_CXX11 = -std=gnu++0x include(./items/items.pri) -include(./scene2d/scene2d.pri) load(qt_module) diff --git a/src/quick3d/quick3dscene2d/items/items.pri b/src/quick3d/quick3dscene2d/items/items.pri new file mode 100644 index 000000000..7a9a641f8 --- /dev/null +++ b/src/quick3d/quick3dscene2d/items/items.pri @@ -0,0 +1,10 @@ +HEADERS += \ + $$PWD/scene2d_p.h \ + $$PWD/qscene2d_p.h \ + $$PWD/qscene2d.h + +SOURCES += \ + $$PWD/qscene2d.cpp \ + $$PWD/scene2d.cpp + +INCLUDEPATH += $$PWD diff --git a/src/quick3d/quick3drender/scene2d/qscene2d.cpp b/src/quick3d/quick3dscene2d/items/qscene2d.cpp index fa46cd3d2..fa46cd3d2 100644 --- a/src/quick3d/quick3drender/scene2d/qscene2d.cpp +++ b/src/quick3d/quick3dscene2d/items/qscene2d.cpp diff --git a/src/quick3d/quick3drender/scene2d/qscene2d.h b/src/quick3d/quick3dscene2d/items/qscene2d.h index 0a7e943d6..c9bd9bea2 100644 --- a/src/quick3d/quick3drender/scene2d/qscene2d.h +++ b/src/quick3d/quick3dscene2d/items/qscene2d.h @@ -34,10 +34,10 @@ ** ****************************************************************************/ -#ifndef QT3DRENDER_QUICK3DRENDER_QSCENE2D_H -#define QT3DRENDER_QUICK3DRENDER_QSCENE2D_H +#ifndef QT3DRENDER_QUICK3DSCENE2D_QSCENE2D_H +#define QT3DRENDER_QUICK3DSCENE2D_QSCENE2D_H -#include <Qt3DQuickRender/qt3dquickrender_global.h> +#include <Qt3DQuickScene2D/qt3dquickscene2d_global.h> #include <Qt3DRender/qrendertargetoutput.h> #include <QtCore/QUrl> @@ -55,7 +55,7 @@ namespace Quick { class QScene2DPrivate; -class QT3DQUICKRENDERSHARED_EXPORT QScene2D : public Qt3DCore::QNode +class QT3DQUICKSCENE2DSHARED_EXPORT QScene2D : public Qt3DCore::QNode { Q_OBJECT @@ -114,4 +114,4 @@ private: QT_END_NAMESPACE -#endif // QT3DRENDER_QUICK3DRENDER_QSCENE2D_H +#endif // QT3DRENDER_QUICK3DSCENE2D_QSCENE2D_H diff --git a/src/quick3d/quick3drender/scene2d/qscene2d_p.h b/src/quick3d/quick3dscene2d/items/qscene2d_p.h index 34b54b231..1aecbedd7 100644 --- a/src/quick3d/quick3drender/scene2d/qscene2d_p.h +++ b/src/quick3d/quick3dscene2d/items/qscene2d_p.h @@ -34,8 +34,8 @@ ** ****************************************************************************/ -#ifndef QT3DRENDER_QUICK3DRENDER_QSCENE2D_P_H -#define QT3DRENDER_QUICK3DRENDER_QSCENE2D_P_H +#ifndef QT3DRENDER_QUICK3DSCENE2D_QSCENE2D_P_H +#define QT3DRENDER_QUICK3DSCENE2D_QSCENE2D_P_H // // W A R N I N G @@ -58,7 +58,7 @@ #include <QtCore/QWaitCondition> #include <QtCore/QThread> -#include <Qt3DQuickRender/qscene2d.h> +#include <Qt3DQuickScene2D/qscene2d.h> #include <Qt3DRender/qabstracttexture.h> #include <private/qobject_p.h> @@ -216,4 +216,4 @@ QT_END_NAMESPACE Q_DECLARE_METATYPE(Qt3DRender::Quick::Scene2DSharedObjectPtr) -#endif // QT3DRENDER_QUICK3DRENDER_QSCENE2D_P_H +#endif // QT3DRENDER_QUICK3DSCENE2D_QSCENE2D_P_H diff --git a/src/quick3d/quick3drender/scene2d/scene2d.cpp b/src/quick3d/quick3dscene2d/items/scene2d.cpp index 9317dc2c5..ef677bab8 100644 --- a/src/quick3d/quick3drender/scene2d/scene2d.cpp +++ b/src/quick3d/quick3dscene2d/items/scene2d.cpp @@ -35,7 +35,7 @@ ****************************************************************************/ #include <Qt3DCore/qpropertyupdatedchange.h> -#include <Qt3DQuickRender/qscene2d.h> +#include <Qt3DQuickScene2D/qscene2d.h> #include <QtCore/qthread.h> #include <QtCore/qatomic.h> @@ -47,7 +47,7 @@ #include <private/nodemanagers_p.h> #include <private/resourceaccessor_p.h> #include <private/attachmentpack_p.h> -#include <private/qt3dquickrender_logging_p.h> +#include <private/qt3dquickscene2d_logging_p.h> QT_BEGIN_NAMESPACE diff --git a/src/quick3d/quick3drender/scene2d/scene2d.pri b/src/quick3d/quick3dscene2d/items/scene2d.pri index 4635c43e1..4635c43e1 100644 --- a/src/quick3d/quick3drender/scene2d/scene2d.pri +++ b/src/quick3d/quick3dscene2d/items/scene2d.pri diff --git a/src/quick3d/quick3drender/scene2d/scene2d_p.h b/src/quick3d/quick3dscene2d/items/scene2d_p.h index 3a8ccf531..db32264c0 100644 --- a/src/quick3d/quick3drender/scene2d/scene2d_p.h +++ b/src/quick3d/quick3dscene2d/items/scene2d_p.h @@ -34,8 +34,8 @@ ** ****************************************************************************/ -#ifndef QT3DRENDER_RENDER_QUICK_SCENE2D_P_H -#define QT3DRENDER_RENDER_QUICK_SCENE2D_P_H +#ifndef QT3DRENDER_RENDER_QUICK3DSCENE2D_SCENE2D_P_H +#define QT3DRENDER_RENDER_QUICK3DSCENE2D_SCENE2D_P_H // // W A R N I N G @@ -49,7 +49,7 @@ // #include <Qt3DCore/qnodeid.h> -#include <Qt3DQuickRender/qscene2d.h> +#include <Qt3DQuickScene2D/qscene2d.h> #include <QtCore/QCoreApplication> #include <QtCore/QSemaphore> @@ -82,7 +82,7 @@ private: Scene2D *m_node; }; -class QT3DQUICKRENDERSHARED_EXPORT Scene2D : public Qt3DRender::Render::BackendNode +class QT3DQUICKSCENE2DSHARED_EXPORT Scene2D : public Qt3DRender::Render::BackendNode { public: Scene2D(); @@ -124,4 +124,4 @@ public: QT_END_NAMESPACE -#endif // QT3DRENDER_RENDER_QUICK_SCENE2D_P_H +#endif // QT3DRENDER_RENDER_QUICK3DSCENE2D_SCENE2D_P_H diff --git a/src/quick3d/quick3dscene2d/qt3dquickscene2d_global.cpp b/src/quick3d/quick3dscene2d/qt3dquickscene2d_global.cpp new file mode 100644 index 000000000..da5698d52 --- /dev/null +++ b/src/quick3d/quick3dscene2d/qt3dquickscene2d_global.cpp @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** 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 "qt3dquickscene2d_global_p.h" +#include "qt3dquickscene2dnodefactory_p.h" + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { +namespace Quick { + +void Quick3DScene2D_initialize() +{ + Qt3DCore::QAbstractNodeFactory::registerNodeFactory(QuickScene2DNodeFactory::instance()); +} + +void Quick3DScene2D_registerType(const char *className, const char *quickName, int major, int minor) +{ + QuickScene2DNodeFactory::instance()->registerType(className, quickName, major, minor); +} + +} // namespace Quick +} // namespace Qt3DRender + +QT_END_NAMESPACE diff --git a/src/quick3d/quick3dscene2d/qt3dquickscene2d_global.h b/src/quick3d/quick3dscene2d/qt3dquickscene2d_global.h new file mode 100644 index 000000000..509a62024 --- /dev/null +++ b/src/quick3d/quick3dscene2d/qt3dquickscene2d_global.h @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** 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 QT3DQUICKSCENE2D_GLOBAL_H +#define QT3DQUICKSCENE2D_GLOBAL_H + +#include <Qt3DCore/qt3dcore_global.h> + +QT_BEGIN_NAMESPACE + +#if defined(QT_SHARED) || !defined(QT_STATIC) +# if defined(QT_BUILD_3DQUICKSCENE2D_LIB) +# define QT3DQUICKSCENE2DSHARED_EXPORT Q_DECL_EXPORT +# else +# define QT3DQUICKSCENE2DSHARED_EXPORT Q_DECL_IMPORT +# endif +#else +# define QT3DQUICKSCENE2DSHARED_EXPORT +#endif + +QT_END_NAMESPACE + +#endif // QT3DQUICKSCENE2D_GLOBAL_H diff --git a/src/quick3d/quick3dscene2d/qt3dquickscene2d_global_p.h b/src/quick3d/quick3dscene2d/qt3dquickscene2d_global_p.h new file mode 100644 index 000000000..e115e3d5e --- /dev/null +++ b/src/quick3d/quick3dscene2d/qt3dquickscene2d_global_p.h @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** 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 QT3DQUICKSCENE2D_GLOBAL_P_H +#define QT3DQUICKSCENE2D_GLOBAL_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <Qt3DQuickScene2D/qt3dquickscene2d_global.h> +#include <QtQml/qqml.h> + +#define QT3DQUICKSCENE2DSHARED_PRIVATE_EXPORT QT3DQUICKSCENE2DSHARED_EXPORT + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { + +namespace Quick { + +QT3DQUICKSCENE2DSHARED_PRIVATE_EXPORT void Quick3DScene2D_initialize(); +QT3DQUICKSCENE2DSHARED_PRIVATE_EXPORT void Quick3DScene2D_registerType(const char *className, + const char *quickName, + int major, int minor); + +template<class T, class E> void registerExtendedType(const char *className, const char *quickName, + const char *uri, int major, int minor, + const char *name) +{ + qmlRegisterExtendedType<T, E>(uri, major, minor, name); + Quick3DScene2D_registerType(className, quickName, major, minor); +} + +template<class T> void registerType(const char *className, const char *quickName, + const char *uri, int major, int minor, const char *name) +{ + qmlRegisterType<T>(uri, major, minor, name); + Quick3DScene2D_registerType(className, quickName, major, minor); +} + +} // Quick + +} // Qt3D + +QT_END_NAMESPACE + +#endif // QT3DQUICKSCENE2D_GLOBAL_P_H diff --git a/src/quick3d/quick3drender/qt3dquickrender_logging.cpp b/src/quick3d/quick3dscene2d/qt3dquickscene2d_logging.cpp index b9e5d2e08..c9af316de 100644 --- a/src/quick3d/quick3drender/qt3dquickrender_logging.cpp +++ b/src/quick3d/quick3dscene2d/qt3dquickscene2d_logging.cpp @@ -34,7 +34,7 @@ ** ****************************************************************************/ -#include "qt3dquickrender_logging_p.h" +#include "qt3dquickscene2d_logging_p.h" QT_BEGIN_NAMESPACE diff --git a/src/quick3d/quick3drender/qt3dquickrender_logging_p.h b/src/quick3d/quick3dscene2d/qt3dquickscene2d_logging_p.h index c34abfdd3..3120e9919 100644 --- a/src/quick3d/quick3drender/qt3dquickrender_logging_p.h +++ b/src/quick3d/quick3dscene2d/qt3dquickscene2d_logging_p.h @@ -34,8 +34,8 @@ ** ****************************************************************************/ -#ifndef QT3DQUICKRENDER_LOGGING_P_H -#define QT3DQUICKRENDER_LOGGING_P_H +#ifndef QT3DQUICKSCENE2D_LOGGING_P_H +#define QT3DQUICKSCENE2D_LOGGING_P_H // // W A R N I N G diff --git a/src/quick3d/quick3dscene2d/qt3dquickscene2dnodefactory.cpp b/src/quick3d/quick3dscene2d/qt3dquickscene2dnodefactory.cpp new file mode 100644 index 000000000..a796e74c0 --- /dev/null +++ b/src/quick3d/quick3dscene2d/qt3dquickscene2dnodefactory.cpp @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd and/or its subsidiary(-ies). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qt3dquickscene2dnodefactory_p.h" +#include <QtQml/private/qqmlmetatype_p.h> + +#include <private/qrenderaspect_p.h> + +#include <QtCore/qcoreapplication.h> + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { + +Q_GLOBAL_STATIC(QuickScene2DNodeFactory, quick_scene2d_node_factory) + +static void initScene2dPlugin() +{ + Qt3DRender::QRenderAspectPrivate::configurePlugin("scene2d"); +} + +Q_COREAPP_STARTUP_FUNCTION(initScene2dPlugin) + +QuickScene2DNodeFactory *QuickScene2DNodeFactory::instance() +{ + return quick_scene2d_node_factory(); +} + +void QuickScene2DNodeFactory::registerType(const char *className, const char *quickName, + int major, int minor) +{ + m_types.insert(className, Type(quickName, major, minor)); +} + +Qt3DCore::QNode *QuickScene2DNodeFactory::createNode(const char *type) +{ + if (!m_types.contains(type)) + return nullptr; + + Type &typeInfo(m_types[type]); + + if (!typeInfo.resolved) { + typeInfo.resolved = true; + typeInfo.t = QQmlMetaType::qmlType(QString::fromLatin1(typeInfo.quickName), + typeInfo.version.first, typeInfo.version.second); + } + + return typeInfo.t ? qobject_cast<Qt3DCore::QNode *>(typeInfo.t->create()) : nullptr; +} + +} // namespace Qt3DRender + +QT_END_NAMESPACE diff --git a/src/quick3d/quick3dscene2d/qt3dquickscene2dnodefactory_p.h b/src/quick3d/quick3dscene2d/qt3dquickscene2dnodefactory_p.h new file mode 100644 index 000000000..b5eb82aa1 --- /dev/null +++ b/src/quick3d/quick3dscene2d/qt3dquickscene2dnodefactory_p.h @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd and/or its subsidiary(-ies). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QUICKSCENENODEFACTORY_H +#define QUICKSCENENODEFACTORY_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <Qt3DCore/private/qabstractnodefactory_p.h> +#include <QtCore/qhash.h> + +QT_BEGIN_NAMESPACE + +class QQmlType; + +namespace Qt3DRender { + +class QuickScene2DNodeFactory : public Qt3DCore::QAbstractNodeFactory +{ +public: + Qt3DCore::QNode *createNode(const char *type) Q_DECL_OVERRIDE; + + void registerType(const char *className, const char *quickName, int major, int minor); + + static QuickScene2DNodeFactory *instance(); + +private: + struct Type { + Type() : t(nullptr), resolved(false) { } + Type(const char *quickName, int major, int minor) + : quickName(quickName), version(major, minor), t(nullptr), resolved(false) { } + QByteArray quickName; + QPair<int, int> version; + QQmlType *t; + bool resolved; + }; + QHash<QByteArray, Type> m_types; +}; + +} // namespace Qt3DRender + +QT_END_NAMESPACE + +#endif // QUICKRENDERERNODEFACTORY_H diff --git a/src/quick3d/quick3dscene2d/quick3dscene2d.pro b/src/quick3d/quick3dscene2d/quick3dscene2d.pro new file mode 100644 index 000000000..7d2d59392 --- /dev/null +++ b/src/quick3d/quick3dscene2d/quick3dscene2d.pro @@ -0,0 +1,31 @@ +TARGET = Qt3DQuickScene2D +MODULE = 3dquickscene2d + +QT += core core-private qml qml-private 3dcore 3drender 3dquick 3dquick-private 3dcore-private 3drender-private +CONFIG -= precompile_header + +# Qt3D is free of Q_FOREACH - make sure it stays that way: +DEFINES += QT_NO_FOREACH + +gcov { + QMAKE_CXXFLAGS += -fprofile-arcs -ftest-coverage + QMAKE_LFLAGS += -fprofile-arcs -ftest-coverage +} + +SOURCES += \ + qt3dquickscene2d_global.cpp \ + qt3dquickscene2dnodefactory.cpp \ + qt3dquickscene2d_logging.cpp + +HEADERS += \ + qt3dquickscene2dnodefactory_p.h \ + qt3dquickscene2d_global_p.h \ + qt3dquickscene2d_global.h \ + qt3dquickscene2d_logging_p.h + +# otherwise mingw headers do not declare common functions like ::strcasecmp +win32-g++*:QMAKE_CXXFLAGS_CXX11 = -std=gnu++0x + +include(./items/items.pri) + +load(qt_module) diff --git a/src/render/frontend/qrenderaspect.cpp b/src/render/frontend/qrenderaspect.cpp index a1a65989f..73030138f 100644 --- a/src/render/frontend/qrenderaspect.cpp +++ b/src/render/frontend/qrenderaspect.cpp @@ -172,8 +172,8 @@ QRenderAspectPrivate::QRenderAspectPrivate(QRenderAspect::RenderType type) , m_renderType(type) , m_offscreenHelper(nullptr) { + m_instances.append(this); loadSceneParsers(); - loadRenderPlugins(); } /*! \internal */ @@ -185,6 +185,7 @@ QRenderAspectPrivate::~QRenderAspectPrivate() if (m_renderer != nullptr) qWarning() << Q_FUNC_INFO << "The renderer should have been deleted when reaching this point (this warning may be normal when running tests)"; delete m_nodeManagers; + m_instances.removeAll(this); } /*! \internal */ @@ -257,8 +258,8 @@ void QRenderAspectPrivate::registerBackendTypes() q->registerBackendType<QEventForward>(QSharedPointer<Render::NodeFunctor<Render::EventForward, Render::EventForwardManager> >::create(m_renderer)); // Plugins - for (Render::QRenderPlugin *plugin : qAsConst(m_renderPlugins)) - plugin->registerBackendTypes(q, m_renderer); + for (QString plugin : m_pluginConfig) + loadRenderPlugin(plugin); } /*! \internal */ @@ -570,13 +571,36 @@ void QRenderAspectPrivate::loadSceneParsers() } } -void QRenderAspectPrivate::loadRenderPlugins() +void QRenderAspectPrivate::loadRenderPlugin(const QString &pluginName) { + Q_Q(QRenderAspect); const QStringList keys = Render::QRenderPluginFactory::keys(); - for (const QString &key : keys) { - Render::QRenderPlugin *plugin = Render::QRenderPluginFactory::create(key, QStringList()); - if (plugin != nullptr) + if (!keys.contains(pluginName)) + return; + + if (m_pluginConfig.contains(pluginName) && !m_loadedPlugins.contains(pluginName)) { + Render::QRenderPlugin *plugin + = Render::QRenderPluginFactory::create(pluginName, QStringList()); + if (plugin != nullptr) { + m_loadedPlugins.append(pluginName); m_renderPlugins.append(plugin); + plugin->registerBackendTypes(q, m_renderer); + } + } +} + +QVector<QString> QRenderAspectPrivate::m_pluginConfig; +QMutex QRenderAspectPrivate::m_pluginLock; +QVector<QRenderAspectPrivate *> QRenderAspectPrivate::m_instances; + +void QRenderAspectPrivate::configurePlugin(const QString &plugin) +{ + QMutexLocker lock(&m_pluginLock); + if (!m_pluginConfig.contains(plugin)) { + m_pluginConfig.append(plugin); + + for (QRenderAspectPrivate *instance : m_instances) + instance->loadRenderPlugin(plugin); } } diff --git a/src/render/frontend/qrenderaspect_p.h b/src/render/frontend/qrenderaspect_p.h index 1fa0b26df..4f9983d32 100644 --- a/src/render/frontend/qrenderaspect_p.h +++ b/src/render/frontend/qrenderaspect_p.h @@ -55,6 +55,8 @@ #include <Qt3DCore/private/qabstractaspect_p.h> #include <Qt3DRender/private/qt3drender_global_p.h> +#include <QtCore/qmutex.h> + QT_BEGIN_NAMESPACE class QSurface; @@ -84,7 +86,7 @@ public: void registerBackendTypes(); void unregisterBackendTypes(); void loadSceneParsers(); - void loadRenderPlugins(); + void loadRenderPlugin(const QString &pluginName); void renderInitialize(QOpenGLContext *context); void renderSynchronous(); void renderShutdown(); @@ -96,9 +98,15 @@ public: bool m_initialized; QList<QSceneImporter *> m_sceneImporter; + QVector<QString> m_loadedPlugins; QVector<Render::QRenderPlugin *> m_renderPlugins; QRenderAspect::RenderType m_renderType; Render::OffscreenSurfaceHelper *m_offscreenHelper; + + static QMutex m_pluginLock; + static QVector<QString> m_pluginConfig; + static QVector<QRenderAspectPrivate *> m_instances; + static void configurePlugin(const QString &plugin); }; } diff --git a/src/src.pro b/src/src.pro index a9b1a38f9..86a885e51 100644 --- a/src/src.pro +++ b/src/src.pro @@ -44,6 +44,10 @@ src_quick3d_extras.subdir = $$PWD/quick3d/quick3dextras src_quick3d_extras.target = sub-quick3d-extras src_quick3d_extras.depends = src_render src_logic src_input src_extras src_quick3d_core +src_quick3d_scene2d.subdir = $$PWD/quick3d/quick3dscene2d +src_quick3d_scene2d.target = sub-quick3d-scene2d +src_quick3d_scene2d.depends = src_render src_logic src_input src_quick3d_core + # Quick3D imports src_quick3d_core_imports.file = $$PWD/quick3d/imports/core/importscore.pro src_quick3d_core_imports.target = sub-quick3d-imports-core @@ -73,6 +77,10 @@ src_quick3d_imports_extras.file = $$PWD/quick3d/imports/extras/importsextras.pro src_quick3d_imports_extras.target = sub-quick3d-imports-extras src_quick3d_imports_extras.depends = src_extras src_quick3d_extras +src_quick3d_imports_scene2d.file = $$PWD/quick3d/imports/scene2d/importsscene2d.pro +src_quick3d_imports_scene2d.target = sub-quick3d-imports-scene2d +src_quick3d_imports_scene2d.depends = src_quick3d_scene2d + # Qt3D Scene Parser plugins src_plugins_sceneparsers.file = $$PWD/plugins/sceneparsers/sceneparsers.pro src_plugins_sceneparsers.target = sub-plugins-sceneparsers @@ -86,7 +94,7 @@ src_plugins_geometryloaders.depends = src_render src_extras # Qt3D Render plugins src_plugins_render.file = $$PWD/plugins/renderplugins/renderplugins.pro src_plugins_render.target = sub-plugins-render -src_plugins_render.depends = src_render src_extras src_quick3d_render +src_plugins_render.depends = src_render src_extras src_quick3d_render src_quick3d_scene2d SUBDIRS += \ src_core \ @@ -110,4 +118,6 @@ SUBDIRS += \ src_plugins_sceneparsers \ src_plugins_geometryloaders \ src_plugins_render \ + src_quick3d_scene2d \ + src_quick3d_imports_scene2d \ doc diff --git a/sync.profile b/sync.profile index 27b98417e..5382d7e88 100644 --- a/sync.profile +++ b/sync.profile @@ -10,6 +10,7 @@ "Qt3DLogic" => "$basedir/src/logic", "Qt3DExtras" => "$basedir/src/extras", "Qt3DQuickExtras" => "$basedir/src/quick3d/quick3dextras", + "Qt3DQuickScene2D" => "$basedir/src/quick3d/quick3dscene2d", ); %moduleheaders = ( # restrict the module headers to those found in relative path ); diff --git a/tests/auto/render/qscene2d/qscene2d.pro b/tests/auto/render/qscene2d/qscene2d.pro index b7458d1c2..b1d4d45a9 100644 --- a/tests/auto/render/qscene2d/qscene2d.pro +++ b/tests/auto/render/qscene2d/qscene2d.pro @@ -2,7 +2,7 @@ TEMPLATE = app TARGET = qscene2d -QT += 3dcore 3dcore-private 3drender 3drender-private testlib 3dquickrender 3dquickrender-private +QT += 3dcore 3dcore-private 3drender 3drender-private testlib 3dquickscene2d 3dquickscene2d-private CONFIG += testcase diff --git a/tests/auto/render/qscene2d/tst_qscene2d.cpp b/tests/auto/render/qscene2d/tst_qscene2d.cpp index 8d27945e4..f0ff2db1e 100644 --- a/tests/auto/render/qscene2d/tst_qscene2d.cpp +++ b/tests/auto/render/qscene2d/tst_qscene2d.cpp @@ -27,7 +27,7 @@ ****************************************************************************/ #include <QtTest/QTest> -#include <Qt3DQuickRender/qscene2d.h> +#include <Qt3DQuickScene2D/qscene2d.h> #include <Qt3DRender/qrendertargetoutput.h> #include <private/qscene2d_p.h> #include <QObject> diff --git a/tests/auto/render/scene2d/scene2d.pro b/tests/auto/render/scene2d/scene2d.pro index 8685b0b5b..aacdea3e4 100644 --- a/tests/auto/render/scene2d/scene2d.pro +++ b/tests/auto/render/scene2d/scene2d.pro @@ -2,7 +2,7 @@ TEMPLATE = app TARGET = tst_scene2d -QT += 3dcore 3dcore-private 3drender 3drender-private testlib 3dquickrender 3dquickrender-private +QT += 3dcore 3dcore-private 3drender 3drender-private testlib 3dquickscene2d 3dquickscene2d-private CONFIG += testcase diff --git a/tests/auto/render/scene2d/tst_scene2d.cpp b/tests/auto/render/scene2d/tst_scene2d.cpp index 45ea85b42..b53318e7c 100644 --- a/tests/auto/render/scene2d/tst_scene2d.cpp +++ b/tests/auto/render/scene2d/tst_scene2d.cpp @@ -27,7 +27,7 @@ ****************************************************************************/ #include <QtTest/QTest> -#include <Qt3DQuickRender/qscene2d.h> +#include <Qt3DQuickScene2D/qscene2d.h> #include <private/qscene2d_p.h> #include <private/scene2d_p.h> #include <Qt3DCore/qpropertyupdatedchange.h> diff --git a/tests/manual/render-qml-to-texture-qml/main.qml b/tests/manual/render-qml-to-texture-qml/main.qml index 3f605a1a3..c793078d3 100644 --- a/tests/manual/render-qml-to-texture-qml/main.qml +++ b/tests/manual/render-qml-to-texture-qml/main.qml @@ -39,6 +39,7 @@ import Qt3D.Render 2.9 import Qt3D.Input 2.0 import QtQuick 2.0 as QQ2 import QtQuick.Scene3D 2.0 +import QtQuick.Scene2D 2.9 import QtQuick.Window 2.0 as QW2 import Qt3D.Extras 2.0 diff --git a/tests/manual/render-qml-to-texture-qml/render-qml-to-texture-qml.pro b/tests/manual/render-qml-to-texture-qml/render-qml-to-texture-qml.pro index 8155840d3..23729957c 100644 --- a/tests/manual/render-qml-to-texture-qml/render-qml-to-texture-qml.pro +++ b/tests/manual/render-qml-to-texture-qml/render-qml-to-texture-qml.pro @@ -6,7 +6,7 @@ error( "Couldn't find the render-qml-to-texture.pri file!") } -QT += 3dextras 3dcore 3drender 3dinput 3dquick qml quick 3dquickrender +QT += 3dextras 3dcore 3drender 3dinput 3dquick qml quick SOURCES += main.cpp diff --git a/tests/manual/render-qml-to-texture/main.cpp b/tests/manual/render-qml-to-texture/main.cpp index 79c0dbca2..a2fc6ed09 100644 --- a/tests/manual/render-qml-to-texture/main.cpp +++ b/tests/manual/render-qml-to-texture/main.cpp @@ -49,7 +49,7 @@ #include <Qt3DRender/QEffect> #include <Qt3DRender/QMaterial> #include <Qt3DExtras/QForwardRenderer> -#include <Qt3DQuickRender/QScene2D> +#include <Qt3DQuickScene2D/QScene2D> #include <Qt3DExtras/QPlaneMesh> #include <Qt3DRender/QTextureWrapMode> #include <Qt3DRender/QClearBuffers> diff --git a/tests/manual/render-qml-to-texture/render-qml-to-texture.pro b/tests/manual/render-qml-to-texture/render-qml-to-texture.pro index e98e62654..45c213803 100644 --- a/tests/manual/render-qml-to-texture/render-qml-to-texture.pro +++ b/tests/manual/render-qml-to-texture/render-qml-to-texture.pro @@ -2,7 +2,7 @@ error( "Couldn't find the manual.pri file!" ) } -QT += 3dextras 3dcore 3drender 3dinput 3dquick qml quick 3dquickrender +QT += 3dextras 3dcore 3drender 3dinput 3dquick qml quick 3dquickrender 3dquickscene2d SOURCES += main.cpp \ planematerial.cpp diff --git a/tests/manual/video-texture-qml/main.qml b/tests/manual/video-texture-qml/main.qml index 418ec06c4..6a8dff3d5 100644 --- a/tests/manual/video-texture-qml/main.qml +++ b/tests/manual/video-texture-qml/main.qml @@ -38,6 +38,7 @@ import Qt3D.Core 2.0 import Qt3D.Render 2.9 import Qt3D.Input 2.0 import QtQuick 2.2 as QQ2 +import QtQuick.Scene2D 2.9 import QtQuick.Window 2.0 as QW2 import Qt3D.Extras 2.0 import QtMultimedia 5.6 as QMM |