Fix MSVC warning.
[platform/core/uifw/dali-core.git] / dali / internal / common / core-impl.h
1 #ifndef DALI_INTERNAL_CORE_H
2 #define DALI_INTERNAL_CORE_H
3
4 /*
5  * Copyright (c) 2020 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // INTERNAL INCLUDES
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>
33
34 namespace Dali
35 {
36
37 namespace Integration
38 {
39 class Processor;
40 class RenderController;
41 class PlatformAbstraction;
42 class GlAbstraction;
43 class GlSyncAbstraction;
44 class GlContextHelperAbstraction;
45 class UpdateStatus;
46 class RenderStatus;
47 class RenderSurface;
48 struct Event;
49 struct TouchData;
50 }
51
52 namespace Internal
53 {
54
55 class NotificationManager;
56 class AnimationPlaylist;
57 class PropertyNotificationManager;
58 class EventProcessor;
59 class GestureEventProcessor;
60 class ShaderFactory;
61 class TouchResampler;
62 class RelayoutController;
63 class EventThreadServices;
64
65 namespace SceneGraph
66 {
67 class UpdateManager;
68 class RenderManager;
69 class DiscardQueue;
70 class RenderTaskProcessor;
71 }
72
73 /**
74  * Internal class for Dali::Integration::Core
75  */
76 class Core : public EventThreadServices
77 {
78 public:
79
80   /**
81    * Create and initialise a new Core instance
82    */
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 );
91
92   /**
93    * Destructor
94    */
95   ~Core();
96
97   /**
98    * @copydoc Dali::Integration::Core::Initialize()
99    */
100   void Initialize();
101
102   /**
103    * @copydoc Dali::Integration::Core::GetContextNotifier()
104    */
105   Integration::ContextNotifierInterface* GetContextNotifier();
106
107   /**
108    * @copydoc Dali::Integration::Core::ContextCreated()
109    */
110   void ContextCreated();
111
112   /**
113    * @copydoc Dali::Integration::Core::ContextDestroyed()
114    */
115   void ContextDestroyed();
116
117   /**
118    * @copydoc Dali::Integration::Core::RecoverFromContextLoss()
119    */
120   void RecoverFromContextLoss();
121
122   /**
123    * @copydoc Dali::Integration::Core::SurfaceDeleted(Integration::RenderSurface*)
124    */
125   void SurfaceDeleted( Integration::RenderSurface* surface );
126
127   /**
128    * @copydoc Dali::Integration::Core::SetMinimumFrameTimeInterval(uint32_t)
129    */
130   void SetMinimumFrameTimeInterval(uint32_t interval);
131
132   /**
133    * @copydoc Dali::Integration::Core::Update()
134    */
135   void Update( float elapsedSeconds, uint32_t lastVSyncTimeMilliseconds, uint32_t nextVSyncTimeMilliseconds, Integration::UpdateStatus& status, bool renderToFboEnabled, bool isRenderingToFbo );
136
137   /**
138    * @copydoc Dali::Integration::Core::Render()
139    */
140   void Render( Integration::RenderStatus& status, bool forceClear, bool uploadOnly );
141
142   /**
143    * @copydoc Dali::Integration::Core::SceneCreated()
144    */
145   void SceneCreated();
146
147   /**
148    * @copydoc Dali::Integration::Core::QueueEvent(const Integration::Event&)
149    */
150   void QueueEvent( const Integration::Event& event );
151
152   /**
153    * @copydoc Dali::Integration::Core::ProcessEvents()
154    */
155   void ProcessEvents();
156
157   /**
158    * @copydoc Dali::Integration::Core::GetMaximumUpdateCount()
159    */
160   uint32_t GetMaximumUpdateCount() const;
161
162   /**
163    * @copydoc Dali::Integration::Core::RegisterProcessor
164    */
165   void RegisterProcessor( Dali::Integration::Processor& processor );
166
167   /**
168    * @copydoc Dali::Integration::Core::UnregisterProcessor
169    */
170   void UnregisterProcessor( Dali::Integration::Processor& processor );
171
172   /**
173    * @copydoc Dali::Internal::ThreadLocalStorage::AddScene()
174    */
175   void AddScene( Scene* scene );
176
177   /**
178    * @copydoc Dali::Internal::ThreadLocalStorage::RemoveScene()
179    */
180   void RemoveScene( Scene* scene );
181
182 public: // Implementation of EventThreadServices
183
184   /**
185    * @copydoc EventThreadServices::RegisterObject
186    */
187   void RegisterObject( BaseObject* object) override;
188
189   /**
190    * @copydoc EventThreadServices::UnregisterObject
191    */
192   void UnregisterObject( BaseObject* object) override;
193
194   /**
195    * @copydoc EventThreadServices::GetUpdateManager
196    */
197   SceneGraph::UpdateManager& GetUpdateManager() override;
198
199   /**
200    * @copydoc EventThreadServices::GetRenderController
201    */
202   Integration::RenderController& GetRenderController() override;
203
204   /**
205    * @copydoc EventThreadServices::ReserveMessageSlot
206    */
207   uint32_t* ReserveMessageSlot( uint32_t size, bool updateScene ) override;
208
209   /**
210    * @copydoc EventThreadServices::GetEventBufferIndex
211    */
212   BufferIndex GetEventBufferIndex() const override;
213
214   /**
215    * @copydoc EventThreadServices::ForceNextUpdate
216    */
217   void ForceNextUpdate() override;
218
219   /**
220    * @copydoc EventThreadServices::IsNextUpdateForced
221    */
222   bool IsNextUpdateForced() override;
223
224 private:
225   /**
226    * Run each registered processor
227    */
228   void RunProcessors();
229
230   // for use by ThreadLocalStorage
231
232   /**
233    * Returns the current stage.
234    * @return A smart-pointer to the current stage.
235    */
236   StagePtr GetCurrentStage();
237
238   /**
239    * Returns the platform abstraction.
240    * @return A reference to the platform abstraction.
241    */
242   Integration::PlatformAbstraction& GetPlatform();
243
244   /**
245    * Returns the render manager.
246    * @return A reference to the render manager.
247    */
248   SceneGraph::RenderManager& GetRenderManager();
249
250   /**
251    * Returns the notification manager.
252    * @return A reference to the Notification Manager.
253    */
254   NotificationManager& GetNotificationManager();
255
256   /**
257    * Returns the Shader factory
258    * @return A reference to the Shader binary factory.
259    */
260   ShaderFactory& GetShaderFactory();
261
262   /**
263    * Returns the gesture event processor.
264    * @return A reference to the gesture event processor.
265    */
266   GestureEventProcessor& GetGestureEventProcessor();
267
268   /**
269    * Return the relayout controller
270    * @Return Return a reference to the relayout controller
271    */
272   RelayoutController& GetRelayoutController();
273
274   /**
275    * @brief Gets the Object registry.
276    * @return A reference to the object registry
277    */
278   ObjectRegistry& GetObjectRegistry() const;
279
280   /**
281    * @brief Gets the event thread services.
282    * @return A reference to the event thread services
283    */
284   EventThreadServices& GetEventThreadServices();
285
286   /**
287    * @brief Gets the property notification manager.
288    * @return A reference to the property notification manager
289    */
290   PropertyNotificationManager& GetPropertyNotificationManager() const;
291
292   /**
293    * @brief Gets the animation play list.
294    * @return A reference to the animation play list
295    */
296   AnimationPlaylist& GetAnimationPlaylist() const;
297
298 private:
299
300   /**
301    * Undefined copy and assignment operators
302    */
303   Core(const Core& core) = delete;  // No definition
304   Core& operator=(const Core& core) = delete;  // No definition
305
306   /**
307    * Create Thread local storage
308    */
309   void CreateThreadLocalStorage();
310
311 private:
312
313   Integration::RenderController&            mRenderController;            ///< Reference to Render controller to tell it to keep rendering
314   Integration::PlatformAbstraction&         mPlatform;                    ///< The interface providing platform specific services.
315
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
320
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)
329
330   using SceneContainer = std::vector<ScenePtr>;
331   SceneContainer                                mScenes;                      ///< A container of scenes that bound to a surface for rendering, owned by Core
332
333   // The object registry
334   ObjectRegistryPtr                             mObjectRegistry;
335
336   bool                                      mProcessingEvent  : 1;        ///< True during ProcessEvents()
337   bool                                      mForceNextUpdate:1;           ///< True if the next rendering is really required.
338
339   friend class ThreadLocalStorage;
340
341 };
342
343 } // namespace Internal
344
345 } // namespace Dali
346
347 #endif // DALI_INTERNAL_CORE_H