Revert "[Tizen] Support Client Rotation and Screen Rotation"
[platform/core/uifw/dali-core.git] / dali / internal / render / common / render-manager.cpp
index 2d4d9e8..2d550b5 100644 (file)
@@ -50,6 +50,13 @@ namespace Internal
 namespace SceneGraph
 {
 
+#if defined(DEBUG_ENABLED)
+namespace
+{
+Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_RENDER_MANAGER" );
+} // unnamed namespace
+#endif
+
 /**
  * Structure to contain internal data
  */
@@ -303,16 +310,17 @@ void RenderManager::SetWrapMode( Render::Sampler* sampler, uint32_t rWrapMode, u
   sampler->mTWrapMode = static_cast<Dali::WrapMode::Type>(tWrapMode);
 }
 
-void RenderManager::AddFrameBuffer( Render::FrameBuffer* frameBuffer )
+void RenderManager::AddFrameBuffer( OwnerPointer< Render::FrameBuffer >& frameBuffer )
 {
-  mImpl->frameBufferContainer.PushBack( frameBuffer );
-  if ( frameBuffer->IsSurfaceBacked() )
+  Render::FrameBuffer* frameBufferPtr = frameBuffer.Release();
+  mImpl->frameBufferContainer.PushBack( frameBufferPtr );
+  if ( frameBufferPtr->IsSurfaceBacked() )
   {
-    frameBuffer->Initialize( *mImpl->CreateSurfaceContext() );
+    frameBufferPtr->Initialize( *mImpl->CreateSurfaceContext() );
   }
   else
   {
-    frameBuffer->Initialize( mImpl->context );
+    frameBufferPtr->Initialize( mImpl->context );
   }
 }
 
@@ -450,9 +458,17 @@ void RenderManager::Render( Integration::RenderStatus& status, bool forceClear )
   const uint32_t count = mImpl->instructions.Count( mImpl->renderBufferIndex );
   const bool haveInstructions = count > 0u;
 
+  DALI_LOG_INFO( gLogFilter, Debug::General,
+                 "Render: haveInstructions(%s) || mImpl->lastFrameWasRendered(%s) || forceClear(%s)\n",
+                 haveInstructions ? "true" : "false",
+                 mImpl->lastFrameWasRendered ? "true" : "false",
+                 forceClear ? "true" : "false" );
+
   // Only render if we have instructions to render, or the last frame was rendered (and therefore a clear is required).
   if( haveInstructions || mImpl->lastFrameWasRendered || forceClear )
   {
+    DALI_LOG_INFO( gLogFilter, Debug::General, "Render: Processing\n" );
+
     // Mark that we will require a post-render step to be performed (includes swap-buffers).
     status.SetNeedsPostRender( true );
 
@@ -521,6 +537,10 @@ void RenderManager::Render( Integration::RenderStatus& status, bool forceClear )
       iter->OnRenderFinished();
     }
   }
+  else
+  {
+    DALI_LOG_RELEASE_INFO( "RenderManager::Render: Skip rendering [%d, %d, %d]\n", haveInstructions, mImpl->lastFrameWasRendered, forceClear );
+  }
 
   mImpl->UpdateTrackers();
 
@@ -557,23 +577,32 @@ void RenderManager::DoRender( RenderInstruction& instruction )
   Integration::StencilBufferAvailable stencilBufferAvailable = mImpl->stencilBufferAvailable;
 
   Render::SurfaceFrameBuffer* surfaceFrameBuffer = nullptr;
-  if ( ( instruction.mFrameBuffer != 0 ) && instruction.mFrameBuffer->IsSurfaceBacked() )
+  if ( instruction.mFrameBuffer != 0 )
   {
-    surfaceFrameBuffer = static_cast<Render::SurfaceFrameBuffer*>( instruction.mFrameBuffer );
+    if ( instruction.mFrameBuffer->IsSurfaceBacked() )
+    {
+      surfaceFrameBuffer = static_cast<Render::SurfaceFrameBuffer*>( instruction.mFrameBuffer );
 
-#if DALI_GLES_VERSION >= 30
-    Context* surfaceContext = surfaceFrameBuffer->GetContext();
-    if ( mImpl->currentContext != surfaceContext )
+      if ( mImpl->currentContext->IsSurfacelessContextSupported() )
+      {
+        Context* surfaceContext = surfaceFrameBuffer->GetContext();
+        if ( mImpl->currentContext != surfaceContext )
+        {
+          // Switch the correct context if rendering to a surface
+          mImpl->currentContext = surfaceContext;
+          // Clear the current cached program when the context is switched
+          mImpl->programController.ClearCurrentProgram();
+        }
+      }
+
+      surfaceRect = Rect<int32_t>( 0, 0, static_cast<int32_t>( surfaceFrameBuffer->GetWidth() ), static_cast<int32_t>( surfaceFrameBuffer->GetHeight() ) );
+      backgroundColor = surfaceFrameBuffer->GetBackgroundColor();
+    }
+    else
     {
-      // Switch the correct context if rendering to a surface
-      mImpl->currentContext = surfaceContext;
-      // Clear the current cached program when the context is switched
-      mImpl->programController.ClearCurrentProgram();
+      // Switch to shared context for off-screen buffer
+      mImpl->currentContext = &mImpl->context;
     }
-#endif
-
-    surfaceRect = Rect<int32_t>( 0, 0, static_cast<int32_t>( surfaceFrameBuffer->GetWidth() ), static_cast<int32_t>( surfaceFrameBuffer->GetHeight() ) );
-    backgroundColor = surfaceFrameBuffer->GetBackgroundColor();
   }
 
   DALI_ASSERT_DEBUG( mImpl->currentContext->IsGlContextCreated() );