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;
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 Integration::RenderToFrameBuffer renderToFboEnabled,
89 Integration::DepthBufferAvailable depthBufferAvailable,
90 Integration::StencilBufferAvailable stencilBufferAvailable );
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::SurfaceDeleted(Integration::RenderSurface*)
125 void SurfaceDeleted( Integration::RenderSurface* surface );
128 * @copydoc Dali::Integration::Core::SetMinimumFrameTimeInterval(uint32_t)
130 void SetMinimumFrameTimeInterval(uint32_t interval);
133 * @copydoc Dali::Integration::Core::Update()
135 void Update( float elapsedSeconds, uint32_t lastVSyncTimeMilliseconds, uint32_t nextVSyncTimeMilliseconds, Integration::UpdateStatus& status, bool renderToFboEnabled, bool isRenderingToFbo );
138 * @copydoc Dali::Integration::Core::Render()
140 void Render( Integration::RenderStatus& status, bool forceClear, bool uploadOnly );
143 * @copydoc Dali::Integration::Core::SceneCreated()
148 * @copydoc Dali::Integration::Core::QueueEvent(const Integration::Event&)
150 void QueueEvent( const Integration::Event& event );
153 * @copydoc Dali::Integration::Core::ProcessEvents()
155 void ProcessEvents();
158 * @copydoc Dali::Integration::Core::GetMaximumUpdateCount()
160 uint32_t GetMaximumUpdateCount() const;
163 * @copydoc Dali::Integration::Core::RegisterProcessor
165 void RegisterProcessor( Dali::Integration::Processor& processor );
168 * @copydoc Dali::Integration::Core::UnregisterProcessor
170 void UnregisterProcessor( Dali::Integration::Processor& processor );
173 * @copydoc Dali::Internal::ThreadLocalStorage::AddScene()
175 void AddScene( Scene* scene );
178 * @copydoc Dali::Internal::ThreadLocalStorage::RemoveScene()
180 void RemoveScene( Scene* scene );
182 public: // Implementation of EventThreadServices
185 * @copydoc EventThreadServices::RegisterObject
187 void RegisterObject( BaseObject* object) override;
190 * @copydoc EventThreadServices::UnregisterObject
192 void UnregisterObject( BaseObject* object) override;
195 * @copydoc EventThreadServices::GetUpdateManager
197 SceneGraph::UpdateManager& GetUpdateManager() override;
200 * @copydoc EventThreadServices::GetRenderController
202 Integration::RenderController& GetRenderController() override;
205 * @copydoc EventThreadServices::ReserveMessageSlot
207 uint32_t* ReserveMessageSlot( uint32_t size, bool updateScene ) override;
210 * @copydoc EventThreadServices::GetEventBufferIndex
212 BufferIndex GetEventBufferIndex() const override;
215 * @copydoc EventThreadServices::ForceNextUpdate
217 void ForceNextUpdate() override;
220 * @copydoc EventThreadServices::IsNextUpdateForced
222 bool IsNextUpdateForced() override;
226 * Run each registered processor
228 void RunProcessors();
230 // for use by ThreadLocalStorage
233 * Returns the current stage.
234 * @return A smart-pointer to the current stage.
236 StagePtr GetCurrentStage();
239 * Returns the platform abstraction.
240 * @return A reference to the platform abstraction.
242 Integration::PlatformAbstraction& GetPlatform();
245 * Returns the render manager.
246 * @return A reference to the render manager.
248 SceneGraph::RenderManager& GetRenderManager();
251 * Returns the notification manager.
252 * @return A reference to the Notification Manager.
254 NotificationManager& GetNotificationManager();
257 * Returns the Shader factory
258 * @return A reference to the Shader binary factory.
260 ShaderFactory& GetShaderFactory();
263 * Returns the gesture event processor.
264 * @return A reference to the gesture event processor.
266 GestureEventProcessor& GetGestureEventProcessor();
269 * Return the relayout controller
270 * @Return Return a reference to the relayout controller
272 RelayoutController& GetRelayoutController();
275 * @brief Gets the Object registry.
276 * @return A reference to the object registry
278 ObjectRegistry& GetObjectRegistry() const;
281 * @brief Gets the event thread services.
282 * @return A reference to the event thread services
284 EventThreadServices& GetEventThreadServices();
287 * @brief Gets the property notification manager.
288 * @return A reference to the property notification manager
290 PropertyNotificationManager& GetPropertyNotificationManager() const;
293 * @brief Gets the animation play list.
294 * @return A reference to the animation play list
296 AnimationPlaylist& GetAnimationPlaylist() const;
301 * Undefined copy and assignment operators
303 Core(const Core& core) = delete; // No definition
304 Core& operator=(const Core& core) = delete; // No definition
307 * Create Thread local storage
309 void CreateThreadLocalStorage();
313 Integration::RenderController& mRenderController; ///< Reference to Render controller to tell it to keep rendering
314 Integration::PlatformAbstraction& mPlatform; ///< The interface providing platform specific services.
316 IntrusivePtr<Stage> mStage; ///< The current stage
317 AnimationPlaylistOwner mAnimationPlaylist; ///< For 'Fire and forget' animation support
318 OwnerPointer<PropertyNotificationManager> mPropertyNotificationManager; ///< For safe signal emmision of property changed notifications
319 IntrusivePtr< RelayoutController > mRelayoutController; ///< Size negotiation relayout controller
321 OwnerPointer<SceneGraph::RenderTaskProcessor> mRenderTaskProcessor; ///< Handles the processing of render tasks
322 OwnerPointer<SceneGraph::RenderManager> mRenderManager; ///< Render manager
323 OwnerPointer<SceneGraph::UpdateManager> mUpdateManager; ///< Update manager
324 OwnerPointer<SceneGraph::DiscardQueue> mDiscardQueue; ///< Used to cleanup nodes & resources when no longer in use.
325 OwnerPointer<ShaderFactory> mShaderFactory; ///< Shader resource factory
326 OwnerPointer<NotificationManager> mNotificationManager; ///< Notification manager
327 OwnerPointer<GestureEventProcessor> mGestureEventProcessor; ///< The gesture event processor
328 Dali::Vector<Integration::Processor*> mProcessors; ///< Registered processors (not owned)
330 using SceneContainer = std::vector<ScenePtr>;
331 SceneContainer mScenes; ///< A container of scenes that bound to a surface for rendering, owned by Core
333 // The object registry
334 ObjectRegistryPtr mObjectRegistry;
336 bool mProcessingEvent : 1; ///< True during ProcessEvents()
337 bool mForceNextUpdate:1; ///< True if the next rendering is really required.
339 friend class ThreadLocalStorage;
343 } // namespace Internal
347 #endif // DALI_INTERNAL_CORE_H