2 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <dali/internal/event/common/stage-impl.h>
24 #include <cstring> // for strcmp
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 #include <dali/public-api/rendering/frame-buffer.h>
44 using Dali::Internal::SceneGraph::Node;
48 #if defined(DEBUG_ENABLED)
49 Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_DEPTH_TIMER" );
62 const float DEFAULT_STEREO_BASE( 65.0f );
66 const char* const SIGNAL_KEY_EVENT = "keyEvent";
67 const char* const SIGNAL_KEY_EVENT_GENERATED = "keyEventGenerated";
68 const char* const SIGNAL_EVENT_PROCESSING_FINISHED = "eventProcessingFinished";
69 const char* const SIGNAL_TOUCHED = "touched";
70 const char* const SIGNAL_TOUCH = "touch";
71 const char* const SIGNAL_WHEEL_EVENT = "wheelEvent";
72 const char* const SIGNAL_CONTEXT_LOST = "contextLost";
73 const char* const SIGNAL_CONTEXT_REGAINED = "contextRegained";
74 const char* const SIGNAL_SCENE_CREATED = "sceneCreated";
76 TypeRegistration mType( typeid(Dali::Stage), typeid(Dali::BaseHandle), NULL );
78 SignalConnectorType signalConnector1( mType, SIGNAL_KEY_EVENT, &Stage::DoConnectSignal );
79 SignalConnectorType signalConnector2( mType, SIGNAL_EVENT_PROCESSING_FINISHED, &Stage::DoConnectSignal );
80 SignalConnectorType signalConnector3( mType, SIGNAL_TOUCHED, &Stage::DoConnectSignal );
81 SignalConnectorType signalConnector4( mType, SIGNAL_WHEEL_EVENT, &Stage::DoConnectSignal );
82 SignalConnectorType signalConnector5( mType, SIGNAL_CONTEXT_LOST, &Stage::DoConnectSignal );
83 SignalConnectorType signalConnector6( mType, SIGNAL_CONTEXT_REGAINED, &Stage::DoConnectSignal );
84 SignalConnectorType signalConnector7( mType, SIGNAL_SCENE_CREATED, &Stage::DoConnectSignal );
85 SignalConnectorType signalConnector8( mType, SIGNAL_KEY_EVENT_GENERATED, &Stage::DoConnectSignal );
86 SignalConnectorType signalConnector9( mType, SIGNAL_TOUCH, &Stage::DoConnectSignal );
88 } // unnamed namespace
90 StagePtr Stage::New( AnimationPlaylist& playlist,
91 PropertyNotificationManager& propertyNotificationManager,
92 SceneGraph::UpdateManager& updateManager,
93 NotificationManager& notificationManager,
94 Integration::RenderController& renderController )
96 return StagePtr( new Stage( playlist, propertyNotificationManager, updateManager, notificationManager, renderController ) );
99 void Stage::Initialize( bool renderToFbo )
101 mRenderToFbo = renderToFbo;
102 mObjectRegistry = ObjectRegistry::New();
104 // Create the ordered list of layers
105 mLayerList = LayerList::New( mUpdateManager, false/*not system-level*/ );
107 // The stage owns the default layer
108 mRootLayer = Layer::NewRoot( *mLayerList, mUpdateManager, false/*not system-level*/ );
109 mRootLayer->SetName("RootLayer");
110 // The root layer needs to have a fixed resize policy (as opposed to the default USE_NATURAL_SIZE).
111 // This stops actors parented to the stage having their relayout requests propagating
112 // up to the root layer, and down through other children unnecessarily.
113 mRootLayer->SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
115 // Create the default camera actor first; this is needed by the RenderTaskList
116 CreateDefaultCameraActor();
118 // Create the list of render-tasks
119 mRenderTaskList = RenderTaskList::New( *this, *this, false/*not system-level*/ );
121 // Create the default render-task
122 Dali::RenderTask defaultRenderTask = mRenderTaskList->CreateTask();
124 // init current default camera orientation
125 mNeedToRotation = false;
126 mCurrentOrientation = 0;
129 void Stage::Uninitialize()
131 // Remove actors added to SystemOverlay
132 delete mSystemOverlay;
133 mSystemOverlay = NULL;
137 // its enough to release the handle so the object is released
138 // don't need to remove it from root actor as root actor will delete the object
139 mDefaultCamera.Reset();
144 // we are closing down so just delete the root, no point emit disconnect
145 // signals or send messages to update
150 StagePtr Stage::GetCurrent()
152 StagePtr stage( NULL );
153 // no checking in this version
154 ThreadLocalStorage* tls = ThreadLocalStorage::GetInternal();
157 stage = tls->GetCurrentStage();
162 bool Stage::IsInstalled()
164 return ThreadLocalStorage::Created();
167 ObjectRegistry& Stage::GetObjectRegistry()
169 return *mObjectRegistry;
172 void Stage::RegisterObject( Dali::BaseObject* object )
174 mObjectRegistry->RegisterObject( object );
177 void Stage::UnregisterObject( Dali::BaseObject* object )
179 mObjectRegistry->UnregisterObject( object );
182 Layer& Stage::GetRootActor()
187 AnimationPlaylist& Stage::GetAnimationPlaylist()
189 return mAnimationPlaylist;
192 PropertyNotificationManager& Stage::GetPropertyNotificationManager()
194 return mPropertyNotificationManager;
197 void Stage::Add( Actor& actor )
199 mRootLayer->Add( actor );
202 void Stage::Remove( Actor& actor )
204 mRootLayer->Remove( actor );
207 void Stage::SurfaceResized( float width, float height )
209 if( ( fabs( width - mSurfaceSize.width ) > Math::MACHINE_EPSILON_1000 ) || ( fabs( height - mSurfaceSize.height ) > Math::MACHINE_EPSILON_1000 )
212 mNeedToRotation = false;
214 mSurfaceSize.width = width;
215 mSurfaceSize.height = height;
217 // Internally we want to report the actual size of the stage.
219 mSize.height = height - mTopMargin;
221 // Calculates the aspect ratio, near and far clipping planes, field of view and camera Z position.
222 mDefaultCamera->SetPerspectiveProjection( mSurfaceSize );
224 // Adjust the camera height to allow for top-margin
225 SetDefaultCameraPosition();
227 mRootLayer->SetSize( mSize.width, mSize.height );
229 // Repeat for SystemOverlay actors
232 // Note that the SystemOverlay has a separate camera, configured for the full surface-size.
233 // This will remain unaffected by changes in SetDefaultCameraPosition()
234 mSystemOverlay->GetImpl()->SetSize( width, height );
237 if( mCurrentOrientation == 90 || mCurrentOrientation == 270)
239 SetDefaultSurfaceRectMessage( mUpdateManager, Rect<int>( 0, 0, height, width ) );
243 SetDefaultSurfaceRectMessage( mUpdateManager, Rect<int>( 0, 0, width, height ) );
246 // if single render task to screen then set its viewport parameters
247 if( 1 == mRenderTaskList->GetTaskCount() )
249 Dali::RenderTask defaultRenderTask = mRenderTaskList->GetTask( 0u );
251 if(!defaultRenderTask.GetTargetFrameBuffer())
253 if( mCurrentOrientation == 90 || mCurrentOrientation == 270)
255 defaultRenderTask.SetViewport( Viewport(0, 0, height, width) );
259 defaultRenderTask.SetViewport( Viewport(0, 0, width, height) );
266 Dali::FrameBuffer frameBuffer = Dali::FrameBuffer::New( width, height, Dali::FrameBuffer::Attachment::NONE );
267 Dali::Texture texture = Dali::Texture::New( Dali::TextureType::TEXTURE_2D, Dali::Pixel::RGB888, width, height );
268 frameBuffer.AttachColorTexture( texture );
270 Dali::RenderTask defaultRenderTask = mRenderTaskList->GetTask( 0u );
271 defaultRenderTask.SetFrameBuffer( frameBuffer );
276 void Stage::SurfaceResized( float width, float height, int orientation )
278 // Calculates the angle of rotation.
279 int rotDelta = ( 360 + orientation - mCurrentOrientation ) % 360;
280 Quaternion rotateAngle;
286 rotateAngle = Quaternion( Dali::ANGLE_270, Vector3::ZAXIS );
291 rotateAngle = Quaternion( Dali::ANGLE_90, Vector3::ZAXIS );
296 rotateAngle = Quaternion( Dali::ANGLE_180, Vector3::ZAXIS );
300 rotateAngle = Quaternion( Dali::ANGLE_0, Vector3::ZAXIS );
304 // set current orientation
305 mCurrentOrientation = orientation;
308 mNeedToRotation = true;
311 // do surface resized
312 SurfaceResized( width, height );
314 // If we need to rotate, rotate the camera.
317 // Calculates the aspect ratio, near and far clipping planes, field of view and camera Z position depending on the orientation
318 if( mCurrentOrientation == 90 || mCurrentOrientation == 270 )
320 mDefaultCamera->SetPerspectiveProjection( Vector2( height, width ) );
323 mSystemOverlay->GetImpl()->GetDefaultCameraActor().SetPerspectiveProjection( Vector2( height, width ) );
327 mDefaultCamera->RotateBy( rotateAngle );
331 mSystemOverlay->GetImpl()->GetDefaultCameraActor().RotateBy( rotateAngle );
336 Vector2 Stage::GetSize() const
341 void Stage::SetTopMargin( unsigned int margin )
343 if (mTopMargin == margin)
349 mSize.width = mSurfaceSize.width;
350 mSize.height = mSurfaceSize.height - mTopMargin;
352 // Adjust the camera height to allow for top-margin
353 SetDefaultCameraPosition();
355 mRootLayer->SetSize( mSize.width, mSize.height );
358 RenderTaskList& Stage::GetRenderTaskList() const
360 return *mRenderTaskList;
363 void Stage::CreateDefaultCameraActor()
365 // The default camera attributes and position is such that
366 // children of the default layer, can be positioned at (0,0) and
367 // be at the top-left of the viewport.
368 mDefaultCamera = CameraActor::New( Size::ZERO );
369 mDefaultCamera->SetParentOrigin(ParentOrigin::CENTER);
370 Add(*(mDefaultCamera.Get()));
373 void Stage::SetDefaultCameraPosition()
375 mDefaultCamera->SetY( -(static_cast<float>(mTopMargin) * 0.5f) );
378 Actor& Stage::GetDefaultRootActor()
383 CameraActor& Stage::GetDefaultCameraActor()
385 return *mDefaultCamera;
388 unsigned int Stage::GetLayerCount() const
390 return mLayerList->GetLayerCount();
393 Dali::Layer Stage::GetLayer( unsigned int depth ) const
395 return Dali::Layer(mLayerList->GetLayer( depth ));
398 Dali::Layer Stage::GetRootLayer() const
400 return Dali::Layer( mRootLayer.Get() );
403 LayerList& Stage::GetLayerList()
408 Integration::SystemOverlay& Stage::GetSystemOverlay()
410 // Lazily create system-level if requested
411 if( !mSystemOverlay )
413 mSystemOverlay = new Integration::SystemOverlay( SystemOverlay::New( *this ) );
414 DALI_ASSERT_ALWAYS( NULL != mSystemOverlay && "Failed to create system overlay" );
416 mSystemOverlay->GetImpl()->SetSize( mSize.width, mSize.height );
419 return *mSystemOverlay;
422 SystemOverlay* Stage::GetSystemOverlayInternal()
424 SystemOverlay* overlay( NULL );
428 overlay = mSystemOverlay->GetImpl();
434 void Stage::SetViewMode( ViewMode viewMode )
436 if( mViewMode != viewMode )
438 DALI_LOG_INFO( Debug::Filter::gActor, Debug::Concise, "View mode changed from %d to %d\n", mViewMode, viewMode);
440 if( mViewMode == MONO )
442 mDefaultCamera->SetOrientation( Dali::ANGLE_180, Vector3::YAXIS );
443 mRenderTaskList->GetTask(0).SetSourceActor( Dali::Actor() );
445 //Create camera and RenderTask for left eye
446 mLeftCamera = CameraActor::New( Size::ZERO );
447 mLeftCamera->SetParentOrigin( ParentOrigin::CENTER );
448 mDefaultCamera->Add( *mLeftCamera.Get() );
449 mLeftRenderTask = mRenderTaskList->CreateTask();
450 mLeftRenderTask.SetCameraActor( Dali::CameraActor( mLeftCamera.Get() ) );
451 mLeftCamera->SetType( Dali::Camera::FREE_LOOK );
453 //Create camera and RenderTask for right eye
454 mRightCamera = CameraActor::New( Size::ZERO );
455 mRightCamera->SetParentOrigin( ParentOrigin::CENTER );
456 mDefaultCamera->Add( *mRightCamera.Get() );
457 mRightRenderTask = mRenderTaskList->CreateTask();
458 mRightRenderTask.SetClearColor( Vector4( 1.0f,0.0f,0.0f,1.0f));
460 mRightRenderTask.SetCameraActor( Dali::CameraActor( mRightCamera.Get() ) );
461 mRightCamera->SetType( Dali::Camera::FREE_LOOK );
465 mViewMode = viewMode;
471 // delete extra stereoscopic render tasks and cameras
472 mRenderTaskList->RemoveTask( mLeftRenderTask );
473 mDefaultCamera->Remove( *mLeftCamera.Get() );
474 mLeftRenderTask.Reset();
476 mRenderTaskList->RemoveTask( mRightRenderTask );
477 mDefaultCamera->Remove( *mRightCamera.Get() );
478 mRightRenderTask.Reset();
479 mRightCamera.Reset();
480 mDefaultCamera->SetOrientation( Dali::ANGLE_0, Vector3::YAXIS );
481 mDefaultCamera->SetType( Dali::Camera::LOOK_AT_TARGET );
482 mRenderTaskList->GetTask(0).SetSourceActor( Dali::Layer(mRootLayer.Get()) );
486 case STEREO_HORIZONTAL:
488 //Stereo mode with horizontal split is for landscape mode. That's the reason for the cameras being rotated
489 //Top camera renders the scene as seen from the right eye and bottom camera as seen from left.
491 //Calculate separation in pixels along vertical axis ( mStereoBase is defined in millimetres )
492 const float stereoBase( ( (mStereoBase / 25.4f) * GetDpi().y ) * 0.5f );
494 //Calculate aspect ratio
495 float aspect = mSize.width / (mSize.height * 0.5f);
497 mLeftCamera->SetPerspectiveProjection( mSize, Vector2( 0.0f,stereoBase) );
498 mLeftCamera->SetAspectRatio( aspect );
500 mLeftCamera->SetOrientation( -Dali::ANGLE_90, Vector3::ZAXIS );
501 mLeftCamera->SetPosition( Vector3( stereoBase, 0.0f, 0.0f ) );
502 mLeftRenderTask.SetViewport( Viewport(0, mSize.height * 0.5f, mSize.width, mSize.height * 0.5f) );
504 mRightCamera->SetPerspectiveProjection( mSize, Vector2( 0.0, -stereoBase) );
505 mRightCamera->SetAspectRatio( aspect );
506 mRightCamera->SetOrientation( -Dali::ANGLE_90, Vector3::ZAXIS );
507 mRightCamera->SetPosition( Vector3(-stereoBase, 0.0f, 0.0f ) );
508 mRightRenderTask.SetViewport( Viewport(0, 0, mSize.width, mSize.height * 0.5f ) );
512 case STEREO_VERTICAL:
514 //Calculate separation in pixels along horizontal axis
515 const float stereoBase( ( (mStereoBase / 25.4f) * GetDpi().x ) * 0.5f );
517 //Recalculate fov based on viewport size
518 const float fov = 2.0f * std::atan( mSize.y / (2.0f * std::max( mSize.x*0.5f, mSize.y )) );
520 mLeftCamera->SetPerspectiveProjection( Size( mSize.x * 0.5f, mSize.y ), Vector2(stereoBase,0.0f) );
521 mLeftCamera->SetFieldOfView( fov );
522 mLeftCamera->SetOrientation( Dali::ANGLE_0, Vector3::ZAXIS );
523 mLeftCamera->SetPosition( Vector3( stereoBase, 0.0f, 0.0f ) );
524 mLeftRenderTask.SetViewport( Viewport(0, 0, mSize.width * 0.5f, mSize.height ) );
526 mRightCamera->SetPerspectiveProjection( Size( mSize.x * 0.5f, mSize.y ), Vector2(-stereoBase,0.0f) );
527 mRightCamera->SetFieldOfView( fov );
528 mRightCamera->SetOrientation( Dali::ANGLE_0, Vector3::ZAXIS );
529 mRightCamera->SetPosition( Vector3( -stereoBase, 0.0f, 0.0f ) );
530 mRightRenderTask.SetViewport( Viewport(mSize.width * 0.5f, 0, mSize.width * 0.5f, mSize.height ) );
534 case STEREO_INTERLACED:
542 ViewMode Stage::GetViewMode() const
547 void Stage::SetStereoBase( float stereoBase )
549 if( ! Equals( mStereoBase, stereoBase ) )
551 DALI_LOG_INFO( Debug::Filter::gActor, Debug::Concise, "old( %.2f) new(%.2f)\n", mStereoBase, stereoBase );
552 mStereoBase = stereoBase;
556 case STEREO_HORIZONTAL:
558 stereoBase = mStereoBase / 25.4f * GetDpi().y * 0.5f;
559 float aspect = mSize.width / (mSize.height * 0.5f);
561 mLeftCamera->SetPerspectiveProjection( mSize, Vector2( 0.0, stereoBase) );
562 mLeftCamera->SetAspectRatio( aspect );
563 mLeftCamera->SetPosition( Vector3( stereoBase, 0.0f, 0.0f ) );
565 mRightCamera->SetPerspectiveProjection( mSize, Vector2( 0.0, -stereoBase) );
566 mRightCamera->SetAspectRatio( aspect );
567 mRightCamera->SetPosition( Vector3(-stereoBase, 0.0f, 0.0f ) );
571 case STEREO_VERTICAL:
573 stereoBase = mStereoBase / 25.4f * GetDpi().x * 0.5f;
574 const float fov = 2.0f * std::atan( mSize.y / (2.0f * std::max( mSize.x*0.5f, mSize.y )) );
576 mLeftCamera->SetPerspectiveProjection( Size( mSize.x * 0.5f, mSize.y ), Vector2(stereoBase,0.0f) );
577 mLeftCamera->SetFieldOfView( fov );
578 mLeftCamera->SetPosition( Vector3( stereoBase, 0.0f, 0.0f ) );
580 mRightCamera->SetPerspectiveProjection( Size( mSize.x * 0.5f, mSize.y ), Vector2(-stereoBase,0.0f) );
581 mRightCamera->SetFieldOfView( fov );
582 mRightCamera->SetPosition( Vector3(-stereoBase, 0.0f, 0.0f ) );
592 float Stage::GetStereoBase() const
597 void Stage::SetBackgroundColor(Vector4 color)
599 // Cache for public GetBackgroundColor()
600 mBackgroundColor = color;
602 // Send message to change color in next frame
603 SetBackgroundColorMessage( mUpdateManager, color );
606 Vector4 Stage::GetBackgroundColor() const
608 return mBackgroundColor;
611 Vector2 Stage::GetDpi() const
616 void Stage::SetDpi(Vector2 dpi)
621 void Stage::KeepRendering( float durationSeconds )
623 // Send message to keep rendering
624 KeepRenderingMessage( mUpdateManager, durationSeconds );
627 bool Stage::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
629 bool connected( true );
630 Stage* stage = static_cast< Stage* >(object); // TypeRegistry guarantees that this is the correct type.
632 if( 0 == strcmp( signalName.c_str(), SIGNAL_KEY_EVENT ) )
634 stage->KeyEventSignal().Connect( tracker, functor );
636 else if( 0 == strcmp( signalName.c_str(), SIGNAL_KEY_EVENT_GENERATED ) )
638 stage->KeyEventGeneratedSignal().Connect( tracker, functor );
640 else if( 0 == strcmp( signalName.c_str(), SIGNAL_EVENT_PROCESSING_FINISHED ) )
642 stage->EventProcessingFinishedSignal().Connect( tracker, functor );
644 else if( 0 == strcmp( signalName.c_str(), SIGNAL_TOUCHED ) )
646 stage->TouchedSignal().Connect( tracker, functor );
648 else if( 0 == strcmp( signalName.c_str(), SIGNAL_TOUCH ) )
650 stage->TouchSignal().Connect( tracker, functor );
652 else if( 0 == strcmp( signalName.c_str(), SIGNAL_WHEEL_EVENT ) )
654 stage->WheelEventSignal().Connect( tracker, functor );
656 else if( 0 == strcmp( signalName.c_str(), SIGNAL_CONTEXT_LOST ) )
658 stage->ContextLostSignal().Connect( tracker, functor );
660 else if( 0 == strcmp( signalName.c_str(), SIGNAL_CONTEXT_REGAINED ) )
662 stage->ContextRegainedSignal().Connect( tracker, functor );
664 else if( 0 == strcmp( signalName.c_str(), SIGNAL_SCENE_CREATED ) )
666 stage->SceneCreatedSignal().Connect( tracker, functor );
670 // signalName does not match any signal
677 void Stage::EmitKeyEventSignal(const KeyEvent& event)
679 // Emit the key event signal when no actor in the stage has gained the key input focus
681 mKeyEventSignal.Emit( event );
684 bool Stage::EmitKeyEventGeneratedSignal(const KeyEvent& event)
686 // Emit the KeyEventGenerated signal when KeyEvent is generated
688 return mKeyEventGeneratedSignal.Emit( event );
691 void Stage::EmitEventProcessingFinishedSignal()
693 mEventProcessingFinishedSignal.Emit();
696 void Stage::EmitTouchedSignal( const TouchEvent& touchEvent, const Dali::TouchData& touch )
698 mTouchedSignal.Emit( touchEvent );
699 mTouchSignal.Emit( touch );
702 void Stage::EmitWheelEventSignal(const WheelEvent& event)
704 // Emit the wheel event signal when no actor in the stage has gained the wheel input focus
706 mWheelEventSignal.Emit( event );
709 void Stage::EmitSceneCreatedSignal()
711 mSceneCreatedSignal.Emit();
714 Dali::Stage::KeyEventSignalType& Stage::KeyEventSignal()
716 return mKeyEventSignal;
719 Dali::DevelStage::KeyEventGeneratedSignalType& Stage::KeyEventGeneratedSignal()
721 return mKeyEventGeneratedSignal;
724 Dali::Stage::EventProcessingFinishedSignalType& Stage::EventProcessingFinishedSignal()
726 return mEventProcessingFinishedSignal;
729 Dali::Stage::TouchedSignalType& Stage::TouchedSignal()
731 DALI_LOG_WARNING( "Deprecated. Use TouchSignal() instead.\n" );
732 return mTouchedSignal;
735 Dali::Stage::TouchSignalType& Stage::TouchSignal()
740 Dali::Stage::WheelEventSignalType& Stage::WheelEventSignal()
742 return mWheelEventSignal;
745 Dali::Stage::ContextStatusSignal& Stage::ContextLostSignal()
747 return mContextLostSignal;
750 Dali::Stage::ContextStatusSignal& Stage::ContextRegainedSignal()
752 return mContextRegainedSignal;
755 Dali::Stage::SceneCreatedSignalType& Stage::SceneCreatedSignal()
757 return mSceneCreatedSignal;
760 void Stage::NotifyContextLost()
762 mContextLostSignal.Emit();
765 void Stage::NotifyContextRegained()
767 mContextRegainedSignal.Emit();
771 void Stage::RequestRebuildDepthTree()
773 DALI_LOG_INFO(gLogFilter, Debug::General, "RequestRebuildDepthTree()\n");
774 mDepthTreeDirty = true;
777 void Stage::RebuildDepthTree()
779 // If the depth tree needs rebuilding, do it in this frame only.
780 if( mDepthTreeDirty )
782 DALI_LOG_INFO(gLogFilter, Debug::Concise, "RebuildDepthTree() dirty:T\n");
784 ActorPtr actor( mRootLayer.Get() );
785 actor->RebuildDepthTree();
786 mDepthTreeDirty = false;
791 Stage::Stage( AnimationPlaylist& playlist,
792 PropertyNotificationManager& propertyNotificationManager,
793 SceneGraph::UpdateManager& updateManager,
794 NotificationManager& notificationManager,
795 Integration::RenderController& renderController )
796 : mAnimationPlaylist( playlist ),
797 mPropertyNotificationManager( propertyNotificationManager ),
798 mUpdateManager( updateManager ),
799 mNotificationManager( notificationManager ),
800 mRenderController( renderController ),
801 mSize( Vector2::ZERO ),
802 mBackgroundColor( Dali::Stage::DEFAULT_BACKGROUND_COLOR ),
804 mStereoBase( DEFAULT_STEREO_BASE ),
806 mSystemOverlay( NULL ),
807 mDepthTreeDirty( false ),
808 mForceNextUpdate( false ),
809 mRenderToFbo( false )
813 SceneGraph::UpdateManager& Stage::GetUpdateManager()
815 return mUpdateManager;
818 Integration::RenderController& Stage::GetRenderController()
820 return mRenderController;
823 unsigned int* Stage::ReserveMessageSlot( std::size_t size, bool updateScene )
825 return mUpdateManager.ReserveMessageSlot( size, updateScene );
828 BufferIndex Stage::GetEventBufferIndex() const
830 return mUpdateManager.GetEventBufferIndex();
833 void Stage::ForceNextUpdate()
835 mForceNextUpdate = true;
838 bool Stage::IsNextUpdateForced()
840 bool nextUpdateForced = mForceNextUpdate;
841 mForceNextUpdate = false;
842 return nextUpdateForced;
847 delete mSystemOverlay;
849 mObjectRegistry.Reset();
852 } // namespace Internal