[Tizen] Add screen and client rotation itself function
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / common / window-render-surface.cpp
old mode 100755 (executable)
new mode 100644 (file)
index 76bf702..9158f95
 #include <dali/integration-api/debug.h>
 
 // INTERNAL INCLUDES
-#include <dali/integration-api/trigger-event-factory-interface.h>
-#include <dali/integration-api/thread-synchronization-interface.h>
-#include <dali/internal/graphics/gles/egl-implementation.h>
+#include <dali/integration-api/adaptor-framework/thread-synchronization-interface.h>
+#include <dali/integration-api/adaptor-framework/trigger-event-factory-interface.h>
 #include <dali/internal/adaptor/common/adaptor-impl.h>
 #include <dali/internal/adaptor/common/adaptor-internal-services.h>
+#include <dali/internal/graphics/gles/egl-graphics.h>
+#include <dali/internal/graphics/gles/egl-implementation.h>
 #include <dali/internal/window-system/common/window-base.h>
 #include <dali/internal/window-system/common/window-factory.h>
 #include <dali/internal/window-system/common/window-system.h>
-#include <dali/internal/graphics/gles/egl-graphics.h>
 #include <dali/internal/system/common/environment-variables.h>
 
-
 namespace Dali
 {
 namespace Internal
@@ -46,7 +45,6 @@ namespace
 {
 
 const int MINIMUM_DIMENSION_CHANGE( 1 ); ///< Minimum change for window to be considered to have moved
-const int TILE_SIZE = 16u;  ///< Unit of tile size at GPU driver
 
 #if defined(DEBUG_ENABLED)
 Debug::Filter* gWindowRenderSurfaceLogFilter = Debug::Filter::New(Debug::Verbose, false, "LOG_WINDOW_RENDER_SURFACE");
@@ -69,16 +67,13 @@ WindowRenderSurface::WindowRenderSurface( Dali::PositionSize positionSize, Any s
   mOutputTransformedSignal(),
   mRotationAngle( 0 ),
   mScreenRotationAngle( 0 ),
-  mBufferAge( 0 ),
-  mPreBufferAge( 0 ),
   mOwnSurface( false ),
   mRotationSupported( false ),
   mRotationFinished( true ),
   mScreenRotationFinished( true ),
   mResizeFinished( true ),
   mDpiHorizontal( 0 ),
-  mDpiVertical( 0 ),
-  mPreDamagedRect()
+  mDpiVertical( 0 )
 {
   DALI_LOG_INFO( gWindowRenderSurfaceLogFilter, Debug::Verbose, "Creating Window\n" );
   Initialize( surface );
@@ -105,7 +100,6 @@ void WindowRenderSurface::Initialize( Any surface )
     // Default window size == screen size
     mPositionSize.x = 0;
     mPositionSize.y = 0;
-
     WindowSystem::GetScreenSize( mPositionSize.width, mPositionSize.height );
   }
 
@@ -256,10 +250,8 @@ void WindowRenderSurface::CreateSurface()
   // Check rotation capability
   mRotationSupported = mWindowBase->IsEglWindowRotationSupported();
 
-  int screenWidth, screenHeight;
-  WindowSystem::GetScreenSize( screenWidth, screenHeight );
-  DALI_LOG_RELEASE_INFO("WindowRenderSurface::CreateSurface: w = %d h = %d screenWidth = %d screenHeight = %d angle = %d screen rotation = %d\n",
-      mPositionSize.width, mPositionSize.height, screenWidth, screenHeight, mRotationAngle, mScreenRotationAngle );
+  DALI_LOG_RELEASE_INFO("WindowRenderSurface::CreateSurface: WinId (%d), w = %d h = %d angle = %d screen rotation = %d\n",
+      mWindowBase->GetNativeWindowId(), mPositionSize.width, mPositionSize.height, mRotationAngle, mScreenRotationAngle );
 }
 
 void WindowRenderSurface::DestroySurface()
@@ -268,6 +260,8 @@ void WindowRenderSurface::DestroySurface()
 
   auto eglGraphics = static_cast<EglGraphics *>(mGraphics);
 
+  DALI_LOG_RELEASE_INFO("WindowRenderSurface::DestroySurface: WinId (%d)\n", mWindowBase->GetNativeWindowId() );
+
   Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
   eglImpl.DestroySurface( mEGLSurface );
 
@@ -415,95 +409,6 @@ bool WindowRenderSurface::PreRender( bool resizingSurface )
   return true;
 }
 
-std::vector<int32_t> WindowRenderSurface::MergeRect( Rect<int32_t> damagedRect, int bufferAge )
-{
-  std::vector<int32_t> mergedRectArray;
-  // merge bounding
-  int dx1 = mPositionSize.width, dx2 = 0, dy1 = mPositionSize.height, dy2 = 0;
-  int checkWidth = mPositionSize.width - TILE_SIZE;
-  int checkHeight = mPositionSize.height - TILE_SIZE;
-
-  dx1 = std::min( damagedRect.x, dx1 );
-  dx2 = std::max( damagedRect.x + damagedRect.width, dx2);
-  dy1 = std::min( damagedRect.y, dy1 );
-  dy2 = std::max( damagedRect.y + damagedRect.height, dy2 );
-
-  for( int j = 0; j <= bufferAge; j++ )
-  {
-    if( !mPreDamagedRect[j].IsEmpty() )
-    {
-      dx1 = std::min( mPreDamagedRect[j].x, dx1 );
-      dx2 = std::max( mPreDamagedRect[j].x + mPreDamagedRect[j].width, dx2);
-      dy1 = std::min( mPreDamagedRect[j].y, dy1 );
-      dy2 = std::max( mPreDamagedRect[j].y + mPreDamagedRect[j].height, dy2 );
-
-      if( dx1 < TILE_SIZE && dx2 > checkWidth && dy1 < TILE_SIZE && dy2 > checkHeight )
-      {
-        dx1 = 0, dx2 = mPositionSize.width, dy1 = 0, dy2 = mPositionSize.height;
-        break;
-      }
-    }
-  }
-
-  dx1 = TILE_SIZE * (dx1 / TILE_SIZE);
-  dy1 = TILE_SIZE * (dy1 / TILE_SIZE);
-  dx2 = TILE_SIZE * ((dx2 + TILE_SIZE - 1) / TILE_SIZE);
-  dy2 = TILE_SIZE * ((dy2 + TILE_SIZE - 1) / TILE_SIZE);
-
-  mergedRectArray.push_back( dx1 );
-  mergedRectArray.push_back( dy1 );
-  mergedRectArray.push_back( dx2 - dx1 );
-  mergedRectArray.push_back( dy2 - dy1 );
-
-  return mergedRectArray;
-}
-
-
-Rect<int32_t> WindowRenderSurface::SetDamagedRect( Rect<int32_t> damagedRect )
-{
-  auto eglGraphics = static_cast<EglGraphics *>( mGraphics );
-  std::vector<int32_t> rectArray;
-  Rect<int32_t> mergedDamagedRect;
-  if( eglGraphics )
-  {
-    Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
-
-    rectArray = MergeRect( damagedRect, mBufferAge );
-
-    mPreDamagedRect[4] = std::move( mPreDamagedRect[3] );
-    mPreDamagedRect[3] = std::move( mPreDamagedRect[2] );
-    mPreDamagedRect[2] = std::move( mPreDamagedRect[1] );
-    mPreDamagedRect[1] = std::move( mPreDamagedRect[0] );
-    mPreDamagedRect[0] = std::move( damagedRect );
-
-    eglImpl.SetDamagedRect( rectArray, mEGLSurface );
-  }
-
-  if( !rectArray.empty() )
-  {
-    mergedDamagedRect.x = rectArray[0];
-    mergedDamagedRect.y = rectArray[1];
-    mergedDamagedRect.width = rectArray[2];
-    mergedDamagedRect.height = rectArray[3];
-  }
-
-  return mergedDamagedRect;
-}
-
-int WindowRenderSurface::GetBufferAge()
-{
-  auto result = mBufferAge = 0;
-  auto eglGraphics = static_cast<EglGraphics *>( mGraphics );
-  if( eglGraphics )
-  {
-    Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
-    mBufferAge = eglImpl.GetBufferAge( mEGLSurface );;
-    result = ( mBufferAge != mPreBufferAge ) ? 0 : mBufferAge;
-    mPreBufferAge = mBufferAge;
-  }
-  return result;
-}
-
 void WindowRenderSurface::PostRender( bool renderToFbo, bool replacingSurface, bool resizingSurface )
 {
   // Inform the gl implementation that rendering has finished before informing the surface
@@ -524,7 +429,13 @@ void WindowRenderSurface::PostRender( bool renderToFbo, bool replacingSurface, b
       {
         if( !mRotationFinished )
         {
-          DALI_LOG_INFO( gWindowRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurface::PostRender: Trigger rotation event\n" );
+          if( mThreadSynchronization )
+          {
+            // Enable PostRender flag
+            mThreadSynchronization->PostRenderStarted();
+          }
+
+          DALI_LOG_RELEASE_INFO("WindowRenderSurface::PostRender: Trigger rotation event\n" );
 
           mRotationTrigger->Trigger();
 
@@ -538,7 +449,6 @@ void WindowRenderSurface::PostRender( bool renderToFbo, bool replacingSurface, b
     }
 
     Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
-
     eglImpl.SwapBuffers( mEGLSurface );
 
     if( mRenderNotification )