Revert "[Tizen] Add OffscreenApplication"
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / tizen-wayland / native-render-surface-ecore-wl.cpp
index ed8a360..dc3f03d 100644 (file)
@@ -54,11 +54,14 @@ Debug::Filter* gNativeSurfaceLogFilter = Debug::Filter::New(Debug::Verbose, fals
 } // unnamed namespace
 
 NativeRenderSurfaceEcoreWl::NativeRenderSurfaceEcoreWl( SurfaceSize surfaceSize, Any surface, bool isTransparent )
-: mRenderNotification( NULL ),
+: mSurfaceSize( surfaceSize ),
+  mRenderNotification( NULL ),
   mGraphics( NULL ),
   mEGL( nullptr ),
   mEGLSurface( nullptr ),
   mEGLContext( nullptr ),
+  mColorDepth( isTransparent ? COLOR_DEPTH_32 : COLOR_DEPTH_24 ),
+  mTbmFormat( isTransparent ? TBM_FORMAT_ARGB8888 : TBM_FORMAT_RGB888 ),
   mOwnSurface( false ),
   mDrawableCompleted( false ),
   mTbmQueue( NULL ),
@@ -69,22 +72,13 @@ NativeRenderSurfaceEcoreWl::NativeRenderSurfaceEcoreWl( SurfaceSize surfaceSize,
 
   if( surface.Empty() )
   {
-    mSurfaceSize = surfaceSize;
-    mColorDepth = isTransparent ? COLOR_DEPTH_32 : COLOR_DEPTH_24;
-    mTbmFormat = isTransparent ? TBM_FORMAT_ARGB8888 : TBM_FORMAT_RGB888;
     CreateNativeRenderable();
   }
   else
   {
+    // check we have a valid type
+    DALI_ASSERT_ALWAYS( ( surface.GetType() == typeid (tbm_surface_queue_h) ) && "Surface type is invalid" );
     mTbmQueue = AnyCast< tbm_surface_queue_h >( surface );
-
-    uint16_t width = static_cast<uint16_t>( tbm_surface_queue_get_width( mTbmQueue ) );
-    uint16_t height = static_cast<uint16_t>( tbm_surface_queue_get_height( mTbmQueue ) );
-    mSurfaceSize = SurfaceSize( width, height );
-
-    mTbmFormat = tbm_surface_queue_get_format( mTbmQueue );
-
-    mColorDepth = ( mTbmFormat == TBM_FORMAT_ARGB8888 ) ? COLOR_DEPTH_32 : COLOR_DEPTH_24;
   }
 }
 
@@ -132,11 +126,6 @@ void NativeRenderSurfaceEcoreWl::WaitUntilSurfaceReplaced()
   mDrawableCompleted = false;
 }
 
-Any NativeRenderSurfaceEcoreWl::GetNativeRenderable()
-{
-  return mTbmQueue;
-}
-
 PositionSize NativeRenderSurfaceEcoreWl::GetPositionSize() const
 {
   return PositionSize( 0, 0, static_cast<int>( mSurfaceSize.GetWidth() ), static_cast<int>( mSurfaceSize.GetHeight() ) );
@@ -242,20 +231,7 @@ void NativeRenderSurfaceEcoreWl::StartRender()
 
 bool NativeRenderSurfaceEcoreWl::PreRender( bool resizingSurface, const std::vector<Rect<int>>& damagedRects, Rect<int>& clippingRect )
 {
-  MakeContextCurrent();
-
-  auto eglGraphics = static_cast<Internal::Adaptor::EglGraphics*>(mGraphics);
-  if (eglGraphics)
-  {
-    Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
-    if (resizingSurface)
-    {
-      eglImpl.SetFullSwapNextFrame();
-    }
-
-    eglImpl.SetDamage(mEGLSurface, damagedRects, clippingRect);
-  }
-
+  //TODO: Need to support partial update
   return true;
 }
 
@@ -268,61 +244,45 @@ void NativeRenderSurfaceEcoreWl::PostRender( bool renderToFbo, bool replacingSur
     eglImpl.SwapBuffers( mEGLSurface, damagedRects );
   }
 
-  if ( mOwnSurface )
+  if( mThreadSynchronization )
   {
-    if( mThreadSynchronization )
-    {
-      mThreadSynchronization->PostRenderStarted();
-    }
-
-    if( tbm_surface_queue_can_acquire( mTbmQueue, 1 ) )
-    {
-      if( tbm_surface_queue_acquire( mTbmQueue, &mConsumeSurface ) != TBM_SURFACE_QUEUE_ERROR_NONE )
-      {
-        DALI_LOG_ERROR( "Failed to acquire a tbm_surface\n" );
-        return;
-      }
-    }
-
-    if ( mConsumeSurface )
-    {
-      tbm_surface_internal_ref( mConsumeSurface );
-    }
+    mThreadSynchronization->PostRenderStarted();
+  }
 
-    if( replacingSurface )
+  if( tbm_surface_queue_can_acquire( mTbmQueue, 1 ) )
+  {
+    if( tbm_surface_queue_acquire( mTbmQueue, &mConsumeSurface ) != TBM_SURFACE_QUEUE_ERROR_NONE )
     {
-      ConditionalWait::ScopedLock lock( mTbmSurfaceCondition );
-      mDrawableCompleted = true;
-      mTbmSurfaceCondition.Notify( lock );
+      DALI_LOG_ERROR( "Failed to acquire a tbm_surface\n" );
+      return;
     }
+  }
 
-   // create damage for client applications which wish to know the update timing
-    if( !replacingSurface && mRenderNotification )
-    {
-      // use notification trigger
-      // Tell the event-thread to render the tbm_surface
-      mRenderNotification->Trigger();
-    }
+  tbm_surface_internal_ref( mConsumeSurface );
 
-    if( mThreadSynchronization )
-    {
-      // wait until the event-thread completed to use the tbm_surface
-      mThreadSynchronization->PostRenderWaitForCompletion();
-    }
+  if( replacingSurface )
+  {
+    ConditionalWait::ScopedLock lock( mTbmSurfaceCondition );
+    mDrawableCompleted = true;
+    mTbmSurfaceCondition.Notify( lock );
+  }
 
-    // release the consumed surface after post render was completed
-    ReleaseDrawable();
+ // create damage for client applications which wish to know the update timing
+  if( !replacingSurface && mRenderNotification )
+  {
+    // use notification trigger
+    // Tell the event-thread to render the tbm_surface
+    mRenderNotification->Trigger();
   }
-  else
+
+  if( mThreadSynchronization )
   {
-    // create damage for client applications which wish to know the update timing
-    if( !replacingSurface && mRenderNotification )
-    {
-      // use notification trigger
-      // Tell the event-thread to render the tbm_surface
-      mRenderNotification->Trigger();
-    }
+    // wait until the event-thread completed to use the tbm_surface
+    mThreadSynchronization->PostRenderWaitForCompletion();
   }
+
+  // release the consumed surface after post render was completed
+  ReleaseDrawable();
 }
 
 void NativeRenderSurfaceEcoreWl::StopRender()