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;
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);
131 * @copydoc Dali::Integration::Core::PreRender()
133 void PreRender(Integration::RenderStatus& status, bool forceClear, bool uploadOnly);
136 * @copydoc Dali::Integration::Core::PreRender()
138 void PreRender(Integration::RenderStatus& status, 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()
153 void PostRender(bool uploadOnly);
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;
201 public: // Implementation of EventThreadServices
203 * @copydoc EventThreadServices::RegisterObject
205 void RegisterObject(BaseObject* object) override;
208 * @copydoc EventThreadServices::UnregisterObject
210 void UnregisterObject(BaseObject* object) override;
213 * @copydoc EventThreadServices::GetUpdateManager
215 SceneGraph::UpdateManager& GetUpdateManager() override;
218 * @copydoc EventThreadServices::GetRenderController
220 Integration::RenderController& GetRenderController() override;
223 * @copydoc EventThreadServices::ReserveMessageSlot
225 uint32_t* ReserveMessageSlot(uint32_t size, bool updateScene) override;
228 * @copydoc EventThreadServices::GetEventBufferIndex
230 BufferIndex GetEventBufferIndex() const override;
233 * @copydoc EventThreadServices::ForceNextUpdate
235 void ForceNextUpdate() override;
238 * @copydoc EventThreadServices::IsNextUpdateForced
240 bool IsNextUpdateForced() override;
244 * Run each registered processor
246 void RunProcessors();
249 * Run each registered postprocessor
251 void RunPostProcessors();
253 // for use by ThreadLocalStorage
256 * Returns the current stage.
257 * @return A smart-pointer to the current stage.
259 StagePtr GetCurrentStage();
262 * Returns the platform abstraction.
263 * @return A reference to the platform abstraction.
265 Integration::PlatformAbstraction& GetPlatform();
268 * Returns the render manager.
269 * @return A reference to the render manager.
271 SceneGraph::RenderManager& GetRenderManager();
274 * Returns the notification manager.
275 * @return A reference to the Notification Manager.
277 NotificationManager& GetNotificationManager();
280 * Returns the Shader factory
281 * @return A reference to the Shader binary factory.
283 ShaderFactory& GetShaderFactory();
286 * Returns the gesture event processor.
287 * @return A reference to the gesture event processor.
289 GestureEventProcessor& GetGestureEventProcessor();
292 * Return the relayout controller
293 * @Return Return a reference to the relayout controller
295 RelayoutController& GetRelayoutController();
298 * @brief Gets the event thread services.
299 * @return A reference to the event thread services
301 EventThreadServices& GetEventThreadServices();
304 * @brief Gets the property notification manager.
305 * @return A reference to the property notification manager
307 PropertyNotificationManager& GetPropertyNotificationManager() const;
310 * @brief Gets the animation play list.
311 * @return A reference to the animation play list
313 AnimationPlaylist& GetAnimationPlaylist() const;
316 * @brief Returns GlAbstraction.
317 * @note Use only for the capability. Do not use this for bypass context
318 * @return GlAbstraction
320 Integration::GlAbstraction& GetGlAbstraction() const;
324 * Undefined copy and assignment operators
326 Core(const Core& core) = delete; // No definition
327 Core& operator=(const Core& core) = delete; // No definition
330 * Create Thread local storage
332 void CreateThreadLocalStorage();
335 Integration::RenderController& mRenderController; ///< Reference to Render controller to tell it to keep rendering
336 Integration::PlatformAbstraction& mPlatform; ///< The interface providing platform specific services.
338 IntrusivePtr<Stage> mStage; ///< The current stage
339 AnimationPlaylistOwner mAnimationPlaylist; ///< For 'Fire and forget' animation support
340 OwnerPointer<PropertyNotificationManager> mPropertyNotificationManager; ///< For safe signal emmision of property changed notifications
341 IntrusivePtr<RelayoutController> mRelayoutController; ///< Size negotiation relayout controller
343 OwnerPointer<SceneGraph::RenderTaskProcessor> mRenderTaskProcessor; ///< Handles the processing of render tasks
344 OwnerPointer<SceneGraph::RenderManager> mRenderManager; ///< Render manager
345 OwnerPointer<SceneGraph::UpdateManager> mUpdateManager; ///< Update manager
346 OwnerPointer<SceneGraph::DiscardQueue> mDiscardQueue; ///< Used to cleanup nodes & resources when no longer in use.
347 OwnerPointer<ShaderFactory> mShaderFactory; ///< Shader resource factory
348 OwnerPointer<NotificationManager> mNotificationManager; ///< Notification manager
349 OwnerPointer<GestureEventProcessor> mGestureEventProcessor; ///< The gesture event processor
350 Dali::Vector<Integration::Processor*> mProcessors; ///< Registered processors (not owned)
351 Dali::Vector<Integration::Processor*> mPostProcessors; ///< Registered post processors those will called after relayout(not owned)
353 using SceneContainer = std::vector<ScenePtr>;
354 SceneContainer mScenes; ///< A container of scenes that bound to a surface for rendering, owned by Core
356 // The object registry
357 ObjectRegistryPtr mObjectRegistry;
359 Graphics::Controller& mGraphicsController;
361 bool mProcessingEvent : 1; ///< True during ProcessEvents()
362 bool mForceNextUpdate : 1; ///< True if the next rendering is really required.
364 friend class ThreadLocalStorage;
367 } // namespace Internal
371 #endif // DALI_INTERNAL_CORE_H