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