1// Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QT3DRENDER_QRENDERASPECT_P_H
5#define QT3DRENDER_QRENDERASPECT_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists for the convenience
12// of other Qt classes. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <Qt3DRender/qrenderaspect.h>
19#include <Qt3DCore/private/qabstractaspect_p.h>
20#include <Qt3DRender/private/qt3drender_global_p.h>
21#include <Qt3DRender/private/expandboundingvolumejob_p.h>
22#include <Qt3DRender/private/updateworldtransformjob_p.h>
23#include <Qt3DRender/private/updateworldboundingvolumejob_p.h>
24#include <Qt3DRender/private/calcboundingvolumejob_p.h>
25#include <Qt3DRender/private/updateskinningpalettejob_p.h>
26#include <Qt3DRender/private/updateentitylayersjob_p.h>
27#include <Qt3DRender/private/updatetreeenabledjob_p.h>
28#include <Qt3DRender/private/genericlambdajob_p.h>
29#include <Qt3DRender/private/pickboundingvolumejob_p.h>
30#include <Qt3DRender/private/raycastingjob_p.h>
31
32#include <QtCore/qmutex.h>
33
34QT_BEGIN_NAMESPACE
35
36class QSurface;
37class QScreen;
38class QRhi;
39namespace Qt3DRender {
40
41class QSceneImporter;
42
43namespace Render {
44class AbstractRenderer;
45class NodeManagers;
46class QRenderPlugin;
47}
48
49namespace Render {
50class OffscreenSurfaceHelper;
51class PickEventFilter;
52
53using SynchronizerJobPtr = GenericLambdaJobPtr<std::function<void()>>;
54
55class UpdateLevelOfDetailJob;
56typedef QSharedPointer<UpdateLevelOfDetailJob> UpdateLevelOfDetailJobPtr;
57}
58
59class Q_3DRENDERSHARED_PRIVATE_EXPORT QRenderAspectPrivate : public Qt3DCore::QAbstractAspectPrivate
60{
61public:
62 QRenderAspectPrivate(QRenderAspect::SubmissionType submissionType);
63 ~QRenderAspectPrivate();
64
65 Q_DECLARE_PUBLIC(QRenderAspect)
66
67 static QRenderAspectPrivate* findPrivate(Qt3DCore::QAspectEngine *engine);
68 static QRenderAspectPrivate *get(QRenderAspect *q);
69
70 void jobsDone() override;
71 void frameDone() override;
72
73 void createNodeManagers();
74 void onEngineStartup();
75 void onEngineAboutToShutdown() override;
76
77 void registerBackendTypes();
78 void unregisterBackendTypes();
79 void loadSceneImporters();
80 void loadRenderPlugin(const QString &pluginName);
81 void registerBackendType(const QMetaObject &, const Qt3DCore::QBackendNodeMapperPtr &functor);
82 std::vector<Qt3DCore::QAspectJobPtr> createGeometryRendererJobs() const;
83 std::vector<Qt3DCore::QAspectJobPtr> createPreRendererJobs() const;
84 std::vector<Qt3DCore::QAspectJobPtr> createRenderBufferJobs() const;
85 Render::AbstractRenderer *loadRendererPlugin();
86
87 bool processMouseEvent(QObject *obj, QMouseEvent *event);
88 bool processKeyEvent(QObject *obj, QKeyEvent *event);
89
90 Render::NodeManagers *m_nodeManagers;
91 Render::AbstractRenderer *m_renderer;
92
93 bool m_initialized;
94 const bool m_renderAfterJobs;
95 bool m_sceneImportersLoaded;
96 QList<QSceneImporter *> m_sceneImporters;
97 QList<QString> m_loadedPlugins;
98 QList<Render::QRenderPlugin *> m_renderPlugins;
99 Render::OffscreenSurfaceHelper *m_offscreenHelper;
100 QScreen *m_screen = nullptr;
101
102 Render::UpdateTreeEnabledJobPtr m_updateTreeEnabledJob;
103 Render::UpdateWorldTransformJobPtr m_worldTransformJob;
104 Render::ExpandBoundingVolumeJobPtr m_expandBoundingVolumeJob;
105 Render::CalculateBoundingVolumeJobPtr m_calculateBoundingVolumeJob;
106 Render::UpdateWorldBoundingVolumeJobPtr m_updateWorldBoundingVolumeJob;
107 Render::UpdateSkinningPaletteJobPtr m_updateSkinningPaletteJob;
108 Render::UpdateLevelOfDetailJobPtr m_updateLevelOfDetailJob;
109 Render::UpdateEntityLayersJobPtr m_updateEntityLayersJob;
110 Render::SynchronizerJobPtr m_syncLoadingJobs;
111 Render::PickBoundingVolumeJobPtr m_pickBoundingVolumeJob;
112 Render::RayCastingJobPtr m_rayCastingJob;
113
114 QScopedPointer<Render::PickEventFilter> m_pickEventFilter;
115 QRenderAspect::SubmissionType m_submissionType;
116
117 static QMutex m_pluginLock;
118 static QList<QString> m_pluginConfig;
119 static QList<QRenderAspectPrivate *> m_instances;
120 static void configurePlugin(const QString &plugin);
121};
122
123}
124
125QT_END_NAMESPACE
126
127#endif // QT3DRENDER_QRENDERASPECT_P_H
128

source code of qt3d/src/render/frontend/qrenderaspect_p.h