1 #ifndef DALI_INTERNAL_CORE_H
2 #define DALI_INTERNAL_CORE_H
5 * Copyright (c) 2024 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
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>
43 class RenderController;
44 class PlatformAbstraction;
49 } // namespace Integration
53 class NotificationManager;
54 class AnimationPlaylist;
55 class PropertyNotificationManager;
57 class GestureEventProcessor;
60 class RelayoutController;
61 class EventThreadServices;
67 class RenderTaskProcessor;
68 } // namespace SceneGraph
71 * Internal class for Dali::Integration::Core
73 class Core : public EventThreadServices
77 * Create and initialise a new Core instance
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);
93 * @copydoc Dali::Integration::Core::Initialize()
98 * @copydoc Dali::Integration::Core::GetContextNotifier()
100 Integration::ContextNotifierInterface* GetContextNotifier();
103 * @copydoc Dali::Integration::Core::ContextCreated()
105 void ContextCreated();
108 * @copydoc Dali::Integration::Core::ContextDestroyed()
110 void ContextDestroyed();
113 * @copydoc Dali::Integration::Core::RecoverFromContextLoss()
115 void RecoverFromContextLoss();
118 * @copydoc Dali::Integration::Core::SetMinimumFrameTimeInterval(uint32_t)
120 void SetMinimumFrameTimeInterval(uint32_t interval);
123 * @copydoc Dali::Integration::Core::Update()
125 void Update(float elapsedSeconds, uint32_t lastVSyncTimeMilliseconds, uint32_t nextVSyncTimeMilliseconds, Integration::UpdateStatus& status, bool renderToFboEnabled, bool isRenderingToFbo, bool uploadOnly);
128 * @copydoc Dali::Integration::Core::PreRender()
130 void PreRender(Integration::RenderStatus& status, bool forceClear);
133 * @copydoc Dali::Integration::Core::PreRender()
135 void PreRender(Integration::Scene& scene, std::vector<Rect<int>>& damagedRects);
138 * @copydoc Dali::Integration::Core::RenderScene()
140 void RenderScene(Integration::RenderStatus& status, Integration::Scene& scene, bool renderToFbo);
143 * @copydoc Dali::Integration::Core::RenderScene()
145 void RenderScene(Integration::RenderStatus& status, Integration::Scene& scene, bool renderToFbo, Rect<int>& clippingRect);
148 * @copydoc Dali::Integration::Core::Render()
153 * @copydoc Dali::Integration::Core::SceneCreated()
158 * @copydoc Dali::Integration::Core::QueueEvent(const Integration::Event&)
160 void QueueEvent(const Integration::Event& event);
163 * @copydoc Dali::Integration::Core::ForceRelayout()
165 void ForceRelayout();
168 * @copydoc Dali::Integration::Core::ProcessEvents()
170 void ProcessEvents();
173 * @copydoc Dali::Integration::Core::GetMaximumUpdateCount()
175 uint32_t GetMaximumUpdateCount() const;
178 * @copydoc Dali::Integration::Core::RegisterProcessor
180 void RegisterProcessor(Integration::Processor& processor, bool postProcessor = false);
183 * @copydoc Dali::Integration::Core::UnregisterProcessor
185 void UnregisterProcessor(Dali::Integration::Processor& processor, bool postProcessor = false);
188 * @copydoc Dali::Internal::ThreadLocalStorage::AddScene()
190 void AddScene(Scene* scene);
193 * @copydoc Dali::Internal::ThreadLocalStorage::RemoveScene()
195 void RemoveScene(Scene* scene);
198 * @brief Gets the Object registry.
199 * @return A reference to the object registry
201 ObjectRegistry& GetObjectRegistry() const;
204 * Log the capacity of DALi memory pools
206 void LogMemoryPools() const;
208 public: // Implementation of EventThreadServices
210 * @copydoc EventThreadServices::RegisterObject
212 void RegisterObject(BaseObject* object) override;
215 * @copydoc EventThreadServices::UnregisterObject
217 void UnregisterObject(BaseObject* object) override;
220 * @copydoc EventThreadServices::GetUpdateManager
222 SceneGraph::UpdateManager& GetUpdateManager() override;
225 * @copydoc EventThreadServices::GetRenderController
227 Integration::RenderController& GetRenderController() override;
230 * @copydoc EventThreadServices::ReserveMessageSlot
232 uint32_t* ReserveMessageSlot(uint32_t size, bool updateScene) override;
235 * @copydoc EventThreadServices::GetEventBufferIndex
237 BufferIndex GetEventBufferIndex() const override;
240 using SceneContainer = std::vector<ScenePtr>;
243 * Run each registered processor
245 void RunProcessors();
248 * Run each registered postprocessor
250 void RunPostProcessors();
253 * Run registered processors, and relayout, and flush messages
255 void RelayoutAndFlush(SceneContainer& scenes);
257 // for use by ThreadLocalStorage
260 * Returns the current stage.
261 * @return A smart-pointer to the current stage.
263 StagePtr GetCurrentStage();
266 * Returns the platform abstraction.
267 * @return A reference to the platform abstraction.
269 Integration::PlatformAbstraction& GetPlatform();
272 * Returns the render manager.
273 * @return A reference to the render manager.
275 SceneGraph::RenderManager& GetRenderManager();
278 * Returns the notification manager.
279 * @return A reference to the Notification Manager.
281 NotificationManager& GetNotificationManager();
284 * Returns the Shader factory
285 * @return A reference to the Shader binary factory.
287 ShaderFactory& GetShaderFactory();
290 * Returns the gesture event processor.
291 * @return A reference to the gesture event processor.
293 GestureEventProcessor& GetGestureEventProcessor();
296 * Return the relayout controller
297 * @Return Return a reference to the relayout controller
299 RelayoutController& GetRelayoutController();
302 * @brief Gets the event thread services.
303 * @return A reference to the event thread services
305 EventThreadServices& GetEventThreadServices();
308 * @brief Gets the property notification manager.
309 * @return A reference to the property notification manager
311 PropertyNotificationManager& GetPropertyNotificationManager() const;
314 * @brief Gets the animation play list.
315 * @return A reference to the animation play list
317 AnimationPlaylist& GetAnimationPlaylist() const;
320 * @brief Returns GraphicsConfig
321 * @return A reference to the GraphicsConfig struct.
323 Integration::GraphicsConfig& GetGraphicsConfig() const;
327 * Undefined copy and assignment operators
329 Core(const Core& core) = delete; // No definition
330 Core& operator=(const Core& core) = delete; // No definition
333 * Create Thread local storage
335 void CreateThreadLocalStorage();
338 Integration::RenderController& mRenderController; ///< Reference to Render controller to tell it to keep rendering
339 Integration::PlatformAbstraction& mPlatform; ///< The interface providing platform specific services.
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
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)
355 SceneContainer mScenes; ///< A container of scenes that bound to a surface for rendering, owned by Core
357 // The object registry
358 ObjectRegistryPtr mObjectRegistry;
360 Graphics::Controller& mGraphicsController;
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()
367 friend class ThreadLocalStorage;
370 } // namespace Internal
374 #endif // DALI_INTERNAL_CORE_H