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