[4.0] Supports screen rotation.
[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) 2017 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/integration-api/core-enumerations.h>
25 #include <dali/internal/common/owner-pointer.h>
26 #include <dali/internal/event/animation/animation-playlist-declarations.h>
27 #include <dali/internal/event/common/stage-def.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 ShaderFactory;
57 class TouchResampler;
58 class RelayoutController;
59
60 namespace SceneGraph
61 {
62 class UpdateManager;
63 class RenderManager;
64 class DiscardQueue;
65 class RenderTaskProcessor;
66 }
67
68 /**
69  * Internal class for Dali::Integration::Core
70  */
71 class Core
72 {
73 public:
74
75   /**
76    * Create and initialise a new Core instance
77    */
78   Core( Integration::RenderController& renderController,
79         Integration::PlatformAbstraction& platform,
80         Integration::GlAbstraction& glAbstraction,
81         Integration::GlSyncAbstraction& glSyncAbstraction,
82         Integration::GestureManager& gestureManager,
83         ResourcePolicy::DataRetention dataRetentionPolicy,
84         Integration::RenderToFrameBuffer renderToFboEnabled,
85         Integration::DepthBufferAvailable depthBufferAvailable,
86         Integration::StencilBufferAvailable stencilBufferAvailable );
87
88   /**
89    * Destructor
90    */
91   ~Core();
92
93   /**
94    * @copydoc Dali::Integration::Core::GetContextNotifier()
95    */
96   Integration::ContextNotifierInterface* GetContextNotifier();
97
98   /**
99    * @copydoc Dali::Integration::Core::ContextCreated()
100    */
101   void ContextCreated();
102
103   /**
104    * @copydoc Dali::Integration::Core::ContextDestroyed()
105    */
106   void ContextDestroyed();
107
108   /**
109    * @copydoc Dali::Integration::Core::RecoverFromContextLoss()
110    */
111   void RecoverFromContextLoss();
112
113   /**
114    * @copydoc Dali::Integration::Core::SurfaceResized(unsigned int, unsigned int)
115    */
116   void SurfaceResized(unsigned int width, unsigned int height);
117
118   /**
119    * @copydoc Dali::Integration::Core::SurfaceResized(unsigned int, unsigned int, int orientation)
120    */
121   void SurfaceResized( unsigned int width, unsigned int height, int orientation );
122
123   /**
124    * @copydoc Dali::Integration::Core::SetTopMargin( unsigned int margin )
125    */
126   void SetTopMargin( unsigned int margin );
127
128   /**
129    * @copydoc Dali::Integration::Core::SetDpi(unsigned int, unsigned int)
130    */
131   void SetDpi(unsigned int dpiHorizontal, unsigned int dpiVertical);
132
133   /**
134    * @copydoc Dali::Integration::Core::SetMinimumFrameTimeInterval(unsigned int)
135    */
136   void SetMinimumFrameTimeInterval(unsigned int interval);
137
138   /**
139    * @copydoc Dali::Integration::Core::Update()
140    */
141   void Update( float elapsedSeconds, unsigned int lastVSyncTimeMilliseconds, unsigned int nextVSyncTimeMilliseconds, Integration::UpdateStatus& status, bool renderToFboEnabled, bool isRenderingToFbo );
142
143   /**
144    * @copydoc Dali::Integration::Core::Render()
145    */
146   void Render( Integration::RenderStatus& status );
147
148   /**
149    * @copydoc Dali::Integration::Core::SceneCreated()
150    */
151   void SceneCreated();
152
153   /**
154    * @copydoc Dali::Integration::Core::QueueEvent(const Integration::Event&)
155    */
156   void QueueEvent( const Integration::Event& event );
157
158   /**
159    * @copydoc Dali::Integration::Core::ProcessEvents()
160    */
161   void ProcessEvents();
162
163   /**
164    * @copydoc Dali::Integration::Core::GetMaximumUpdateCount()
165    */
166   unsigned int GetMaximumUpdateCount() const;
167
168   /**
169    * @copydoc Dali::Integration::Core::GetSystemOverlay()
170    */
171   Integration::SystemOverlay& GetSystemOverlay();
172
173   // Stereoscopy
174
175   /**
176    * @copydoc Dali::Integration::Core::SetViewMode()
177    */
178   void SetViewMode( ViewMode viewMode );
179
180   /**
181    * @copydoc Dali::Integration::Core::GetViewMode()
182    */
183   ViewMode GetViewMode() const;
184
185   /**
186    * @copydoc Dali::Integration::Core::SetStereoBase()
187    */
188   void SetStereoBase( float stereoBase );
189
190   /**
191    * @copydoc Dali::Integration::Core::GetStereoBase()
192    */
193   float GetStereoBase() const;
194
195 private:  // for use by ThreadLocalStorage
196
197   /**
198    * Returns the current stage.
199    * @return A smart-pointer to the current stage.
200    */
201   StagePtr GetCurrentStage();
202
203   /**
204    * Returns the platform abstraction.
205    * @return A reference to the platform abstraction.
206    */
207   Integration::PlatformAbstraction& GetPlatform();
208
209   /**
210    * Returns the update manager.
211    * @return A reference to the update manager.
212    */
213   SceneGraph::UpdateManager& GetUpdateManager();
214
215   /**
216    * Returns the render manager.
217    * @return A reference to the render manager.
218    */
219   SceneGraph::RenderManager& GetRenderManager();
220
221   /**
222    * Returns the notification manager.
223    * @return A reference to the Notification Manager.
224    */
225   NotificationManager& GetNotificationManager();
226
227   /**
228    * Returns the Shader factory
229    * @return A reference to the Shader binary factory.
230    */
231   ShaderFactory& GetShaderFactory();
232
233   /**
234    * Returns the gesture event processor.
235    * @return A reference to the gesture event processor.
236    */
237   GestureEventProcessor& GetGestureEventProcessor();
238
239   /**
240    * Return the relayout controller
241    * @Return Return a reference to the relayout controller
242    */
243   RelayoutController& GetRelayoutController();
244
245 private:
246
247   /**
248    * Undefined copy and assignment operators
249    */
250   Core(const Core& core);  // No definition
251   Core& operator=(const Core& core);  // No definition
252
253   /**
254    * Create Thread local storage
255    */
256   void CreateThreadLocalStorage();
257
258 private:
259
260   Integration::RenderController&            mRenderController;            ///< Reference to Render controller to tell it to keep rendering
261   Integration::PlatformAbstraction&         mPlatform;                    ///< The interface providing platform specific services.
262
263   IntrusivePtr<Stage>                       mStage;                       ///< The current stage
264   AnimationPlaylistOwner                    mAnimationPlaylist;           ///< For 'Fire and forget' animation support
265   OwnerPointer<PropertyNotificationManager> mPropertyNotificationManager; ///< For safe signal emmision of property changed notifications
266   IntrusivePtr< RelayoutController >        mRelayoutController;          ///< Size negotiation relayout controller
267   bool                                      mProcessingEvent  : 1;        ///< True during ProcessEvents()
268
269   OwnerPointer<SceneGraph::RenderTaskProcessor> mRenderTaskProcessor;         ///< Handles the processing of render tasks
270   OwnerPointer<SceneGraph::RenderManager>       mRenderManager;               ///< Render manager
271   OwnerPointer<SceneGraph::UpdateManager>       mUpdateManager;               ///< Update manager
272   OwnerPointer<SceneGraph::DiscardQueue>        mDiscardQueue;                ///< Used to cleanup nodes & resources when no longer in use.
273   OwnerPointer<ShaderFactory>                   mShaderFactory;               ///< Shader resource factory
274   OwnerPointer<NotificationManager>             mNotificationManager;         ///< Notification manager
275   OwnerPointer<GestureEventProcessor>           mGestureEventProcessor;       ///< The gesture event processor
276   OwnerPointer<EventProcessor>                  mEventProcessor;              ///< The event processor
277
278   friend class ThreadLocalStorage;
279
280 };
281
282 } // namespace Internal
283
284 } // namespace Dali
285
286 #endif // DALI_INTERNAL_CORE_H