From 0112f2ca914af28f08d7e72e8d64de416a7d13fe Mon Sep 17 00:00:00 2001 From: Heeyong Song Date: Wed, 17 Oct 2018 13:57:57 +0900 Subject: [PATCH] Fix initialization issue Sometimes EGL image extensions are initialized after NativeImageSource is created. Change-Id: Iae3847e20e6f25ca4e27cf0e8fd1f9ca51788f62 --- .../native-image-source-queue.cpp | 12 ++++- .../tizen/native-image-source-impl-tizen.cpp | 11 ++-- .../imaging/tizen/native-image-source-impl-tizen.h | 2 + .../tizen/native-image-source-queue-impl-tizen.cpp | 60 +++++++++++----------- .../tizen/native-image-source-queue-impl-tizen.h | 2 + 5 files changed, 48 insertions(+), 39 deletions(-) diff --git a/dali/devel-api/adaptor-framework/native-image-source-queue.cpp b/dali/devel-api/adaptor-framework/native-image-source-queue.cpp index 7774cf1..1538f66 100755 --- a/dali/devel-api/adaptor-framework/native-image-source-queue.cpp +++ b/dali/devel-api/adaptor-framework/native-image-source-queue.cpp @@ -29,13 +29,21 @@ NativeImageSourceQueuePtr NativeImageSourceQueue::New( unsigned int width, unsig { Any empty; NativeImageSourceQueuePtr image = new NativeImageSourceQueue( width, height, depth, empty ); - return image; + if( image->mImpl ) + { + return image; + } + return nullptr; } NativeImageSourceQueuePtr NativeImageSourceQueue::New( Any nativeImageSourceQueue ) { NativeImageSourceQueuePtr image = new NativeImageSourceQueue( 0, 0, COLOR_DEPTH_DEFAULT, nativeImageSourceQueue ); - return image; + if( image->mImpl ) + { + return image; + } + return nullptr; } Any NativeImageSourceQueue::GetNativeImageSourceQueue() diff --git a/dali/internal/imaging/tizen/native-image-source-impl-tizen.cpp b/dali/internal/imaging/tizen/native-image-source-impl-tizen.cpp index 97210da..e4bcc00 100644 --- a/dali/internal/imaging/tizen/native-image-source-impl-tizen.cpp +++ b/dali/internal/imaging/tizen/native-image-source-impl-tizen.cpp @@ -33,7 +33,6 @@ // Allow this to be encoded and saved: #include - namespace Dali { @@ -88,17 +87,14 @@ NativeImageSourceTizen::NativeImageSourceTizen( unsigned int width, unsigned int mBlendingRequired( false ), mColorDepth( depth ), mEglImageKHR( NULL ), + mEglGraphics( NULL ), mEglImageExtensions( NULL ), mSetSource( false ) { DALI_ASSERT_ALWAYS( Adaptor::IsAvailable() ); GraphicsInterface* graphics = &( Adaptor::GetImplementation( Adaptor::Get() ).GetGraphicsInterface() ); - auto eglGraphics = static_cast(graphics); - - mEglImageExtensions = eglGraphics->GetImageExtensions(); - - DALI_ASSERT_DEBUG( mEglImageExtensions ); + mEglGraphics = static_cast(graphics); mTbmSurface = GetSurfaceFromAny( nativeImageSource ); @@ -411,6 +407,9 @@ bool NativeImageSourceTizen::GlExtensionCreate() return false; } + mEglImageExtensions = mEglGraphics->GetImageExtensions(); + DALI_ASSERT_DEBUG( mEglImageExtensions ); + mEglImageKHR = mEglImageExtensions->CreateImageKHR( eglBuffer ); return mEglImageKHR != NULL; diff --git a/dali/internal/imaging/tizen/native-image-source-impl-tizen.h b/dali/internal/imaging/tizen/native-image-source-impl-tizen.h index 8578d69..fdf1ed0 100755 --- a/dali/internal/imaging/tizen/native-image-source-impl-tizen.h +++ b/dali/internal/imaging/tizen/native-image-source-impl-tizen.h @@ -36,6 +36,7 @@ namespace Internal namespace Adaptor { +class EglGraphics; class EglImageExtensions; /** @@ -186,6 +187,7 @@ private: bool mBlendingRequired; ///< Whether blending is required Dali::NativeImageSource::ColorDepth mColorDepth; ///< color depth of image void* mEglImageKHR; ///< From EGL extension + EglGraphics* mEglGraphics; ///< EGL Graphics EglImageExtensions* mEglImageExtensions; ///< The EGL Image Extensions bool mSetSource; }; diff --git a/dali/internal/imaging/tizen/native-image-source-queue-impl-tizen.cpp b/dali/internal/imaging/tizen/native-image-source-queue-impl-tizen.cpp index c7b547f..8223c81 100644 --- a/dali/internal/imaging/tizen/native-image-source-queue-impl-tizen.cpp +++ b/dali/internal/imaging/tizen/native-image-source-queue-impl-tizen.cpp @@ -79,6 +79,7 @@ NativeImageSourceQueueTizen::NativeImageSourceQueueTizen( unsigned int width, un mTbmQueue( NULL ), mConsumeSurface( NULL ), mEglImages(), + mEglGraphics( NULL ), mEglImageExtensions( NULL ), mOwnTbmQueue( false ), mBlendingRequired( false ) @@ -86,11 +87,7 @@ NativeImageSourceQueueTizen::NativeImageSourceQueueTizen( unsigned int width, un DALI_ASSERT_ALWAYS( Adaptor::IsAvailable() ); GraphicsInterface* graphics = &( Adaptor::GetImplementation( Adaptor::Get() ).GetGraphicsInterface() ); - auto eglGraphics = static_cast(graphics); - - mEglImageExtensions = eglGraphics->GetImageExtensions(); - - DALI_ASSERT_DEBUG( mEglImageExtensions ); + mEglGraphics = static_cast(graphics); mTbmQueue = GetSurfaceFromAny( nativeImageSourceQueue ); @@ -187,6 +184,9 @@ void NativeImageSourceQueueTizen::SetSource( Any source ) bool NativeImageSourceQueueTizen::GlExtensionCreate() { + mEglImageExtensions = mEglGraphics->GetImageExtensions(); + DALI_ASSERT_DEBUG( mEglImageExtensions ); + return true; } @@ -210,48 +210,46 @@ void NativeImageSourceQueueTizen::PrepareTexture() { tbm_surface_h oldSurface = mConsumeSurface; - bool needToWait = ( mConsumeSurface == NULL ) ? true : false; - - if( tbm_surface_queue_can_acquire( mTbmQueue, needToWait ) ) + if( tbm_surface_queue_can_acquire( mTbmQueue, 0 ) ) { if( tbm_surface_queue_acquire( mTbmQueue, &mConsumeSurface ) != TBM_SURFACE_QUEUE_ERROR_NONE ) { DALI_LOG_ERROR( "Failed to aquire a tbm_surface\n" ); return; } - } - if( oldSurface && oldSurface != mConsumeSurface ) - { - if( tbm_surface_internal_is_valid( oldSurface ) ) + if( oldSurface ) { - tbm_surface_queue_release( mTbmQueue, oldSurface ); + if( tbm_surface_internal_is_valid( oldSurface ) ) + { + tbm_surface_queue_release( mTbmQueue, oldSurface ); + } } - } - if( mConsumeSurface ) - { - bool existing = false; - for( auto&& iter : mEglImages ) + if( mConsumeSurface ) { - if( iter.first == mConsumeSurface ) + bool existing = false; + for( auto&& iter : mEglImages ) { - // Find the surface in the existing list - existing = true; - mEglImageExtensions->TargetTextureKHR( iter.second ); - break; + if( iter.first == mConsumeSurface ) + { + // Find the surface in the existing list + existing = true; + mEglImageExtensions->TargetTextureKHR( iter.second ); + break; + } } - } - if( !existing ) - { - // Push the surface - tbm_surface_internal_ref( mConsumeSurface ); + if( !existing ) + { + // Push the surface + tbm_surface_internal_ref( mConsumeSurface ); - void* eglImageKHR = mEglImageExtensions->CreateImageKHR( reinterpret_cast< EGLClientBuffer >( mConsumeSurface ) ); - mEglImageExtensions->TargetTextureKHR( eglImageKHR ); + void* eglImageKHR = mEglImageExtensions->CreateImageKHR( reinterpret_cast< EGLClientBuffer >( mConsumeSurface ) ); + mEglImageExtensions->TargetTextureKHR( eglImageKHR ); - mEglImages.push_back( EglImagePair( mConsumeSurface, eglImageKHR) ); + mEglImages.push_back( EglImagePair( mConsumeSurface, eglImageKHR) ); + } } } } diff --git a/dali/internal/imaging/tizen/native-image-source-queue-impl-tizen.h b/dali/internal/imaging/tizen/native-image-source-queue-impl-tizen.h index 8d25513..19e50a7 100755 --- a/dali/internal/imaging/tizen/native-image-source-queue-impl-tizen.h +++ b/dali/internal/imaging/tizen/native-image-source-queue-impl-tizen.h @@ -36,6 +36,7 @@ namespace Internal namespace Adaptor { +class EglGraphics; class EglImageExtensions; /** @@ -166,6 +167,7 @@ private: tbm_surface_queue_h mTbmQueue; ///< Tbm surface queue handle tbm_surface_h mConsumeSurface; ///< The current tbm surface std::vector< EglImagePair > mEglImages; ///< EGL Image vector + EglGraphics* mEglGraphics; ///< EGL Graphics EglImageExtensions* mEglImageExtensions; ///< The EGL Image Extensions bool mOwnTbmQueue; ///< Whether we created tbm queue bool mBlendingRequired; ///< Whether blending is required -- 2.7.4