X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fevent%2Fcommon%2Fstage-impl.cpp;h=0ae2eaf2a008c8c0463be1aa575105ff6e628912;hb=85a80d48b8627b6029033b9e70776edf7678393f;hp=b54e34f36199a850dfb5c0ddb501552bff943b8f;hpb=10ef5ef1fff23dbfaf21a7e3fb8360c65ffb23fa;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/event/common/stage-impl.cpp b/dali/internal/event/common/stage-impl.cpp old mode 100644 new mode 100755 index b54e34f..0ae2eaf --- a/dali/internal/event/common/stage-impl.cpp +++ b/dali/internal/event/common/stage-impl.cpp @@ -120,6 +120,10 @@ void Stage::Initialize( bool renderToFbo ) // Create the default render-task Dali::RenderTask defaultRenderTask = mRenderTaskList->CreateTask(); + + // init current default camera orientation + mNeedToRotation = false; + mCurrentOrientation = 0; } void Stage::Uninitialize() @@ -202,8 +206,11 @@ void Stage::Remove( Actor& actor ) void Stage::SurfaceResized( float width, float height ) { - if( ( fabs( width - mSurfaceSize.width ) > Math::MACHINE_EPSILON_1000 ) || ( fabs( height - mSurfaceSize.height ) > Math::MACHINE_EPSILON_1000 ) ) + if( ( fabs( width - mSurfaceSize.width ) > Math::MACHINE_EPSILON_1000 ) || ( fabs( height - mSurfaceSize.height ) > Math::MACHINE_EPSILON_1000 ) + || mNeedToRotation ) { + mNeedToRotation = false; + mSurfaceSize.width = width; mSurfaceSize.height = height; @@ -227,7 +234,14 @@ void Stage::SurfaceResized( float width, float height ) mSystemOverlay->GetImpl()->SetSize( width, height ); } - SetDefaultSurfaceRectMessage( mUpdateManager, Rect( 0, 0, width, height ) ); + if( mCurrentOrientation == 90 || mCurrentOrientation == 270) + { + SetDefaultSurfaceRectMessage( mUpdateManager, Rect( 0, 0, height, width ) ); + } + else + { + SetDefaultSurfaceRectMessage( mUpdateManager, Rect( 0, 0, width, height ) ); + } // if single render task to screen then set its viewport parameters if( 1 == mRenderTaskList->GetTaskCount() ) @@ -236,7 +250,14 @@ void Stage::SurfaceResized( float width, float height ) if(!defaultRenderTask.GetTargetFrameBuffer()) { - defaultRenderTask.SetViewport( Viewport(0, 0, width, height) ); + if( mCurrentOrientation == 90 || mCurrentOrientation == 270) + { + defaultRenderTask.SetViewport( Viewport(0, 0, height, width) ); + } + else + { + defaultRenderTask.SetViewport( Viewport(0, 0, width, height) ); + } } } @@ -252,6 +273,66 @@ void Stage::SurfaceResized( float width, float height ) } } +void Stage::SurfaceResized( float width, float height, int orientation ) +{ + // Calculates the angle of rotation. + int rotDelta = ( 360 + orientation - mCurrentOrientation ) % 360; + Quaternion rotateAngle; + + switch( rotDelta ) + { + case 90: + { + rotateAngle = Quaternion( Dali::ANGLE_270, Vector3::ZAXIS ); + break; + } + case 270: + { + rotateAngle = Quaternion( Dali::ANGLE_90, Vector3::ZAXIS ); + break; + } + case 180: + { + rotateAngle = Quaternion( Dali::ANGLE_180, Vector3::ZAXIS ); + break; + } + default: + rotateAngle = Quaternion( Dali::ANGLE_0, Vector3::ZAXIS ); + break; + } + + // set current orientation + mCurrentOrientation = orientation; + if( rotDelta ) + { + mNeedToRotation = true; + } + + // do surface resized + SurfaceResized( width, height ); + + // If we need to rotate, rotate the camera. + if( rotDelta ) + { + // Calculates the aspect ratio, near and far clipping planes, field of view and camera Z position depending on the orientation + if( mCurrentOrientation == 90 || mCurrentOrientation == 270 ) + { + mDefaultCamera->SetPerspectiveProjection( Vector2( height, width ) ); + if( mSystemOverlay ) + { + mSystemOverlay->GetImpl()->GetDefaultCameraActor().SetPerspectiveProjection( Vector2( height, width ) ); + } + } + + mDefaultCamera->RotateBy( rotateAngle ); + + if( mSystemOverlay ) + { + mSystemOverlay->GetImpl()->GetDefaultCameraActor().RotateBy( rotateAngle ); + } + } +} + Vector2 Stage::GetSize() const { return mSize;