Revert "License conversion from Flora to Apache 2.0"
[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) 2014 Samsung Electronics Co., Ltd.
6 //
7 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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 // INTERNAL INCLUDES
21 #include <dali/public-api/object/ref-object.h>
22 #include <dali/internal/common/owner-pointer.h>
23 #include <dali/internal/event/animation/animation-playlist-declarations.h>
24 #include <dali/internal/event/common/stage-def.h>
25 #include <dali/internal/update/resources/resource-manager-declarations.h>
26 #include <dali/public-api/common/view-mode.h>
27
28 namespace Dali
29 {
30
31 namespace Integration
32 {
33 class RenderController;
34 class PlatformAbstraction;
35 class GestureManager;
36 class GlAbstraction;
37 class GlSyncAbstraction;
38 class SystemOverlay;
39 class UpdateStatus;
40 class RenderStatus;
41 struct Event;
42 struct TouchData;
43 }
44
45 namespace Internal
46 {
47
48 class NotificationManager;
49 class AnimationPlaylist;
50 class PropertyNotificationManager;
51 class Context;
52 class EventProcessor;
53 class GestureEventProcessor;
54 class ResourceClient;
55 class ResourceManager;
56 class FrameTime;
57 class FontFactory;
58 class ImageFactory;
59 class ModelFactory;
60 class ShaderFactory;
61 class TouchResampler;
62 class EmojiFactory;
63
64 namespace SceneGraph
65 {
66 class UpdateManager;
67 class RenderManager;
68 class DiscardQueue;
69 }
70
71 /**
72  * Internal class for Dali::Integration::Core
73  */
74 class Core
75 {
76 public:
77
78   /**
79    * Create and initialise a new Core instance
80    */
81   Core( Integration::RenderController& renderController,
82         Integration::PlatformAbstraction& platform,
83         Integration::GlAbstraction& glAbstraction,
84         Integration::GlSyncAbstraction& glSyncAbstraction,
85         Integration::GestureManager& gestureManager );
86
87   /**
88    * Destructor
89    */
90   ~Core();
91
92   /**
93    * @copydoc Dali::Integration::Core::ContextCreated()
94    */
95   void ContextCreated();
96
97   /**
98    * @copydoc Dali::Integration::Core::ContextToBeDestroyed()
99    */
100   void ContextToBeDestroyed();
101
102   /**
103    * @copydoc Dali::Integration::Core::SurfaceResized(unsigned int, unsigned int)
104    */
105   void SurfaceResized(unsigned int width, unsigned int height);
106
107   /**
108    * @copydoc Dali::Integration::Core::SetDpi(unsigned int, unsigned int)
109    */
110   void SetDpi(unsigned int dpiHorizontal, unsigned int dpiVertical);
111
112   /**
113    * @copydoc Dali::Integration::Core::SetMinimumFrameTimeInterval(unsigned int)
114    */
115   void SetMinimumFrameTimeInterval(unsigned int interval);
116
117   /**
118    * @copydoc Dali::Integration::Core::Update()
119    */
120   void Update( Integration::UpdateStatus& status );
121
122   /**
123    * @copydoc Dali::Integration::Core::Render()
124    */
125   void Render( Integration::RenderStatus& status );
126
127   /**
128    * @copydoc Dali::Integration::Core::Suspend()
129    */
130   void Suspend();
131
132   /**
133    * @copydoc Dali::Integration::Core::Resume()
134    */
135   void Resume();
136
137   /**
138    * @copydoc Dali::Integration::Core::QueueEvent(const Integration::Event&)
139    */
140   void QueueEvent( const Integration::Event& event );
141
142   /**
143    * @copydoc Dali::Integration::Core::ProcessEvents()
144    */
145   void ProcessEvents();
146
147   /**
148    * @copydoc Dali::Integration::Core::UpdateTouchData(const Integration::TouchData&)
149    */
150   void UpdateTouchData(const Integration::TouchData& touch);
151
152   /**
153    * @copydoc Dali::Integration::Core::GetMaximumUpdateCount()
154    */
155   unsigned int GetMaximumUpdateCount() const;
156
157   /**
158    * @copydoc Dali::Integration::Core::Sleep()
159    */
160   void Sleep();
161
162   /**
163    * @copydoc Dali::Integration::Core::Wake()
164    */
165   void WakeUp();
166
167   /**
168    * @copydoc Dali::Integration::Core::VSync()
169    */
170   void VSync( unsigned int frameNumber, unsigned int seconds, unsigned int microseconds );
171
172   /**
173    * @copydoc Dali::Integration::Core::GetSystemOverlay()
174    */
175   Integration::SystemOverlay& GetSystemOverlay();
176
177   // Stereoscopy
178
179   /**
180    * @copydoc Dali::Integration::Core::SetViewMode()
181    */
182   void SetViewMode( ViewMode viewMode );
183
184   /**
185    * @copydoc Dali::Integration::Core::GetViewMode()
186    */
187   ViewMode GetViewMode() const;
188
189   /**
190    * @copydoc Dali::Integration::Core::SetStereoBase()
191    */
192   void SetStereoBase( float stereoBase );
193
194   /**
195    * @copydoc Dali::Integration::Core::GetStereoBase()
196    */
197   float GetStereoBase() const;
198
199 private:  // for use by ThreadLocalStorage
200
201   /**
202    * Returns the current stage.
203    * @return A smart-pointer to the current stage.
204    */
205   StagePtr GetCurrentStage();
206
207   /**
208    * Returns the platform abstraction.
209    * @return A reference to the platform abstraction.
210    */
211   Integration::PlatformAbstraction& GetPlatform();
212
213   /**
214    * Returns the update manager.
215    * @return A reference to the update manager.
216    */
217   SceneGraph::UpdateManager& GetUpdateManager();
218
219   /**
220    * Returns the render manager.
221    * @return A reference to the render manager.
222    */
223   SceneGraph::RenderManager& GetRenderManager();
224
225   /**
226    * Returns the notification manager.
227    * @return A reference to the Notification Manager.
228    */
229   NotificationManager& GetNotificationManager();
230
231   /**
232    * Returns the Resource Manager.
233    * @return A reference to the Resource Manager.
234    */
235   ResourceManager& GetResourceManager();
236
237   /**
238    * Returns the Resource client.
239    * @return A reference to the Resource Client.
240    */
241   ResourceClient& GetResourceClient();
242
243   /**
244    * Returns the Font factory
245    * @return A reference to the Font factory.
246    */
247   FontFactory& GetFontFactory();
248
249   /**
250    * Returns the Image factory
251    * @return A reference to the Image factory.
252    */
253   ImageFactory& GetImageFactory();
254
255   /**
256    * Returns the Model factory
257    * @return A reference to the Model factory.
258    */
259   ModelFactory& GetModelFactory();
260
261   /**
262    * Returns the Shader factory
263    * @return A reference to the Shader binary factory.
264    */
265   ShaderFactory& GetShaderFactory();
266
267   /**
268    * Returns the gesture event processor.
269    * @return A reference to the gesture event processor.
270    */
271   GestureEventProcessor& GetGestureEventProcessor();
272
273   /**
274    * Returns the Emoji factory.
275    * @return a reference to the Emoji factory.
276    */
277   EmojiFactory& GetEmojiFactory();
278
279 private:
280
281   /**
282    * Undefined copy and assignment operators
283    */
284   Core(const Core& core);  // No definition
285   Core& operator=(const Core& core);  // No definition
286
287   /**
288    * Create Thread local storage
289    */
290   void CreateThreadLocalStorage();
291
292 private:
293
294   Integration::RenderController&            mRenderController;            ///< Reference to Render controller to tell it to keep rendering
295   Integration::PlatformAbstraction&         mPlatform;                    ///< The interface providing platform specific services.
296
297   IntrusivePtr<Stage>                       mStage;                       ///< The current stage
298   GestureEventProcessor*                    mGestureEventProcessor;       ///< The gesture event processor
299   EventProcessor*                           mEventProcessor;              ///< The event processor
300   SceneGraph::UpdateManager*                mUpdateManager;               ///< Update manager
301   SceneGraph::RenderManager*                mRenderManager;               ///< Render manager
302   SceneGraph::DiscardQueue*                 mDiscardQueue;                ///< Used to cleanup nodes & resources when no longer in use.
303   ResourcePostProcessList*                  mResourcePostProcessQueue;    ///< Stores resource ids which require post processing after render
304   NotificationManager*                      mNotificationManager;         ///< Notification manager
305   AnimationPlaylistOwner                    mAnimationPlaylist;           ///< For 'Fire and forget' animation support
306   OwnerPointer<PropertyNotificationManager> mPropertyNotificationManager; ///< For safe signal emmision of property changed notifications
307   FrameTime*                                mFrameTime;                   ///< Time when we render
308   FontFactory*                              mFontFactory;                 ///< font resource factory
309   ImageFactory*                             mImageFactory;                ///< Image resource factory
310   ModelFactory*                             mModelFactory;                ///< Model resource factory
311   ShaderFactory*                            mShaderFactory;               ///< Shader resource factory
312   ResourceClient*                           mResourceClient;              ///< Asynchronous Resource Loading
313   ResourceManager*                          mResourceManager;             ///< Asynchronous Resource Loading
314   TouchResampler*                           mTouchResampler;              ///< Resamples touches to correct frame rate.
315   EmojiFactory*                             mEmojiFactory;                ///< Emoji resource factory.
316
317   bool                                      mIsActive         : 1;        ///< Whether Core is active or suspended
318   bool                                      mProcessingEvent  : 1;        ///< True during ProcessEvents()
319
320   friend class ThreadLocalStorage;
321
322 };
323
324 } // namespace Internal
325
326 } // namespace Dali
327
328 #endif // __DALI_INTERNAL_CORE_H__