[Tizen] Fix the sync issue of window rotation.
[platform/core/uifw/dali-core.git] / dali / internal / event / common / scene-impl.cpp
index 4397ac4..5d204cb 100755 (executable)
@@ -68,6 +68,7 @@ Scene::Scene()
   mSize(), // Don't set the proper value here, this will be set when the surface is set later
   mDpi(),
   mBackgroundColor( DEFAULT_BACKGROUND_COLOR ),
+  mSurfaceOrientation( 0 ),
   mDepthTreeDirty( false ),
   mEventProcessor( *this, ThreadLocalStorage::GetInternal()->GetGestureEventProcessor() )
 {
@@ -140,14 +141,13 @@ void Scene::Initialize( Size size, int orientation )
   // Create the default render-task and ensure clear is enabled on it to show the background color
   RenderTaskPtr renderTask = mRenderTaskList->CreateTask( mRootLayer.Get(), mDefaultCamera.Get() );
   renderTask->SetClearEnabled(true);
-  mSurfaceOrientation = orientation;
-
-  SurfaceResized( size.width, size.height );
 
   // Create scene graph object
   mSceneObject = new SceneGraph::Scene();
   OwnerPointer< SceneGraph::Scene > transferOwnership( const_cast< SceneGraph::Scene* >( mSceneObject ) );
   AddSceneMessage( updateManager, transferOwnership );
+
+  SurfaceResized( size.width, size.height, orientation, false );
 }
 
 void Scene::Add(Actor& actor)
@@ -210,23 +210,27 @@ Actor& Scene::GetDefaultRootActor()
   return *mRootLayer;
 }
 
-void Scene::SurfaceResized( float width, float height )
+void Scene::SurfaceResized( float width, float height, int orientation, bool forceUpdate )
 {
-  if( ( fabsf( mSize.width - width ) > Math::MACHINE_EPSILON_1 ) || ( fabsf( mSize.height - height ) > Math::MACHINE_EPSILON_1 ) )
+  if( ( fabsf( mSize.width - width ) > Math::MACHINE_EPSILON_1 ) || ( fabsf( mSize.height - height ) > Math::MACHINE_EPSILON_1 )
+      || ( orientation != mSurfaceOrientation ) || ( forceUpdate ) )
   {
     Rect< int32_t > newSize( 0, 0, static_cast< int32_t >( width ), static_cast< int32_t >( height ) ); // truncated
 
     mSize.width = width;
     mSize.height = height;
+    mSurfaceOrientation = orientation;
 
     // Calculates the aspect ratio, near and far clipping planes, field of view and camera Z position.
     mDefaultCamera->SetPerspectiveProjection( mSize );
+    mDefaultCamera->RotateProjection( mSurfaceOrientation );
 
     mRootLayer->SetSize( mSize.width, mSize.height );
 
     ThreadLocalStorage* tls = ThreadLocalStorage::GetInternal();
     SceneGraph::UpdateManager& updateManager = tls->GetUpdateManager();
     SetDefaultSurfaceRectMessage( updateManager, newSize );
+    SetSurfaceOrientationMessage( tls->GetEventThreadServices(), *mSceneObject, mSurfaceOrientation );
 
     // set default render-task viewport parameters
     RenderTaskPtr defaultRenderTask = mRenderTaskList->GetTask( 0u );