Add IsLoaded() to VectorImageRenderer 68/274968/1
authorHeeyong Song <heeyong.song@samsung.com>
Fri, 13 May 2022 01:15:50 +0000 (10:15 +0900)
committerHeeyong Song <heeyong.song@samsung.com>
Fri, 13 May 2022 01:16:26 +0000 (10:16 +0900)
Change-Id: Iafa1a4174074f8dc428a23e1b55ec33c3504fda4

dali/devel-api/adaptor-framework/vector-image-renderer.cpp
dali/devel-api/adaptor-framework/vector-image-renderer.h
dali/internal/vector-image/common/vector-image-renderer-impl.cpp
dali/internal/vector-image/common/vector-image-renderer-impl.h

index bf69063..79fe80c 100644 (file)
@@ -47,6 +47,11 @@ bool VectorImageRenderer::Load(const Vector<uint8_t>& data, float dpi)
   return GetImplementation(*this).Load(data, dpi);
 }
 
+bool VectorImageRenderer::IsLoaded() const
+{
+  return GetImplementation(*this).IsLoaded();
+}
+
 Dali::Devel::PixelBuffer VectorImageRenderer::Rasterize(uint32_t width, uint32_t height)
 {
   return GetImplementation(*this).Rasterize(width, height);
index f11220d..ab59195 100644 (file)
@@ -86,6 +86,13 @@ public:
   bool Load(const Vector<uint8_t>& data, float dpi);
 
   /**
+   * @brief Query whether the vector image is loaded.
+   *
+   * @return True if the image is loaded, false other wise.
+   */
+  bool IsLoaded() const;
+
+  /**
    * @brief Rasterizes the content to the pixel buffer synchronously.
    *
    * @param[in] width The pixel buffer width
index deec3c4..feb8b5a 100644 (file)
@@ -110,7 +110,7 @@ void VectorImageRenderer::Initialize()
   mSwCanvas->mempool(tvg::SwCanvas::MempoolPolicy::Individual);
   mSwCanvas->reserve(1); //has one picture
 #else
-  mRasterizer  = nsvgCreateRasterizer();
+  mRasterizer = nsvgCreateRasterizer();
 #endif
 }
 
@@ -132,6 +132,10 @@ bool VectorImageRenderer::Load(const Vector<uint8_t>& data, float dpi)
       return false;
     }
   }
+  else
+  {
+    return true;
+  }
 
   tvg::Result ret = mPicture->load(reinterpret_cast<char*>(data.Begin()), data.Size(), true);
 
@@ -170,6 +174,11 @@ bool VectorImageRenderer::Load(const Vector<uint8_t>& data, float dpi)
 
   return true;
 #else
+  if(mParsedImage)
+  {
+    return true;
+  }
+
   mParsedImage = nsvgParse(reinterpret_cast<char*>(data.Begin()), UNITS, dpi);
   if(!mParsedImage || !mParsedImage->shapes)
   {
@@ -184,6 +193,15 @@ bool VectorImageRenderer::Load(const Vector<uint8_t>& data, float dpi)
 #endif
 }
 
+bool VectorImageRenderer::IsLoaded() const
+{
+#ifdef THORVG_SUPPORT
+  return mPicture ? true : false;
+#else
+  return mParsedImage ? true : false;
+#endif
+}
+
 Dali::Devel::PixelBuffer VectorImageRenderer::Rasterize(uint32_t width, uint32_t height)
 {
   if(width == 0)
index ccc9301..19ae0c1 100644 (file)
@@ -62,6 +62,11 @@ public:
   bool Load(const Vector<uint8_t>& data, float dpi);
 
   /**
+   * @copydoc Dali::VectorImageRenderer::IsLoaded()
+   */
+  bool IsLoaded() const;
+
+  /**
    * @copydoc Dali::VectorImageRenderer::Rasterize()
    */
   Dali::Devel::PixelBuffer Rasterize(uint32_t width, uint32_t height);