From: Sunghyun Kim Date: Tue, 17 Nov 2020 02:49:24 +0000 (+0900) Subject: [Tizen] Add lock for image loading X-Git-Tag: accepted/tizen/6.0/unified/20201202.212218^0 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git;a=commitdiff_plain;h=80759a22f22c5b6e82b16a456703840b6f7cc746 [Tizen] Add lock for image loading loading image have to thread-safe. for this, i added lock to gif and webp Change-Id: I2f0921535fc944919916d2ac5e2768e9256c8692 --- diff --git a/dali/internal/imaging/common/gif-loading.cpp b/dali/internal/imaging/common/gif-loading.cpp index 16057f7..111d1cf 100644 --- a/dali/internal/imaging/common/gif-loading.cpp +++ b/dali/internal/imaging/common/gif-loading.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #define IMG_TOO_BIG( w, h ) \ ( ( static_cast(w) * static_cast(h) ) >= \ @@ -1192,7 +1193,8 @@ struct GifLoading::Impl { public: Impl( const std::string& url, bool isLocalResource ) - : mUrl( url ) + : mUrl( url ), + mMutex() { loaderInfo.gif = nullptr; int error; @@ -1232,6 +1234,7 @@ public: std::string mUrl; LoaderInfo loaderInfo; ImageProperties imageProperties; + Mutex mMutex; }; AnimatedImageLoadingPtr GifLoading::New( const std::string &url, bool isLocalResource ) @@ -1255,6 +1258,7 @@ bool GifLoading::LoadNextNFrames( uint32_t frameStartIndex, int count, std::vect int error; bool ret = false; + Mutex::ScopedLock lock( mImpl->mMutex ); const int bufferSize = mImpl->imageProperties.w * mImpl->imageProperties.h * sizeof( uint32_t ); DALI_LOG_INFO( gGifLoadingLogFilter, Debug::Concise, "LoadNextNFrames( frameStartIndex:%d, count:%d )\n", frameStartIndex, count ); @@ -1285,6 +1289,7 @@ Dali::Devel::PixelBuffer GifLoading::LoadFrame( uint32_t frameIndex ) int error; Dali::Devel::PixelBuffer pixelBuffer; + Mutex::ScopedLock lock( mImpl->mMutex ); DALI_LOG_INFO( gGifLoadingLogFilter, Debug::Concise, "LoadFrame( frameIndex:%d )\n", frameIndex ); pixelBuffer = Dali::Devel::PixelBuffer::New( mImpl->imageProperties.w, mImpl->imageProperties.h, Dali::Pixel::RGBA8888 ); diff --git a/dali/internal/imaging/common/webp-loading.cpp b/dali/internal/imaging/common/webp-loading.cpp index cc4246a..f6e65b0 100644 --- a/dali/internal/imaging/common/webp-loading.cpp +++ b/dali/internal/imaging/common/webp-loading.cpp @@ -38,6 +38,7 @@ #include #include #include +#include typedef unsigned char WebPByteType; @@ -65,7 +66,8 @@ struct WebPLoading::Impl { public: Impl( const std::string& url, bool isLocalResource ) - : mUrl( url ) + : mUrl( url ), + mMutex() { #ifdef DALI_WEBP_ENABLED if( ReadWebPInformation( isLocalResource ) ) @@ -180,6 +182,7 @@ public: std::string mUrl; std::vector mTimeStamp; uint32_t mLoadingFrame{0}; + Mutex mMutex; #ifdef DALI_WEBP_ENABLED WebPData mWebPData{0}; @@ -209,6 +212,7 @@ WebPLoading::~WebPLoading() bool WebPLoading::LoadNextNFrames( uint32_t frameStartIndex, int count, std::vector &pixelData ) { #ifdef DALI_WEBP_ENABLED + Mutex::ScopedLock lock( mImpl->mMutex ); if( frameStartIndex >= mImpl->mWebPAnimInfo.frame_count ) { return false; @@ -266,6 +270,7 @@ Dali::Devel::PixelBuffer WebPLoading::LoadFrame( uint32_t frameIndex ) { Dali::Devel::PixelBuffer pixelBuffer; #ifdef DALI_WEBP_ENABLED + Mutex::ScopedLock lock( mImpl->mMutex ); if( frameIndex >= mImpl->mWebPAnimInfo.frame_count ) { return pixelBuffer;