[Tizen] Add screen and client rotation itself function
[platform/core/uifw/dali-core.git] / dali / internal / render / common / render-manager.cpp
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() )