1 #ifndef DALI_INTERNAL_CORE_H
2 #define DALI_INTERNAL_CORE_H
5 * Copyright (c) 2021 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;
45 class PlatformAbstraction;
50 } // namespace Integration
54 class NotificationManager;
55 class AnimationPlaylist;
56 class PropertyNotificationManager;
58 class GestureEventProcessor;
61 class RelayoutController;
62 class EventThreadServices;
69 class RenderTaskProcessor;
70 } // namespace SceneGraph
73 * Internal class for Dali::Integration::Core
75 class Core : public EventThreadServices
79 * Create and initialise a new Core instance
81 Core(Integration::RenderController& renderController,
82 Integration::PlatformAbstraction& platform,
83 Graphics::Controller& graphicsController,
84 Integration::RenderToFrameBuffer renderToFboEnabled,
85 Integration::DepthBufferAvailable depthBufferAvailable,
86 Integration::StencilBufferAvailable stencilBufferAvailable,
87 Integration::PartialUpdateAvailable partialUpdateAvailable);
95 * @copydoc Dali::Integration::Core::Initialize()
100 * @copydoc Dali::Integration::Core::GetContextNotifier()
102 Integration::ContextNotifierInterface* GetContextNotifier();
105 * @copydoc Dali::Integration::Core::ContextCreated()
107 void ContextCreated();
110 * @copydoc Dali::Integration::Core::ContextDestroyed()
112 void ContextDestroyed();
115 * @copydoc Dali::Integration::Core::RecoverFromContextLoss()
117 void RecoverFromContextLoss();
120 * @copydoc Dali::Integration::Core::SetMinimumFrameTimeInterval(uint32_t)
122 void SetMinimumFrameTimeInterval(uint32_t interval);
125 * @copydoc Dali::Integration::Core::Update()
127 void Update(float elapsedSeconds, uint32_t lastVSyncTimeMilliseconds, uint32_t nextVSyncTimeMilliseconds, Integration::UpdateStatus& status, bool renderToFboEnabled, bool isRenderingToFbo);
130 * @copydoc Dali::Integration::Core::PreRender()
132 void PreRender(Integration::RenderStatus& status, bool forceClear, bool uploadOnly);
135 * @copydoc Dali::Integration::Core::PreRender()
137 void PreRender(Integration::Scene& scene, std::vector<Rect<int>>& damagedRects);
140 * @copydoc Dali::Integration::Core::RenderScene()
142 void RenderScene(Integration::RenderStatus& status, Integration::Scene& scene, bool renderToFbo);
145 * @copydoc Dali::Integration::Core::RenderScene()
147 void RenderScene(Integration::RenderStatus& status, Integration::Scene& scene, bool renderToFbo, Rect<int>& clippingRect);
150 * @copydoc Dali::Integration::Core::Render()
152 void PostRender(bool uploadOnly);
155 * @copydoc Dali::Integration::Core::SceneCreated()
160 * @copydoc Dali::Integration::Core::QueueEvent(const Integration::Event&)
162 void QueueEvent(const Integration::Event& event);
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(Dali::Integration::Processor& processor);
180 * @copydoc Dali::Integration::Core::UnregisterProcessor
182 void UnregisterProcessor(Dali::Integration::Processor& processor);
185 * @copydoc Dali::Internal::ThreadLocalStorage::AddScene()
187 void AddScene(Scene* scene);
190 * @copydoc Dali::Internal::ThreadLocalStorage::RemoveScene()
192 void RemoveScene(Scene* scene);
195 * @brief Gets the Object registry.
196 * @return A reference to the object registry
198 ObjectRegistry& GetObjectRegistry() const;
200 public: // Implementation of EventThreadServices
202 * @copydoc EventThreadServices::RegisterObject
204 void RegisterObject(BaseObject* object) override;
207 * @copydoc EventThreadServices::UnregisterObject
209 void UnregisterObject(BaseObject* object) override;
212 * @copydoc EventThreadServices::GetUpdateManager
214 SceneGraph::UpdateManager& GetUpdateManager() override;
217 * @copydoc EventThreadServices::GetRenderController
219 Integration::RenderController& GetRenderController() override;
222 * @copydoc EventThreadServices::ReserveMessageSlot
224 uint32_t* ReserveMessageSlot(uint32_t size, bool updateScene) override;
227 * @copydoc EventThreadServices::GetEventBufferIndex
229 BufferIndex GetEventBufferIndex() const override;
232 * @copydoc EventThreadServices::ForceNextUpdate
234 void ForceNextUpdate() override;
237 * @copydoc EventThreadServices::IsNextUpdateForced
239 bool IsNextUpdateForced() override;
243 * Run each registered processor
245 void RunProcessors();
247 // for use by ThreadLocalStorage
250 * Returns the current stage.
251 * @return A smart-pointer to the current stage.
253 StagePtr GetCurrentStage();
256 * Returns the platform abstraction.
257 * @return A reference to the platform abstraction.
259 Integration::PlatformAbstraction& GetPlatform();
262 * Returns the render manager.
263 * @return A reference to the render manager.
265 SceneGraph::RenderManager& GetRenderManager();
268 * Returns the notification manager.
269 * @return A reference to the Notification Manager.
271 NotificationManager& GetNotificationManager();
274 * Returns the Shader factory
275 * @return A reference to the Shader binary factory.
277 ShaderFactory& GetShaderFactory();
280 * Returns the gesture event processor.
281 * @return A reference to the gesture event processor.
283 GestureEventProcessor& GetGestureEventProcessor();
286 * Return the relayout controller
287 * @Return Return a reference to the relayout controller
289 RelayoutController& GetRelayoutController();
292 * @brief Gets the event thread services.
293 * @return A reference to the event thread services
295 EventThreadServices& GetEventThreadServices();
298 * @brief Gets the property notification manager.
299 * @return A reference to the property notification manager
301 PropertyNotificationManager& GetPropertyNotificationManager() const;
304 * @brief Gets the animation play list.
305 * @return A reference to the animation play list
307 AnimationPlaylist& GetAnimationPlaylist() const;
310 * @brief Returns GlAbstraction.
311 * @note Use only for the capability. Do not use this for bypass context
312 * @return GlAbstraction
314 Integration::GlAbstraction& GetGlAbstraction() const;
318 * Undefined copy and assignment operators
320 Core(const Core& core) = delete; // No definition
321 Core& operator=(const Core& core) = delete; // No definition
324 * Create Thread local storage
326 void CreateThreadLocalStorage();
329 Integration::RenderController& mRenderController; ///< Reference to Render controller to tell it to keep rendering
330 Integration::PlatformAbstraction& mPlatform; ///< The interface providing platform specific services.
332 IntrusivePtr<Stage> mStage; ///< The current stage
333 AnimationPlaylistOwner mAnimationPlaylist; ///< For 'Fire and forget' animation support
334 OwnerPointer<PropertyNotificationManager> mPropertyNotificationManager; ///< For safe signal emmision of property changed notifications
335 IntrusivePtr<RelayoutController> mRelayoutController; ///< Size negotiation relayout controller
337 OwnerPointer<SceneGraph::RenderTaskProcessor> mRenderTaskProcessor; ///< Handles the processing of render tasks
338 OwnerPointer<SceneGraph::RenderManager> mRenderManager; ///< Render manager
339 OwnerPointer<SceneGraph::UpdateManager> mUpdateManager; ///< Update manager
340 OwnerPointer<SceneGraph::DiscardQueue> mDiscardQueue; ///< Used to cleanup nodes & resources when no longer in use.
341 OwnerPointer<ShaderFactory> mShaderFactory; ///< Shader resource factory
342 OwnerPointer<NotificationManager> mNotificationManager; ///< Notification manager
343 OwnerPointer<GestureEventProcessor> mGestureEventProcessor; ///< The gesture event processor
344 Dali::Vector<Integration::Processor*> mProcessors; ///< Registered processors (not owned)
346 using SceneContainer = std::vector<ScenePtr>;
347 SceneContainer mScenes; ///< A container of scenes that bound to a surface for rendering, owned by Core
349 // The object registry
350 ObjectRegistryPtr mObjectRegistry;
352 Graphics::Controller& mGraphicsController;
354 bool mProcessingEvent : 1; ///< True during ProcessEvents()
355 bool mForceNextUpdate : 1; ///< True if the next rendering is really required.
357 friend class ThreadLocalStorage;
360 } // namespace Internal
364 #endif // DALI_INTERNAL_CORE_H