X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=adaptors%2Ftizen%2Fnative-render-surface-tizen.cpp;h=787507fd35f3895256b81b0375253b059cd3af8f;hb=283bac2c393372a421231221e180516b0f1fe44e;hp=7f1b1a7ba94d272ecc27b4b70600e57830ee8be1;hpb=d362ed8511f2cb5311d0919e2c22bfa5293c25ff;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git diff --git a/adaptors/tizen/native-render-surface-tizen.cpp b/adaptors/tizen/native-render-surface-tizen.cpp index 7f1b1a7..787507f 100644 --- a/adaptors/tizen/native-render-surface-tizen.cpp +++ b/adaptors/tizen/native-render-surface-tizen.cpp @@ -26,6 +26,7 @@ #include #include #include +#include // INTERNAL INCLUDES #include @@ -49,6 +50,7 @@ struct NativeRenderSurface::Impl mColorDepth( isTransparent ? COLOR_DEPTH_32 : COLOR_DEPTH_24 ), mTbmFormat( isTransparent ? TBM_FORMAT_ARGB8888 : TBM_FORMAT_RGB888 ), mOwnSurface( false ), + mDrawableCompleted( false ), mConsumeSurface( NULL ), mThreadSynchronization( NULL ) { @@ -60,6 +62,7 @@ struct NativeRenderSurface::Impl ColorDepth mColorDepth; tbm_format mTbmFormat; bool mOwnSurface; + bool mDrawableCompleted; tbm_surface_queue_h mTbmQueue; tbm_surface_h mConsumeSurface; @@ -74,6 +77,7 @@ NativeRenderSurface::NativeRenderSurface(Dali::PositionSize positionSize, { ecore_wl_init(NULL); CreateNativeRenderable(); + setenv( "EGL_PLATFORM", "tbm", 1 ); } NativeRenderSurface::~NativeRenderSurface() @@ -81,12 +85,7 @@ NativeRenderSurface::~NativeRenderSurface() // release the surface if we own one if( mImpl->mOwnSurface ) { - - if( mImpl->mConsumeSurface ) - { - tbm_surface_queue_release( mImpl->mTbmQueue, mImpl->mConsumeSurface ); - mImpl->mConsumeSurface = NULL; - } + ReleaseDrawable(); if( mImpl->mTbmQueue ) { @@ -106,8 +105,6 @@ void NativeRenderSurface::SetRenderNotification( TriggerEventInterface* renderNo tbm_surface_h NativeRenderSurface::GetDrawable() { - ConditionalWait::ScopedLock lock( mImpl->mTbmSurfaceCondition ); - return mImpl->mConsumeSurface; } @@ -119,6 +116,7 @@ Any NativeRenderSurface::GetSurface() void NativeRenderSurface::InitializeEgl( EglInterface& egl ) { DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter ); + unsetenv( "EGL_PLATFORM" ); Internal::Adaptor::EglImplementation& eglImpl = static_cast( egl ); @@ -146,19 +144,6 @@ bool NativeRenderSurface::ReplaceEGLSurface( EglInterface& egl ) { DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter ); - if( mImpl->mConsumeSurface ) - { - tbm_surface_queue_release( mImpl->mTbmQueue, mImpl->mConsumeSurface ); - mImpl->mConsumeSurface = NULL; - } - - if( mImpl->mTbmQueue ) - { - tbm_surface_queue_destroy( mImpl->mTbmQueue ); - } - - CreateNativeRenderable(); - if( !mImpl->mTbmQueue ) { return false; @@ -184,32 +169,45 @@ void NativeRenderSurface::PostRender( EglInterface& egl, Integration::GlAbstract Internal::Adaptor::EglImplementation& eglImpl = static_cast( egl ); eglImpl.SwapBuffers(); - // flush gl instruction queue - glAbstraction.Flush(); + if( mImpl->mThreadSynchronization ) + { + mImpl->mThreadSynchronization->PostRenderStarted(); + } + if( tbm_surface_queue_can_acquire( mImpl->mTbmQueue, 1 ) ) { - if( tbm_surface_queue_can_acquire( mImpl->mTbmQueue, 1 ) ) + if( tbm_surface_queue_acquire( mImpl->mTbmQueue, &mImpl->mConsumeSurface ) != TBM_SURFACE_QUEUE_ERROR_NONE ) { - if( tbm_surface_queue_acquire( mImpl->mTbmQueue, &mImpl->mConsumeSurface ) != TBM_SURFACE_QUEUE_ERROR_NONE ) - { - DALI_LOG_ERROR( "Failed aquire consume tbm_surface\n" ); - return; - } + DALI_LOG_ERROR( "Failed to aquire a tbm_surface\n" ); + return; } } + tbm_surface_internal_ref( mImpl->mConsumeSurface ); + + if( replacingSurface ) + { + ConditionalWait::ScopedLock lock( mImpl->mTbmSurfaceCondition ); + mImpl->mDrawableCompleted = true; + mImpl->mTbmSurfaceCondition.Notify( lock ); + } + // create damage for client applications which wish to know the update timing - if( mImpl->mRenderNotification ) + if( !replacingSurface && 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 + + if( mImpl->mThreadSynchronization ) { - // FIXME + // wait until the event-thread completed to use the tbm_surface + mImpl->mThreadSynchronization->PostRenderWaitForCompletion(); } + // release the consumed surface after post render was completed + ReleaseDrawable(); } void NativeRenderSurface::StopRender() @@ -243,7 +241,7 @@ RenderSurface::Type NativeRenderSurface::GetSurfaceType() void NativeRenderSurface::CreateNativeRenderable() { // check we're creating one with a valid size - DALI_ASSERT_ALWAYS( mImpl->mPosition.width > 0 && mImpl->mPosition.height > 0 && "Pixmap size is invalid" ); + DALI_ASSERT_ALWAYS( mImpl->mPosition.width > 0 && mImpl->mPosition.height > 0 && "tbm_surface size is invalid" ); mImpl->mTbmQueue = tbm_surface_queue_create( 3, mImpl->mPosition.width, mImpl->mPosition.height, mImpl->mTbmFormat, TBM_BO_DEFAULT ); @@ -257,20 +255,36 @@ void NativeRenderSurface::CreateNativeRenderable() } } -void NativeRenderSurface::ReleaseSurface() +void NativeRenderSurface::ReleaseLock() { - if( mImpl->mConsumeSurface ) + if( mImpl->mThreadSynchronization ) { - tbm_surface_queue_release( mImpl->mTbmQueue, mImpl->mConsumeSurface ); - mImpl->mConsumeSurface = NULL; + mImpl->mThreadSynchronization->PostRenderComplete(); } } -void NativeRenderSurface::ReleaseLock() +void NativeRenderSurface::WaitUntilSurfaceReplaced() { - if( mImpl->mThreadSynchronization ) + ConditionalWait::ScopedLock lock( mImpl->mTbmSurfaceCondition ); + while( !mImpl->mDrawableCompleted ) { - mImpl->mThreadSynchronization->PostRenderComplete(); + mImpl->mTbmSurfaceCondition.Wait( lock ); + } + + mImpl->mDrawableCompleted = false; +} + +void NativeRenderSurface::ReleaseDrawable() +{ + if( mImpl->mConsumeSurface ) + { + tbm_surface_internal_unref( mImpl->mConsumeSurface ); + + if( tbm_surface_internal_is_valid( mImpl->mConsumeSurface ) ) + { + tbm_surface_queue_release( mImpl->mTbmQueue, mImpl->mConsumeSurface ); + } + mImpl->mConsumeSurface = NULL; } }