Merge "DALi Version 1.2.34" into devel/master
[platform/core/uifw/dali-core.git] / dali / internal / event / common / stage-impl.cpp
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali/internal/event/common/stage-impl.h>
20
21 // EXTERNAL INCLUDES
22 #include <algorithm>
23 #include <cmath>
24 #include <cstring> // for strcmp
25
26 // INTERNAL INCLUDES
27 #include <dali/integration-api/system-overlay.h>
28 #include <dali/internal/event/actors/layer-impl.h>
29 #include <dali/internal/event/actors/layer-list.h>
30 #include <dali/internal/event/actors/camera-actor-impl.h>
31 #include <dali/internal/event/common/system-overlay-impl.h>
32 #include <dali/internal/event/common/thread-local-storage.h>
33 #include <dali/internal/event/common/property-notification-manager.h>
34 #include <dali/internal/event/render-tasks/render-task-list-impl.h>
35 #include <dali/internal/update/nodes/node.h>
36 #include <dali/internal/event/common/object-registry-impl.h>
37 #include <dali/integration-api/platform-abstraction.h>
38 #include <dali/public-api/common/constants.h>
39 #include <dali/public-api/events/touch-data.h>
40 #include <dali/public-api/object/type-registry.h>
41 #include <dali/public-api/render-tasks/render-task-list.h>
42
43 using Dali::Internal::SceneGraph::Node;
44
45 namespace Dali
46 {
47
48 namespace Internal
49 {
50
51 namespace
52 {
53
54 const float DEFAULT_STEREO_BASE( 65.0f );
55
56 // Signals
57
58 const char* const SIGNAL_KEY_EVENT =                 "keyEvent";
59 const char* const SIGNAL_KEY_EVENT_GENERATED =       "keyEventGenerated";
60 const char* const SIGNAL_EVENT_PROCESSING_FINISHED = "eventProcessingFinished";
61 const char* const SIGNAL_TOUCHED =                   "touched";
62 const char* const SIGNAL_TOUCH =                     "touch";
63 const char* const SIGNAL_WHEEL_EVENT =               "wheelEvent";
64 const char* const SIGNAL_CONTEXT_LOST =              "contextLost";
65 const char* const SIGNAL_CONTEXT_REGAINED =          "contextRegained";
66 const char* const SIGNAL_SCENE_CREATED =             "sceneCreated";
67
68 TypeRegistration mType( typeid(Dali::Stage), typeid(Dali::BaseHandle), NULL );
69
70 SignalConnectorType signalConnector1( mType, SIGNAL_KEY_EVENT,                 &Stage::DoConnectSignal );
71 SignalConnectorType signalConnector2( mType, SIGNAL_EVENT_PROCESSING_FINISHED, &Stage::DoConnectSignal );
72 SignalConnectorType signalConnector3( mType, SIGNAL_TOUCHED,                   &Stage::DoConnectSignal );
73 SignalConnectorType signalConnector4( mType, SIGNAL_WHEEL_EVENT,               &Stage::DoConnectSignal );
74 SignalConnectorType signalConnector5( mType, SIGNAL_CONTEXT_LOST,              &Stage::DoConnectSignal );
75 SignalConnectorType signalConnector6( mType, SIGNAL_CONTEXT_REGAINED,          &Stage::DoConnectSignal );
76 SignalConnectorType signalConnector7( mType, SIGNAL_SCENE_CREATED,             &Stage::DoConnectSignal );
77 SignalConnectorType signalConnector8( mType, SIGNAL_KEY_EVENT_GENERATED,       &Stage::DoConnectSignal );
78 SignalConnectorType signalConnector9( mType, SIGNAL_TOUCH,                     &Stage::DoConnectSignal );
79
80 } // unnamed namespace
81
82 StagePtr Stage::New( AnimationPlaylist& playlist,
83                      PropertyNotificationManager& propertyNotificationManager,
84                      SceneGraph::UpdateManager& updateManager,
85                      NotificationManager& notificationManager )
86 {
87   return StagePtr( new Stage( playlist, propertyNotificationManager, updateManager, notificationManager ) );
88 }
89
90 void Stage::Initialize()
91 {
92   mObjectRegistry = ObjectRegistry::New();
93
94   // Create the ordered list of layers
95   mLayerList = LayerList::New( mUpdateManager, false/*not system-level*/ );
96
97   // The stage owns the default layer
98   mRootLayer = Layer::NewRoot( *mLayerList, mUpdateManager, false/*not system-level*/ );
99   mRootLayer->SetName("RootLayer");
100   // The root layer needs to have a fixed resize policy (as opposed to the default USE_NATURAL_SIZE).
101   // This stops actors parented to the stage having their relayout requests propagating
102   // up to the root layer, and down through other children unnecessarily.
103   mRootLayer->SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
104
105   // Create the default camera actor first; this is needed by the RenderTaskList
106   CreateDefaultCameraActor();
107
108   // Create the list of render-tasks
109   mRenderTaskList = RenderTaskList::New( *this, *this, false/*not system-level*/ );
110
111   // Create the default render-task
112   Dali::RenderTask defaultRenderTask = mRenderTaskList->CreateTask();
113 }
114
115 void Stage::Uninitialize()
116 {
117   // Remove actors added to SystemOverlay
118   delete mSystemOverlay;
119   mSystemOverlay = NULL;
120
121   if( mDefaultCamera )
122   {
123     // its enough to release the handle so the object is released
124     // don't need to remove it from root actor as root actor will delete the object
125     mDefaultCamera.Reset();
126   }
127
128   if( mRootLayer )
129   {
130     // we are closing down so just delete the root, no point emit disconnect
131     // signals or send messages to update
132     mRootLayer.Reset();
133   }
134 }
135
136 StagePtr Stage::GetCurrent()
137 {
138   StagePtr stage( NULL );
139   // no checking in this version
140   ThreadLocalStorage* tls = ThreadLocalStorage::GetInternal();
141   if( tls )
142   {
143     stage = tls->GetCurrentStage();
144   }
145   return stage;
146 }
147
148 bool Stage::IsInstalled()
149 {
150   return ThreadLocalStorage::Created();
151 }
152
153 ObjectRegistry& Stage::GetObjectRegistry()
154 {
155   return *mObjectRegistry;
156 }
157
158 void Stage::RegisterObject( Dali::BaseObject* object )
159 {
160   mObjectRegistry->RegisterObject( object );
161 }
162
163 void Stage::UnregisterObject( Dali::BaseObject* object )
164 {
165   mObjectRegistry->UnregisterObject( object );
166 }
167
168 Layer& Stage::GetRootActor()
169 {
170   return *mRootLayer;
171 }
172
173 AnimationPlaylist& Stage::GetAnimationPlaylist()
174 {
175   return mAnimationPlaylist;
176 }
177
178 PropertyNotificationManager& Stage::GetPropertyNotificationManager()
179 {
180   return mPropertyNotificationManager;
181 }
182
183 void Stage::Add( Actor& actor )
184 {
185   mRootLayer->Add( actor );
186 }
187
188 void Stage::Remove( Actor& actor )
189 {
190   mRootLayer->Remove( actor );
191 }
192
193 void Stage::SurfaceResized(float width, float height)
194 {
195   mSurfaceSize.width = width;
196   mSurfaceSize.height = height;
197
198   // Internally we want to report the actual size of the stage.
199   mSize.width = width;
200   mSize.height = height - mTopMargin;
201
202   // Calculates the aspect ratio, near and far clipping planes, field of view and camera Z position.
203   mDefaultCamera->SetPerspectiveProjection( mSurfaceSize );
204
205   // Adjust the camera height to allow for top-margin
206   SetDefaultCameraPosition();
207
208   mRootLayer->SetSize( mSize.width, mSize.height );
209
210   // Repeat for SystemOverlay actors
211   if( mSystemOverlay )
212   {
213     // Note that the SystemOverlay has a separate camera, configured for the full surface-size.
214     // This will remain unaffected by changes in SetDefaultCameraPosition()
215     mSystemOverlay->GetImpl()->SetSize( width, height );
216   }
217
218   SetDefaultSurfaceRectMessage( mUpdateManager, Rect<int>( 0, 0, width, height ) );
219
220   // if single render task to screen then set its viewport parameters
221   if( 1 == mRenderTaskList->GetTaskCount() )
222   {
223     Dali::RenderTask mDefaultRenderTask = mRenderTaskList->GetTask(0);
224
225     if(!mDefaultRenderTask.GetTargetFrameBuffer())
226     {
227       mDefaultRenderTask.SetViewport( Viewport(0, 0, width, height) );
228     }
229   }
230
231 }
232
233 Vector2 Stage::GetSize() const
234 {
235   return mSize;
236 }
237
238 void Stage::SetTopMargin( unsigned int margin )
239 {
240   if (mTopMargin == margin)
241   {
242     return;
243   }
244   mTopMargin = margin;
245
246   mSize.width = mSurfaceSize.width;
247   mSize.height = mSurfaceSize.height - mTopMargin;
248
249   // Adjust the camera height to allow for top-margin
250   SetDefaultCameraPosition();
251
252   mRootLayer->SetSize( mSize.width, mSize.height );
253 }
254
255 RenderTaskList& Stage::GetRenderTaskList() const
256 {
257   return *mRenderTaskList;
258 }
259
260 void Stage::CreateDefaultCameraActor()
261 {
262   // The default camera attributes and position is such that
263   // children of the default layer, can be positioned at (0,0) and
264   // be at the top-left of the viewport.
265   mDefaultCamera = CameraActor::New( Size::ZERO );
266   mDefaultCamera->SetParentOrigin(ParentOrigin::CENTER);
267   Add(*(mDefaultCamera.Get()));
268 }
269
270 void Stage::SetDefaultCameraPosition()
271 {
272   mDefaultCamera->SetY( -(static_cast<float>(mTopMargin) * 0.5f) );
273 }
274
275 Actor& Stage::GetDefaultRootActor()
276 {
277   return *mRootLayer;
278 }
279
280 CameraActor& Stage::GetDefaultCameraActor()
281 {
282   return *mDefaultCamera;
283 }
284
285 unsigned int Stage::GetLayerCount() const
286 {
287   return mLayerList->GetLayerCount();
288 }
289
290 Dali::Layer Stage::GetLayer( unsigned int depth ) const
291 {
292   return Dali::Layer(mLayerList->GetLayer( depth ));
293 }
294
295 Dali::Layer Stage::GetRootLayer() const
296 {
297   return Dali::Layer( mRootLayer.Get() );
298 }
299
300 LayerList& Stage::GetLayerList()
301 {
302   return *mLayerList;
303 }
304
305 Integration::SystemOverlay& Stage::GetSystemOverlay()
306 {
307   // Lazily create system-level if requested
308   if( !mSystemOverlay )
309   {
310     mSystemOverlay = new Integration::SystemOverlay( SystemOverlay::New( *this ) );
311     DALI_ASSERT_ALWAYS( NULL != mSystemOverlay && "Failed to create system overlay" );
312
313     mSystemOverlay->GetImpl()->SetSize( mSize.width, mSize.height );
314   }
315
316   return *mSystemOverlay;
317 }
318
319 SystemOverlay* Stage::GetSystemOverlayInternal()
320 {
321   SystemOverlay* overlay( NULL );
322
323   if( mSystemOverlay )
324   {
325     overlay = mSystemOverlay->GetImpl();
326   }
327
328   return overlay;
329 }
330
331 void Stage::SetViewMode( ViewMode viewMode )
332 {
333   if( mViewMode != viewMode )
334   {
335     DALI_LOG_INFO( Debug::Filter::gActor, Debug::Concise, "View mode changed from %d to %d\n", mViewMode, viewMode);
336
337     if( mViewMode == MONO )
338     {
339       mDefaultCamera->SetOrientation( Dali::ANGLE_180, Vector3::YAXIS );
340       mRenderTaskList->GetTask(0).SetSourceActor( Dali::Actor() );
341
342       //Create camera and RenderTask for left eye
343       mLeftCamera = CameraActor::New( Size::ZERO );
344       mLeftCamera->SetParentOrigin( ParentOrigin::CENTER );
345       mDefaultCamera->Add( *mLeftCamera.Get() );
346       mLeftRenderTask = mRenderTaskList->CreateTask();
347       mLeftRenderTask.SetCameraActor( Dali::CameraActor( mLeftCamera.Get() ) );
348       mLeftCamera->SetType( Dali::Camera::FREE_LOOK );
349
350       //Create camera and RenderTask for right eye
351       mRightCamera = CameraActor::New( Size::ZERO );
352       mRightCamera->SetParentOrigin( ParentOrigin::CENTER );
353       mDefaultCamera->Add( *mRightCamera.Get() );
354       mRightRenderTask = mRenderTaskList->CreateTask();
355       mRightRenderTask.SetClearColor( Vector4( 1.0f,0.0f,0.0f,1.0f));
356
357       mRightRenderTask.SetCameraActor( Dali::CameraActor( mRightCamera.Get() ) );
358       mRightCamera->SetType( Dali::Camera::FREE_LOOK );
359     }
360
361     // save new mode
362     mViewMode = viewMode;
363
364     switch( viewMode )
365     {
366       case MONO:
367       {
368         // delete extra stereoscopic render tasks and cameras
369         mRenderTaskList->RemoveTask( mLeftRenderTask );
370         mDefaultCamera->Remove( *mLeftCamera.Get() );
371         mLeftRenderTask.Reset();
372         mLeftCamera.Reset();
373         mRenderTaskList->RemoveTask( mRightRenderTask );
374         mDefaultCamera->Remove( *mRightCamera.Get() );
375         mRightRenderTask.Reset();
376         mRightCamera.Reset();
377         mDefaultCamera->SetOrientation( Dali::ANGLE_0, Vector3::YAXIS );
378         mDefaultCamera->SetType( Dali::Camera::LOOK_AT_TARGET );
379         mRenderTaskList->GetTask(0).SetSourceActor( Dali::Layer(mRootLayer.Get()) );
380
381         break;
382       }
383       case STEREO_HORIZONTAL:
384       {
385         //Stereo mode with horizontal split is for landscape mode. That's the reason for the cameras being rotated
386         //Top camera renders the scene as seen from the right eye and bottom camera as seen from left.
387
388         //Calculate separation in pixels along vertical axis ( mStereoBase is defined in millimetres )
389         const float stereoBase( ( (mStereoBase / 25.4f) * GetDpi().y ) * 0.5f );
390
391         //Calculate aspect ratio
392         float aspect = mSize.width / (mSize.height * 0.5f);
393
394         mLeftCamera->SetPerspectiveProjection( mSize, Vector2( 0.0f,stereoBase) );
395         mLeftCamera->SetAspectRatio( aspect );
396
397         mLeftCamera->SetOrientation( -Dali::ANGLE_90, Vector3::ZAXIS );
398         mLeftCamera->SetPosition( Vector3( stereoBase, 0.0f, 0.0f ) );
399         mLeftRenderTask.SetViewport( Viewport(0, mSize.height * 0.5f, mSize.width, mSize.height * 0.5f) );
400
401         mRightCamera->SetPerspectiveProjection( mSize, Vector2( 0.0,  -stereoBase) );
402         mRightCamera->SetAspectRatio( aspect );
403         mRightCamera->SetOrientation( -Dali::ANGLE_90, Vector3::ZAXIS );
404         mRightCamera->SetPosition( Vector3(-stereoBase, 0.0f, 0.0f ) );
405         mRightRenderTask.SetViewport( Viewport(0, 0, mSize.width, mSize.height * 0.5f ) );
406
407         break;
408       }
409       case STEREO_VERTICAL:
410       {
411         //Calculate separation in pixels along horizontal axis
412         const float stereoBase( ( (mStereoBase / 25.4f) * GetDpi().x ) * 0.5f );
413
414         //Recalculate fov based on viewport size
415         const float fov = 2.0f * std::atan(  mSize.y / (2.0f * std::max( mSize.x*0.5f, mSize.y )) );
416
417         mLeftCamera->SetPerspectiveProjection( Size( mSize.x * 0.5f, mSize.y ), Vector2(stereoBase,0.0f) );
418         mLeftCamera->SetFieldOfView( fov );
419         mLeftCamera->SetOrientation( Dali::ANGLE_0, Vector3::ZAXIS );
420         mLeftCamera->SetPosition( Vector3( stereoBase, 0.0f, 0.0f ) );
421         mLeftRenderTask.SetViewport( Viewport(0, 0, mSize.width * 0.5f, mSize.height ) );
422
423         mRightCamera->SetPerspectiveProjection( Size( mSize.x * 0.5f, mSize.y ), Vector2(-stereoBase,0.0f) );
424         mRightCamera->SetFieldOfView( fov );
425         mRightCamera->SetOrientation( Dali::ANGLE_0, Vector3::ZAXIS );
426         mRightCamera->SetPosition( Vector3( -stereoBase, 0.0f, 0.0f ) );
427         mRightRenderTask.SetViewport( Viewport(mSize.width * 0.5f, 0, mSize.width * 0.5f, mSize.height ) );
428
429         break;
430       }
431       case STEREO_INTERLACED:
432       {
433         break;
434       }
435     }
436   }
437 }
438
439 ViewMode Stage::GetViewMode() const
440 {
441   return mViewMode;
442 }
443
444 void Stage::SetStereoBase( float stereoBase )
445 {
446   if( ! Equals( mStereoBase, stereoBase ) )
447   {
448     DALI_LOG_INFO( Debug::Filter::gActor, Debug::Concise, "old( %.2f) new(%.2f)\n", mStereoBase, stereoBase );
449     mStereoBase = stereoBase;
450
451     switch( mViewMode  )
452     {
453       case STEREO_HORIZONTAL:
454       {
455         stereoBase = mStereoBase / 25.4f * GetDpi().y * 0.5f;
456         float aspect = mSize.width / (mSize.height * 0.5f);
457
458         mLeftCamera->SetPerspectiveProjection( mSize, Vector2( 0.0, stereoBase) );
459         mLeftCamera->SetAspectRatio( aspect );
460         mLeftCamera->SetPosition( Vector3( stereoBase, 0.0f, 0.0f ) );
461
462         mRightCamera->SetPerspectiveProjection( mSize, Vector2( 0.0, -stereoBase) );
463         mRightCamera->SetAspectRatio( aspect );
464         mRightCamera->SetPosition( Vector3(-stereoBase, 0.0f, 0.0f ) );
465
466         break;
467       }
468       case STEREO_VERTICAL:
469       {
470         stereoBase = mStereoBase / 25.4f * GetDpi().x * 0.5f;
471         const float fov = 2.0f * std::atan(  mSize.y / (2.0f * std::max( mSize.x*0.5f, mSize.y )) );
472
473         mLeftCamera->SetPerspectiveProjection( Size( mSize.x * 0.5f, mSize.y ), Vector2(stereoBase,0.0f) );
474         mLeftCamera->SetFieldOfView( fov );
475         mLeftCamera->SetPosition( Vector3( stereoBase, 0.0f, 0.0f ) );
476
477         mRightCamera->SetPerspectiveProjection( Size( mSize.x * 0.5f, mSize.y ), Vector2(-stereoBase,0.0f) );
478         mRightCamera->SetFieldOfView( fov );
479         mRightCamera->SetPosition( Vector3(-stereoBase, 0.0f, 0.0f ) );
480
481         break;
482       }
483       default:
484         break;
485     }
486   }
487 }
488
489 float Stage::GetStereoBase() const
490 {
491   return mStereoBase;
492 }
493
494 void Stage::SetBackgroundColor(Vector4 color)
495 {
496   // Cache for public GetBackgroundColor()
497   mBackgroundColor = color;
498
499   // Send message to change color in next frame
500   SetBackgroundColorMessage( mUpdateManager, color );
501 }
502
503 Vector4 Stage::GetBackgroundColor() const
504 {
505   return mBackgroundColor;
506 }
507
508 Vector2 Stage::GetDpi() const
509 {
510   return mDpi;
511 }
512
513 void Stage::SetDpi(Vector2 dpi)
514 {
515   mDpi = dpi;
516 }
517
518 void Stage::KeepRendering( float durationSeconds )
519 {
520   // Send message to keep rendering
521   KeepRenderingMessage( mUpdateManager, durationSeconds );
522 }
523
524 bool Stage::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
525 {
526   bool connected( true );
527   Stage* stage = static_cast< Stage* >(object); // TypeRegistry guarantees that this is the correct type.
528
529   if( 0 == strcmp( signalName.c_str(), SIGNAL_KEY_EVENT ) )
530   {
531     stage->KeyEventSignal().Connect( tracker, functor );
532   }
533   else if( 0 == strcmp( signalName.c_str(), SIGNAL_KEY_EVENT_GENERATED ) )
534   {
535     stage->KeyEventGeneratedSignal().Connect( tracker, functor );
536   }
537   else if( 0 == strcmp( signalName.c_str(), SIGNAL_EVENT_PROCESSING_FINISHED ) )
538   {
539     stage->EventProcessingFinishedSignal().Connect( tracker, functor );
540   }
541   else if( 0 == strcmp( signalName.c_str(), SIGNAL_TOUCHED ) )
542   {
543     stage->TouchedSignal().Connect( tracker, functor );
544   }
545   else if( 0 == strcmp( signalName.c_str(), SIGNAL_TOUCH ) )
546   {
547     stage->TouchSignal().Connect( tracker, functor );
548   }
549   else if( 0 == strcmp( signalName.c_str(), SIGNAL_WHEEL_EVENT ) )
550   {
551     stage->WheelEventSignal().Connect( tracker, functor );
552   }
553   else if( 0 == strcmp( signalName.c_str(), SIGNAL_CONTEXT_LOST ) )
554   {
555     stage->ContextLostSignal().Connect( tracker, functor );
556   }
557   else if( 0 == strcmp( signalName.c_str(), SIGNAL_CONTEXT_REGAINED ) )
558   {
559     stage->ContextRegainedSignal().Connect( tracker, functor );
560   }
561   else if( 0 == strcmp( signalName.c_str(), SIGNAL_SCENE_CREATED ) )
562   {
563     stage->SceneCreatedSignal().Connect( tracker, functor );
564   }
565   else
566   {
567     // signalName does not match any signal
568     connected = false;
569   }
570
571   return connected;
572 }
573
574 void Stage::EmitKeyEventSignal(const KeyEvent& event)
575 {
576   // Emit the key event signal when no actor in the stage has gained the key input focus
577
578   mKeyEventSignal.Emit( event );
579 }
580
581 bool Stage::EmitKeyEventGeneratedSignal(const KeyEvent& event)
582 {
583   // Emit the KeyEventGenerated signal when KeyEvent is generated
584
585   return mKeyEventGeneratedSignal.Emit( event );
586 }
587
588 void Stage::EmitEventProcessingFinishedSignal()
589 {
590    mEventProcessingFinishedSignal.Emit();
591 }
592
593 void Stage::EmitTouchedSignal( const TouchEvent& touchEvent, const Dali::TouchData& touch )
594 {
595   mTouchedSignal.Emit( touchEvent );
596   mTouchSignal.Emit( touch );
597 }
598
599 void Stage::EmitWheelEventSignal(const WheelEvent& event)
600 {
601   // Emit the wheel event signal when no actor in the stage has gained the wheel input focus
602
603   mWheelEventSignal.Emit( event );
604 }
605
606 void Stage::EmitSceneCreatedSignal()
607 {
608   mSceneCreatedSignal.Emit();
609 }
610
611 Dali::Stage::KeyEventSignalType& Stage::KeyEventSignal()
612 {
613   return mKeyEventSignal;
614 }
615
616 Dali::DevelStage::KeyEventGeneratedSignalType& Stage::KeyEventGeneratedSignal()
617 {
618   return mKeyEventGeneratedSignal;
619 }
620
621 Dali::Stage::EventProcessingFinishedSignalType& Stage::EventProcessingFinishedSignal()
622 {
623   return mEventProcessingFinishedSignal;
624 }
625
626 Dali::Stage::TouchedSignalType& Stage::TouchedSignal()
627 {
628   DALI_LOG_WARNING( "Deprecated. Use TouchSignal() instead.\n" );
629   return mTouchedSignal;
630 }
631
632 Dali::Stage::TouchSignalType& Stage::TouchSignal()
633 {
634   return mTouchSignal;
635 }
636
637 Dali::Stage::WheelEventSignalType& Stage::WheelEventSignal()
638 {
639   return mWheelEventSignal;
640 }
641
642 Dali::Stage::ContextStatusSignal& Stage::ContextLostSignal()
643 {
644   return mContextLostSignal;
645 }
646
647 Dali::Stage::ContextStatusSignal& Stage::ContextRegainedSignal()
648 {
649   return mContextRegainedSignal;
650 }
651
652 Dali::Stage::SceneCreatedSignalType& Stage::SceneCreatedSignal()
653 {
654   return mSceneCreatedSignal;
655 }
656
657 void Stage::NotifyContextLost()
658 {
659   mContextLostSignal.Emit();
660 }
661
662 void Stage::NotifyContextRegained()
663 {
664   mContextRegainedSignal.Emit();
665 }
666
667 Stage::Stage( AnimationPlaylist& playlist,
668               PropertyNotificationManager& propertyNotificationManager,
669               SceneGraph::UpdateManager& updateManager,
670               NotificationManager& notificationManager )
671 : mAnimationPlaylist( playlist ),
672   mPropertyNotificationManager(propertyNotificationManager),
673   mUpdateManager(updateManager),
674   mNotificationManager(notificationManager),
675   mSize(Vector2::ZERO),
676   mBackgroundColor(Dali::Stage::DEFAULT_BACKGROUND_COLOR),
677   mViewMode( MONO ),
678   mStereoBase( DEFAULT_STEREO_BASE ),
679   mTopMargin( 0 ),
680   mSystemOverlay(NULL)
681 {
682 }
683
684 SceneGraph::UpdateManager& Stage::GetUpdateManager()
685 {
686   return mUpdateManager;
687 }
688
689 unsigned int* Stage::ReserveMessageSlot( std::size_t size, bool updateScene )
690 {
691   return mUpdateManager.ReserveMessageSlot( size, updateScene );
692 }
693
694 BufferIndex Stage::GetEventBufferIndex() const
695 {
696   return mUpdateManager.GetEventBufferIndex();
697 }
698
699 Stage::~Stage()
700 {
701   delete mSystemOverlay;
702
703   mObjectRegistry.Reset();
704 }
705
706 } // namespace Internal
707
708 } // namespace Dali