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