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