(SVG) Add mutex to make thread safe 92/277592/1
authorHeeyong Song <heeyong.song@samsung.com>
Mon, 11 Jul 2022 01:57:31 +0000 (10:57 +0900)
committerHeeyong Song <heeyong.song@samsung.com>
Mon, 11 Jul 2022 01:57:31 +0000 (10:57 +0900)
Change-Id: I194d4d45810c3d5bcdb0e7c881630914ee7204a5

dali/internal/vector-image/common/vector-image-renderer-impl.cpp
dali/internal/vector-image/common/vector-image-renderer-impl.h

index feb8b5a..88414b7 100644 (file)
@@ -74,6 +74,7 @@ VectorImageRenderer::VectorImageRenderer()
 
 VectorImageRenderer::~VectorImageRenderer()
 {
+  Mutex::ScopedLock lock(mMutex);
 #ifdef THORVG_SUPPORT
 
   //NOTE: Initializer::term() will call clear() internally.
@@ -116,6 +117,7 @@ void VectorImageRenderer::Initialize()
 
 bool VectorImageRenderer::Load(const Vector<uint8_t>& data, float dpi)
 {
+  Mutex::ScopedLock lock(mMutex);
 #ifdef THORVG_SUPPORT
   if(!mSwCanvas)
   {
@@ -204,6 +206,8 @@ bool VectorImageRenderer::IsLoaded() const
 
 Dali::Devel::PixelBuffer VectorImageRenderer::Rasterize(uint32_t width, uint32_t height)
 {
+  Mutex::ScopedLock lock(mMutex);
+
   if(width == 0)
   {
     if(mDefaultWidth == 0)
index 19ae0c1..e2c2cee 100644 (file)
  */
 
 // EXTERNAL INCLUDES
+#include <dali/devel-api/threading/mutex.h>
 #include <dali/public-api/object/base-object.h>
 #include <dali/public-api/signals/connection-tracker.h>
+
 #ifdef THORVG_SUPPORT
 #include <thorvg.h>
 #endif
@@ -105,8 +107,9 @@ private:
   NSVGimage*      mParsedImage{nullptr};
   NSVGrasterizer* mRasterizer{nullptr};
 #endif
-  uint32_t mDefaultWidth{0};  ///< The default width of the file
-  uint32_t mDefaultHeight{0}; ///< The default height of the file
+  Dali::Mutex mMutex{};          ///< The mutex
+  uint32_t    mDefaultWidth{0};  ///< The default width of the file
+  uint32_t    mDefaultHeight{0}; ///< The default height of the file
 };
 
 } // namespace Adaptor