1 #ifndef DALI_INTERNAL_CORE_H
2 #define DALI_INTERNAL_CORE_H
5 * Copyright (c) 2020 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/public-api/common/dali-vector.h>
23 #include <dali/public-api/object/ref-object.h>
24 #include <dali/integration-api/context-notifier.h>
25 #include <dali/integration-api/core-enumerations.h>
26 #include <dali/internal/common/owner-pointer.h>
27 #include <dali/devel-api/common/owner-container.h>
28 #include <dali/internal/event/animation/animation-playlist-declarations.h>
29 #include <dali/internal/event/common/stage-def.h>
30 #include <dali/integration-api/resource-policies.h>
31 #include <dali/internal/event/common/scene-impl.h>
32 #include <dali/internal/event/common/object-registry-impl.h>
40 class RenderController;
41 class PlatformAbstraction;
43 class GlSyncAbstraction;
44 class GlContextHelperAbstraction;
54 class NotificationManager;
55 class AnimationPlaylist;
56 class PropertyNotificationManager;
58 class GestureEventProcessor;
61 class RelayoutController;
62 class EventThreadServices;
69 class RenderTaskProcessor;
73 * Internal class for Dali::Integration::Core
75 class Core : public EventThreadServices
80 * Create and initialise a new Core instance
82 Core( Integration::RenderController& renderController,
83 Integration::PlatformAbstraction& platform,
84 Integration::GlAbstraction& glAbstraction,
85 Integration::GlSyncAbstraction& glSyncAbstraction,
86 Integration::GlContextHelperAbstraction& glContextHelperAbstraction,
87 Integration::RenderToFrameBuffer renderToFboEnabled,
88 Integration::DepthBufferAvailable depthBufferAvailable,
89 Integration::StencilBufferAvailable stencilBufferAvailable,
90 Integration::PartialUpdateAvailable partialUpdateAvailable );
98 * @copydoc Dali::Integration::Core::Initialize()
103 * @copydoc Dali::Integration::Core::GetContextNotifier()
105 Integration::ContextNotifierInterface* GetContextNotifier();
108 * @copydoc Dali::Integration::Core::ContextCreated()
110 void ContextCreated();
113 * @copydoc Dali::Integration::Core::ContextDestroyed()
115 void ContextDestroyed();
118 * @copydoc Dali::Integration::Core::RecoverFromContextLoss()
120 void RecoverFromContextLoss();
123 * @copydoc Dali::Integration::Core::SetMinimumFrameTimeInterval(uint32_t)
125 void SetMinimumFrameTimeInterval(uint32_t interval);
128 * @copydoc Dali::Integration::Core::Update()
130 void Update( float elapsedSeconds, uint32_t lastVSyncTimeMilliseconds, uint32_t nextVSyncTimeMilliseconds, Integration::UpdateStatus& status, bool renderToFboEnabled, bool isRenderingToFbo );
133 * @copydoc Dali::Integration::Core::PreRender()
135 void PreRender( Integration::RenderStatus& status, bool forceClear, bool uploadOnly );
138 * @copydoc Dali::Integration::Core::PreRender()
140 void PreRender( Integration::Scene& scene, std::vector<Rect<int>>& damagedRects );
143 * @copydoc Dali::Integration::Core::RenderScene()
145 void RenderScene( Integration::RenderStatus& status, Integration::Scene& scene, bool renderToFbo );
148 * @copydoc Dali::Integration::Core::RenderScene()
150 void RenderScene( Integration::RenderStatus& status, Integration::Scene& scene, bool renderToFbo, Rect<int>& clippingRect );
153 * @copydoc Dali::Integration::Core::Render()
155 void PostRender( bool uploadOnly );
158 * @copydoc Dali::Integration::Core::SceneCreated()
163 * @copydoc Dali::Integration::Core::QueueEvent(const Integration::Event&)
165 void QueueEvent( const Integration::Event& event );
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( Dali::Integration::Processor& processor );
183 * @copydoc Dali::Integration::Core::UnregisterProcessor
185 void UnregisterProcessor( Dali::Integration::Processor& processor );
188 * @copydoc Dali::Internal::ThreadLocalStorage::AddScene()
190 void AddScene( Scene* scene );
193 * @copydoc Dali::Internal::ThreadLocalStorage::RemoveScene()
195 void RemoveScene( Scene* scene );
197 public: // Implementation of EventThreadServices
200 * @copydoc EventThreadServices::RegisterObject
202 void RegisterObject( BaseObject* object) override;
205 * @copydoc EventThreadServices::UnregisterObject
207 void UnregisterObject( BaseObject* object) override;
210 * @copydoc EventThreadServices::GetUpdateManager
212 SceneGraph::UpdateManager& GetUpdateManager() override;
215 * @copydoc EventThreadServices::GetRenderController
217 Integration::RenderController& GetRenderController() override;
220 * @copydoc EventThreadServices::ReserveMessageSlot
222 uint32_t* ReserveMessageSlot( uint32_t size, bool updateScene ) override;
225 * @copydoc EventThreadServices::GetEventBufferIndex
227 BufferIndex GetEventBufferIndex() const override;
230 * @copydoc EventThreadServices::ForceNextUpdate
232 void ForceNextUpdate() override;
235 * @copydoc EventThreadServices::IsNextUpdateForced
237 bool IsNextUpdateForced() override;
241 * Run each registered processor
243 void RunProcessors();
245 // for use by ThreadLocalStorage
248 * Returns the current stage.
249 * @return A smart-pointer to the current stage.
251 StagePtr GetCurrentStage();
254 * Returns the platform abstraction.
255 * @return A reference to the platform abstraction.
257 Integration::PlatformAbstraction& GetPlatform();
260 * Returns the render manager.
261 * @return A reference to the render manager.
263 SceneGraph::RenderManager& GetRenderManager();
266 * Returns the notification manager.
267 * @return A reference to the Notification Manager.
269 NotificationManager& GetNotificationManager();
272 * Returns the Shader factory
273 * @return A reference to the Shader binary factory.
275 ShaderFactory& GetShaderFactory();
278 * Returns the gesture event processor.
279 * @return A reference to the gesture event processor.
281 GestureEventProcessor& GetGestureEventProcessor();
284 * Return the relayout controller
285 * @Return Return a reference to the relayout controller
287 RelayoutController& GetRelayoutController();
290 * @brief Gets the Object registry.
291 * @return A reference to the object registry
293 ObjectRegistry& GetObjectRegistry() const;
296 * @brief Gets the event thread services.
297 * @return A reference to the event thread services
299 EventThreadServices& GetEventThreadServices();
302 * @brief Gets the property notification manager.
303 * @return A reference to the property notification manager
305 PropertyNotificationManager& GetPropertyNotificationManager() const;
308 * @brief Gets the animation play list.
309 * @return A reference to the animation play list
311 AnimationPlaylist& GetAnimationPlaylist() const;
316 * Undefined copy and assignment operators
318 Core(const Core& core) = delete; // No definition
319 Core& operator=(const Core& core) = delete; // No definition
322 * Create Thread local storage
324 void CreateThreadLocalStorage();
328 Integration::RenderController& mRenderController; ///< Reference to Render controller to tell it to keep rendering
329 Integration::PlatformAbstraction& mPlatform; ///< The interface providing platform specific services.
331 IntrusivePtr<Stage> mStage; ///< The current stage
332 AnimationPlaylistOwner mAnimationPlaylist; ///< For 'Fire and forget' animation support
333 OwnerPointer<PropertyNotificationManager> mPropertyNotificationManager; ///< For safe signal emmision of property changed notifications
334 IntrusivePtr< RelayoutController > mRelayoutController; ///< Size negotiation relayout controller
336 OwnerPointer<SceneGraph::RenderTaskProcessor> mRenderTaskProcessor; ///< Handles the processing of render tasks
337 OwnerPointer<SceneGraph::RenderManager> mRenderManager; ///< Render manager
338 OwnerPointer<SceneGraph::UpdateManager> mUpdateManager; ///< Update manager
339 OwnerPointer<SceneGraph::DiscardQueue> mDiscardQueue; ///< Used to cleanup nodes & resources when no longer in use.
340 OwnerPointer<ShaderFactory> mShaderFactory; ///< Shader resource factory
341 OwnerPointer<NotificationManager> mNotificationManager; ///< Notification manager
342 OwnerPointer<GestureEventProcessor> mGestureEventProcessor; ///< The gesture event processor
343 Dali::Vector<Integration::Processor*> mProcessors; ///< Registered processors (not owned)
345 using SceneContainer = std::vector<ScenePtr>;
346 SceneContainer mScenes; ///< A container of scenes that bound to a surface for rendering, owned by Core
348 // The object registry
349 ObjectRegistryPtr mObjectRegistry;
351 bool mProcessingEvent : 1; ///< True during ProcessEvents()
352 bool mForceNextUpdate:1; ///< True if the next rendering is really required.
354 friend class ThreadLocalStorage;
358 } // namespace Internal
362 #endif // DALI_INTERNAL_CORE_H