[dali_1.0.32] Merge branch '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) 2014 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/object/ref-object.h>
23 #include <dali/integration-api/context-notifier.h>
24 #include <dali/internal/common/owner-pointer.h>
25 #include <dali/internal/event/animation/animation-playlist-declarations.h>
26 #include <dali/internal/event/common/stage-def.h>
27 #include <dali/internal/update/resources/resource-manager-declarations.h>
28 #include <dali/public-api/common/view-mode.h>
29 #include <dali/integration-api/resource-policies.h>
30
31 namespace Dali
32 {
33
34 namespace Integration
35 {
36 class RenderController;
37 class PlatformAbstraction;
38 class GestureManager;
39 class GlAbstraction;
40 class GlSyncAbstraction;
41 class SystemOverlay;
42 class UpdateStatus;
43 class RenderStatus;
44 struct Event;
45 struct TouchData;
46 }
47
48 namespace Internal
49 {
50
51 class NotificationManager;
52 class AnimationPlaylist;
53 class PropertyNotificationManager;
54 class Context;
55 class EventProcessor;
56 class GestureEventProcessor;
57 class ResourceClient;
58 class ResourceManager;
59 class FontFactory;
60 class ImageFactory;
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         ResourcePolicy::DataRetention dataRetentionPolicy );
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(unsigned int, unsigned int)
116    */
117   void SurfaceResized(unsigned int width, unsigned int height);
118
119   /**
120    * @copydoc Dali::Integration::Core::SetDpi(unsigned int, unsigned int)
121    */
122   void SetDpi(unsigned int dpiHorizontal, unsigned int dpiVertical);
123
124   /**
125    * @copydoc Dali::Integration::Core::SetMinimumFrameTimeInterval(unsigned int)
126    */
127   void SetMinimumFrameTimeInterval(unsigned int interval);
128
129   /**
130    * @copydoc Dali::Integration::Core::Update()
131    */
132   void Update( float elapsedSeconds, unsigned int lastVSyncTimeMilliseconds, unsigned int nextVSyncTimeMilliseconds, Integration::UpdateStatus& status );
133
134   /**
135    * @copydoc Dali::Integration::Core::Render()
136    */
137   void Render( Integration::RenderStatus& status );
138
139   /**
140    * @copydoc Dali::Integration::Core::Suspend()
141    */
142   void Suspend();
143
144   /**
145    * @copydoc Dali::Integration::Core::Resume()
146    */
147   void Resume();
148
149   /**
150    * @copydoc Dali::Integration::Core::SceneCreated()
151    */
152   void SceneCreated();
153
154   /**
155    * @copydoc Dali::Integration::Core::QueueEvent(const Integration::Event&)
156    */
157   void QueueEvent( const Integration::Event& event );
158
159   /**
160    * @copydoc Dali::Integration::Core::ProcessEvents()
161    */
162   void ProcessEvents();
163
164   /**
165    * @copydoc Dali::Integration::Core::UpdateTouchData(const Integration::TouchData&)
166    */
167   void UpdateTouchData(const Integration::TouchData& touch);
168
169   /**
170    * @copydoc Dali::Integration::Core::GetMaximumUpdateCount()
171    */
172   unsigned int GetMaximumUpdateCount() const;
173
174   /**
175    * @copydoc Dali::Integration::Core::GetSystemOverlay()
176    */
177   Integration::SystemOverlay& GetSystemOverlay();
178
179   // Stereoscopy
180
181   /**
182    * @copydoc Dali::Integration::Core::SetViewMode()
183    */
184   void SetViewMode( ViewMode viewMode );
185
186   /**
187    * @copydoc Dali::Integration::Core::GetViewMode()
188    */
189   ViewMode GetViewMode() const;
190
191   /**
192    * @copydoc Dali::Integration::Core::SetStereoBase()
193    */
194   void SetStereoBase( float stereoBase );
195
196   /**
197    * @copydoc Dali::Integration::Core::GetStereoBase()
198    */
199   float GetStereoBase() const;
200
201 private:  // for use by ThreadLocalStorage
202
203   /**
204    * Returns the current stage.
205    * @return A smart-pointer to the current stage.
206    */
207   StagePtr GetCurrentStage();
208
209   /**
210    * Returns the platform abstraction.
211    * @return A reference to the platform abstraction.
212    */
213   Integration::PlatformAbstraction& GetPlatform();
214
215   /**
216    * Returns the update manager.
217    * @return A reference to the update manager.
218    */
219   SceneGraph::UpdateManager& GetUpdateManager();
220
221   /**
222    * Returns the render manager.
223    * @return A reference to the render manager.
224    */
225   SceneGraph::RenderManager& GetRenderManager();
226
227   /**
228    * Returns the notification manager.
229    * @return A reference to the Notification Manager.
230    */
231   NotificationManager& GetNotificationManager();
232
233   /**
234    * Returns the Resource Manager.
235    * @return A reference to the Resource Manager.
236    */
237   ResourceManager& GetResourceManager();
238
239   /**
240    * Returns the Resource client.
241    * @return A reference to the Resource Client.
242    */
243   ResourceClient& GetResourceClient();
244
245   /**
246    * Returns the Font factory
247    * @return A reference to the Font factory.
248    */
249   FontFactory& GetFontFactory();
250
251   /**
252    * Returns the Image factory
253    * @return A reference to the Image factory.
254    */
255   ImageFactory& GetImageFactory();
256
257   /**
258    * Returns the Shader factory
259    * @return A reference to the Shader binary factory.
260    */
261   ShaderFactory& GetShaderFactory();
262
263   /**
264    * Returns the gesture event processor.
265    * @return A reference to the gesture event processor.
266    */
267   GestureEventProcessor& GetGestureEventProcessor();
268
269   /**
270    * Returns the Emoji factory.
271    * @return a reference to the Emoji factory.
272    */
273   EmojiFactory& GetEmojiFactory();
274
275 private:
276
277   /**
278    * Undefined copy and assignment operators
279    */
280   Core(const Core& core);  // No definition
281   Core& operator=(const Core& core);  // No definition
282
283   /**
284    * Create Thread local storage
285    */
286   void CreateThreadLocalStorage();
287
288 private:
289
290   Integration::RenderController&            mRenderController;            ///< Reference to Render controller to tell it to keep rendering
291   Integration::PlatformAbstraction&         mPlatform;                    ///< The interface providing platform specific services.
292
293   IntrusivePtr<Stage>                       mStage;                       ///< The current stage
294   GestureEventProcessor*                    mGestureEventProcessor;       ///< The gesture event processor
295   EventProcessor*                           mEventProcessor;              ///< The event processor
296   SceneGraph::UpdateManager*                mUpdateManager;               ///< Update manager
297   SceneGraph::RenderManager*                mRenderManager;               ///< Render manager
298   SceneGraph::DiscardQueue*                 mDiscardQueue;                ///< Used to cleanup nodes & resources when no longer in use.
299   ResourcePostProcessList*                  mResourcePostProcessQueue;    ///< Stores resource ids which require post processing after render
300   NotificationManager*                      mNotificationManager;         ///< Notification manager
301   AnimationPlaylistOwner                    mAnimationPlaylist;           ///< For 'Fire and forget' animation support
302   OwnerPointer<PropertyNotificationManager> mPropertyNotificationManager; ///< For safe signal emmision of property changed notifications
303   FontFactory*                              mFontFactory;                 ///< font resource factory
304   ImageFactory*                             mImageFactory;                ///< Image resource factory
305   ShaderFactory*                            mShaderFactory;               ///< Shader resource factory
306   ResourceClient*                           mResourceClient;              ///< Asynchronous Resource Loading
307   ResourceManager*                          mResourceManager;             ///< Asynchronous Resource Loading
308   TouchResampler*                           mTouchResampler;              ///< Resamples touches to correct frame rate.
309   EmojiFactory*                             mEmojiFactory;                ///< Emoji resource factory.
310
311   bool                                      mIsActive         : 1;        ///< Whether Core is active or suspended
312   bool                                      mProcessingEvent  : 1;        ///< True during ProcessEvents()
313
314   friend class ThreadLocalStorage;
315
316 };
317
318 } // namespace Internal
319
320 } // namespace Dali
321
322 #endif // __DALI_INTERNAL_CORE_H__