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