From e093e50bbe66b4954e7c225ef5f35f293d4158b6 Mon Sep 17 00:00:00 2001 From: Sunghyun Kim Date: Tue, 17 Nov 2020 11:49:24 +0900 Subject: [PATCH] Add lock for image loading loading image have to thread-safe. for this, i added lock to gif and webp Change-Id: I2f0921535fc944919916d2ac5e2768e9256c8692 --- dali/internal/imaging/common/gif-loading.cpp | 8 +++++++- dali/internal/imaging/common/webp-loading.cpp | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/dali/internal/imaging/common/gif-loading.cpp b/dali/internal/imaging/common/gif-loading.cpp index 6b0d709..a142447 100644 --- a/dali/internal/imaging/common/gif-loading.cpp +++ b/dali/internal/imaging/common/gif-loading.cpp @@ -29,6 +29,7 @@ #include #include +#include #include #include #include @@ -1238,7 +1239,8 @@ struct GifLoading::Impl public: Impl(const std::string& url, bool isLocalResource) : mUrl(url), - mLoadSucceeded(true) + mLoadSucceeded(true), + mMutex() { loaderInfo.gifAccessor = nullptr; int error; @@ -1258,6 +1260,7 @@ public: LoaderInfo loaderInfo; ImageProperties imageProperties; bool mLoadSucceeded; + Mutex mMutex; }; AnimatedImageLoadingPtr GifLoading::New(const std::string& url, bool isLocalResource) @@ -1279,6 +1282,8 @@ bool GifLoading::LoadNextNFrames(uint32_t frameStartIndex, int count, std::vecto { int error; bool ret = false; + + Mutex::ScopedLock lock(mImpl->mMutex); if(!mImpl->mLoadSucceeded) { return false; @@ -1316,6 +1321,7 @@ Dali::Devel::PixelBuffer GifLoading::LoadFrame(uint32_t frameIndex) return 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 2068240..7e4511c 100644 --- a/dali/internal/imaging/common/webp-loading.cpp +++ b/dali/internal/imaging/common/webp-loading.cpp @@ -31,6 +31,7 @@ #include #include +#include #include #include #include @@ -62,7 +63,8 @@ struct WebPLoading::Impl public: Impl(const std::string& url, bool isLocalResource) : mUrl(url), - mLoadSucceeded(true) + mLoadSucceeded(true), + mMutex() { #ifdef DALI_WEBP_ENABLED if(ReadWebPInformation(isLocalResource)) @@ -182,6 +184,7 @@ public: std::vector mTimeStamp; uint32_t mLoadingFrame{0}; bool mLoadSucceeded; + Mutex mMutex; #ifdef DALI_WEBP_ENABLED WebPData mWebPData{0}; @@ -211,6 +214,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 || !mImpl->mLoadSucceeded) { return false; @@ -267,6 +271,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 || !mImpl->mLoadSucceeded) { return pixelBuffer; -- 2.7.4