[Tizen] Add screen and client rotation itself function
[platform/core/uifw/dali-core.git] / dali / internal / event / actors / camera-actor-impl.cpp
index 715781e..a0faef3 100644 (file)
@@ -25,6 +25,7 @@
 // INTERNAL INCLUDES
 #include <dali/public-api/common/stage.h>
 #include <dali/public-api/object/type-registry.h>
+#include <dali/devel-api/actors/camera-actor-devel.h>
 #include <dali/integration-api/debug.h>
 #include <dali/internal/event/common/property-helper.h>
 #include <dali/internal/event/common/stage-impl.h>
@@ -199,6 +200,23 @@ void CameraActor::OnInitialize()
   AddCameraMessage( GetEventThreadServices().GetUpdateManager(), sceneGraphCameraOwner );
 }
 
+void CameraActor::OnStageConnectionInternal()
+{
+  // If the canvas size has not been set, then use the size of the scene we've been added to to set up the perspective projection
+  if( ( mCanvasSize.width < Math::MACHINE_EPSILON_1000 ) || ( mCanvasSize.height < Math::MACHINE_EPSILON_1000 ) )
+  {
+    SetPerspectiveProjection( GetScene().GetSize() );
+  }
+}
+
+void CameraActor::SetReflectByPlane(const Vector4& plane) {
+  SceneGraph::Camera* cam = const_cast<SceneGraph::Camera*>(GetCamera());
+  if (cam)
+  {
+    cam->SetReflectByPlane(plane);
+  }
+}
+
 void CameraActor::SetTarget( const Vector3& target )
 {
   if( target != mTarget ) // using range epsilon
@@ -372,15 +390,26 @@ bool CameraActor::GetInvertYAxis() const
 
 void CameraActor::SetPerspectiveProjection( const Size& size )
 {
+  mCanvasSize = size;
+
   if( ( size.width < Math::MACHINE_EPSILON_1000 ) || ( size.height < Math::MACHINE_EPSILON_1000 ) )
   {
-    // Not allowed to set the canvas size to be 0.
-    DALI_LOG_ERROR( "Canvas size can not be 0\n" );
-    return;
+    // If the size given is invalid, i.e. ZERO, then check if we've been added to a scene
+    if( OnStage() )
+    {
+      // We've been added to a scene already, set the canvas size to the scene's size
+      mCanvasSize = GetScene().GetSize();
+    }
+    else
+    {
+      // We've not been added to a scene yet, so just return.
+      // We'll set the canvas size when we get added to a scene later
+      return;
+    }
   }
 
-  float width = size.width;
-  float height = size.height;
+  float width = mCanvasSize.width;
+  float height = mCanvasSize.height;
 
   float nearClippingPlane;
   float farClippingPlane;
@@ -604,6 +633,12 @@ void CameraActor::SetDefaultProperty( Property::Index index, const Property::Val
         SetInvertYAxis( propertyValue.Get<bool>() ); // set to false in case property is not bool
         break;
       }
+      case Dali::DevelCameraActor::Property::REFLECTION_PLANE:
+      {
+        SetReflectByPlane( propertyValue.Get<Vector4>() );
+        break;
+      }
+
       default:
       {
         DALI_LOG_WARNING( "Unknown property (%d)\n", index );