[Tizen] Use broken image when animated image loading is failed
[platform/core/uifw/dali-adaptor.git] / dali / internal / imaging / common / gif-loading.cpp
index 6b0d709..1b195b9 100644 (file)
@@ -29,6 +29,7 @@
 #include <cstring>
 #include <memory>
 
+#include <dali/devel-api/threading/mutex.h>
 #include <dali/integration-api/debug.h>
 #include <dali/internal/imaging/common/file-download.h>
 #include <dali/internal/system/common/file-reader.h>
@@ -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)
@@ -1284,6 +1287,12 @@ bool GifLoading::LoadNextNFrames(uint32_t frameStartIndex, int count, std::vecto
     return false;
   }
 
+  Mutex::ScopedLock lock(mImpl->mMutex);
+  if(!mImpl->mLoadSucceeded)
+  {
+    return false;
+  }
+
   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);
@@ -1316,6 +1325,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);