[3.0] Fix rendering issue by tbm_surface and eglSwapBuffers in native render surface
[platform/core/uifw/dali-adaptor.git] / adaptors / tizen / native-render-surface-tizen.cpp
index 7f1b1a7..3799b0e 100644 (file)
@@ -74,6 +74,7 @@ NativeRenderSurface::NativeRenderSurface(Dali::PositionSize positionSize,
 {
   ecore_wl_init(NULL);
   CreateNativeRenderable();
+  setenv( "EGL_PLATFORM", "tbm", 1 );
 }
 
 NativeRenderSurface::~NativeRenderSurface()
@@ -119,6 +120,7 @@ Any NativeRenderSurface::GetSurface()
 void NativeRenderSurface::InitializeEgl( EglInterface& egl )
 {
   DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter );
+  unsetenv( "EGL_PLATFORM" );
 
   Internal::Adaptor::EglImplementation& eglImpl = static_cast<Internal::Adaptor::EglImplementation&>( egl );
 
@@ -184,10 +186,9 @@ void NativeRenderSurface::PostRender( EglInterface& egl, Integration::GlAbstract
   Internal::Adaptor::EglImplementation& eglImpl = static_cast<Internal::Adaptor::EglImplementation&>( egl );
   eglImpl.SwapBuffers();
 
-  // flush gl instruction queue
-  glAbstraction.Flush();
-
   {
+    ConditionalWait::ScopedLock lock( mImpl->mTbmSurfaceCondition );
+
     if( tbm_surface_queue_can_acquire( mImpl->mTbmQueue, 1 ) )
     {
       if( tbm_surface_queue_acquire( mImpl->mTbmQueue, &mImpl->mConsumeSurface ) != TBM_SURFACE_QUEUE_ERROR_NONE )
@@ -202,14 +203,9 @@ void NativeRenderSurface::PostRender( EglInterface& egl, Integration::GlAbstract
   if( mImpl->mRenderNotification )
   {
     // use notification trigger
-    // Tell the event-thread to render the pixmap
+    // Tell the event-thread to render the tbm_surface
     mImpl->mRenderNotification->Trigger();
   }
-  else
-  {
-    // FIXME
-  }
-
 }
 
 void NativeRenderSurface::StopRender()
@@ -259,6 +255,7 @@ void NativeRenderSurface::CreateNativeRenderable()
 
 void NativeRenderSurface::ReleaseSurface()
 {
+  ConditionalWait::ScopedLock lock( mImpl->mTbmSurfaceCondition );
   if( mImpl->mConsumeSurface )
   {
     tbm_surface_queue_release( mImpl->mTbmQueue, mImpl->mConsumeSurface );