Render to Frame Buffer Object.
[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         bool renderToFboEnabled );
84
85   /**
86    * Destructor
87    */
88   ~Core();
89
90   /**
91    * @copydoc Dali::Integration::Core::GetContextNotifier()
92    */
93   Integration::ContextNotifierInterface* GetContextNotifier();
94
95   /**
96    * @copydoc Dali::Integration::Core::ContextCreated()
97    */
98   void ContextCreated();
99
100   /**
101    * @copydoc Dali::Integration::Core::ContextDestroyed()
102    */
103   void ContextDestroyed();
104
105   /**
106    * @copydoc Dali::Integration::Core::RecoverFromContextLoss()
107    */
108   void RecoverFromContextLoss();
109
110   /**
111    * @copydoc Dali::Integration::Core::SurfaceResized(unsigned int, unsigned int)
112    */
113   void SurfaceResized(unsigned int width, unsigned int height);
114
115   /**
116    * @copydoc Dali::Integration::Core::SetTopMargin( unsigned int margin )
117    */
118   void SetTopMargin( unsigned int margin );
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, bool renderToFboEnabled, bool isRenderingToFbo );
134
135   /**
136    * @copydoc Dali::Integration::Core::Render()
137    */
138   void Render( Integration::RenderStatus& status );
139
140   /**
141    * @copydoc Dali::Integration::Core::SceneCreated()
142    */
143   void SceneCreated();
144
145   /**
146    * @copydoc Dali::Integration::Core::QueueEvent(const Integration::Event&)
147    */
148   void QueueEvent( const Integration::Event& event );
149
150   /**
151    * @copydoc Dali::Integration::Core::ProcessEvents()
152    */
153   void ProcessEvents();
154
155   /**
156    * @copydoc Dali::Integration::Core::GetMaximumUpdateCount()
157    */
158   unsigned int GetMaximumUpdateCount() const;
159
160   /**
161    * @copydoc Dali::Integration::Core::GetSystemOverlay()
162    */
163   Integration::SystemOverlay& GetSystemOverlay();
164
165   // Stereoscopy
166
167   /**
168    * @copydoc Dali::Integration::Core::SetViewMode()
169    */
170   void SetViewMode( ViewMode viewMode );
171
172   /**
173    * @copydoc Dali::Integration::Core::GetViewMode()
174    */
175   ViewMode GetViewMode() const;
176
177   /**
178    * @copydoc Dali::Integration::Core::SetStereoBase()
179    */
180   void SetStereoBase( float stereoBase );
181
182   /**
183    * @copydoc Dali::Integration::Core::GetStereoBase()
184    */
185   float GetStereoBase() const;
186
187 private:  // for use by ThreadLocalStorage
188
189   /**
190    * Returns the current stage.
191    * @return A smart-pointer to the current stage.
192    */
193   StagePtr GetCurrentStage();
194
195   /**
196    * Returns the platform abstraction.
197    * @return A reference to the platform abstraction.
198    */
199   Integration::PlatformAbstraction& GetPlatform();
200
201   /**
202    * Returns the update manager.
203    * @return A reference to the update manager.
204    */
205   SceneGraph::UpdateManager& GetUpdateManager();
206
207   /**
208    * Returns the render manager.
209    * @return A reference to the render manager.
210    */
211   SceneGraph::RenderManager& GetRenderManager();
212
213   /**
214    * Returns the notification manager.
215    * @return A reference to the Notification Manager.
216    */
217   NotificationManager& GetNotificationManager();
218
219   /**
220    * Returns the Shader factory
221    * @return A reference to the Shader binary factory.
222    */
223   ShaderFactory& GetShaderFactory();
224
225   /**
226    * Returns the gesture event processor.
227    * @return A reference to the gesture event processor.
228    */
229   GestureEventProcessor& GetGestureEventProcessor();
230
231   /**
232    * Return the relayout controller
233    * @Return Return a reference to the relayout controller
234    */
235   RelayoutController& GetRelayoutController();
236
237 private:
238
239   /**
240    * Undefined copy and assignment operators
241    */
242   Core(const Core& core);  // No definition
243   Core& operator=(const Core& core);  // No definition
244
245   /**
246    * Create Thread local storage
247    */
248   void CreateThreadLocalStorage();
249
250 private:
251
252   Integration::RenderController&            mRenderController;            ///< Reference to Render controller to tell it to keep rendering
253   Integration::PlatformAbstraction&         mPlatform;                    ///< The interface providing platform specific services.
254
255   IntrusivePtr<Stage>                       mStage;                       ///< The current stage
256   AnimationPlaylistOwner                    mAnimationPlaylist;           ///< For 'Fire and forget' animation support
257   OwnerPointer<PropertyNotificationManager> mPropertyNotificationManager; ///< For safe signal emmision of property changed notifications
258   IntrusivePtr< RelayoutController >        mRelayoutController;          ///< Size negotiation relayout controller
259   bool                                      mProcessingEvent  : 1;        ///< True during ProcessEvents()
260
261   OwnerPointer<SceneGraph::RenderTaskProcessor> mRenderTaskProcessor;         ///< Handles the processing of render tasks
262   OwnerPointer<SceneGraph::RenderManager>       mRenderManager;               ///< Render manager
263   OwnerPointer<SceneGraph::UpdateManager>       mUpdateManager;               ///< Update manager
264   OwnerPointer<SceneGraph::DiscardQueue>        mDiscardQueue;                ///< Used to cleanup nodes & resources when no longer in use.
265   OwnerPointer<ShaderFactory>                   mShaderFactory;               ///< Shader resource factory
266   OwnerPointer<NotificationManager>             mNotificationManager;         ///< Notification manager
267   OwnerPointer<GestureEventProcessor>           mGestureEventProcessor;       ///< The gesture event processor
268   OwnerPointer<EventProcessor>                  mEventProcessor;              ///< The event processor
269
270   friend class ThreadLocalStorage;
271
272 };
273
274 } // namespace Internal
275
276 } // namespace Dali
277
278 #endif // DALI_INTERNAL_CORE_H