Remove RenderSurface from Core
[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 struct Event;
48 struct TouchData;
49 }
50
51 namespace Internal
52 {
53
54 class NotificationManager;
55 class AnimationPlaylist;
56 class PropertyNotificationManager;
57 class EventProcessor;
58 class GestureEventProcessor;
59 class ShaderFactory;
60 class TouchResampler;
61 class RelayoutController;
62 class EventThreadServices;
63
64 namespace SceneGraph
65 {
66 class UpdateManager;
67 class RenderManager;
68 class DiscardQueue;
69 class RenderTaskProcessor;
70 }
71
72 /**
73  * Internal class for Dali::Integration::Core
74  */
75 class Core : public EventThreadServices
76 {
77 public:
78
79   /**
80    * Create and initialise a new Core instance
81    */
82   Core( Integration::RenderController& renderController,
83         Integration::PlatformAbstraction& platform,
84         Integration::GlAbstraction& glAbstraction,
85         Integration::GlSyncAbstraction& glSyncAbstraction,
86         Integration::GlContextHelperAbstraction& glContextHelperAbstraction,
87         Integration::RenderToFrameBuffer renderToFboEnabled,
88         Integration::DepthBufferAvailable depthBufferAvailable,
89         Integration::StencilBufferAvailable stencilBufferAvailable );
90
91   /**
92    * Destructor
93    */
94   ~Core();
95
96   /**
97    * @copydoc Dali::Integration::Core::Initialize()
98    */
99   void Initialize();
100
101   /**
102    * @copydoc Dali::Integration::Core::GetContextNotifier()
103    */
104   Integration::ContextNotifierInterface* GetContextNotifier();
105
106   /**
107    * @copydoc Dali::Integration::Core::ContextCreated()
108    */
109   void ContextCreated();
110
111   /**
112    * @copydoc Dali::Integration::Core::ContextDestroyed()
113    */
114   void ContextDestroyed();
115
116   /**
117    * @copydoc Dali::Integration::Core::RecoverFromContextLoss()
118    */
119   void RecoverFromContextLoss();
120
121   /**
122    * @copydoc Dali::Integration::Core::SetMinimumFrameTimeInterval(uint32_t)
123    */
124   void SetMinimumFrameTimeInterval(uint32_t interval);
125
126   /**
127    * @copydoc Dali::Integration::Core::Update()
128    */
129   void Update( float elapsedSeconds, uint32_t lastVSyncTimeMilliseconds, uint32_t nextVSyncTimeMilliseconds, Integration::UpdateStatus& status, bool renderToFboEnabled, bool isRenderingToFbo );
130
131   /**
132    * @copydoc Dali::Integration::Core::Render()
133    */
134   void PreRender( Integration::RenderStatus& status, bool forceClear, bool uploadOnly );
135
136   /**
137    * @copydoc Dali::Integration::Core::RenderScene()
138    */
139   void RenderScene( Integration::Scene& scene, bool renderToFbo );
140
141   /**
142    * @copydoc Dali::Integration::Core::Render()
143    */
144   void PostRender( bool uploadOnly );
145
146   /**
147    * @copydoc Dali::Integration::Core::SceneCreated()
148    */
149   void SceneCreated();
150
151   /**
152    * @copydoc Dali::Integration::Core::QueueEvent(const Integration::Event&)
153    */
154   void QueueEvent( const Integration::Event& event );
155
156   /**
157    * @copydoc Dali::Integration::Core::ProcessEvents()
158    */
159   void ProcessEvents();
160
161   /**
162    * @copydoc Dali::Integration::Core::GetMaximumUpdateCount()
163    */
164   uint32_t GetMaximumUpdateCount() const;
165
166   /**
167    * @copydoc Dali::Integration::Core::RegisterProcessor
168    */
169   void RegisterProcessor( Dali::Integration::Processor& processor );
170
171   /**
172    * @copydoc Dali::Integration::Core::UnregisterProcessor
173    */
174   void UnregisterProcessor( Dali::Integration::Processor& processor );
175
176   /**
177    * @copydoc Dali::Internal::ThreadLocalStorage::AddScene()
178    */
179   void AddScene( Scene* scene );
180
181   /**
182    * @copydoc Dali::Internal::ThreadLocalStorage::RemoveScene()
183    */
184   void RemoveScene( Scene* scene );
185
186 public: // Implementation of EventThreadServices
187
188   /**
189    * @copydoc EventThreadServices::RegisterObject
190    */
191   void RegisterObject( BaseObject* object) override;
192
193   /**
194    * @copydoc EventThreadServices::UnregisterObject
195    */
196   void UnregisterObject( BaseObject* object) override;
197
198   /**
199    * @copydoc EventThreadServices::GetUpdateManager
200    */
201   SceneGraph::UpdateManager& GetUpdateManager() override;
202
203   /**
204    * @copydoc EventThreadServices::GetRenderController
205    */
206   Integration::RenderController& GetRenderController() override;
207
208   /**
209    * @copydoc EventThreadServices::ReserveMessageSlot
210    */
211   uint32_t* ReserveMessageSlot( uint32_t size, bool updateScene ) override;
212
213   /**
214    * @copydoc EventThreadServices::GetEventBufferIndex
215    */
216   BufferIndex GetEventBufferIndex() const override;
217
218   /**
219    * @copydoc EventThreadServices::ForceNextUpdate
220    */
221   void ForceNextUpdate() override;
222
223   /**
224    * @copydoc EventThreadServices::IsNextUpdateForced
225    */
226   bool IsNextUpdateForced() override;
227
228 private:
229   /**
230    * Run each registered processor
231    */
232   void RunProcessors();
233
234   // for use by ThreadLocalStorage
235
236   /**
237    * Returns the current stage.
238    * @return A smart-pointer to the current stage.
239    */
240   StagePtr GetCurrentStage();
241
242   /**
243    * Returns the platform abstraction.
244    * @return A reference to the platform abstraction.
245    */
246   Integration::PlatformAbstraction& GetPlatform();
247
248   /**
249    * Returns the render manager.
250    * @return A reference to the render manager.
251    */
252   SceneGraph::RenderManager& GetRenderManager();
253
254   /**
255    * Returns the notification manager.
256    * @return A reference to the Notification Manager.
257    */
258   NotificationManager& GetNotificationManager();
259
260   /**
261    * Returns the Shader factory
262    * @return A reference to the Shader binary factory.
263    */
264   ShaderFactory& GetShaderFactory();
265
266   /**
267    * Returns the gesture event processor.
268    * @return A reference to the gesture event processor.
269    */
270   GestureEventProcessor& GetGestureEventProcessor();
271
272   /**
273    * Return the relayout controller
274    * @Return Return a reference to the relayout controller
275    */
276   RelayoutController& GetRelayoutController();
277
278   /**
279    * @brief Gets the Object registry.
280    * @return A reference to the object registry
281    */
282   ObjectRegistry& GetObjectRegistry() const;
283
284   /**
285    * @brief Gets the event thread services.
286    * @return A reference to the event thread services
287    */
288   EventThreadServices& GetEventThreadServices();
289
290   /**
291    * @brief Gets the property notification manager.
292    * @return A reference to the property notification manager
293    */
294   PropertyNotificationManager& GetPropertyNotificationManager() const;
295
296   /**
297    * @brief Gets the animation play list.
298    * @return A reference to the animation play list
299    */
300   AnimationPlaylist& GetAnimationPlaylist() const;
301
302 private:
303
304   /**
305    * Undefined copy and assignment operators
306    */
307   Core(const Core& core) = delete;  // No definition
308   Core& operator=(const Core& core) = delete;  // No definition
309
310   /**
311    * Create Thread local storage
312    */
313   void CreateThreadLocalStorage();
314
315 private:
316
317   Integration::RenderController&            mRenderController;            ///< Reference to Render controller to tell it to keep rendering
318   Integration::PlatformAbstraction&         mPlatform;                    ///< The interface providing platform specific services.
319
320   IntrusivePtr<Stage>                       mStage;                       ///< The current stage
321   AnimationPlaylistOwner                    mAnimationPlaylist;           ///< For 'Fire and forget' animation support
322   OwnerPointer<PropertyNotificationManager> mPropertyNotificationManager; ///< For safe signal emmision of property changed notifications
323   IntrusivePtr< RelayoutController >        mRelayoutController;          ///< Size negotiation relayout controller
324
325   OwnerPointer<SceneGraph::RenderTaskProcessor> mRenderTaskProcessor;         ///< Handles the processing of render tasks
326   OwnerPointer<SceneGraph::RenderManager>       mRenderManager;               ///< Render manager
327   OwnerPointer<SceneGraph::UpdateManager>       mUpdateManager;               ///< Update manager
328   OwnerPointer<SceneGraph::DiscardQueue>        mDiscardQueue;                ///< Used to cleanup nodes & resources when no longer in use.
329   OwnerPointer<ShaderFactory>                   mShaderFactory;               ///< Shader resource factory
330   OwnerPointer<NotificationManager>             mNotificationManager;         ///< Notification manager
331   OwnerPointer<GestureEventProcessor>           mGestureEventProcessor;       ///< The gesture event processor
332   Dali::Vector<Integration::Processor*>         mProcessors;                  ///< Registered processors (not owned)
333
334   using SceneContainer = std::vector<ScenePtr>;
335   SceneContainer                                mScenes;                      ///< A container of scenes that bound to a surface for rendering, owned by Core
336
337   // The object registry
338   ObjectRegistryPtr                             mObjectRegistry;
339
340   bool                                      mProcessingEvent  : 1;        ///< True during ProcessEvents()
341   bool                                      mForceNextUpdate:1;           ///< True if the next rendering is really required.
342
343   friend class ThreadLocalStorage;
344
345 };
346
347 } // namespace Internal
348
349 } // namespace Dali
350
351 #endif // DALI_INTERNAL_CORE_H