Geometry Batching
[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 class TextureCacheDispatcher;
69 class GeometryBatcher;
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::GetMaximumUpdateCount()
166    */
167   unsigned int GetMaximumUpdateCount() const;
168
169   /**
170    * @copydoc Dali::Integration::Core::GetSystemOverlay()
171    */
172   Integration::SystemOverlay& GetSystemOverlay();
173
174   // Stereoscopy
175
176   /**
177    * @copydoc Dali::Integration::Core::SetViewMode()
178    */
179   void SetViewMode( ViewMode viewMode );
180
181   /**
182    * @copydoc Dali::Integration::Core::GetViewMode()
183    */
184   ViewMode GetViewMode() const;
185
186   /**
187    * @copydoc Dali::Integration::Core::SetStereoBase()
188    */
189   void SetStereoBase( float stereoBase );
190
191   /**
192    * @copydoc Dali::Integration::Core::GetStereoBase()
193    */
194   float GetStereoBase() const;
195
196 private:  // for use by ThreadLocalStorage
197
198   /**
199    * Returns the current stage.
200    * @return A smart-pointer to the current stage.
201    */
202   StagePtr GetCurrentStage();
203
204   /**
205    * Returns the platform abstraction.
206    * @return A reference to the platform abstraction.
207    */
208   Integration::PlatformAbstraction& GetPlatform();
209
210   /**
211    * Returns the update manager.
212    * @return A reference to the update manager.
213    */
214   SceneGraph::UpdateManager& GetUpdateManager();
215
216   /**
217    * Returns the render manager.
218    * @return A reference to the render manager.
219    */
220   SceneGraph::RenderManager& GetRenderManager();
221
222   /**
223    * Returns the notification manager.
224    * @return A reference to the Notification Manager.
225    */
226   NotificationManager& GetNotificationManager();
227
228   /**
229    * Returns the Resource Manager.
230    * @return A reference to the Resource Manager.
231    */
232   ResourceManager& GetResourceManager();
233
234   /**
235    * Returns the Resource client.
236    * @return A reference to the Resource Client.
237    */
238   ResourceClient& GetResourceClient();
239
240   /**
241    * Returns the Image factory
242    * @return A reference to the Image factory.
243    */
244   ImageFactory& GetImageFactory();
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    * Return the relayout controller
260    * @Return Return a reference to the relayout controller
261    */
262   RelayoutController& GetRelayoutController();
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   SceneGraph::TextureCacheDispatcher*       mTextureCacheDispatcher;      ///< Used to send messages to TextureCache
289   LockedResourceQueue*                      mTextureUploadedQueue;        ///< Stores resource ids which require post processing after render
290   NotificationManager*                      mNotificationManager;         ///< Notification manager
291   AnimationPlaylistOwner                    mAnimationPlaylist;           ///< For 'Fire and forget' animation support
292   OwnerPointer<PropertyNotificationManager> mPropertyNotificationManager; ///< For safe signal emmision of property changed notifications
293   ImageFactory*                             mImageFactory;                ///< Image resource factory
294   ShaderFactory*                            mShaderFactory;               ///< Shader resource factory
295   ResourceClient*                           mResourceClient;              ///< Asynchronous Resource Loading
296   ResourceManager*                          mResourceManager;             ///< Asynchronous Resource Loading
297   IntrusivePtr< RelayoutController >        mRelayoutController;          ///< Size negotiation relayout controller
298   SceneGraph::GeometryBatcher*              mGeometryBatcher;             ///< Instance of the geometry batcher
299   bool                                      mIsActive         : 1;        ///< Whether Core is active or suspended
300   bool                                      mProcessingEvent  : 1;        ///< True during ProcessEvents()
301
302   friend class ThreadLocalStorage;
303
304 };
305
306 } // namespace Internal
307
308 } // namespace Dali
309
310 #endif // __DALI_INTERNAL_CORE_H__