Revert "[Tizen] Partial rendering rotation does not work"
[platform/core/uifw/dali-core.git] / dali / internal / render / common / render-manager.cpp
index 56495cc..c44c328 100644 (file)
@@ -41,8 +41,9 @@
 #include <dali/internal/render/renderers/uniform-buffer-manager.h>
 #include <dali/internal/render/renderers/uniform-buffer-view-pool.h>
 #include <dali/internal/render/shaders/program-controller.h>
+#include <dali/internal/render/renderers/pipeline-cache.h>
 
-#include <dali/internal/render/renderers/uniform-buffer-manager.h>
+#include <memory>
 
 namespace Dali
 {
@@ -57,6 +58,43 @@ Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_REN
 } // unnamed namespace
 #endif
 
+namespace
+{
+inline Graphics::Rect2D RecalculateScissorArea(Graphics::Rect2D scissorArea, int orientation, Rect<int32_t> viewportRect)
+{
+  Graphics::Rect2D newScissorArea;
+
+  if(orientation == 90)
+  {
+    newScissorArea.x      = viewportRect.height - (scissorArea.y + scissorArea.height);
+    newScissorArea.y      = scissorArea.x;
+    newScissorArea.width  = scissorArea.height;
+    newScissorArea.height = scissorArea.width;
+  }
+  else if(orientation == 180)
+  {
+    newScissorArea.x      = viewportRect.width - (scissorArea.x + scissorArea.width);
+    newScissorArea.y      = viewportRect.height - (scissorArea.y + scissorArea.height);
+    newScissorArea.width  = scissorArea.width;
+    newScissorArea.height = scissorArea.height;
+  }
+  else if(orientation == 270)
+  {
+    newScissorArea.x      = scissorArea.y;
+    newScissorArea.y      = viewportRect.width - (scissorArea.x + scissorArea.width);
+    newScissorArea.width  = scissorArea.height;
+    newScissorArea.height = scissorArea.width;
+  }
+  else
+  {
+    newScissorArea.x      = scissorArea.x;
+    newScissorArea.y      = scissorArea.y;
+    newScissorArea.width  = scissorArea.width;
+    newScissorArea.height = scissorArea.height;
+  }
+  return newScissorArea;
+}
+} // namespace
 /**
  * Structure to contain internal data
  */
@@ -83,10 +121,11 @@ struct RenderManager::Impl
     partialUpdateAvailable(partialUpdateAvailableParam)
   {
     // 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());
+    threadPool = std::make_unique<Dali::ThreadPool>();
     threadPool->Initialize(1u);
 
-    uniformBufferManager.reset(new Render::UniformBufferManager(&graphicsController));
+    uniformBufferManager = std::make_unique<Render::UniformBufferManager>(&graphicsController);
+    pipelineCache = std::make_unique<Render::PipelineCache>(graphicsController);
   }
 
   ~Impl()
@@ -139,6 +178,7 @@ struct RenderManager::Impl
   Render::ShaderCache shaderCache;       ///< The cache for the graphics shaders
 
   std::unique_ptr<Render::UniformBufferManager> uniformBufferManager; ///< The uniform buffer manager
+  std::unique_ptr<Render::PipelineCache> pipelineCache;
 
   Integration::DepthBufferAvailable   depthBufferAvailable;   ///< Whether the depth buffer is available
   Integration::StencilBufferAvailable stencilBufferAvailable; ///< Whether the stencil buffer is available
@@ -184,7 +224,8 @@ void RenderManager::SetShaderSaver(ShaderSaver& upstream)
 void RenderManager::AddRenderer(OwnerPointer<Render::Renderer>& renderer)
 {
   // Initialize the renderer as we are now in render thread
-  renderer->Initialize(mImpl->graphicsController, mImpl->programController, mImpl->shaderCache, *(mImpl->uniformBufferManager.get()));
+  renderer->Initialize(mImpl->graphicsController, mImpl->programController, mImpl->shaderCache, *(mImpl->uniformBufferManager.get()),
+                       *(mImpl->pipelineCache.get()));
 
   mImpl->rendererContainer.PushBack(renderer.Release());
 }
@@ -877,6 +918,11 @@ void RenderManager::RenderScene(Integration::RenderStatus& status, Integration::
       }
     }
 
+    // Scissor's value should be set based on the default system coordinates.
+    // When the surface is rotated, the input values already were set with the rotated angle.
+    // So, re-calculation is needed.
+    scissorArea = RecalculateScissorArea(scissorArea, surfaceOrientation, viewportRect);
+
     // Begin render pass
     mainCommandBuffer->BeginRenderPass(
       currentRenderPass,