Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qquick3dscenemanager_p.h
Go to the documentation of this file.
1// Copyright (C) 2019 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef QSSGSCENEMANAGER_P_H
5#define QSSGSCENEMANAGER_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 purely as an
12// implementation detail. 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 <QtCore/QObject>
19#include <QtCore/QSet>
20
21#include <QtQuick3D/private/qtquick3dglobal_p.h>
22
23#include "qquick3dobject_p.h"
24#include "qquick3dnode_p.h"
25
27
29class QQuickWindow;
32
33class Q_QUICK3D_PRIVATE_EXPORT QQuick3DWindowAttachment : public QObject
34{
36public:
39
40 Q_INVOKABLE void preSync();
41 Q_INVOKABLE void cleanupResources();
42 Q_INVOKABLE bool synchronize(QSet<QSSGRenderGraphObject *> &resourceLoaders);
43 Q_INVOKABLE void requestUpdate();
44
45 QQuickWindow *window() const;
46
47 const std::shared_ptr<QSSGRenderContextInterface> &rci() const { return m_rci; }
48 void setRci(const std::shared_ptr<QSSGRenderContextInterface> &rciptr);
49
50 void registerSceneManager(QQuick3DSceneManager &manager);
51 void unregisterSceneManager(QQuick3DSceneManager &manager);
52
53 void queueForCleanup(QSSGRenderGraphObject *obj);
54 void queueForCleanup(QQuick3DSceneManager *manager);
55
59
60private:
61 Q_INVOKABLE void onReleaseCachedResources();
62 Q_INVOKABLE void onInvalidated();
63
65 std::shared_ptr<QSSGRenderContextInterface> m_rci;
67 QList<QQuick3DSceneManager *> sceneManagerCleanupQueue;
68 QList<QSSGRenderGraphObject *> pendingResourceCleanupQueue;
69 QSet<QSSGRenderGraphObject *> resourceCleanupQueue;
70};
71
72class Q_QUICK3D_PRIVATE_EXPORT QQuick3DSceneManager : public QObject
73{
75public:
76 explicit QQuick3DSceneManager(QObject *parent = nullptr);
77 ~QQuick3DSceneManager() override;
78
79 void setWindow(QQuickWindow *window);
81
82 void dirtyItem(QQuick3DObject *item);
83 void requestUpdate();
84 void cleanup(QSSGRenderGraphObject *item);
85
86 void polishItems();
87 void forcePolish();
88 void sync();
89 void preSync();
90
91 bool cleanupNodes();
92 bool updateDirtyResourceNodes();
93 void updateDirtySpatialNodes();
94 void updateDiryExtensions();
95
96 void updateDirtyResource(QQuick3DObject *resourceObject);
97 void updateDirtySpatialNode(QQuick3DNode *spatialNode);
98 void updateBoundingBoxes(QSSGBufferManager &mgr);
99
100 QQuick3DObject *lookUpNode(const QSSGRenderGraphObject *node) const;
101
102 // Where the enumerator is placed will decide the priority it gets.
103 // NOTE: Place new list types before 'Count'.
104 // NOTE: InstanceNodes are nodes that have an instance root set, we'll process these
105 // after the other nodes but before light nodes; this implies that lights are not good candidates
106 // for being instance roots...
107 enum class NodePriority { Skeleton, Other, ModelWithInstanceRoot, Lights, Count };
108 enum class ResourcePriority { TextureData, Texture, Other, Count };
109 enum class ExtensionPriority { RenderExtension, Count };
110
112 {
114
116 return size_t(ResourcePriority::Texture);
117
118 if (type == QSSGRenderGraphObject::Type::TextureData)
119 return size_t(ResourcePriority::TextureData);
120
121 return size_t(ResourcePriority::Other);
122 }
123
125 {
127
129 return size_t(NodePriority::Lights);
130
131 if (type == QSSGRenderGraphObject::Type::Skeleton)
132 return size_t(NodePriority::Skeleton);
133
134 return size_t(NodePriority::Other);
135 }
136
138 {
140
141 return size_t(ExtensionPriority::RenderExtension);
142 }
143
144 static QQuick3DWindowAttachment *getOrSetWindowAttachment(QQuickWindow &window);
145
146 QQuick3DObject *dirtyResources[size_t(ResourcePriority::Count)] {};
147 QQuick3DObject *dirtyNodes[size_t(NodePriority::Count)] {};
148 QQuick3DObject *dirtyExtensions[size_t(ExtensionPriority::Count)] {};
149
153
158 QQuickWindow *m_window = nullptr;
160 int inputHandlingEnabled = 0; // Holds the count of active item2Ds, input disabled if zero.
161 bool sharedResourceRemoved = false;
163
167
168private Q_SLOTS:
169 bool updateResources(QQuick3DObject **listHead);
170 void updateNodes(QQuick3DObject **listHead);
171 void updateExtensions(QQuick3DObject **listHead);
172};
173
175
177
178#endif // QSSGSCENEMANAGER_P_H
\inmodule QtCore
Definition qhash.h:818
Definition qlist.h:74
\inmodule QtCore
Definition qobject.h:90
\inmodule QtCore
Definition qpointer.h:18
\qmltype Object3D \inqmlmodule QtQuick3D \instantiates QQuick3DObject \inherits QtObject
static size_t nodeListIndex(QSSGRenderGraphObject::Type type)
QSet< QSSGRenderGraphObject * > resourceLoaders
QVector< QSGDynamicTexture * > qsgDynamicTextures
QPointer< QQuick3DWindowAttachment > wattached
QList< QSSGRenderGraphObject * > resourceCleanupQueue
QList< QQuick3DObject * > dirtyBoundingBoxList
QSet< QQuick3DObject * > parentlessItems
QList< QSSGRenderGraphObject * > cleanupNodeList
static size_t resourceListIndex(QSSGRenderGraphObject::Type type)
static constexpr size_t extensionListIndex(QSSGRenderGraphObject::Type type)
QHash< const QSSGRenderGraphObject *, QQuick3DObject * > m_nodeMap
const std::shared_ptr< QSSGRenderContextInterface > & rci() const
\qmltype Window \instantiates QQuickWindow \inqmlmodule QtQuick
The QSGDynamicTexture class serves as a baseclass for dynamically changing textures,...
Definition qsgtexture.h:100
Definition qset.h:18
Combined button and popup list for selecting options.
GLenum type
GLhandleARB obj
[2]
#define QML_DECLARE_TYPE(TYPE)
Definition qqml.h:19
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
#define Q_OBJECT
#define Q_INVOKABLE
#define Q_SLOTS
#define Q_SIGNALS
QGraphicsItem * item
aWidget window() -> setWindowTitle("New Window Title")
[2]
QNetworkAccessManager manager
static Q_REQUIRED_RESULT constexpr bool isNodeType(Type type) Q_DECL_NOTHROW
static Q_REQUIRED_RESULT constexpr bool isTexture(Type type) Q_DECL_NOTHROW
static Q_REQUIRED_RESULT constexpr bool isLight(Type type) Q_DECL_NOTHROW
static constexpr bool isExtension(Type type) noexcept
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent