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,
92 Integration::PartialUpdateAvailable partialUpdateAvailable );
100 * @copydoc Dali::Integration::Core::Initialize()
105 * @copydoc Dali::Integration::Core::GetContextNotifier()
107 Integration::ContextNotifierInterface* GetContextNotifier();
110 * @copydoc Dali::Integration::Core::ContextCreated()
112 void ContextCreated();
115 * @copydoc Dali::Integration::Core::ContextDestroyed()
117 void ContextDestroyed();
120 * @copydoc Dali::Integration::Core::RecoverFromContextLoss()
122 void RecoverFromContextLoss();
125 * @copydoc Dali::Integration::Core::SurfaceDeleted(Integration::RenderSurface*)
127 void SurfaceDeleted( Integration::RenderSurface* surface );
130 * @copydoc Dali::Integration::Core::SetMinimumFrameTimeInterval(uint32_t)
132 void SetMinimumFrameTimeInterval(uint32_t interval);
135 * @copydoc Dali::Integration::Core::Update()
137 void Update( float elapsedSeconds, uint32_t lastVSyncTimeMilliseconds, uint32_t nextVSyncTimeMilliseconds, Integration::UpdateStatus& status, bool renderToFboEnabled, bool isRenderingToFbo );
140 * @copydoc Dali::Integration::Core::Render()
142 void Render( Integration::RenderStatus& status, bool forceClear, bool uploadOnly );
145 * @copydoc Dali::Integration::Core::SceneCreated()
150 * @copydoc Dali::Integration::Core::QueueEvent(const Integration::Event&)
152 void QueueEvent( const Integration::Event& event );
155 * @copydoc Dali::Integration::Core::ProcessEvents()
157 void ProcessEvents();
160 * @copydoc Dali::Integration::Core::GetMaximumUpdateCount()
162 uint32_t GetMaximumUpdateCount() const;
165 * @copydoc Dali::Integration::Core::RegisterProcessor
167 void RegisterProcessor( Dali::Integration::Processor& processor );
170 * @copydoc Dali::Integration::Core::UnregisterProcessor
172 void UnregisterProcessor( Dali::Integration::Processor& processor );
175 * @copydoc Dali::Internal::ThreadLocalStorage::AddScene()
177 void AddScene( Scene* scene );
180 * @copydoc Dali::Internal::ThreadLocalStorage::RemoveScene()
182 void RemoveScene( Scene* scene );
184 public: // Implementation of EventThreadServices
187 * @copydoc EventThreadServices::RegisterObject
189 void RegisterObject( BaseObject* object) override;
192 * @copydoc EventThreadServices::UnregisterObject
194 void UnregisterObject( BaseObject* object) override;
197 * @copydoc EventThreadServices::GetUpdateManager
199 SceneGraph::UpdateManager& GetUpdateManager() override;
202 * @copydoc EventThreadServices::GetRenderController
204 Integration::RenderController& GetRenderController() override;
207 * @copydoc EventThreadServices::ReserveMessageSlot
209 uint32_t* ReserveMessageSlot( uint32_t size, bool updateScene ) override;
212 * @copydoc EventThreadServices::GetEventBufferIndex
214 BufferIndex GetEventBufferIndex() const override;
217 * @copydoc EventThreadServices::ForceNextUpdate
219 void ForceNextUpdate() override;
222 * @copydoc EventThreadServices::IsNextUpdateForced
224 bool IsNextUpdateForced() override;
228 * Run each registered processor
230 void RunProcessors();
232 // for use by ThreadLocalStorage
235 * Returns the current stage.
236 * @return A smart-pointer to the current stage.
238 StagePtr GetCurrentStage();
241 * Returns the platform abstraction.
242 * @return A reference to the platform abstraction.
244 Integration::PlatformAbstraction& GetPlatform();
247 * Returns the render manager.
248 * @return A reference to the render manager.
250 SceneGraph::RenderManager& GetRenderManager();
253 * Returns the notification manager.
254 * @return A reference to the Notification Manager.
256 NotificationManager& GetNotificationManager();
259 * Returns the Shader factory
260 * @return A reference to the Shader binary factory.
262 ShaderFactory& GetShaderFactory();
265 * Returns the gesture event processor.
266 * @return A reference to the gesture event processor.
268 GestureEventProcessor& GetGestureEventProcessor();
271 * Return the relayout controller
272 * @Return Return a reference to the relayout controller
274 RelayoutController& GetRelayoutController();
277 * @brief Gets the Object registry.
278 * @return A reference to the object registry
280 ObjectRegistry& GetObjectRegistry() const;
283 * @brief Gets the event thread services.
284 * @return A reference to the event thread services
286 EventThreadServices& GetEventThreadServices();
289 * @brief Gets the property notification manager.
290 * @return A reference to the property notification manager
292 PropertyNotificationManager& GetPropertyNotificationManager() const;
295 * @brief Gets the animation play list.
296 * @return A reference to the animation play list
298 AnimationPlaylist& GetAnimationPlaylist() const;
303 * Undefined copy and assignment operators
305 Core(const Core& core) = delete; // No definition
306 Core& operator=(const Core& core) = delete; // No definition
309 * Create Thread local storage
311 void CreateThreadLocalStorage();
315 Integration::RenderController& mRenderController; ///< Reference to Render controller to tell it to keep rendering
316 Integration::PlatformAbstraction& mPlatform; ///< The interface providing platform specific services.
318 IntrusivePtr<Stage> mStage; ///< The current stage
319 AnimationPlaylistOwner mAnimationPlaylist; ///< For 'Fire and forget' animation support
320 OwnerPointer<PropertyNotificationManager> mPropertyNotificationManager; ///< For safe signal emmision of property changed notifications
321 IntrusivePtr< RelayoutController > mRelayoutController; ///< Size negotiation relayout controller
323 OwnerPointer<SceneGraph::RenderTaskProcessor> mRenderTaskProcessor; ///< Handles the processing of render tasks
324 OwnerPointer<SceneGraph::RenderManager> mRenderManager; ///< Render manager
325 OwnerPointer<SceneGraph::UpdateManager> mUpdateManager; ///< Update manager
326 OwnerPointer<SceneGraph::DiscardQueue> mDiscardQueue; ///< Used to cleanup nodes & resources when no longer in use.
327 OwnerPointer<ShaderFactory> mShaderFactory; ///< Shader resource factory
328 OwnerPointer<NotificationManager> mNotificationManager; ///< Notification manager
329 OwnerPointer<GestureEventProcessor> mGestureEventProcessor; ///< The gesture event processor
330 Dali::Vector<Integration::Processor*> mProcessors; ///< Registered processors (not owned)
332 using SceneContainer = std::vector<ScenePtr>;
333 SceneContainer mScenes; ///< A container of scenes that bound to a surface for rendering, owned by Core
335 // The object registry
336 ObjectRegistryPtr mObjectRegistry;
338 bool mProcessingEvent : 1; ///< True during ProcessEvents()
339 bool mForceNextUpdate:1; ///< True if the next rendering is really required.
341 friend class ThreadLocalStorage;
345 } // namespace Internal
349 #endif // DALI_INTERNAL_CORE_H