diff options
author | Antti Määttä <antti.maatta@qt.io> | 2016-11-02 11:50:43 +0200 |
---|---|---|
committer | Antti Määttä <antti.maatta@qt.io> | 2017-01-27 08:33:20 +0000 |
commit | 7d4968bf04bdd86e5651763979c5e91699ca06a4 (patch) | |
tree | 5b574fe62b0a14402547afe33f7fbe83ae4a673f /src/render/frontend | |
parent | 4c8bdacc8521e52cc655e6eddcc19d73ebcb6678 (diff) |
Add render plugin
Change-Id: I083b029a9bde4a3c6d81cfd06dfc509ba4f60a2d
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/render/frontend')
-rw-r--r-- | src/render/frontend/qrenderplugin_p.h | 89 | ||||
-rw-r--r-- | src/render/frontend/qrenderpluginfactory.cpp | 99 | ||||
-rw-r--r-- | src/render/frontend/qrenderpluginfactory_p.h | 75 | ||||
-rw-r--r-- | src/render/frontend/qrenderpluginfactoryif.cpp | 65 | ||||
-rw-r--r-- | src/render/frontend/qrenderpluginfactoryif_p.h | 82 | ||||
-rw-r--r-- | src/render/frontend/render-frontend.pri | 9 |
6 files changed, 417 insertions, 2 deletions
diff --git a/src/render/frontend/qrenderplugin_p.h b/src/render/frontend/qrenderplugin_p.h new file mode 100644 index 000000000..5144448c1 --- /dev/null +++ b/src/render/frontend/qrenderplugin_p.h @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** 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 QT3DRENDER_RENDER_QRENDERPLUGIN_P_H +#define QT3DRENDER_RENDER_QRENDERPLUGIN_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 <private/qt3drender_global_p.h> + +#include <Qt3DCore/qbackendnode.h> +#include <Qt3DRender/qrenderaspect.h> + +#include <QtCore/qobject.h> +#include <QtCore/qstringlist.h> + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { + +namespace Render { + +class AbstractRenderer; + +class QT3DRENDERSHARED_PRIVATE_EXPORT QRenderPlugin +{ +public: + virtual bool registerBackendTypes(QRenderAspect *aspect, AbstractRenderer *renderer) = 0; + virtual bool unregisterBackendTypes(QRenderAspect *aspect) = 0; + +protected: + void registerBackendType(QRenderAspect *aspect, const QMetaObject &obj, const Qt3DCore::QBackendNodeMapperPtr &functor) + { + aspect->registerBackendType(obj, functor); + } + void unregisterBackendType(QRenderAspect *aspect, const QMetaObject &obj) + { + aspect->unregisterBackendType(obj); + } +}; + +} // namespace Render +} // namespace Qt3DRender + +QT_END_NAMESPACE + +#endif // QT3DRENDER_RENDER_QRENDERPLUGIN_P_H diff --git a/src/render/frontend/qrenderpluginfactory.cpp b/src/render/frontend/qrenderpluginfactory.cpp new file mode 100644 index 000000000..51fa068c6 --- /dev/null +++ b/src/render/frontend/qrenderpluginfactory.cpp @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** 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 "qrenderpluginfactory_p.h" +#include "qrenderpluginfactoryif_p.h" +#include "qrenderplugin_p.h" + +#include <QtCore/qcoreapplication.h> +#include <QtCore/qdir.h> + +#include <private/qfactoryloader_p.h> + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { +namespace Render { + +#ifndef QT_NO_LIBRARY +Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, (QRenderPluginFactoryInterface_iid, QLatin1String("/renderplugins"), Qt::CaseInsensitive)) +Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, directLoader, (QRenderPluginFactoryInterface_iid, QLatin1String(""), Qt::CaseInsensitive)) +#endif + +QStringList QRenderPluginFactory::keys(const QString &pluginPath) +{ +#ifndef QT_NO_LIBRARY + QStringList list; + if (!pluginPath.isEmpty()) { + QCoreApplication::addLibraryPath(pluginPath); + list = directLoader()->keyMap().values(); + if (!list.isEmpty()) { + const QString postFix = QLatin1String(" (from ") + + QDir::toNativeSeparators(pluginPath) + + QLatin1Char(')'); + const QStringList::iterator end = list.end(); + for (QStringList::iterator it = list.begin(); it != end; ++it) + (*it).append(postFix); + } + } + list.append(loader()->keyMap().values()); + return list; +#else + return QStringList(); +#endif +} + +QRenderPlugin *QRenderPluginFactory::create(const QString &name, const QStringList &args, + const QString &pluginPath) +{ +#ifndef QT_NO_LIBRARY + if (!pluginPath.isEmpty()) { + QCoreApplication::addLibraryPath(pluginPath); + if (QRenderPlugin *ret + = qLoadPlugin<QRenderPlugin, QRenderPluginFactoryIf>(directLoader(), name, args)) { + return ret; + } + } + if (QRenderPlugin *ret = qLoadPlugin<QRenderPlugin, QRenderPluginFactoryIf>(loader(), name, args)) + return ret; +#endif + return nullptr; +} + +} // namespace Render +} // namespace Qt3DRender + +QT_END_NAMESPACE diff --git a/src/render/frontend/qrenderpluginfactory_p.h b/src/render/frontend/qrenderpluginfactory_p.h new file mode 100644 index 000000000..9cffd500a --- /dev/null +++ b/src/render/frontend/qrenderpluginfactory_p.h @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** 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 QT3DRENDER_RENDER_QRENDERPLUGINFACTORY_P_H +#define QT3DRENDER_RENDER_QRENDERPLUGINFACTORY_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 <private/qt3drender_global_p.h> + +#include <QtCore/qstringlist.h> + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { +namespace Render { + +class QRenderPlugin; + +class QT3DRENDERSHARED_PRIVATE_EXPORT QRenderPluginFactory +{ +public: + static QStringList keys(const QString &pluginPath = QString()); + static QRenderPlugin *create(const QString &name, const QStringList &args, + const QString &pluginPath = QString()); +}; + +} // namespace Render +} // namespace Qt3DRender + +QT_END_NAMESPACE + +#endif // QT3DRENDER_RENDER_QRENDERPLUGINFACTORY_P_H diff --git a/src/render/frontend/qrenderpluginfactoryif.cpp b/src/render/frontend/qrenderpluginfactoryif.cpp new file mode 100644 index 000000000..af567084c --- /dev/null +++ b/src/render/frontend/qrenderpluginfactoryif.cpp @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** 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 "qrenderpluginfactoryif_p.h" + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { +namespace Render { + +QRenderPluginFactoryIf::QRenderPluginFactoryIf(QObject *parent) + : QObject(parent) +{ + +} + +QRenderPluginFactoryIf::~QRenderPluginFactoryIf() +{ + +} + +QRenderPlugin *QRenderPluginFactoryIf::create(const QString &key, const QStringList ¶mList) +{ + Q_UNUSED(key) + Q_UNUSED(paramList) + return nullptr; +} + +} // namespace Render +} // namespace Qt3DRender + +QT_END_NAMESPACE diff --git a/src/render/frontend/qrenderpluginfactoryif_p.h b/src/render/frontend/qrenderpluginfactoryif_p.h new file mode 100644 index 000000000..d5f0008d2 --- /dev/null +++ b/src/render/frontend/qrenderpluginfactoryif_p.h @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** 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 QT3DRENDER_RENDER_QRENDERPLUGINFACTORYIF_P_H +#define QT3DRENDER_RENDER_QRENDERPLUGINFACTORYIF_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 <QtCore/qobject.h> +#include <QtCore/qplugin.h> +#include <QtCore/qfactoryinterface.h> + +#include <private/qt3drender_global_p.h> + + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { +namespace Render { + +#define QRenderPluginFactoryInterface_iid "org.qt-project.Qt3DRender.QRenderPluginFactoryInterface 5.9" + +class QRenderPlugin; + +class QT3DRENDERSHARED_PRIVATE_EXPORT QRenderPluginFactoryIf : public QObject +{ + Q_OBJECT +public: + explicit QRenderPluginFactoryIf(QObject *parent = nullptr); + ~QRenderPluginFactoryIf(); + + virtual QRenderPlugin *create(const QString &key, const QStringList ¶mList); +}; + +} // namespace Render +} // namespace Qt3DRender + +QT_END_NAMESPACE + +#endif // QT3DRENDER_QRENDERPLUGINFACTORYIF_P_H diff --git a/src/render/frontend/render-frontend.pri b/src/render/frontend/render-frontend.pri index 829e3d756..d42f33b87 100644 --- a/src/render/frontend/render-frontend.pri +++ b/src/render/frontend/render-frontend.pri @@ -21,7 +21,10 @@ HEADERS += \ $$PWD/qpickingsettings.h \ $$PWD/qpickingsettings_p.h \ $$PWD/qcomputecommand_p.h \ - $$PWD/qcomputecommand.h + $$PWD/qcomputecommand.h \ + $$PWD/qrenderplugin_p.h \ + $$PWD/qrenderpluginfactory_p.h \ + $$PWD/qrenderpluginfactoryif_p.h SOURCES += \ $$PWD/qabstractfunctor.cpp \ @@ -35,5 +38,7 @@ SOURCES += \ $$PWD/qrendersettings.cpp \ $$PWD/qpickingsettings.cpp \ $$PWD/qrendertargetoutput.cpp \ - $$PWD/qcomputecommand.cpp + $$PWD/qcomputecommand.cpp \ + $$PWD/qrenderpluginfactory.cpp \ + $$PWD/qrenderpluginfactoryif.cpp |