X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fimaging%2Ftizen%2Fnative-image-source-impl-tizen.cpp;h=6970fc03855accc44c2f6bd1da238e45d56b9128;hb=c12c1126016b3e49cf1237064f4b7ce5c302e0e4;hp=3cd791f9339687bd3ac17ac8ac596b0fd08ddac7;hpb=6bf6d6611129add5d4907a0fa05fc9b0c4049df6;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git diff --git a/dali/internal/imaging/tizen/native-image-source-impl-tizen.cpp b/dali/internal/imaging/tizen/native-image-source-impl-tizen.cpp old mode 100644 new mode 100755 index 3cd791f..6970fc0 --- a/dali/internal/imaging/tizen/native-image-source-impl-tizen.cpp +++ b/dali/internal/imaging/tizen/native-image-source-impl-tizen.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,9 +26,9 @@ // INTERNAL INCLUDES #include -#include +#include #include -#include +#include // Allow this to be encoded and saved: #include @@ -65,7 +65,7 @@ const int NUM_FORMATS_BLENDING_REQUIRED = 18; using Dali::Integration::PixelBuffer; -NativeImageSourceTizen* NativeImageSourceTizen::New(unsigned int width, unsigned int height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource ) +NativeImageSourceTizen* NativeImageSourceTizen::New( uint32_t width, uint32_t height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource ) { NativeImageSourceTizen* image = new NativeImageSourceTizen( width, height, depth, nativeImageSource ); DALI_ASSERT_DEBUG( image && "NativeImageSource allocation failed." ); @@ -78,7 +78,7 @@ NativeImageSourceTizen* NativeImageSourceTizen::New(unsigned int width, unsigned return image; } -NativeImageSourceTizen::NativeImageSourceTizen( unsigned int width, unsigned int height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource ) +NativeImageSourceTizen::NativeImageSourceTizen( uint32_t width, uint32_t height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource ) : mWidth( width ), mHeight( height ), mOwnTbmSurface( false ), @@ -87,13 +87,15 @@ NativeImageSourceTizen::NativeImageSourceTizen( unsigned int width, unsigned int mBlendingRequired( false ), mColorDepth( depth ), mEglImageKHR( NULL ), + mEglGraphics( NULL ), mEglImageExtensions( NULL ), - mSetSource( false ) + mSetSource( false ), + mMutex() { DALI_ASSERT_ALWAYS( Adaptor::IsAvailable() ); - EglFactory& eglFactory = Adaptor::GetImplementation( Adaptor::Get() ).GetEGLFactory(); - mEglImageExtensions = eglFactory.GetImageExtensions(); - DALI_ASSERT_DEBUG( mEglImageExtensions ); + + GraphicsInterface* graphics = &( Adaptor::GetImplementation( Adaptor::Get() ).GetGraphicsInterface() ); + mEglGraphics = static_cast(graphics); mTbmSurface = GetSurfaceFromAny( nativeImageSource ); @@ -208,6 +210,7 @@ Any NativeImageSourceTizen::GetNativeImageSource() const bool NativeImageSourceTizen::GetPixels(std::vector& pixbuf, unsigned& width, unsigned& height, Pixel::Format& pixelFormat) const { + Dali::Mutex::ScopedLock lock( mMutex ); if( mTbmSurface != NULL ) { tbm_surface_info_s surface_info; @@ -314,6 +317,7 @@ bool NativeImageSourceTizen::EncodeToFile(const std::string& filename) const void NativeImageSourceTizen::SetSource( Any source ) { + Dali::Mutex::ScopedLock lock( mMutex ); if( mOwnTbmSurface ) { if( mTbmSurface != NULL && tbm_surface_destroy( mTbmSurface ) != TBM_SURFACE_ERROR_NONE ) @@ -401,11 +405,14 @@ bool NativeImageSourceTizen::GlExtensionCreate() // casting from an unsigned int to a void *, which should then be cast back // to an unsigned int in the driver. EGLClientBuffer eglBuffer = reinterpret_cast< EGLClientBuffer >(mTbmSurface); - if( !eglBuffer ) + if( !eglBuffer || !tbm_surface_internal_is_valid( mTbmSurface ) ) { return false; } + mEglImageExtensions = mEglGraphics->GetImageExtensions(); + DALI_ASSERT_DEBUG( mEglImageExtensions ); + mEglImageKHR = mEglImageExtensions->CreateImageKHR( eglBuffer ); return mEglImageKHR != NULL; @@ -413,6 +420,7 @@ bool NativeImageSourceTizen::GlExtensionCreate() void NativeImageSourceTizen::GlExtensionDestroy() { + Dali::Mutex::ScopedLock lock( mMutex ); if( mEglImageKHR ) { mEglImageExtensions->DestroyImageKHR(mEglImageKHR); @@ -421,7 +429,7 @@ void NativeImageSourceTizen::GlExtensionDestroy() } } -unsigned int NativeImageSourceTizen::TargetTexture() +uint32_t NativeImageSourceTizen::TargetTexture() { mEglImageExtensions->TargetTextureKHR(mEglImageKHR); @@ -430,6 +438,7 @@ unsigned int NativeImageSourceTizen::TargetTexture() void NativeImageSourceTizen::PrepareTexture() { + Dali::Mutex::ScopedLock lock( mMutex ); if( mSetSource ) { void* eglImage = mEglImageKHR;