[Tizen] Add screen and client rotation itself function
authorWonsik Jung <sidein@samsung.com>
Tue, 10 Nov 2020 06:28:07 +0000 (15:28 +0900)
committerWonsik Jung <sidein@samsung.com>
Tue, 10 Nov 2020 06:28:14 +0000 (15:28 +0900)
This reverts commit 4c9fb2902c2b74710ca56c2068b13644b8c2bcb6.

16 files changed:
automated-tests/src/dali/utc-Dali-Scene.cpp
dali/integration-api/scene.cpp
dali/integration-api/scene.h
dali/internal/event/actors/camera-actor-impl.cpp
dali/internal/event/actors/camera-actor-impl.h
dali/internal/event/common/scene-impl.cpp
dali/internal/event/common/scene-impl.h
dali/internal/render/common/render-algorithms.cpp
dali/internal/render/common/render-algorithms.h
dali/internal/render/common/render-instruction.h
dali/internal/render/common/render-manager.cpp
dali/internal/render/common/render-manager.h
dali/internal/update/manager/update-manager.cpp
dali/internal/update/manager/update-manager.h
dali/internal/update/render-tasks/scene-graph-camera.cpp
dali/internal/update/render-tasks/scene-graph-camera.h

index 2fb7d3c..5098878 100644 (file)
@@ -886,7 +886,8 @@ int UtcDaliSceneSurfaceResizedDefaultScene(void)
   // Resize the scene
   Vector2 newSize(1000.0f, 2000.0f);
   DALI_TEST_CHECK(stage.GetSize() != newSize);
-  defaultScene.SurfaceResized(newSize.width, newSize.height);
+
+  defaultScene.SurfaceResized(newSize.width, newSize.height, 0, false);
 
   DALI_TEST_EQUALS(stage.GetSize(), newSize, TEST_LOCATION);
   DALI_TEST_EQUALS(defaultScene.GetSize(), newSize, TEST_LOCATION);
@@ -929,7 +930,7 @@ int UtcDaliSceneSurfaceResizedDefaultSceneViewport(void)
   Vector2     newSize(1000.0f, 2000.0f);
   std::string viewportParams("0, 0, 1000, 2000"); // to match newSize
   DALI_TEST_CHECK(stage.GetSize() != newSize);
-  defaultScene.SurfaceResized(newSize.width, newSize.height);
+  defaultScene.SurfaceResized(newSize.width, newSize.height, 0, false);
 
   DALI_TEST_EQUALS(stage.GetSize(), newSize, TEST_LOCATION);
   DALI_TEST_EQUALS(defaultScene.GetSize(), newSize, TEST_LOCATION);
@@ -1001,7 +1002,7 @@ int UtcDaliSceneSurfaceResizedMultipleRenderTasks(void)
   Vector2     newSize(1000.0f, 2000.0f);
   std::string viewportParams("0, 0, 1000, 2000"); // to match newSize
   DALI_TEST_CHECK(stage.GetSize() != newSize);
-  defaultScene.SurfaceResized(newSize.width, newSize.height);
+  defaultScene.SurfaceResized(newSize.width, newSize.height, 0, false);
 
   DALI_TEST_EQUALS(stage.GetSize(), newSize, TEST_LOCATION);
   DALI_TEST_EQUALS(defaultScene.GetSize(), newSize, TEST_LOCATION);
@@ -1041,7 +1042,8 @@ int UtcDaliSceneSurfaceResizedAdditionalScene(void)
   // Resize the surface and inform the scene accordingly
   Vector2 newSize(1000.0f, 2000.0f);
   DALI_TEST_CHECK(stage.GetSize() != newSize);
-  scene.SurfaceResized(newSize.width, newSize.height);
+
+  scene.SurfaceResized(newSize.width, newSize.height, 0, false);
 
   // Ensure the stage hasn't been resized
   DALI_TEST_EQUALS(stage.GetSize(), stageSize, TEST_LOCATION);
index 6d69db8..4389c60 100644 (file)
@@ -112,9 +112,9 @@ Layer Scene::GetLayer(uint32_t depth) const
   return GetImplementation(*this).GetLayer(depth);
 }
 
-void Scene::SurfaceResized(float width, float height)
+void Scene::SurfaceResized(float width, float height, int orientation, bool forceUpdate)
 {
-  GetImplementation(*this).SurfaceResized(width, height);
+  GetImplementation(*this).SurfaceResized(width, height, orientation, forceUpdate);
 }
 
 void Scene::SurfaceReplaced()
index e396295..1f6a60a 100644 (file)
@@ -213,8 +213,10 @@ public:
    *
    * @param[in] width The new width of the set surface
    * @param[in] height The new height of the set surface
+   * @param[in] orientation The orientation of the surface
+   * @param[in] forceUpdate The flag to update force
    */
-  void SurfaceResized(float width, float height);
+  void SurfaceResized(float width, float height, int orientation, bool forceUpdate);
 
   /**
    * @brief Informs the scene that the surface has been replaced.
index fecea3c..d637337 100644 (file)
@@ -524,6 +524,12 @@ const SceneGraph::Camera* CameraActor::GetCamera() const
   return mSceneObject;
 }
 
+void CameraActor::RotateProjection( int rotationAngle )
+{
+  // sceneObject is being used in a separate thread; queue a message to set
+  RotateProjectionMessage( GetEventThreadServices(), *mSceneObject, rotationAngle );
+}
+
 void CameraActor::SetDefaultProperty( Property::Index index, const Property::Value& propertyValue )
 {
   if(index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT)
index 4463ba1..dac4483 100644 (file)
@@ -204,6 +204,13 @@ public:
    */
   const SceneGraph::Camera* GetCamera() const;
 
+  /**
+   * Rotate the projection.
+   * It is used in case that the target buffer direction is different from the window direction.
+   * @param [in] rotationAngle The rotation angle
+   */
+  void RotateProjection( int rotationAngle );
+
 public: // properties
 
   /**
index 4397ac4..208c1f7 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() )
 {
@@ -142,7 +143,7 @@ void Scene::Initialize( Size size, int orientation )
   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();
@@ -210,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 );
index 66247bc..c84d4c6 100755 (executable)
@@ -176,8 +176,10 @@ public:
    *
    * @param[in] width The new width of the set surface
    * @param[in] height The new height of the set surface
+   * @param[in] orientation The orientation of the surface
+   * @param[in] forceUpdate The flag to update force
    */
-  void SurfaceResized( float width, float height );
+  void SurfaceResized( float width, float height, int orientation, bool forceUpdate );
 
   /**
    * @copydoc Dali::Integration::Scene::SurfaceReplaced
@@ -362,6 +364,9 @@ private:
 
   Vector4 mBackgroundColor;
 
+  // The SurfaceOrientation
+  int mSurfaceOrientation;
+
   LayerPtr mRootLayer;
 
   // Ordered list of currently on-stage layers
index d40614c..406f216 100755 (executable)
@@ -231,7 +231,7 @@ inline void SetupDepthBuffer( const RenderItem& item, Context& context, bool dep
  * @param[in]     item                     The current RenderItem about to be rendered
  * @param[in]     context                  The context
  */
-inline void RenderAlgorithms::SetupScissorClipping( const RenderItem& item, Context& context )
+inline void RenderAlgorithms::SetupScissorClipping( const RenderItem& item, Context& context, int orientation )
 {
   // Get the number of child scissors in the stack (do not include layer or root box).
   size_t childStackDepth = mScissorStack.size() - 1u;
@@ -292,7 +292,30 @@ inline void RenderAlgorithms::SetupScissorClipping( const RenderItem& item, Cont
     if( scissorEnabled )
     {
       ClippingBox useScissorBox( mScissorStack.back() );
-      context.Scissor( useScissorBox.x, useScissorBox.y, useScissorBox.width, useScissorBox.height );
+      GLint x = useScissorBox.x;
+      GLint y = useScissorBox.y;
+      if( orientation == 90 )
+      {
+        x = mViewportRectangle.height - (useScissorBox.y + useScissorBox.height);
+        y = useScissorBox.x;
+        context.Scissor( x, y, useScissorBox.height, useScissorBox.width );
+      }
+      else if( orientation == 180 )
+      {
+        x = mViewportRectangle.width - (useScissorBox.x + useScissorBox.width);
+        y = mViewportRectangle.height - (useScissorBox.y + useScissorBox.height);
+        context.Scissor( x, y, useScissorBox.width, useScissorBox.height );
+      }
+      else if( orientation == 270 )
+      {
+        x = useScissorBox.y;
+        y = mViewportRectangle.width - (useScissorBox.x + useScissorBox.width);
+        context.Scissor( x, y, useScissorBox.height, useScissorBox.width );
+      }
+      else
+      {
+        context.Scissor( x, y, useScissorBox.width, useScissorBox.height );
+      }
     }
   }
 }
@@ -302,7 +325,8 @@ inline void RenderAlgorithms::SetupClipping( const RenderItem& item,
                                              bool& usedStencilBuffer,
                                              uint32_t& lastClippingDepth,
                                              uint32_t& lastClippingId,
-                                             Integration::StencilBufferAvailable stencilBufferAvailable )
+                                             Integration::StencilBufferAvailable stencilBufferAvailable,
+                                             int orientation )
 {
   RenderMode::Type renderMode = RenderMode::AUTO;
   const Renderer *renderer = item.mRenderer;
@@ -324,7 +348,7 @@ inline void RenderAlgorithms::SetupClipping( const RenderItem& item,
       // As both scissor and stencil clips can be nested, we may be simultaneously traversing up the scissor tree, requiring a scissor to be un-done. Whilst simultaneously adding a new stencil clip.
       // We process both based on our current and old clipping depths for each mode.
       // Both methods with return rapidly if there is nothing to be done for that type of clipping.
-      SetupScissorClipping( item, context );
+      SetupScissorClipping( item, context, orientation );
 
       if( stencilBufferAvailable == Integration::StencilBufferAvailable::TRUE )
       {
@@ -392,8 +416,8 @@ inline void RenderAlgorithms::ProcessRenderList( const RenderList& renderList,
                                                  Integration::StencilBufferAvailable stencilBufferAvailable,
                                                  Vector<GLuint>& boundTextures,
                                                  const RenderInstruction& instruction,
-                                                 const Rect<int>& rootClippingRect
-                                                 )
+                                                 const Rect<int>& rootClippingRect,
+                                                 int orientation )
 {
   DALI_PRINT_RENDER_LIST( renderList );
 
@@ -410,6 +434,13 @@ inline void RenderAlgorithms::ProcessRenderList( const RenderList& renderList,
   mViewportRectangle = context.GetViewport();
   mHasLayerScissor = false;
 
+  if( orientation == 90 || orientation == 270 )
+  {
+    int temp = mViewportRectangle.width;
+    mViewportRectangle.width = mViewportRectangle.height;
+    mViewportRectangle.height = temp;
+  }
+
   // Setup Scissor testing (for both viewport and per-node scissor)
   mScissorStack.clear();
 
@@ -432,7 +463,32 @@ inline void RenderAlgorithms::ProcessRenderList( const RenderList& renderList,
   {
     context.SetScissorTest( true );
     const ClippingBox& layerScissorBox = renderList.GetClippingBox();
-    context.Scissor( layerScissorBox.x, layerScissorBox.y, layerScissorBox.width, layerScissorBox.height );
+    GLint x = layerScissorBox.x;
+    GLint y = layerScissorBox.y;
+
+    if( orientation == 90 )
+    {
+      x = mViewportRectangle.height - (layerScissorBox.y + layerScissorBox.height);
+      y = layerScissorBox.x;
+      context.Scissor( x, y, layerScissorBox.height, layerScissorBox.width );
+    }
+    else if( orientation == 180 )
+    {
+      x = mViewportRectangle.width - (layerScissorBox.x + layerScissorBox.width);
+      y = mViewportRectangle.height - (layerScissorBox.y + layerScissorBox.height);
+      context.Scissor( x, y, layerScissorBox.width, layerScissorBox.height );
+    }
+    else if( orientation == 270 )
+    {
+      x = layerScissorBox.y;
+      y = mViewportRectangle.width - (layerScissorBox.x + layerScissorBox.width);
+      context.Scissor( x, y, layerScissorBox.height, layerScissorBox.width );
+    }
+    else
+    {
+      context.Scissor( x, y, layerScissorBox.width, layerScissorBox.height );
+    }
+
     mScissorStack.push_back( layerScissorBox );
     mHasLayerScissor = true;
   }
@@ -462,7 +518,7 @@ inline void RenderAlgorithms::ProcessRenderList( const RenderList& renderList,
 
     // Set up clipping based on both the Renderer and Actor APIs.
     // The Renderer API will be used if specified. If AUTO, the Actors automatic clipping feature will be used.
-    SetupClipping( item, context, usedStencilBuffer, lastClippingDepth, lastClippingId, stencilBufferAvailable );
+    SetupClipping( item, context, usedStencilBuffer, lastClippingDepth, lastClippingId, stencilBufferAvailable, orientation );
 
     if( DALI_LIKELY( item.mRenderer ) )
     {
@@ -507,7 +563,8 @@ void RenderAlgorithms::ProcessRenderInstruction( const RenderInstruction& instru
                                                  Integration::DepthBufferAvailable depthBufferAvailable,
                                                  Integration::StencilBufferAvailable stencilBufferAvailable,
                                                  Vector<GLuint>& boundTextures,
-                                                 const Rect<int>& rootClippingRect )
+                                                 const Rect<int>& rootClippingRect,
+                                                 int orientation )
 {
   DALI_PRINT_RENDER_INSTRUCTION( instruction, bufferIndex );
 
@@ -538,7 +595,8 @@ void RenderAlgorithms::ProcessRenderInstruction( const RenderInstruction& instru
                             stencilBufferAvailable,
                             boundTextures,
                             instruction, //added for reflection effect
-                            rootClippingRect );
+                            rootClippingRect,
+                            orientation );
       }
     }
   }
index 9d359b4..ee5fd12 100644 (file)
@@ -66,7 +66,8 @@ class RenderAlgorithms
                                    Integration::DepthBufferAvailable depthBufferAvailable,
                                    Integration::StencilBufferAvailable stencilBufferAvailable,
                                    Vector<GLuint>& boundTextures,
-                                   const Rect<int>& rootClippingRect );
+                                   const Rect<int>& rootClippingRect,
+                                   int orientation);
 
   private:
 
@@ -89,7 +90,7 @@ class RenderAlgorithms
      * @param[in] item     The current RenderItem (about to be rendered)
      * @param[in] context  The current Context
      */
-    inline void SetupScissorClipping( const Dali::Internal::SceneGraph::RenderItem& item, Context& context );
+    inline void SetupScissorClipping( const Dali::Internal::SceneGraph::RenderItem& item, Context& context, int orientation );
 
     /**
      * @brief Set up the clipping based on the specified clipping settings.
@@ -105,7 +106,8 @@ class RenderAlgorithms
                                bool& usedStencilBuffer,
                                uint32_t& lastClippingDepth,
                                uint32_t& lastClippingId,
-                               Integration::StencilBufferAvailable stencilBufferAvailable );
+                               Integration::StencilBufferAvailable stencilBufferAvailable,
+                               int orientation );
 
     /**
      * @brief Process a render-list.
@@ -127,7 +129,8 @@ class RenderAlgorithms
                                    Integration::StencilBufferAvailable stencilBufferAvailable,
                                    Vector<GLuint>& boundTextures,
                                    const Dali::Internal::SceneGraph::RenderInstruction& instruction, // in the case of reflection, things like CullFace need to be adjusted for reflection world
-                                   const Rect<int>& rootClippingRect );
+                                   const Rect<int>& rootClippingRect,
+                                   int orientation );
 
     // Prevent copying:
     RenderAlgorithms( RenderAlgorithms& rhs );
index 8f59b13..91a48f4 100644 (file)
@@ -122,7 +122,7 @@ public:
   const Matrix* GetProjectionMatrix( BufferIndex index ) const
   {
     // inlined as this is called once per frame per render instruction
-    return &mCamera->GetProjectionMatrix( index );
+    return &mCamera->GetFinalProjectionMatrix( index );
   }
   // for reflection effect
   const Camera* GetCamera() const
index e885c33..d819228 100755 (executable)
@@ -77,7 +77,8 @@ struct RenderManager::Impl
     programController( glAbstraction ),
     depthBufferAvailable( depthBufferAvailableParam ),
     stencilBufferAvailable( stencilBufferAvailableParam ),
-    partialUpdateAvailable( partialUpdateAvailableParam )
+    partialUpdateAvailable( partialUpdateAvailableParam ),
+    defaultSurfaceOrientation( 0 )
   {
      // Create thread pool with just one thread ( there may be a need to create more threads in the future ).
     threadPool = std::unique_ptr<Dali::ThreadPool>( new Dali::ThreadPool() );
@@ -174,6 +175,7 @@ struct RenderManager::Impl
   std::unique_ptr<Dali::ThreadPool>         threadPool;               ///< The thread pool
   Vector<GLuint>                            boundTextures;            ///< The textures bound for rendering
   Vector<GLuint>                            textureDependencyList;    ///< The dependency list of binded textures
+  int                                       defaultSurfaceOrientation; ///< defaultSurfaceOrientation for the default surface we are rendering to
 };
 
 RenderManager* RenderManager::New( Integration::GlAbstraction& glAbstraction,
@@ -257,6 +259,11 @@ void RenderManager::SetDefaultSurfaceRect(const Rect<int32_t>& rect)
   mImpl->defaultSurfaceRect = rect;
 }
 
+void RenderManager::SetDefaultSurfaceOrientation( int orientation )
+{
+  mImpl->defaultSurfaceOrientation = orientation;
+}
+
 void RenderManager::AddRenderer( OwnerPointer< Render::Renderer >& renderer )
 {
   // Initialize the renderer as we are now in render thread
@@ -822,6 +829,7 @@ void RenderManager::RenderScene( Integration::RenderStatus& status, Integration:
     Rect<int32_t> surfaceRect = mImpl->defaultSurfaceRect;
     Integration::DepthBufferAvailable depthBufferAvailable = mImpl->depthBufferAvailable;
     Integration::StencilBufferAvailable stencilBufferAvailable = mImpl->stencilBufferAvailable;
+    int surfaceOrientation = mImpl->defaultSurfaceOrientation;
 
     if ( instruction.mFrameBuffer )
     {
@@ -921,6 +929,7 @@ void RenderManager::RenderScene( Integration::RenderStatus& status, Integration:
       {
         viewportRect.Set( 0, 0, instruction.mFrameBuffer->GetWidth(), instruction.mFrameBuffer->GetHeight() );
       }
+      surfaceOrientation = 0;
     }
     else // No Offscreen frame buffer rendering
     {
@@ -937,6 +946,13 @@ void RenderManager::RenderScene( Integration::RenderStatus& status, Integration:
       }
     }
 
+    if( surfaceOrientation == 90 || surfaceOrientation == 270 )
+    {
+      int temp = viewportRect.width;
+      viewportRect.width = viewportRect.height;
+      viewportRect.height = temp;
+    }
+
     bool clearFullFrameRect = true;
     if( instruction.mFrameBuffer != nullptr )
     {
@@ -1000,7 +1016,8 @@ void RenderManager::RenderScene( Integration::RenderStatus& status, Integration:
         depthBufferAvailable,
         stencilBufferAvailable,
         mImpl->boundTextures,
-        clippingRect );
+        clippingRect,
+        surfaceOrientation );
 
     // Synchronise the FBO/Texture access when there are multiple contexts
     if ( mImpl->currentContext->IsSurfacelessContextSupported() )
index 2e3ea2d..dd6ce7a 100644 (file)
@@ -131,6 +131,12 @@ public:
   void SetDefaultSurfaceRect( const Rect<int>& rect );
 
   /**
+   * Returns the orintation for the default surface (probably the application window).
+   * @return Orientation for the surface.
+   */
+  void SetDefaultSurfaceOrientation( int orientation );
+
+  /**
    * Add a Renderer to the render manager.
    * @param[in] renderer The renderer to add.
    * @post renderer is owned by RenderManager
index a7ca327..ce30100 100644 (file)
@@ -1148,6 +1148,17 @@ void UpdateManager::SurfaceReplaced( Scene* scene )
   new (slot) DerivedType( &mImpl->renderManager,  &RenderManager::SurfaceReplaced, scene );
 }
 
+void UpdateManager::SetDefaultSurfaceOrientation( int orientation )
+{
+  typedef MessageValue1< RenderManager, int > DerivedType;
+
+  // Reserve some memory inside the render queue
+  unsigned int* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
+
+  // Construct message in the render queue memory; note that delete should not be called on the return value
+  new (slot) DerivedType( &mImpl->renderManager,  &RenderManager::SetDefaultSurfaceOrientation, orientation );
+}
+
 void UpdateManager::KeepRendering( float durationSeconds )
 {
   mImpl->keepRenderingSeconds = std::max( mImpl->keepRenderingSeconds, durationSeconds );
index 8f272d8..0954733 100644 (file)
@@ -634,6 +634,12 @@ public:
   void SetDefaultSurfaceRect( const Rect<int>& rect );
 
   /**
+   * Set the default surface orientation.
+   * @param[in] orientation The orientation value representing the surface.
+   */
+  void SetDefaultSurfaceOrientation( int orientation );
+
+  /**
    * @copydoc Dali::Stage::KeepRendering()
    */
   void KeepRendering( float durationSeconds );
@@ -1095,6 +1101,17 @@ inline void SurfaceReplacedMessage( UpdateManager& manager, const SceneGraph::Sc
   new (slot) LocalType( &manager, &UpdateManager::SurfaceReplaced, &scene );
 }
 
+inline void SetDefaultSurfaceOrientationMessage( UpdateManager& manager, int orientation  )
+{
+  typedef MessageValue1< UpdateManager, int > LocalType;
+
+  // Reserve some memory inside the message queue
+  unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
+
+  // Construct message in the message queue memory; note that delete should not be called on the return value
+  new (slot) LocalType( &manager, &UpdateManager::SetDefaultSurfaceOrientation, orientation );
+}
+
 inline void KeepRenderingMessage( UpdateManager& manager, float durationSeconds )
 {
   using LocalType = MessageValue1<UpdateManager, float>;
index e644bb3..a27b886 100644 (file)
@@ -161,6 +161,7 @@ const Vector3 Camera::DEFAULT_TARGET_POSITION( 0.0f, 0.0f, 0.0f );
 Camera::Camera()
 : mUpdateViewFlag( UPDATE_COUNT ),
   mUpdateProjectionFlag( UPDATE_COUNT ),
+  mProjectionRotation( 0 ),
   mNode( nullptr ),
   mType( DEFAULT_TYPE ),
   mProjectionMode( DEFAULT_MODE ),
@@ -176,7 +177,8 @@ Camera::Camera()
   mTargetPosition( DEFAULT_TARGET_POSITION ),
   mViewMatrix(),
   mProjectionMatrix(),
-  mInverseViewProjection( Matrix::IDENTITY )
+  mInverseViewProjection( Matrix::IDENTITY ),
+  mFinalProjection( Matrix::IDENTITY )
 {
 }
 
@@ -268,8 +270,6 @@ void Camera::SetTargetPosition( const Vector3& targetPosition )
   mUpdateViewFlag = UPDATE_COUNT;
 }
 
-
-
 void VectorReflectedByPlane(Vector4 &out, Vector4 &in, Vector4 &plane)
 {
   float d = float(2.0) * plane.Dot(in);
@@ -331,6 +331,12 @@ void Camera::SetReflectByPlane( const Vector4& plane )
   mUpdateViewFlag = UPDATE_COUNT;
 }
 
+void Camera::RotateProjection( int rotationAngle )
+{
+  mProjectionRotation = rotationAngle;
+  mUpdateViewFlag = UPDATE_COUNT;
+}
+
 const Matrix& Camera::GetProjectionMatrix( BufferIndex bufferIndex ) const
 {
   return mProjectionMatrix[ bufferIndex ];
@@ -346,6 +352,11 @@ const Matrix& Camera::GetInverseViewProjectionMatrix( BufferIndex bufferIndex )
   return mInverseViewProjection[ bufferIndex ];
 }
 
+const Matrix& Camera::GetFinalProjectionMatrix( BufferIndex bufferIndex ) const
+{
+  return mFinalProjection[ bufferIndex ];
+}
+
 const PropertyInputImpl* Camera::GetProjectionMatrix() const
 {
   return &mProjectionMatrix;
@@ -655,6 +666,38 @@ uint32_t Camera::UpdateProjection( BufferIndex updateBufferIndex )
       }
 
       mProjectionMatrix.SetDirty( updateBufferIndex );
+
+      Matrix &finalProjection = mFinalProjection[ updateBufferIndex ];
+      finalProjection.SetIdentity();
+
+      Quaternion rotationAngle;
+      switch( mProjectionRotation )
+      {
+        case 90:
+        {
+          rotationAngle = Quaternion( Dali::ANGLE_90, Vector3::ZAXIS );
+          break;
+        }
+        case 180:
+        {
+          rotationAngle = Quaternion( Dali::ANGLE_180, Vector3::ZAXIS );
+          break;
+        }
+        case 270:
+        {
+          rotationAngle = Quaternion( Dali::ANGLE_270, Vector3::ZAXIS );
+          break;
+        }
+        default:
+          rotationAngle = Quaternion( Dali::ANGLE_0, Vector3::ZAXIS );
+          break;
+      }
+
+      Matrix rotation;
+      rotation.SetIdentity();
+      rotation.SetTransformComponents( Vector3( 1.0f, 1.0f, 1.0f ), rotationAngle, Vector3( 0.0f, 0.0f, 0.0f ) );
+
+      Matrix::Multiply( finalProjection, mProjectionMatrix.Get( updateBufferIndex ), rotation );
     }
     --mUpdateProjectionFlag;
   }
index c5917a0..f61ddc6 100644 (file)
@@ -161,6 +161,11 @@ public:
   void SetFarClippingPlane( float farClippingPlane );
 
   /**
+   * @copydoc Dali::Internal::CameraActor::RotateProjection
+   */
+  void RotateProjection( int rotationAngle );
+
+  /**
    * @copydoc Dali::Internal::CameraActor::SetTarget
    */
   void SetTargetPosition( const Vector3& targetPosition );
@@ -224,6 +229,13 @@ public:
   const Matrix& GetInverseViewProjectionMatrix( BufferIndex bufferIndex ) const;
 
   /**
+   * Retrieve the final projection-matrix; this is double buffered for input handling.
+   * @param[in] bufferIndex The buffer to read from.
+   * @return The projection-matrix that should be used to render.
+   */
+  const Matrix& GetFinalProjectionMatrix( BufferIndex bufferIndex ) const;
+
+  /**
    * Retrieve the projection-matrix property querying interface.
    * @pre The camera is on-stage.
    * @return The projection-matrix property querying interface.
@@ -295,6 +307,7 @@ private:
 
   uint32_t                  mUpdateViewFlag;       ///< This is non-zero if the view matrix requires an update
   uint32_t                  mUpdateProjectionFlag; ///< This is non-zero if the projection matrix requires an update
+  int                       mProjectionRotation;   ///< The rotaion angle of the projection
   const Node*                   mNode;                 ///< The node this scene graph camera belongs to
 
 public:  // PROPERTIES
@@ -323,6 +336,7 @@ public:  // PROPERTIES
 
   DoubleBuffered< FrustumPlanes > mFrustum;               ///< Clipping frustum; double buffered for input handling
   DoubleBuffered< Matrix >        mInverseViewProjection; ///< Inverted viewprojection; double buffered for input handling
+  DoubleBuffered< Matrix >        mFinalProjection;       ///< Final projection matrix; double buffered for input handling
 
 };
 
@@ -460,6 +474,17 @@ inline void SetInvertYAxisMessage( EventThreadServices& eventThreadServices, con
   new (slot) LocalType( &camera, &Camera::SetInvertYAxis, parameter );
 }
 
+inline void RotateProjectionMessage( EventThreadServices& eventThreadServices, const Camera& camera, int parameter )
+{
+  typedef MessageValue1< Camera, int > LocalType;
+
+  // Reserve some memory inside the message queue
+  unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+
+  // Construct message in the message queue memory; note that delete should not be called on the return value
+  new (slot) LocalType( &camera, &Camera::RotateProjection, parameter );
+}
+
 } // namespace SceneGraph
 
 } // namespace Internal