- return *mLayerList;
-}
-
-Integration::SystemOverlay& Stage::GetSystemOverlay()
-{
- // Lazily create system-level if requested
- if( !mSystemOverlay )
- {
- mSystemOverlay = new Integration::SystemOverlay( SystemOverlay::New( *this ) );
- DALI_ASSERT_ALWAYS( NULL != mSystemOverlay && "Failed to create system overlay" );
-
- mSystemOverlay->GetImpl()->SetSize( mSize.width, mSize.height );
- }
-
- return *mSystemOverlay;
-}
-
-SystemOverlay* Stage::GetSystemOverlayInternal()
-{
- SystemOverlay* overlay( NULL );
-
- if( mSystemOverlay )
- {
- overlay = mSystemOverlay->GetImpl();
- }
-
- return overlay;
-}
-
-void Stage::SetViewMode( ViewMode viewMode )
-{
- if( mViewMode != viewMode )
- {
- DALI_LOG_INFO( Debug::Filter::gActor, Debug::Concise, "View mode changed from %d to %d\n", mViewMode, viewMode);
-
- if( mViewMode == MONO )
- {
- mDefaultCamera->SetOrientation( Degree( 180.0f ), Vector3::YAXIS );
- mRenderTaskList->GetTask(0).SetSourceActor( Dali::Actor() );
-
- //Create camera and RenderTask for left eye
- mLeftCamera = CameraActor::New( Size::ZERO );
- mLeftCamera->SetParentOrigin( ParentOrigin::CENTER );
- mDefaultCamera->Add( *mLeftCamera.Get() );
- mLeftRenderTask = mRenderTaskList->CreateTask();
- mLeftRenderTask.SetCameraActor( Dali::CameraActor( mLeftCamera.Get() ) );
- mLeftCamera->SetType( Dali::Camera::FREE_LOOK );
-
- //Create camera and RenderTask for right eye
- mRightCamera = CameraActor::New( Size::ZERO );
- mRightCamera->SetParentOrigin( ParentOrigin::CENTER );
- mDefaultCamera->Add( *mRightCamera.Get() );
- mRightRenderTask = mRenderTaskList->CreateTask();
- mRightRenderTask.SetClearColor( Vector4( 1.0f,0.0f,0.0f,1.0f));
-
- mRightRenderTask.SetCameraActor( Dali::CameraActor( mRightCamera.Get() ) );
- mRightCamera->SetType( Dali::Camera::FREE_LOOK );
- }
-
- // save new mode
- mViewMode = viewMode;
-
- switch( viewMode )
- {
- case MONO:
- {
- // delete extra stereoscopic render tasks and cameras
- mRenderTaskList->RemoveTask( mLeftRenderTask );
- mDefaultCamera->Remove( *mLeftCamera.Get() );
- mLeftRenderTask.Reset();
- mLeftCamera.Reset();
- mRenderTaskList->RemoveTask( mRightRenderTask );
- mDefaultCamera->Remove( *mRightCamera.Get() );
- mRightRenderTask.Reset();
- mRightCamera.Reset();
-
- mDefaultCamera->SetOrientation( Degree( 0.0f ), Vector3::YAXIS );
- mDefaultCamera->SetType( Dali::Camera::LOOK_AT_TARGET );
- mRenderTaskList->GetTask(0).SetSourceActor( Dali::Layer(mRootLayer.Get()) );
-
- break;
- }
- case STEREO_HORIZONTAL:
- {
- //Stereo mode with horizontal split is for landscape mode. That's the reason for the cameras being rotated
- //Top camera renders the scene as seen from the right eye and bottom camera as seen from left.
-
- //Calculate separation in pixels along vertical axis ( mStereoBase is defined in millimetres )
- const float stereoBase( ( (mStereoBase / 25.4f) * GetDpi().y ) * 0.5f );
-
- //Calculate aspect ratio
- float aspect = mSize.width / (mSize.height * 0.5f);
-
- mLeftCamera->SetPerspectiveProjection( mSize, Vector2( 0.0f,stereoBase) );
- mLeftCamera->SetAspectRatio( aspect );
- mLeftCamera->SetOrientation( Degree(-90.0f), Vector3::ZAXIS );
- mLeftCamera->SetPosition( Vector3( stereoBase, 0.0f, 0.0f ) );
- mLeftRenderTask.SetViewport( Viewport(0, mSize.height * 0.5f, mSize.width, mSize.height * 0.5f) );
-
- mRightCamera->SetPerspectiveProjection( mSize, Vector2( 0.0, -stereoBase) );
- mRightCamera->SetAspectRatio( aspect );
- mRightCamera->SetOrientation( Degree(-90.0f), Vector3::ZAXIS );
- mRightCamera->SetPosition( Vector3(-stereoBase, 0.0f, 0.0f ) );
- mRightRenderTask.SetViewport( Viewport(0, 0, mSize.width, mSize.height * 0.5f ) );
-
- break;
- }
- case STEREO_VERTICAL:
- {
- //Calculate separation in pixels along horizontal axis
- const float stereoBase( ( (mStereoBase / 25.4f) * GetDpi().x ) * 0.5f );
-
- //Recalculate fov based on viewport size
- const float fov = 2.0f * std::atan( mSize.y / (2.0f * std::max( mSize.x*0.5f, mSize.y )) );
-
- mLeftCamera->SetPerspectiveProjection( Size( mSize.x * 0.5f, mSize.y ), Vector2(stereoBase,0.0f) );
- mLeftCamera->SetFieldOfView( fov );
- mLeftCamera->SetOrientation( Degree(0.0f), Vector3::ZAXIS );
- mLeftCamera->SetPosition( Vector3( stereoBase, 0.0f, 0.0f ) );
- mLeftRenderTask.SetViewport( Viewport(0, 0, mSize.width * 0.5f, mSize.height ) );
-
- mRightCamera->SetPerspectiveProjection( Size( mSize.x * 0.5f, mSize.y ), Vector2(-stereoBase,0.0f) );
- mRightCamera->SetFieldOfView( fov );
- mRightCamera->SetOrientation( Degree(0.0f), Vector3::ZAXIS );
- mRightCamera->SetPosition( Vector3( -stereoBase, 0.0f, 0.0f ) );
- mRightRenderTask.SetViewport( Viewport(mSize.width * 0.5f, 0, mSize.width * 0.5f, mSize.height ) );
-
- break;
- }
- case STEREO_INTERLACED:
- {
- break;
- }
- }
- }
-}
-
-ViewMode Stage::GetViewMode() const
-{
- return mViewMode;
-}
-
-void Stage::SetStereoBase( float stereoBase )
-{
- if( ! Equals( mStereoBase, stereoBase ) )
- {
- DALI_LOG_INFO( Debug::Filter::gActor, Debug::Concise, "old( %.2f) new(%.2f)", mStereoBase, stereoBase );
- mStereoBase = stereoBase;
-
- switch( mViewMode )
- {
- case STEREO_HORIZONTAL:
- {
- stereoBase = mStereoBase / 25.4f * GetDpi().y * 0.5f;
- float aspect = mSize.width / (mSize.height * 0.5f);
-
- mLeftCamera->SetPerspectiveProjection( mSize, Vector2( 0.0, stereoBase) );
- mLeftCamera->SetAspectRatio( aspect );
- mLeftCamera->SetPosition( Vector3( stereoBase, 0.0f, 0.0f ) );
-
- mRightCamera->SetPerspectiveProjection( mSize, Vector2( 0.0, -stereoBase) );
- mRightCamera->SetAspectRatio( aspect );
- mRightCamera->SetPosition( Vector3(-stereoBase, 0.0f, 0.0f ) );
-
- break;
- }
- case STEREO_VERTICAL:
- {
- stereoBase = mStereoBase / 25.4f * GetDpi().x * 0.5f;
- const float fov = 2.0f * std::atan( mSize.y / (2.0f * std::max( mSize.x*0.5f, mSize.y )) );
-
- mLeftCamera->SetPerspectiveProjection( Size( mSize.x * 0.5f, mSize.y ), Vector2(stereoBase,0.0f) );
- mLeftCamera->SetFieldOfView( fov );
- mLeftCamera->SetPosition( Vector3( stereoBase, 0.0f, 0.0f ) );
-
- mRightCamera->SetPerspectiveProjection( Size( mSize.x * 0.5f, mSize.y ), Vector2(-stereoBase,0.0f) );
- mRightCamera->SetFieldOfView( fov );
- mRightCamera->SetPosition( Vector3(-stereoBase, 0.0f, 0.0f ) );
-
- break;
- }
- default:
- break;
- }
- }
-}
-
-float Stage::GetStereoBase() const
-{
- return mStereoBase;