+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 );
+ }
+ }
+}
+