1 #ifndef DALI_INTERNAL_CORE_H
2 #define DALI_INTERNAL_CORE_H
5 * Copyright (c) 2019 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;
55 class NotificationManager;
56 class AnimationPlaylist;
57 class PropertyNotificationManager;
59 class GestureEventProcessor;
62 class RelayoutController;
63 class EventThreadServices;
70 class RenderTaskProcessor;
74 * Internal class for Dali::Integration::Core
76 class Core : public EventThreadServices
81 * Create and initialise a new Core instance
83 Core( Integration::RenderController& renderController,
84 Integration::PlatformAbstraction& platform,
85 Integration::GlAbstraction& glAbstraction,
86 Integration::GlSyncAbstraction& glSyncAbstraction,
87 Integration::GlContextHelperAbstraction& glContextHelperAbstraction,
88 ResourcePolicy::DataRetention dataRetentionPolicy,
89 Integration::RenderToFrameBuffer renderToFboEnabled,
90 Integration::DepthBufferAvailable depthBufferAvailable,
91 Integration::StencilBufferAvailable stencilBufferAvailable );
99 * @copydoc Dali::Integration::Core::Initialize()
104 * @copydoc Dali::Integration::Core::GetContextNotifier()
106 Integration::ContextNotifierInterface* GetContextNotifier();
109 * @copydoc Dali::Integration::Core::ContextCreated()
111 void ContextCreated();
114 * @copydoc Dali::Integration::Core::ContextDestroyed()
116 void ContextDestroyed();
119 * @copydoc Dali::Integration::Core::RecoverFromContextLoss()
121 void RecoverFromContextLoss();
124 * @copydoc Dali::Integration::Core::SurfaceResized(Integration::RenderSurface*)
126 void SurfaceResized( Integration::RenderSurface* surface );
129 * @copydoc Dali::Integration::Core::SurfaceDeleted(Integration::RenderSurface*)
131 void SurfaceDeleted( Integration::RenderSurface* surface );
134 * @copydoc Dali::Integration::Core::SetMinimumFrameTimeInterval(uint32_t)
136 void SetMinimumFrameTimeInterval(uint32_t interval);
139 * @copydoc Dali::Integration::Core::Update()
141 void Update( float elapsedSeconds, uint32_t lastVSyncTimeMilliseconds, uint32_t nextVSyncTimeMilliseconds, Integration::UpdateStatus& status, bool renderToFboEnabled, bool isRenderingToFbo );
144 * @copydoc Dali::Integration::Core::Render()
146 void Render( Integration::RenderStatus& status, bool forceClear );
149 * @copydoc Dali::Integration::Core::SceneCreated()
154 * @copydoc Dali::Integration::Core::QueueEvent(const Integration::Event&)
156 void QueueEvent( const Integration::Event& event );
159 * @copydoc Dali::Integration::Core::ProcessEvents()
161 void ProcessEvents();
164 * @copydoc Dali::Integration::Core::GetMaximumUpdateCount()
166 uint32_t GetMaximumUpdateCount() const;
169 * @copydoc Dali::Integration::Core::RegisterProcessor
171 void RegisterProcessor( Dali::Integration::Processor& processor );
174 * @copydoc Dali::Integration::Core::UnregisterProcessor
176 void UnregisterProcessor( Dali::Integration::Processor& processor );
179 * @copydoc Dali::Internal::ThreadLocalStorage::AddScene()
181 void AddScene( Scene* scene );
184 * @copydoc Dali::Internal::ThreadLocalStorage::RemoveScene()
186 void RemoveScene( Scene* scene );
188 public: // Implementation of EventThreadServices
191 * @copydoc EventThreadServices::RegisterObject
193 void RegisterObject( BaseObject* object) override;
196 * @copydoc EventThreadServices::UnregisterObject
198 void UnregisterObject( BaseObject* object) override;
201 * @copydoc EventThreadServices::GetUpdateManager
203 SceneGraph::UpdateManager& GetUpdateManager() override;
206 * @copydoc EventThreadServices::GetRenderController
208 Integration::RenderController& GetRenderController() override;
211 * @copydoc EventThreadServices::ReserveMessageSlot
213 uint32_t* ReserveMessageSlot( uint32_t size, bool updateScene ) override;
216 * @copydoc EventThreadServices::GetEventBufferIndex
218 BufferIndex GetEventBufferIndex() const override;
221 * @copydoc EventThreadServices::ForceNextUpdate
223 void ForceNextUpdate() override;
226 * @copydoc EventThreadServices::IsNextUpdateForced
228 bool IsNextUpdateForced() override;
232 * Run each registered processor
234 void RunProcessors();
236 // for use by ThreadLocalStorage
239 * Returns the current stage.
240 * @return A smart-pointer to the current stage.
242 StagePtr GetCurrentStage();
245 * Returns the platform abstraction.
246 * @return A reference to the platform abstraction.
248 Integration::PlatformAbstraction& GetPlatform();
251 * Returns the render manager.
252 * @return A reference to the render manager.
254 SceneGraph::RenderManager& GetRenderManager();
257 * Returns the notification manager.
258 * @return A reference to the Notification Manager.
260 NotificationManager& GetNotificationManager();
263 * Returns the Shader factory
264 * @return A reference to the Shader binary factory.
266 ShaderFactory& GetShaderFactory();
269 * Returns the gesture event processor.
270 * @return A reference to the gesture event processor.
272 GestureEventProcessor& GetGestureEventProcessor();
275 * Return the relayout controller
276 * @Return Return a reference to the relayout controller
278 RelayoutController& GetRelayoutController();
281 * @brief Gets the Object registry.
282 * @return A reference to the object registry
284 ObjectRegistry& GetObjectRegistry() const;
287 * @brief Gets the event thread services.
288 * @return A reference to the event thread services
290 EventThreadServices& GetEventThreadServices();
293 * @brief Gets the property notification manager.
294 * @return A reference to the property notification manager
296 PropertyNotificationManager& GetPropertyNotificationManager() const;
299 * @brief Gets the animation play list.
300 * @return A reference to the animation play list
302 AnimationPlaylist& GetAnimationPlaylist() const;
307 * Undefined copy and assignment operators
309 Core(const Core& core) = delete; // No definition
310 Core& operator=(const Core& core) = delete; // No definition
313 * Create Thread local storage
315 void CreateThreadLocalStorage();
319 Integration::RenderController& mRenderController; ///< Reference to Render controller to tell it to keep rendering
320 Integration::PlatformAbstraction& mPlatform; ///< The interface providing platform specific services.
322 IntrusivePtr<Stage> mStage; ///< The current stage
323 AnimationPlaylistOwner mAnimationPlaylist; ///< For 'Fire and forget' animation support
324 OwnerPointer<PropertyNotificationManager> mPropertyNotificationManager; ///< For safe signal emmision of property changed notifications
325 IntrusivePtr< RelayoutController > mRelayoutController; ///< Size negotiation relayout controller
327 OwnerPointer<SceneGraph::RenderTaskProcessor> mRenderTaskProcessor; ///< Handles the processing of render tasks
328 OwnerPointer<SceneGraph::RenderManager> mRenderManager; ///< Render manager
329 OwnerPointer<SceneGraph::UpdateManager> mUpdateManager; ///< Update manager
330 OwnerPointer<SceneGraph::DiscardQueue> mDiscardQueue; ///< Used to cleanup nodes & resources when no longer in use.
331 OwnerPointer<ShaderFactory> mShaderFactory; ///< Shader resource factory
332 OwnerPointer<NotificationManager> mNotificationManager; ///< Notification manager
333 OwnerPointer<GestureEventProcessor> mGestureEventProcessor; ///< The gesture event processor
334 Dali::Vector<Integration::Processor*> mProcessors; ///< Registered processors (not owned)
336 using SceneContainer = std::vector<ScenePtr>;
337 SceneContainer mScenes; ///< A container of scenes that bound to a surface for rendering, owned by Core
339 // The object registry
340 ObjectRegistryPtr mObjectRegistry;
342 bool mProcessingEvent : 1; ///< True during ProcessEvents()
343 bool mForceNextUpdate:1; ///< True if the next rendering is really required.
345 friend class ThreadLocalStorage;
349 } // namespace Internal
353 #endif // DALI_INTERNAL_CORE_H