1 #ifndef DALI_INTERNAL_CORE_H
2 #define DALI_INTERNAL_CORE_H
5 * Copyright (c) 2022 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/animation/animation-playlist-declarations.h>
28 #include <dali/internal/event/common/object-registry-impl.h>
29 #include <dali/internal/event/common/scene-impl.h>
30 #include <dali/internal/event/common/stage-def.h>
31 #include <dali/public-api/common/dali-vector.h>
32 #include <dali/public-api/object/ref-object.h>
44 class RenderController;
46 class PlatformAbstraction;
51 } // namespace Integration
55 class NotificationManager;
56 class AnimationPlaylist;
57 class PropertyNotificationManager;
59 class GestureEventProcessor;
62 class RelayoutController;
63 class EventThreadServices;
70 class RenderTaskProcessor;
71 } // namespace SceneGraph
74 * Internal class for Dali::Integration::Core
76 class Core : public EventThreadServices
80 * Create and initialise a new Core instance
82 Core(Integration::RenderController& renderController,
83 Integration::PlatformAbstraction& platform,
84 Graphics::Controller& graphicsController,
85 Integration::RenderToFrameBuffer renderToFboEnabled,
86 Integration::DepthBufferAvailable depthBufferAvailable,
87 Integration::StencilBufferAvailable stencilBufferAvailable,
88 Integration::PartialUpdateAvailable partialUpdateAvailable);
96 * @copydoc Dali::Integration::Core::Initialize()
101 * @copydoc Dali::Integration::Core::GetContextNotifier()
103 Integration::ContextNotifierInterface* GetContextNotifier();
106 * @copydoc Dali::Integration::Core::ContextCreated()
108 void ContextCreated();
111 * @copydoc Dali::Integration::Core::ContextDestroyed()
113 void ContextDestroyed();
116 * @copydoc Dali::Integration::Core::RecoverFromContextLoss()
118 void RecoverFromContextLoss();
121 * @copydoc Dali::Integration::Core::SetMinimumFrameTimeInterval(uint32_t)
123 void SetMinimumFrameTimeInterval(uint32_t interval);
126 * @copydoc Dali::Integration::Core::Update()
128 void Update(float elapsedSeconds, uint32_t lastVSyncTimeMilliseconds, uint32_t nextVSyncTimeMilliseconds, Integration::UpdateStatus& status, bool renderToFboEnabled, bool isRenderingToFbo, bool uploadOnly);
131 * @copydoc Dali::Integration::Core::PreRender()
133 void PreRender(Integration::RenderStatus& status, bool forceClear);
136 * @copydoc Dali::Integration::Core::PreRender()
138 void PreRender(Integration::Scene& scene, std::vector<Rect<int>>& damagedRects);
141 * @copydoc Dali::Integration::Core::RenderScene()
143 void RenderScene(Integration::RenderStatus& status, Integration::Scene& scene, bool renderToFbo);
146 * @copydoc Dali::Integration::Core::RenderScene()
148 void RenderScene(Integration::RenderStatus& status, Integration::Scene& scene, bool renderToFbo, Rect<int>& clippingRect);
151 * @copydoc Dali::Integration::Core::Render()
156 * @copydoc Dali::Integration::Core::SceneCreated()
161 * @copydoc Dali::Integration::Core::QueueEvent(const Integration::Event&)
163 void QueueEvent(const Integration::Event& event);
166 * @copydoc Dali::Integration::Core::ProcessEvents()
168 void ProcessEvents();
171 * @copydoc Dali::Integration::Core::GetMaximumUpdateCount()
173 uint32_t GetMaximumUpdateCount() const;
176 * @copydoc Dali::Integration::Core::RegisterProcessor
178 void RegisterProcessor(Integration::Processor& processor, bool postProcessor = false);
181 * @copydoc Dali::Integration::Core::UnregisterProcessor
183 void UnregisterProcessor(Dali::Integration::Processor& processor, bool postProcessor = false);
186 * @copydoc Dali::Internal::ThreadLocalStorage::AddScene()
188 void AddScene(Scene* scene);
191 * @copydoc Dali::Internal::ThreadLocalStorage::RemoveScene()
193 void RemoveScene(Scene* scene);
196 * @brief Gets the Object registry.
197 * @return A reference to the object registry
199 ObjectRegistry& GetObjectRegistry() const;
202 * Log the capacity of DALi memory pools
204 void LogMemoryPools() const;
206 public: // Implementation of EventThreadServices
208 * @copydoc EventThreadServices::RegisterObject
210 void RegisterObject(BaseObject* object) override;
213 * @copydoc EventThreadServices::UnregisterObject
215 void UnregisterObject(BaseObject* object) override;
218 * @copydoc EventThreadServices::GetUpdateManager
220 SceneGraph::UpdateManager& GetUpdateManager() override;
223 * @copydoc EventThreadServices::GetRenderController
225 Integration::RenderController& GetRenderController() override;
228 * @copydoc EventThreadServices::ReserveMessageSlot
230 uint32_t* ReserveMessageSlot(uint32_t size, bool updateScene) override;
233 * @copydoc EventThreadServices::GetEventBufferIndex
235 BufferIndex GetEventBufferIndex() const override;
238 * @copydoc EventThreadServices::ForceNextUpdate
240 void ForceNextUpdate() override;
243 * @copydoc EventThreadServices::IsNextUpdateForced
245 bool IsNextUpdateForced() override;
249 * Run each registered processor
251 void RunProcessors();
254 * Run each registered postprocessor
256 void RunPostProcessors();
258 // for use by ThreadLocalStorage
261 * Returns the current stage.
262 * @return A smart-pointer to the current stage.
264 StagePtr GetCurrentStage();
267 * Returns the platform abstraction.
268 * @return A reference to the platform abstraction.
270 Integration::PlatformAbstraction& GetPlatform();
273 * Returns the render manager.
274 * @return A reference to the render manager.
276 SceneGraph::RenderManager& GetRenderManager();
279 * Returns the notification manager.
280 * @return A reference to the Notification Manager.
282 NotificationManager& GetNotificationManager();
285 * Returns the Shader factory
286 * @return A reference to the Shader binary factory.
288 ShaderFactory& GetShaderFactory();
291 * Returns the gesture event processor.
292 * @return A reference to the gesture event processor.
294 GestureEventProcessor& GetGestureEventProcessor();
297 * Return the relayout controller
298 * @Return Return a reference to the relayout controller
300 RelayoutController& GetRelayoutController();
303 * @brief Gets the event thread services.
304 * @return A reference to the event thread services
306 EventThreadServices& GetEventThreadServices();
309 * @brief Gets the property notification manager.
310 * @return A reference to the property notification manager
312 PropertyNotificationManager& GetPropertyNotificationManager() const;
315 * @brief Gets the animation play list.
316 * @return A reference to the animation play list
318 AnimationPlaylist& GetAnimationPlaylist() const;
321 * @brief Returns GlAbstraction.
322 * @note Use only for the capability. Do not use this for bypass context
323 * @return GlAbstraction
325 Integration::GlAbstraction& GetGlAbstraction() 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 AnimationPlaylistOwner 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<SceneGraph::DiscardQueue> mDiscardQueue; ///< Used to cleanup nodes & resources when no longer in use.
352 OwnerPointer<ShaderFactory> mShaderFactory; ///< Shader resource factory
353 OwnerPointer<NotificationManager> mNotificationManager; ///< Notification manager
354 OwnerPointer<GestureEventProcessor> mGestureEventProcessor; ///< The gesture event processor
355 Dali::Vector<Integration::Processor*> mProcessors; ///< Registered processors (not owned)
356 Dali::Vector<Integration::Processor*> mPostProcessors; ///< Registered post processors those will called after relayout(not owned)
358 using SceneContainer = std::vector<ScenePtr>;
359 SceneContainer mScenes; ///< A container of scenes that bound to a surface for rendering, owned by Core
361 // The object registry
362 ObjectRegistryPtr mObjectRegistry;
364 Graphics::Controller& mGraphicsController;
366 bool mProcessingEvent : 1; ///< True during ProcessEvents()
367 bool mForceNextUpdate : 1; ///< True if the next rendering is really required.
368 bool mProcessorUnregistered : 1; ///< True if the processor is unregistered during RunProcessors()
369 bool mPostProcessorUnregistered : 1; ///< True if the post-processor is unregistered during RunPostProcessors()
371 friend class ThreadLocalStorage;
374 } // namespace Internal
378 #endif // DALI_INTERNAL_CORE_H