Remove inclusion of gl-abstraction.h
[platform/core/uifw/dali-core.git] / dali / internal / common / core-impl.h
1 #ifndef DALI_INTERNAL_CORE_H
2 #define DALI_INTERNAL_CORE_H
3
4 /*
5  * Copyright (c) 2024 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <dali/devel-api/common/owner-container.h>
23 #include <dali/integration-api/context-notifier.h>
24 #include <dali/integration-api/core-enumerations.h>
25 #include <dali/integration-api/resource-policies.h>
26 #include <dali/internal/common/owner-pointer.h>
27 #include <dali/internal/event/common/object-registry-impl.h>
28 #include <dali/internal/event/common/scene-impl.h>
29 #include <dali/internal/event/common/stage-def.h>
30 #include <dali/public-api/common/dali-vector.h>
31 #include <dali/public-api/object/ref-object.h>
32
33 namespace Dali
34 {
35 namespace Graphics
36 {
37 class Controller;
38 }
39
40 namespace Integration
41 {
42 class Processor;
43 class RenderController;
44 class PlatformAbstraction;
45 class UpdateStatus;
46 class RenderStatus;
47 struct Event;
48 struct TouchEvent;
49 } // namespace Integration
50
51 namespace Internal
52 {
53 class NotificationManager;
54 class AnimationPlaylist;
55 class PropertyNotificationManager;
56 class EventProcessor;
57 class GestureEventProcessor;
58 class ShaderFactory;
59 class TouchResampler;
60 class RelayoutController;
61 class EventThreadServices;
62
63 namespace SceneGraph
64 {
65 class UpdateManager;
66 class RenderManager;
67 class RenderTaskProcessor;
68 } // namespace SceneGraph
69
70 /**
71  * Internal class for Dali::Integration::Core
72  */
73 class Core : public EventThreadServices
74 {
75 public:
76   /**
77    * Create and initialise a new Core instance
78    */
79   Core(Integration::RenderController&      renderController,
80        Integration::PlatformAbstraction&   platform,
81        Graphics::Controller&               graphicsController,
82        Integration::RenderToFrameBuffer    renderToFboEnabled,
83        Integration::DepthBufferAvailable   depthBufferAvailable,
84        Integration::StencilBufferAvailable stencilBufferAvailable,
85        Integration::PartialUpdateAvailable partialUpdateAvailable);
86
87   /**
88    * Destructor
89    */
90   ~Core() override;
91
92   /**
93    * @copydoc Dali::Integration::Core::Initialize()
94    */
95   void Initialize();
96
97   /**
98    * @copydoc Dali::Integration::Core::GetContextNotifier()
99    */
100   Integration::ContextNotifierInterface* GetContextNotifier();
101
102   /**
103    * @copydoc Dali::Integration::Core::ContextCreated()
104    */
105   void ContextCreated();
106
107   /**
108    * @copydoc Dali::Integration::Core::ContextDestroyed()
109    */
110   void ContextDestroyed();
111
112   /**
113    * @copydoc Dali::Integration::Core::RecoverFromContextLoss()
114    */
115   void RecoverFromContextLoss();
116
117   /**
118    * @copydoc Dali::Integration::Core::SetMinimumFrameTimeInterval(uint32_t)
119    */
120   void SetMinimumFrameTimeInterval(uint32_t interval);
121
122   /**
123    * @copydoc Dali::Integration::Core::Update()
124    */
125   void Update(float elapsedSeconds, uint32_t lastVSyncTimeMilliseconds, uint32_t nextVSyncTimeMilliseconds, Integration::UpdateStatus& status, bool renderToFboEnabled, bool isRenderingToFbo, bool uploadOnly);
126
127   /**
128    * @copydoc Dali::Integration::Core::PreRender()
129    */
130   void PreRender(Integration::RenderStatus& status, bool forceClear);
131
132   /**
133    * @copydoc Dali::Integration::Core::PreRender()
134    */
135   void PreRender(Integration::Scene& scene, std::vector<Rect<int>>& damagedRects);
136
137   /**
138    * @copydoc Dali::Integration::Core::RenderScene()
139    */
140   void RenderScene(Integration::RenderStatus& status, Integration::Scene& scene, bool renderToFbo);
141
142   /**
143    * @copydoc Dali::Integration::Core::RenderScene()
144    */
145   void RenderScene(Integration::RenderStatus& status, Integration::Scene& scene, bool renderToFbo, Rect<int>& clippingRect);
146
147   /**
148    * @copydoc Dali::Integration::Core::Render()
149    */
150   void PostRender();
151
152   /**
153    * @copydoc Dali::Integration::Core::SceneCreated()
154    */
155   void SceneCreated();
156
157   /**
158    * @copydoc Dali::Integration::Core::QueueEvent(const Integration::Event&)
159    */
160   void QueueEvent(const Integration::Event& event);
161
162   /**
163    * @copydoc Dali::Integration::Core::ForceRelayout()
164    */
165   void ForceRelayout();
166
167   /**
168    * @copydoc Dali::Integration::Core::ProcessEvents()
169    */
170   void ProcessEvents();
171
172   /**
173    * @copydoc Dali::Integration::Core::GetMaximumUpdateCount()
174    */
175   uint32_t GetMaximumUpdateCount() const;
176
177   /**
178    * @copydoc Dali::Integration::Core::RegisterProcessor
179    */
180   void RegisterProcessor(Integration::Processor& processor, bool postProcessor = false);
181
182   /**
183    * @copydoc Dali::Integration::Core::UnregisterProcessor
184    */
185   void UnregisterProcessor(Dali::Integration::Processor& processor, bool postProcessor = false);
186
187   /**
188    * @copydoc Dali::Internal::ThreadLocalStorage::AddScene()
189    */
190   void AddScene(Scene* scene);
191
192   /**
193    * @copydoc Dali::Internal::ThreadLocalStorage::RemoveScene()
194    */
195   void RemoveScene(Scene* scene);
196
197   /**
198    * @brief Gets the Object registry.
199    * @return A reference to the object registry
200    */
201   ObjectRegistry& GetObjectRegistry() const;
202
203   /**
204    * Log the capacity of DALi memory pools
205    */
206   void LogMemoryPools() const;
207
208 public: // Implementation of EventThreadServices
209   /**
210    * @copydoc EventThreadServices::RegisterObject
211    */
212   void RegisterObject(BaseObject* object) override;
213
214   /**
215    * @copydoc EventThreadServices::UnregisterObject
216    */
217   void UnregisterObject(BaseObject* object) override;
218
219   /**
220    * @copydoc EventThreadServices::GetUpdateManager
221    */
222   SceneGraph::UpdateManager& GetUpdateManager() override;
223
224   /**
225    * @copydoc EventThreadServices::GetRenderController
226    */
227   Integration::RenderController& GetRenderController() override;
228
229   /**
230    * @copydoc EventThreadServices::ReserveMessageSlot
231    */
232   uint32_t* ReserveMessageSlot(uint32_t size, bool updateScene) override;
233
234   /**
235    * @copydoc EventThreadServices::GetEventBufferIndex
236    */
237   BufferIndex GetEventBufferIndex() const override;
238
239 private:
240   using SceneContainer = std::vector<ScenePtr>;
241
242   /**
243    * Run each registered processor
244    */
245   void RunProcessors();
246
247   /**
248    * Run each registered postprocessor
249    */
250   void RunPostProcessors();
251
252   /**
253    * Run registered processors, and relayout, and flush messages
254    */
255   void RelayoutAndFlush(SceneContainer& scenes);
256
257   // for use by ThreadLocalStorage
258
259   /**
260    * Returns the current stage.
261    * @return A smart-pointer to the current stage.
262    */
263   StagePtr GetCurrentStage();
264
265   /**
266    * Returns the platform abstraction.
267    * @return A reference to the platform abstraction.
268    */
269   Integration::PlatformAbstraction& GetPlatform();
270
271   /**
272    * Returns the render manager.
273    * @return A reference to the render manager.
274    */
275   SceneGraph::RenderManager& GetRenderManager();
276
277   /**
278    * Returns the notification manager.
279    * @return A reference to the Notification Manager.
280    */
281   NotificationManager& GetNotificationManager();
282
283   /**
284    * Returns the Shader factory
285    * @return A reference to the Shader binary factory.
286    */
287   ShaderFactory& GetShaderFactory();
288
289   /**
290    * Returns the gesture event processor.
291    * @return A reference to the gesture event processor.
292    */
293   GestureEventProcessor& GetGestureEventProcessor();
294
295   /**
296    * Return the relayout controller
297    * @Return Return a reference to the relayout controller
298    */
299   RelayoutController& GetRelayoutController();
300
301   /**
302    * @brief Gets the event thread services.
303    * @return A reference to the event thread services
304    */
305   EventThreadServices& GetEventThreadServices();
306
307   /**
308    * @brief Gets the property notification manager.
309    * @return A reference to the property notification manager
310    */
311   PropertyNotificationManager& GetPropertyNotificationManager() const;
312
313   /**
314    * @brief Gets the animation play list.
315    * @return A reference to the animation play list
316    */
317   AnimationPlaylist& GetAnimationPlaylist() const;
318
319   /**
320    * @brief Returns GraphicsConfig
321    * @return A reference to the GraphicsConfig struct.
322    */
323   Integration::GraphicsConfig& GetGraphicsConfig() const;
324
325 private:
326   /**
327    * Undefined copy and assignment operators
328    */
329   Core(const Core& core) = delete;            // No definition
330   Core& operator=(const Core& core) = delete; // No definition
331
332   /**
333    * Create Thread local storage
334    */
335   void CreateThreadLocalStorage();
336
337 private:
338   Integration::RenderController&    mRenderController; ///< Reference to Render controller to tell it to keep rendering
339   Integration::PlatformAbstraction& mPlatform;         ///< The interface providing platform specific services.
340
341   IntrusivePtr<Stage>                       mStage;                       ///< The current stage
342   OwnerPointer<AnimationPlaylist>           mAnimationPlaylist;           ///< For 'Fire and forget' animation support
343   OwnerPointer<PropertyNotificationManager> mPropertyNotificationManager; ///< For safe signal emmision of property changed notifications
344   IntrusivePtr<RelayoutController>          mRelayoutController;          ///< Size negotiation relayout controller
345
346   OwnerPointer<SceneGraph::RenderTaskProcessor> mRenderTaskProcessor;   ///< Handles the processing of render tasks
347   OwnerPointer<SceneGraph::RenderManager>       mRenderManager;         ///< Render manager
348   OwnerPointer<SceneGraph::UpdateManager>       mUpdateManager;         ///< Update manager
349   OwnerPointer<ShaderFactory>                   mShaderFactory;         ///< Shader resource factory
350   OwnerPointer<NotificationManager>             mNotificationManager;   ///< Notification manager
351   OwnerPointer<GestureEventProcessor>           mGestureEventProcessor; ///< The gesture event processor
352   Dali::Vector<Integration::Processor*>         mProcessors;            ///< Registered processors (not owned)
353   Dali::Vector<Integration::Processor*>         mPostProcessors;        ///< Registered post processors those will called after relayout(not owned)
354
355   SceneContainer mScenes; ///< A container of scenes that bound to a surface for rendering, owned by Core
356
357   // The object registry
358   ObjectRegistryPtr mObjectRegistry;
359
360   Graphics::Controller& mGraphicsController;
361
362   bool mProcessingEvent : 1;           ///< True during ProcessEvents()
363   bool mProcessorUnregistered : 1;     ///< True if the processor is unregistered during RunProcessors()
364   bool mPostProcessorUnregistered : 1; ///< True if the post-processor is unregistered during RunPostProcessors()
365   bool mRelayoutFlush : 1;             ///< True during RelayoutAndFlush()
366
367   friend class ThreadLocalStorage;
368 };
369
370 } // namespace Internal
371
372 } // namespace Dali
373
374 #endif // DALI_INTERNAL_CORE_H