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;
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 ResourcePolicy::DataRetention dataRetentionPolicy,
87 Integration::RenderToFrameBuffer renderToFboEnabled,
88 Integration::DepthBufferAvailable depthBufferAvailable,
89 Integration::StencilBufferAvailable stencilBufferAvailable );
97 * @copydoc Dali::Integration::Core::Initialize()
102 * @copydoc Dali::Integration::Core::GetContextNotifier()
104 Integration::ContextNotifierInterface* GetContextNotifier();
107 * @copydoc Dali::Integration::Core::ContextCreated()
109 void ContextCreated();
112 * @copydoc Dali::Integration::Core::ContextDestroyed()
114 void ContextDestroyed();
117 * @copydoc Dali::Integration::Core::RecoverFromContextLoss()
119 void RecoverFromContextLoss();
122 * @copydoc Dali::Integration::Core::SurfaceResized(Integration::RenderSurface*)
124 void SurfaceResized( Integration::RenderSurface* surface );
127 * @copydoc Dali::Integration::Core::SetMinimumFrameTimeInterval(uint32_t)
129 void SetMinimumFrameTimeInterval(uint32_t interval);
132 * @copydoc Dali::Integration::Core::Update()
134 void Update( float elapsedSeconds, uint32_t lastVSyncTimeMilliseconds, uint32_t nextVSyncTimeMilliseconds, Integration::UpdateStatus& status, bool renderToFboEnabled, bool isRenderingToFbo );
137 * @copydoc Dali::Integration::Core::Render()
139 void Render( Integration::RenderStatus& status, bool forceClear );
142 * @copydoc Dali::Integration::Core::SceneCreated()
147 * @copydoc Dali::Integration::Core::QueueEvent(const Integration::Event&)
149 void QueueEvent( const Integration::Event& event );
152 * @copydoc Dali::Integration::Core::ProcessEvents()
154 void ProcessEvents();
157 * @copydoc Dali::Integration::Core::GetMaximumUpdateCount()
159 uint32_t GetMaximumUpdateCount() const;
162 * @copydoc Dali::Integration::Core::RegisterProcessor
164 void RegisterProcessor( Dali::Integration::Processor& processor );
167 * @copydoc Dali::Integration::Core::UnregisterProcessor
169 void UnregisterProcessor( Dali::Integration::Processor& processor );
172 * @copydoc Dali::Internal::ThreadLocalStorage::AddScene()
174 void AddScene( Scene* scene );
177 * @copydoc Dali::Internal::ThreadLocalStorage::RemoveScene()
179 void RemoveScene( Scene* scene );
181 public: // Implementation of EventThreadServices
184 * @copydoc EventThreadServices::RegisterObject
186 void RegisterObject( BaseObject* object) override;
189 * @copydoc EventThreadServices::UnregisterObject
191 void UnregisterObject( BaseObject* object) override;
194 * @copydoc EventThreadServices::GetUpdateManager
196 SceneGraph::UpdateManager& GetUpdateManager() override;
199 * @copydoc EventThreadServices::GetRenderController
201 Integration::RenderController& GetRenderController() override;
204 * @copydoc EventThreadServices::ReserveMessageSlot
206 uint32_t* ReserveMessageSlot( uint32_t size, bool updateScene ) override;
209 * @copydoc EventThreadServices::GetEventBufferIndex
211 BufferIndex GetEventBufferIndex() const override;
214 * @copydoc EventThreadServices::ForceNextUpdate
216 void ForceNextUpdate() override;
219 * @copydoc EventThreadServices::IsNextUpdateForced
221 bool IsNextUpdateForced() override;
225 * Run each registered processor
227 void RunProcessors();
229 // for use by ThreadLocalStorage
232 * Returns the current stage.
233 * @return A smart-pointer to the current stage.
235 StagePtr GetCurrentStage();
238 * Returns the platform abstraction.
239 * @return A reference to the platform abstraction.
241 Integration::PlatformAbstraction& GetPlatform();
244 * Returns the render manager.
245 * @return A reference to the render manager.
247 SceneGraph::RenderManager& GetRenderManager();
250 * Returns the notification manager.
251 * @return A reference to the Notification Manager.
253 NotificationManager& GetNotificationManager();
256 * Returns the Shader factory
257 * @return A reference to the Shader binary factory.
259 ShaderFactory& GetShaderFactory();
262 * Returns the gesture event processor.
263 * @return A reference to the gesture event processor.
265 GestureEventProcessor& GetGestureEventProcessor();
268 * Return the relayout controller
269 * @Return Return a reference to the relayout controller
271 RelayoutController& GetRelayoutController();
274 * @brief Gets the Object registry.
275 * @return A reference to the object registry
277 ObjectRegistry& GetObjectRegistry() const;
280 * @brief Gets the event thread services.
281 * @return A reference to the event thread services
283 EventThreadServices& GetEventThreadServices();
286 * @brief Gets the property notification manager.
287 * @return A reference to the property notification manager
289 PropertyNotificationManager& GetPropertyNotificationManager() const;
292 * @brief Gets the animation play list.
293 * @return A reference to the animation play list
295 AnimationPlaylist& GetAnimationPlaylist() const;
300 * Undefined copy and assignment operators
302 Core(const Core& core) = delete; // No definition
303 Core& operator=(const Core& core) = delete; // No definition
306 * Create Thread local storage
308 void CreateThreadLocalStorage();
312 Integration::RenderController& mRenderController; ///< Reference to Render controller to tell it to keep rendering
313 Integration::PlatformAbstraction& mPlatform; ///< The interface providing platform specific services.
315 IntrusivePtr<Stage> mStage; ///< The current stage
316 AnimationPlaylistOwner mAnimationPlaylist; ///< For 'Fire and forget' animation support
317 OwnerPointer<PropertyNotificationManager> mPropertyNotificationManager; ///< For safe signal emmision of property changed notifications
318 IntrusivePtr< RelayoutController > mRelayoutController; ///< Size negotiation relayout controller
320 OwnerPointer<SceneGraph::RenderTaskProcessor> mRenderTaskProcessor; ///< Handles the processing of render tasks
321 OwnerPointer<SceneGraph::RenderManager> mRenderManager; ///< Render manager
322 OwnerPointer<SceneGraph::UpdateManager> mUpdateManager; ///< Update manager
323 OwnerPointer<SceneGraph::DiscardQueue> mDiscardQueue; ///< Used to cleanup nodes & resources when no longer in use.
324 OwnerPointer<ShaderFactory> mShaderFactory; ///< Shader resource factory
325 OwnerPointer<NotificationManager> mNotificationManager; ///< Notification manager
326 OwnerPointer<GestureEventProcessor> mGestureEventProcessor; ///< The gesture event processor
327 Dali::Vector<Integration::Processor*> mProcessors; ///< Registered processors (not owned)
329 using SceneContainer = std::vector<ScenePtr>;
330 SceneContainer mScenes; ///< A container of scenes that bound to a surface for rendering, owned by Core
332 // The object registry
333 ObjectRegistryPtr mObjectRegistry;
335 bool mProcessingEvent : 1; ///< True during ProcessEvents()
336 bool mForceNextUpdate:1; ///< True if the next rendering is really required.
338 friend class ThreadLocalStorage;
342 } // namespace Internal
346 #endif // DALI_INTERNAL_CORE_H