| 1 | /**************************************************************************** |
|---|---|
| 2 | ** |
| 3 | ** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). |
| 4 | ** Contact: https://www.qt.io/licensing/ |
| 5 | ** |
| 6 | ** This file is part of the Qt3D module of the Qt Toolkit. |
| 7 | ** |
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ |
| 9 | ** Commercial License Usage |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in |
| 11 | ** accordance with the commercial license agreement provided with the |
| 12 | ** Software or, alternatively, in accordance with the terms contained in |
| 13 | ** a written agreement between you and The Qt Company. For licensing terms |
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
| 15 | ** information use the contact form at https://www.qt.io/contact-us. |
| 16 | ** |
| 17 | ** GNU Lesser General Public License Usage |
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
| 19 | ** General Public License version 3 as published by the Free Software |
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the |
| 21 | ** packaging of this file. Please review the following information to |
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements |
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
| 24 | ** |
| 25 | ** GNU General Public License Usage |
| 26 | ** Alternatively, this file may be used under the terms of the GNU |
| 27 | ** General Public License version 2.0 or (at your option) the GNU General |
| 28 | ** Public license version 3 or any later version approved by the KDE Free |
| 29 | ** Qt Foundation. The licenses are as published by the Free Software |
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
| 31 | ** included in the packaging of this file. Please review the following |
| 32 | ** information to ensure the GNU General Public License requirements will |
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
| 35 | ** |
| 36 | ** $QT_END_LICENSE$ |
| 37 | ** |
| 38 | ****************************************************************************/ |
| 39 | |
| 40 | #ifndef QT3DRENDER_QRENDERASPECT_P_H |
| 41 | #define QT3DRENDER_QRENDERASPECT_P_H |
| 42 | |
| 43 | // |
| 44 | // W A R N I N G |
| 45 | // ------------- |
| 46 | // |
| 47 | // This file is not part of the Qt API. It exists for the convenience |
| 48 | // of other Qt classes. This header file may change from version to |
| 49 | // version without notice, or even be removed. |
| 50 | // |
| 51 | // We mean it. |
| 52 | // |
| 53 | |
| 54 | #include <Qt3DRender/qrenderaspect.h> |
| 55 | #include <Qt3DCore/private/qabstractaspect_p.h> |
| 56 | #include <Qt3DRender/private/qt3drender_global_p.h> |
| 57 | #include <Qt3DRender/private/expandboundingvolumejob_p.h> |
| 58 | #include <Qt3DRender/private/updateworldtransformjob_p.h> |
| 59 | #include <Qt3DRender/private/updateworldboundingvolumejob_p.h> |
| 60 | #include <Qt3DRender/private/calcboundingvolumejob_p.h> |
| 61 | #include <Qt3DRender/private/updateskinningpalettejob_p.h> |
| 62 | #include <Qt3DRender/private/updateentitylayersjob_p.h> |
| 63 | #include <Qt3DRender/private/updatetreeenabledjob_p.h> |
| 64 | #include <Qt3DRender/private/genericlambdajob_p.h> |
| 65 | #include <Qt3DRender/private/pickboundingvolumejob_p.h> |
| 66 | #include <Qt3DRender/private/raycastingjob_p.h> |
| 67 | |
| 68 | #include <QtCore/qmutex.h> |
| 69 | |
| 70 | QT_BEGIN_NAMESPACE |
| 71 | |
| 72 | class QSurface; |
| 73 | class QScreen; |
| 74 | |
| 75 | namespace Qt3DRender { |
| 76 | |
| 77 | class QSceneImporter; |
| 78 | |
| 79 | namespace Render { |
| 80 | class AbstractRenderer; |
| 81 | class NodeManagers; |
| 82 | class QRenderPlugin; |
| 83 | } |
| 84 | |
| 85 | namespace Render { |
| 86 | class OffscreenSurfaceHelper; |
| 87 | class PickEventFilter; |
| 88 | |
| 89 | using SynchronizerJobPtr = GenericLambdaJobPtr<std::function<void()>>; |
| 90 | |
| 91 | class UpdateLevelOfDetailJob; |
| 92 | typedef QSharedPointer<UpdateLevelOfDetailJob> UpdateLevelOfDetailJobPtr; |
| 93 | } |
| 94 | |
| 95 | class Q_3DRENDERSHARED_PRIVATE_EXPORT QRenderAspectPrivate : public Qt3DCore::QAbstractAspectPrivate |
| 96 | { |
| 97 | public: |
| 98 | QRenderAspectPrivate(QRenderAspect::RenderType type); |
| 99 | ~QRenderAspectPrivate(); |
| 100 | |
| 101 | Q_DECLARE_PUBLIC(QRenderAspect) |
| 102 | |
| 103 | static QRenderAspectPrivate* findPrivate(Qt3DCore::QAspectEngine *engine); |
| 104 | static QRenderAspectPrivate *get(QRenderAspect *q); |
| 105 | |
| 106 | void syncDirtyFrontEndNode(Qt3DCore::QNode *node, Qt3DCore::QBackendNode *backend, bool firstTime) const override; |
| 107 | void jobsDone() override; |
| 108 | void frameDone() override; |
| 109 | |
| 110 | void createNodeManagers(); |
| 111 | void onEngineStartup(); |
| 112 | |
| 113 | void registerBackendTypes(); |
| 114 | void unregisterBackendTypes(); |
| 115 | void loadSceneParsers(); |
| 116 | void loadRenderPlugin(const QString &pluginName); |
| 117 | void renderInitialize(QOpenGLContext *context); |
| 118 | void renderSynchronous(bool swapBuffers = true); |
| 119 | void renderShutdown(); |
| 120 | void registerBackendType(const QMetaObject &, const Qt3DCore::QBackendNodeMapperPtr &functor); |
| 121 | QVector<Qt3DCore::QAspectJobPtr> createGeometryRendererJobs() const; |
| 122 | QVector<Qt3DCore::QAspectJobPtr> createPreRendererJobs() const; |
| 123 | QVector<Qt3DCore::QAspectJobPtr> createRenderBufferJobs() const; |
| 124 | Render::AbstractRenderer *loadRendererPlugin(); |
| 125 | |
| 126 | Render::NodeManagers *m_nodeManagers; |
| 127 | Render::AbstractRenderer *m_renderer; |
| 128 | |
| 129 | bool m_initialized; |
| 130 | bool m_renderAfterJobs; |
| 131 | QList<QSceneImporter *> m_sceneImporter; |
| 132 | QVector<QString> m_loadedPlugins; |
| 133 | QVector<Render::QRenderPlugin *> m_renderPlugins; |
| 134 | QRenderAspect::RenderType m_renderType; |
| 135 | Render::OffscreenSurfaceHelper *m_offscreenHelper; |
| 136 | QScreen *m_screen = nullptr; |
| 137 | |
| 138 | Render::UpdateTreeEnabledJobPtr m_updateTreeEnabledJob; |
| 139 | Render::UpdateWorldTransformJobPtr m_worldTransformJob; |
| 140 | Render::ExpandBoundingVolumeJobPtr m_expandBoundingVolumeJob; |
| 141 | Render::CalculateBoundingVolumeJobPtr m_calculateBoundingVolumeJob; |
| 142 | Render::UpdateWorldBoundingVolumeJobPtr m_updateWorldBoundingVolumeJob; |
| 143 | Render::UpdateSkinningPaletteJobPtr m_updateSkinningPaletteJob; |
| 144 | Render::UpdateLevelOfDetailJobPtr m_updateLevelOfDetailJob; |
| 145 | Render::UpdateEntityLayersJobPtr m_updateEntityLayersJob; |
| 146 | Render::SynchronizerJobPtr m_syncLoadingJobs; |
| 147 | Render::PickBoundingVolumeJobPtr m_pickBoundingVolumeJob; |
| 148 | Render::RayCastingJobPtr m_rayCastingJob; |
| 149 | |
| 150 | QScopedPointer<Render::PickEventFilter> m_pickEventFilter; |
| 151 | |
| 152 | static QMutex m_pluginLock; |
| 153 | static QVector<QString> m_pluginConfig; |
| 154 | static QVector<QRenderAspectPrivate *> m_instances; |
| 155 | static void configurePlugin(const QString &plugin); |
| 156 | }; |
| 157 | |
| 158 | } |
| 159 | |
| 160 | QT_END_NAMESPACE |
| 161 | |
| 162 | #endif // QT3DRENDER_QRENDERASPECT_P_H |
| 163 |
