Merge branch 'devel/master' into devel/new_mesh
[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 EventProcessor;
55 class GestureEventProcessor;
56 class ResourceClient;
57 class ResourceManager;
58 class ImageFactory;
59 class ShaderFactory;
60 class TouchResampler;
61 class RelayoutController;
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         ResourcePolicy::DataRetention dataRetentionPolicy );
86
87   /**
88    * Destructor
89    */
90   ~Core();
91
92   /**
93    * @copydoc Dali::Integration::Core::GetContextNotifier()
94    */
95   Integration::ContextNotifierInterface* GetContextNotifier();
96
97   /**
98    * @copydoc Dali::Integration::Core::ContextCreated()
99    */
100   void ContextCreated();
101
102   /**
103    * @copydoc Dali::Integration::Core::ContextDestroyed()
104    */
105   void ContextDestroyed();
106
107   /**
108    * @copydoc Dali::Integration::Core::RecoverFromContextLoss()
109    */
110   void RecoverFromContextLoss();
111
112   /**
113    * @copydoc Dali::Integration::Core::SurfaceResized(unsigned int, unsigned int)
114    */
115   void SurfaceResized(unsigned int width, unsigned int height);
116
117   /**
118    * @copydoc Dali::Integration::Core::SetDpi(unsigned int, unsigned int)
119    */
120   void SetDpi(unsigned int dpiHorizontal, unsigned int dpiVertical);
121
122   /**
123    * @copydoc Dali::Integration::Core::SetMinimumFrameTimeInterval(unsigned int)
124    */
125   void SetMinimumFrameTimeInterval(unsigned int interval);
126
127   /**
128    * @copydoc Dali::Integration::Core::Update()
129    */
130   void Update( float elapsedSeconds, unsigned int lastVSyncTimeMilliseconds, unsigned int nextVSyncTimeMilliseconds, Integration::UpdateStatus& status );
131
132   /**
133    * @copydoc Dali::Integration::Core::Render()
134    */
135   void Render( Integration::RenderStatus& status );
136
137   /**
138    * @copydoc Dali::Integration::Core::Suspend()
139    */
140   void Suspend();
141
142   /**
143    * @copydoc Dali::Integration::Core::Resume()
144    */
145   void Resume();
146
147   /**
148    * @copydoc Dali::Integration::Core::SceneCreated()
149    */
150   void SceneCreated();
151
152   /**
153    * @copydoc Dali::Integration::Core::QueueEvent(const Integration::Event&)
154    */
155   void QueueEvent( const Integration::Event& event );
156
157   /**
158    * @copydoc Dali::Integration::Core::ProcessEvents()
159    */
160   void ProcessEvents();
161
162   /**
163    * @copydoc Dali::Integration::Core::UpdateTouchData(const Integration::TouchData&)
164    */
165   void UpdateTouchData(const Integration::TouchData& touch);
166
167   /**
168    * @copydoc Dali::Integration::Core::GetMaximumUpdateCount()
169    */
170   unsigned int GetMaximumUpdateCount() const;
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 Image factory
245    * @return A reference to the Image factory.
246    */
247   ImageFactory& GetImageFactory();
248
249   /**
250    * Returns the Shader factory
251    * @return A reference to the Shader binary factory.
252    */
253   ShaderFactory& GetShaderFactory();
254
255   /**
256    * Returns the gesture event processor.
257    * @return A reference to the gesture event processor.
258    */
259   GestureEventProcessor& GetGestureEventProcessor();
260
261   /**
262    * Return the relayout controller
263    * @Return Return a reference to the relayout controller
264    */
265   RelayoutController& GetRelayoutController();
266
267 private:
268
269   /**
270    * Undefined copy and assignment operators
271    */
272   Core(const Core& core);  // No definition
273   Core& operator=(const Core& core);  // No definition
274
275   /**
276    * Create Thread local storage
277    */
278   void CreateThreadLocalStorage();
279
280 private:
281
282   Integration::RenderController&            mRenderController;            ///< Reference to Render controller to tell it to keep rendering
283   Integration::PlatformAbstraction&         mPlatform;                    ///< The interface providing platform specific services.
284
285   IntrusivePtr<Stage>                       mStage;                       ///< The current stage
286   GestureEventProcessor*                    mGestureEventProcessor;       ///< The gesture event processor
287   EventProcessor*                           mEventProcessor;              ///< The event processor
288   SceneGraph::UpdateManager*                mUpdateManager;               ///< Update manager
289   SceneGraph::RenderManager*                mRenderManager;               ///< Render manager
290   SceneGraph::DiscardQueue*                 mDiscardQueue;                ///< Used to cleanup nodes & resources when no longer in use.
291   ResourcePostProcessList*                  mResourcePostProcessQueue;    ///< Stores resource ids which require post processing after render
292   NotificationManager*                      mNotificationManager;         ///< Notification manager
293   AnimationPlaylistOwner                    mAnimationPlaylist;           ///< For 'Fire and forget' animation support
294   OwnerPointer<PropertyNotificationManager> mPropertyNotificationManager; ///< For safe signal emmision of property changed notifications
295   ImageFactory*                             mImageFactory;                ///< Image resource factory
296   ShaderFactory*                            mShaderFactory;               ///< Shader resource factory
297   ResourceClient*                           mResourceClient;              ///< Asynchronous Resource Loading
298   ResourceManager*                          mResourceManager;             ///< Asynchronous Resource Loading
299   TouchResampler*                           mTouchResampler;              ///< Resamples touches to correct frame rate.
300   IntrusivePtr< RelayoutController >        mRelayoutController;          ///< Size negotiation relayout controller
301
302   bool                                      mIsActive         : 1;        ///< Whether Core is active or suspended
303   bool                                      mProcessingEvent  : 1;        ///< True during ProcessEvents()
304
305   friend class ThreadLocalStorage;
306
307 };
308
309 } // namespace Internal
310
311 } // namespace Dali
312
313 #endif // __DALI_INTERNAL_CORE_H__