Clipping API feature in Actor
[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) 2016 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 class RenderTaskProcessor;
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::GetMaximumUpdateCount()
167    */
168   unsigned int GetMaximumUpdateCount() const;
169
170   /**
171    * @copydoc Dali::Integration::Core::GetSystemOverlay()
172    */
173   Integration::SystemOverlay& GetSystemOverlay();
174
175   // Stereoscopy
176
177   /**
178    * @copydoc Dali::Integration::Core::SetViewMode()
179    */
180   void SetViewMode( ViewMode viewMode );
181
182   /**
183    * @copydoc Dali::Integration::Core::GetViewMode()
184    */
185   ViewMode GetViewMode() const;
186
187   /**
188    * @copydoc Dali::Integration::Core::SetStereoBase()
189    */
190   void SetStereoBase( float stereoBase );
191
192   /**
193    * @copydoc Dali::Integration::Core::GetStereoBase()
194    */
195   float GetStereoBase() const;
196
197 private:  // for use by ThreadLocalStorage
198
199   /**
200    * Returns the current stage.
201    * @return A smart-pointer to the current stage.
202    */
203   StagePtr GetCurrentStage();
204
205   /**
206    * Returns the platform abstraction.
207    * @return A reference to the platform abstraction.
208    */
209   Integration::PlatformAbstraction& GetPlatform();
210
211   /**
212    * Returns the update manager.
213    * @return A reference to the update manager.
214    */
215   SceneGraph::UpdateManager& GetUpdateManager();
216
217   /**
218    * Returns the render manager.
219    * @return A reference to the render manager.
220    */
221   SceneGraph::RenderManager& GetRenderManager();
222
223   /**
224    * Returns the notification manager.
225    * @return A reference to the Notification Manager.
226    */
227   NotificationManager& GetNotificationManager();
228
229   /**
230    * Returns the Resource Manager.
231    * @return A reference to the Resource Manager.
232    */
233   ResourceManager& GetResourceManager();
234
235   /**
236    * Returns the Resource client.
237    * @return A reference to the Resource Client.
238    */
239   ResourceClient& GetResourceClient();
240
241   /**
242    * Returns the Image factory
243    * @return A reference to the Image factory.
244    */
245   ImageFactory& GetImageFactory();
246
247   /**
248    * Returns the Shader factory
249    * @return A reference to the Shader binary factory.
250    */
251   ShaderFactory& GetShaderFactory();
252
253   /**
254    * Returns the gesture event processor.
255    * @return A reference to the gesture event processor.
256    */
257   GestureEventProcessor& GetGestureEventProcessor();
258
259   /**
260    * Return the relayout controller
261    * @Return Return a reference to the relayout controller
262    */
263   RelayoutController& GetRelayoutController();
264
265 private:
266
267   /**
268    * Undefined copy and assignment operators
269    */
270   Core(const Core& core);  // No definition
271   Core& operator=(const Core& core);  // No definition
272
273   /**
274    * Create Thread local storage
275    */
276   void CreateThreadLocalStorage();
277
278 private:
279
280   Integration::RenderController&            mRenderController;            ///< Reference to Render controller to tell it to keep rendering
281   Integration::PlatformAbstraction&         mPlatform;                    ///< The interface providing platform specific services.
282
283   IntrusivePtr<Stage>                       mStage;                       ///< The current stage
284   GestureEventProcessor*                    mGestureEventProcessor;       ///< The gesture event processor
285   EventProcessor*                           mEventProcessor;              ///< The event processor
286   SceneGraph::UpdateManager*                mUpdateManager;               ///< Update manager
287   SceneGraph::RenderManager*                mRenderManager;               ///< Render manager
288   SceneGraph::DiscardQueue*                 mDiscardQueue;                ///< Used to cleanup nodes & resources when no longer in use.
289   SceneGraph::TextureCacheDispatcher*       mTextureCacheDispatcher;      ///< Used to send messages to TextureCache
290   LockedResourceQueue*                      mTextureUploadedQueue;        ///< Stores resource ids which require post processing after render
291   NotificationManager*                      mNotificationManager;         ///< Notification manager
292   AnimationPlaylistOwner                    mAnimationPlaylist;           ///< For 'Fire and forget' animation support
293   OwnerPointer<PropertyNotificationManager> mPropertyNotificationManager; ///< For safe signal emmision of property changed notifications
294   ImageFactory*                             mImageFactory;                ///< Image resource factory
295   ShaderFactory*                            mShaderFactory;               ///< Shader resource factory
296   ResourceClient*                           mResourceClient;              ///< Asynchronous Resource Loading
297   ResourceManager*                          mResourceManager;             ///< Asynchronous Resource Loading
298   IntrusivePtr< RelayoutController >        mRelayoutController;          ///< Size negotiation relayout controller
299   SceneGraph::GeometryBatcher*              mGeometryBatcher;             ///< Instance of the geometry batcher
300   SceneGraph::RenderTaskProcessor*          mRenderTaskProcessor;         ///< Handles the processing of render tasks
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