Merge branch 'devel/master' into tizen
[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) 2018 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/internal/event/animation/animation-playlist-declarations.h>
28 #include <dali/internal/event/common/stage-def.h>
29 #include <dali/integration-api/resource-policies.h>
30
31 namespace Dali
32 {
33
34 namespace Integration
35 {
36 class Processor;
37 class RenderController;
38 class PlatformAbstraction;
39 class GestureManager;
40 class GlAbstraction;
41 class GlSyncAbstraction;
42 class SystemOverlay;
43 class UpdateStatus;
44 class RenderStatus;
45 struct Event;
46 struct TouchData;
47 }
48
49 namespace Internal
50 {
51
52 class NotificationManager;
53 class AnimationPlaylist;
54 class PropertyNotificationManager;
55 class EventProcessor;
56 class GestureEventProcessor;
57 class ShaderFactory;
58 class TouchResampler;
59 class RelayoutController;
60
61 namespace SceneGraph
62 {
63 class UpdateManager;
64 class RenderManager;
65 class DiscardQueue;
66 class RenderTaskProcessor;
67 }
68
69 /**
70  * Internal class for Dali::Integration::Core
71  */
72 class Core
73 {
74 public:
75
76   /**
77    * Create and initialise a new Core instance
78    */
79   Core( Integration::RenderController& renderController,
80         Integration::PlatformAbstraction& platform,
81         Integration::GlAbstraction& glAbstraction,
82         Integration::GlSyncAbstraction& glSyncAbstraction,
83         Integration::GestureManager& gestureManager,
84         ResourcePolicy::DataRetention dataRetentionPolicy,
85         Integration::RenderToFrameBuffer renderToFboEnabled,
86         Integration::DepthBufferAvailable depthBufferAvailable,
87         Integration::StencilBufferAvailable stencilBufferAvailable );
88
89   /**
90    * Destructor
91    */
92   ~Core();
93
94   /**
95    * @copydoc Dali::Integration::Core::GetContextNotifier()
96    */
97   Integration::ContextNotifierInterface* GetContextNotifier();
98
99   /**
100    * @copydoc Dali::Integration::Core::ContextCreated()
101    */
102   void ContextCreated();
103
104   /**
105    * @copydoc Dali::Integration::Core::ContextDestroyed()
106    */
107   void ContextDestroyed();
108
109   /**
110    * @copydoc Dali::Integration::Core::RecoverFromContextLoss()
111    */
112   void RecoverFromContextLoss();
113
114   /**
115    * @copydoc Dali::Integration::Core::SurfaceResized(uint32_t, uint32_t)
116    */
117   void SurfaceResized(uint32_t width, uint32_t height);
118
119   /**
120    * @copydoc Dali::Integration::Core::SetTopMargin( uint32_t margin )
121    */
122   void SetTopMargin( uint32_t margin );
123
124   /**
125    * @copydoc Dali::Integration::Core::SetDpi(uint32_t, uint32_t)
126    */
127   void SetDpi(uint32_t dpiHorizontal, uint32_t dpiVertical);
128
129   /**
130    * @copydoc Dali::Integration::Core::SetMinimumFrameTimeInterval(uint32_t)
131    */
132   void SetMinimumFrameTimeInterval(uint32_t interval);
133
134   /**
135    * @copydoc Dali::Integration::Core::Update()
136    */
137   void Update( float elapsedSeconds, uint32_t lastVSyncTimeMilliseconds, uint32_t nextVSyncTimeMilliseconds, Integration::UpdateStatus& status, bool renderToFboEnabled, bool isRenderingToFbo );
138
139   /**
140    * @copydoc Dali::Integration::Core::Render()
141    */
142   void Render( Integration::RenderStatus& status, bool forceClear );
143
144   /**
145    * @copydoc Dali::Integration::Core::SceneCreated()
146    */
147   void SceneCreated();
148
149   /**
150    * @copydoc Dali::Integration::Core::QueueEvent(const Integration::Event&)
151    */
152   void QueueEvent( const Integration::Event& event );
153
154   /**
155    * @copydoc Dali::Integration::Core::ProcessEvents()
156    */
157   void ProcessEvents();
158
159   /**
160    * @copydoc Dali::Integration::Core::GetMaximumUpdateCount()
161    */
162   uint32_t GetMaximumUpdateCount() const;
163
164   /**
165    * @copydoc Dali::Integration::Core::GetSystemOverlay()
166    */
167   Integration::SystemOverlay& GetSystemOverlay();
168
169   /**
170    * @copydoc Dali::Integration::Core::RegisterProcessor
171    */
172   void RegisterProcessor( Dali::Integration::Processor& processor );
173
174   /**
175    * @copydoc Dali::Integration::Core::UnregisterProcessor
176    */
177   void UnregisterProcessor( Dali::Integration::Processor& processor );
178
179 private:
180   /**
181    * Run each registered processor
182    */
183   void RunProcessors();
184
185   // for use by ThreadLocalStorage
186
187   /**
188    * Returns the current stage.
189    * @return A smart-pointer to the current stage.
190    */
191   StagePtr GetCurrentStage();
192
193   /**
194    * Returns the platform abstraction.
195    * @return A reference to the platform abstraction.
196    */
197   Integration::PlatformAbstraction& GetPlatform();
198
199   /**
200    * Returns the update manager.
201    * @return A reference to the update manager.
202    */
203   SceneGraph::UpdateManager& GetUpdateManager();
204
205   /**
206    * Returns the render manager.
207    * @return A reference to the render manager.
208    */
209   SceneGraph::RenderManager& GetRenderManager();
210
211   /**
212    * Returns the notification manager.
213    * @return A reference to the Notification Manager.
214    */
215   NotificationManager& GetNotificationManager();
216
217   /**
218    * Returns the Shader factory
219    * @return A reference to the Shader binary factory.
220    */
221   ShaderFactory& GetShaderFactory();
222
223   /**
224    * Returns the gesture event processor.
225    * @return A reference to the gesture event processor.
226    */
227   GestureEventProcessor& GetGestureEventProcessor();
228
229   /**
230    * Return the relayout controller
231    * @Return Return a reference to the relayout controller
232    */
233   RelayoutController& GetRelayoutController();
234
235 private:
236
237   /**
238    * Undefined copy and assignment operators
239    */
240   Core(const Core& core);  // No definition
241   Core& operator=(const Core& core);  // No definition
242
243   /**
244    * Create Thread local storage
245    */
246   void CreateThreadLocalStorage();
247
248 private:
249
250   Integration::RenderController&            mRenderController;            ///< Reference to Render controller to tell it to keep rendering
251   Integration::PlatformAbstraction&         mPlatform;                    ///< The interface providing platform specific services.
252
253   IntrusivePtr<Stage>                       mStage;                       ///< The current stage
254   AnimationPlaylistOwner                    mAnimationPlaylist;           ///< For 'Fire and forget' animation support
255   OwnerPointer<PropertyNotificationManager> mPropertyNotificationManager; ///< For safe signal emmision of property changed notifications
256   IntrusivePtr< RelayoutController >        mRelayoutController;          ///< Size negotiation relayout controller
257   bool                                      mProcessingEvent  : 1;        ///< True during ProcessEvents()
258
259   OwnerPointer<SceneGraph::RenderTaskProcessor> mRenderTaskProcessor;         ///< Handles the processing of render tasks
260   OwnerPointer<SceneGraph::RenderManager>       mRenderManager;               ///< Render manager
261   OwnerPointer<SceneGraph::UpdateManager>       mUpdateManager;               ///< Update manager
262   OwnerPointer<SceneGraph::DiscardQueue>        mDiscardQueue;                ///< Used to cleanup nodes & resources when no longer in use.
263   OwnerPointer<ShaderFactory>                   mShaderFactory;               ///< Shader resource factory
264   OwnerPointer<NotificationManager>             mNotificationManager;         ///< Notification manager
265   OwnerPointer<GestureEventProcessor>           mGestureEventProcessor;       ///< The gesture event processor
266   OwnerPointer<EventProcessor>                  mEventProcessor;              ///< The event processor
267   Dali::Vector<Integration::Processor*>         mProcessors;                  ///< Registered processors (not owned)
268
269   friend class ThreadLocalStorage;
270
271 };
272
273 } // namespace Internal
274
275 } // namespace Dali
276
277 #endif // DALI_INTERNAL_CORE_H