Revert "[Tizen] Implement partial update"
[platform/core/uifw/dali-core.git] / dali / internal / render / common / render-manager.cpp
index ec299cb..910cb05 100644 (file)
@@ -90,7 +90,8 @@ struct RenderManager::Impl
     lastFrameWasRendered( false ),
     programController( glAbstraction ),
     depthBufferAvailable( depthBufferAvailableParam ),
-    stencilBufferAvailable( stencilBufferAvailableParam )
+    stencilBufferAvailable( stencilBufferAvailableParam ),
+    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() );
@@ -171,6 +172,8 @@ 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,
@@ -251,6 +254,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
@@ -597,6 +605,7 @@ void RenderManager::DoRender( RenderInstruction& instruction )
   }
 
   Rect<int32_t> surfaceRect = mImpl->defaultSurfaceRect;
+  int surfaceOrientation = mImpl->defaultSurfaceOrientation;
   Integration::DepthBufferAvailable depthBufferAvailable = mImpl->depthBufferAvailable;
   Integration::StencilBufferAvailable stencilBufferAvailable = mImpl->stencilBufferAvailable;
 
@@ -655,7 +664,10 @@ void RenderManager::DoRender( RenderInstruction& instruction )
     {
       // For each offscreen buffer, update the dependency list with the new texture id used by this frame buffer.
       Render::TextureFrameBuffer* textureFrameBuffer = static_cast<Render::TextureFrameBuffer*>( instruction.mFrameBuffer );
-      mImpl->textureDependencyList.PushBack( textureFrameBuffer->GetTextureId() );
+      for (unsigned int i0 = 0, i1 = textureFrameBuffer->GetColorAttachmentCount(); i0 < i1; ++i0)
+      {
+        mImpl->textureDependencyList.PushBack( textureFrameBuffer->GetTextureId(i0) );
+      }
     }
   }
   else
@@ -701,7 +713,7 @@ void RenderManager::DoRender( RenderInstruction& instruction )
         // For glViewport the lower-left corner is (0,0)
         // For glViewport the lower-left corner is (0,0)
         const int32_t y = ( surfaceRect.height - instruction.mViewport.height ) - instruction.mViewport.y;
-        viewportRect.Set( instruction.mViewport.x,  y, instruction.mViewport.width, instruction.mViewport.height );
+        viewportRect.Set( instruction.mViewport.x, y, instruction.mViewport.width, instruction.mViewport.height );
       }
       else
       {
@@ -720,6 +732,7 @@ void RenderManager::DoRender( RenderInstruction& instruction )
       {
         viewportRect.Set( 0, 0, instruction.mFrameBuffer->GetWidth(), instruction.mFrameBuffer->GetHeight() );
       }
+      surfaceOrientation = 0;
     }
   }
   else // No Offscreen frame buffer rendering
@@ -731,7 +744,7 @@ void RenderManager::DoRender( RenderInstruction& instruction )
       {
         // For glViewport the lower-left corner is (0,0)
         const int32_t y = ( instruction.mFrameBuffer->GetHeight() - instruction.mViewport.height ) - instruction.mViewport.y;
-        viewportRect.Set( instruction.mViewport.x,  y, instruction.mViewport.width, instruction.mViewport.height );
+        viewportRect.Set( instruction.mViewport.x, y, instruction.mViewport.width, instruction.mViewport.height );
       }
       else
       {
@@ -755,23 +768,34 @@ void RenderManager::DoRender( RenderInstruction& instruction )
     clearFullFrameRect = ( surfaceRect == viewportRect );
   }
 
-  mImpl->currentContext->Viewport(viewportRect.x, viewportRect.y, viewportRect.width, viewportRect.height);
-  mImpl->currentContext->ClearColor( clearColor.r,
-                                     clearColor.g,
-                                     clearColor.b,
-                                     clearColor.a );
-
-  if( instruction.mIsClearColorSet && !clearFullFrameRect )
+  if ( surfaceOrientation == 90 || surfaceOrientation == 270 )
   {
-    mImpl->currentContext->SetScissorTest( true );
-    mImpl->currentContext->Scissor( viewportRect.x, viewportRect.y, viewportRect.width, viewportRect.height );
-    mImpl->currentContext->Clear( clearMask, Context::FORCE_CLEAR );
-    mImpl->currentContext->SetScissorTest( false );
+    int temp = viewportRect.width;
+    viewportRect.width = viewportRect.height;
+    viewportRect.height = temp;
   }
-  else
+
+  mImpl->currentContext->Viewport(viewportRect.x, viewportRect.y, viewportRect.width, viewportRect.height);
+
+  if( instruction.mIsClearColorSet )
   {
-    mImpl->currentContext->SetScissorTest( false );
-    mImpl->currentContext->Clear( clearMask, Context::FORCE_CLEAR );
+    mImpl->currentContext->ClearColor( clearColor.r,
+                                       clearColor.g,
+                                       clearColor.b,
+                                       clearColor.a );
+
+    if( !clearFullFrameRect )
+    {
+      mImpl->currentContext->SetScissorTest( true );
+      mImpl->currentContext->Scissor( viewportRect.x, viewportRect.y, viewportRect.width, viewportRect.height );
+      mImpl->currentContext->Clear( clearMask, Context::FORCE_CLEAR );
+      mImpl->currentContext->SetScissorTest( false );
+    }
+    else
+    {
+      mImpl->currentContext->SetScissorTest( false );
+      mImpl->currentContext->Clear( clearMask, Context::FORCE_CLEAR );
+    }
   }
 
   // Clear the list of bound textures
@@ -783,7 +807,8 @@ void RenderManager::DoRender( RenderInstruction& instruction )
       mImpl->renderBufferIndex,
       depthBufferAvailable,
       stencilBufferAvailable,
-      mImpl->boundTextures );
+      mImpl->boundTextures,
+      surfaceOrientation );
 
   // Synchronise the FBO/Texture access when there are multiple contexts
   if ( mImpl->currentContext->IsSurfacelessContextSupported() )