[Tizen] Add screen and client rotation itself function
[platform/core/uifw/dali-core.git] / dali / internal / event / common / scene-impl.cpp
old mode 100644 (file)
new mode 100755 (executable)
index acb362d..208c1f7
@@ -29,6 +29,7 @@
 #include <dali/internal/update/nodes/node.h>
 #include <dali/internal/update/manager/update-manager.h>
 #include <dali/internal/update/common/scene-graph-scene.h>
+#include <dali/public-api/common/constants.h>
 #include <dali/public-api/object/type-registry.h>
 #include <dali/public-api/render-tasks/render-task-list.h>
 #include <dali/internal/event/rendering/frame-buffer-impl.h>
@@ -42,19 +43,22 @@ namespace Dali
 namespace Internal
 {
 
-namespace
+ScenePtr Scene::New( Size size )
 {
+  ScenePtr scene = new Scene;
 
-const Vector4 DEFAULT_BACKGROUND_COLOR(0.0f, 0.0f, 0.0f, 1.0f); // Default background color
+  // Second-phase construction
+  scene->Initialize( size, 0 );
 
-} //Unnamed namespace
+  return scene;
+}
 
-ScenePtr Scene::New( Size size )
+ScenePtr Scene::New( Size size, int orientation )
 {
   ScenePtr scene = new Scene;
 
   // Second-phase construction
-  scene->Initialize( size );
+  scene->Initialize( size, orientation );
 
   return scene;
 }
@@ -64,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() )
 {
@@ -100,7 +105,7 @@ Scene::~Scene()
   // When this destructor is called, the scene has either already been removed from Core or Core has already been destroyed
 }
 
-void Scene::Initialize( Size size )
+void Scene::Initialize( Size size, int orientation )
 {
   ThreadLocalStorage* tls = ThreadLocalStorage::GetInternal();
 
@@ -136,8 +141,9 @@ void Scene::Initialize( Size size )
   // 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 );
+  SurfaceResized( size.width, size.height, mSurfaceOrientation, false );
 
   // Create scene graph object
   mSceneObject = new SceneGraph::Scene();
@@ -205,23 +211,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 );
+    SetDefaultSurfaceOrientationMessage( updateManager, mSurfaceOrientation );
 
     // set default render-task viewport parameters
     RenderTaskPtr defaultRenderTask = mRenderTaskList->GetTask( 0u );
@@ -291,7 +301,7 @@ SceneGraph::Scene* Scene::GetSceneObject() const
   return mSceneObject;
 }
 
-void Scene::EmitKeyEventSignal(const KeyEvent& event)
+void Scene::EmitKeyEventSignal(const Dali::KeyEvent& event)
 {
   if ( !mKeyEventSignal.Empty() )
   {
@@ -300,9 +310,10 @@ void Scene::EmitKeyEventSignal(const KeyEvent& event)
   }
 }
 
-bool Scene::EmitKeyEventGeneratedSignal(const KeyEvent& event)
+bool Scene::EmitKeyEventGeneratedSignal(const Dali::KeyEvent& event)
 {
   // Emit the KeyEventGenerated signal when KeyEvent is generated
+  Dali::Integration::Scene handle( this );
   return mKeyEventGeneratedSignal.Emit( event );
 }
 
@@ -315,20 +326,16 @@ void Scene::EmitEventProcessingFinishedSignal()
   }
 }
 
-void Scene::EmitTouchedSignal( const TouchEvent& touchEvent, const Dali::TouchData& touch )
+void Scene::EmitTouchedSignal( const Dali::TouchEvent& touch )
 {
   Dali::Integration::Scene handle( this );
   if ( !mTouchedSignal.Empty() )
   {
-    mTouchedSignal.Emit( touchEvent );
-  }
-  if ( !mTouchSignal.Empty() )
-  {
-    mTouchSignal.Emit( touch );
+    mTouchedSignal.Emit( touch );
   }
 }
 
-void Scene::EmitWheelEventSignal(const WheelEvent& event)
+void Scene::EmitWheelEventSignal(const Dali::WheelEvent& event)
 {
   if ( !mWheelEventSignal.Empty() )
   {
@@ -374,19 +381,19 @@ Integration::Scene::EventProcessingFinishedSignalType& Scene::EventProcessingFin
   return mEventProcessingFinishedSignal;
 }
 
-Scene::TouchedSignalType& Scene::TouchedSignal()
+Integration::Scene::TouchEventSignalType& Scene::TouchedSignal()
 {
   return mTouchedSignal;
 }
 
-Integration::Scene::TouchSignalType& Scene::TouchSignal()
+Integration::Scene::WheelEventSignalType& Scene::WheelEventSignal()
 {
-  return mTouchSignal;
+  return mWheelEventSignal;
 }
 
-Integration::Scene::WheelEventSignalType& Scene::WheelEventSignal()
+std::vector<Dali::Internal::SceneGraph::DirtyRect>& Scene::GetItemsDirtyRects()
 {
-  return mWheelEventSignal;
+  return mItemsDirtyRects;
 }
 
 } // Internal