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::CorePolicyFlags corePolicy);
90 * @copydoc Dali::Integration::Core::Initialize()
95 * @copydoc Dali::Integration::Core::GetContextNotifier()
97 Integration::ContextNotifierInterface* GetContextNotifier();
100 * @copydoc Dali::Integration::Core::ContextCreated()
102 void ContextCreated();
105 * @copydoc Dali::Integration::Core::ContextDestroyed()
107 void ContextDestroyed();
110 * @copydoc Dali::Integration::Core::RecoverFromContextLoss()
112 void RecoverFromContextLoss();
115 * @copydoc Dali::Integration::Core::SetMinimumFrameTimeInterval(uint32_t)
117 void SetMinimumFrameTimeInterval(uint32_t interval);
120 * @copydoc Dali::Integration::Core::Update()
122 void Update(float elapsedSeconds, uint32_t lastVSyncTimeMilliseconds, uint32_t nextVSyncTimeMilliseconds, Integration::UpdateStatus& status, bool renderToFboEnabled, bool isRenderingToFbo, bool uploadOnly);
125 * @copydoc Dali::Integration::Core::PreRender()
127 void PreRender(Integration::RenderStatus& status, bool forceClear);
130 * @copydoc Dali::Integration::Core::PreRender()
132 void PreRender(Integration::Scene& scene, std::vector<Rect<int>>& damagedRects);
135 * @copydoc Dali::Integration::Core::RenderScene()
137 void RenderScene(Integration::RenderStatus& status, Integration::Scene& scene, bool renderToFbo);
140 * @copydoc Dali::Integration::Core::RenderScene()
142 void RenderScene(Integration::RenderStatus& status, Integration::Scene& scene, bool renderToFbo, Rect<int>& clippingRect);
145 * @copydoc Dali::Integration::Core::Render()
150 * @copydoc Dali::Integration::Core::SceneCreated()
155 * @copydoc Dali::Integration::Core::QueueEvent(const Integration::Event&)
157 void QueueEvent(const Integration::Event& event);
160 * @copydoc Dali::Integration::Core::ForceRelayout()
162 void ForceRelayout();
165 * @copydoc Dali::Integration::Core::ProcessEvents()
167 void ProcessEvents();
170 * @copydoc Dali::Integration::Core::GetMaximumUpdateCount()
172 uint32_t GetMaximumUpdateCount() const;
175 * @copydoc Dali::Integration::Core::RegisterProcessor
177 void RegisterProcessor(Integration::Processor& processor, bool postProcessor = false);
180 * @copydoc Dali::Integration::Core::UnregisterProcessor
182 void UnregisterProcessor(Dali::Integration::Processor& processor, bool postProcessor = false);
185 * @copydoc Dali::Integration::Core::UnregisterProcessors
187 void UnregisterProcessors();
190 * @copydoc Dali::Internal::ThreadLocalStorage::AddScene()
192 void AddScene(Scene* scene);
195 * @copydoc Dali::Internal::ThreadLocalStorage::RemoveScene()
197 void RemoveScene(Scene* scene);
200 * @brief Gets the Object registry.
201 * @return A reference to the object registry
203 ObjectRegistry& GetObjectRegistry() const;
206 * Log the capacity of DALi memory pools
208 void LogMemoryPools() const;
210 public: // Implementation of EventThreadServices
212 * @copydoc EventThreadServices::RegisterObject
214 void RegisterObject(BaseObject* object) override;
217 * @copydoc EventThreadServices::UnregisterObject
219 void UnregisterObject(BaseObject* object) override;
222 * @copydoc EventThreadServices::GetUpdateManager
224 SceneGraph::UpdateManager& GetUpdateManager() override;
227 * @copydoc EventThreadServices::GetRenderController
229 Integration::RenderController& GetRenderController() override;
232 * @copydoc EventThreadServices::ReserveMessageSlot
234 uint32_t* ReserveMessageSlot(uint32_t size, bool updateScene) override;
237 * @copydoc EventThreadServices::GetEventBufferIndex
239 BufferIndex GetEventBufferIndex() const override;
242 using SceneContainer = std::vector<ScenePtr>;
245 * Run each registered processor
247 void RunProcessors();
250 * Run each registered postprocessor
252 void RunPostProcessors();
255 * Run registered processors, and relayout, and flush messages
257 void RelayoutAndFlush(SceneContainer& scenes);
259 // for use by ThreadLocalStorage
262 * Returns the current stage.
263 * @return A smart-pointer to the current stage.
265 StagePtr GetCurrentStage();
268 * Returns the platform abstraction.
269 * @return A reference to the platform abstraction.
271 Integration::PlatformAbstraction& GetPlatform();
274 * Returns the render manager.
275 * @return A reference to the render manager.
277 SceneGraph::RenderManager& GetRenderManager();
280 * Returns the notification manager.
281 * @return A reference to the Notification Manager.
283 NotificationManager& GetNotificationManager();
286 * Returns the Shader factory
287 * @return A reference to the Shader binary factory.
289 ShaderFactory& GetShaderFactory();
292 * Returns the gesture event processor.
293 * @return A reference to the gesture event processor.
295 GestureEventProcessor& GetGestureEventProcessor();
298 * Return the relayout controller
299 * @Return Return a reference to the relayout controller
301 RelayoutController& GetRelayoutController();
304 * @brief Gets the event thread services.
305 * @return A reference to the event thread services
307 EventThreadServices& GetEventThreadServices();
310 * @brief Gets the property notification manager.
311 * @return A reference to the property notification manager
313 PropertyNotificationManager& GetPropertyNotificationManager() const;
316 * @brief Gets the animation play list.
317 * @return A reference to the animation play list
319 AnimationPlaylist& GetAnimationPlaylist() const;
322 * @brief Returns GraphicsConfig
323 * @return A reference to the GraphicsConfig struct.
325 Integration::GraphicsConfig& GetGraphicsConfig() const;
329 * Undefined copy and assignment operators
331 Core(const Core& core) = delete; // No definition
332 Core& operator=(const Core& core) = delete; // No definition
335 * Create Thread local storage
337 void CreateThreadLocalStorage();
340 Integration::RenderController& mRenderController; ///< Reference to Render controller to tell it to keep rendering
341 Integration::PlatformAbstraction& mPlatform; ///< The interface providing platform specific services.
343 IntrusivePtr<Stage> mStage; ///< The current stage
344 OwnerPointer<AnimationPlaylist> mAnimationPlaylist; ///< For 'Fire and forget' animation support
345 OwnerPointer<PropertyNotificationManager> mPropertyNotificationManager; ///< For safe signal emmision of property changed notifications
346 IntrusivePtr<RelayoutController> mRelayoutController; ///< Size negotiation relayout controller
348 OwnerPointer<SceneGraph::RenderTaskProcessor> mRenderTaskProcessor; ///< Handles the processing of render tasks
349 OwnerPointer<SceneGraph::RenderManager> mRenderManager; ///< Render manager
350 OwnerPointer<SceneGraph::UpdateManager> mUpdateManager; ///< Update manager
351 OwnerPointer<ShaderFactory> mShaderFactory; ///< Shader resource factory
352 OwnerPointer<NotificationManager> mNotificationManager; ///< Notification manager
353 OwnerPointer<GestureEventProcessor> mGestureEventProcessor; ///< The gesture event processor
354 Dali::Vector<Integration::Processor*> mProcessors; ///< Registered processors (not owned)
355 Dali::Vector<Integration::Processor*> mPostProcessors; ///< Registered post processors those will called after relayout(not owned)
357 SceneContainer mScenes; ///< A container of scenes that bound to a surface for rendering, owned by Core
359 // The object registry
360 ObjectRegistryPtr mObjectRegistry;
362 Graphics::Controller& mGraphicsController;
364 bool mProcessingEvent : 1; ///< True during ProcessEvents()
365 bool mProcessorUnregistered : 1; ///< True if the processor is unregistered during RunProcessors()
366 bool mPostProcessorUnregistered : 1; ///< True if the post-processor is unregistered during RunPostProcessors()
367 bool mRelayoutFlush : 1; ///< True during RelayoutAndFlush()
369 friend class ThreadLocalStorage;
372 } // namespace Internal
376 #endif // DALI_INTERNAL_CORE_H