Do not re-rasterize when visual size is floating point 65/311865/1
authorEunki, Hong <eunkiki.hong@samsung.com>
Wed, 29 May 2024 06:46:55 +0000 (15:46 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Wed, 29 May 2024 06:46:55 +0000 (15:46 +0900)
Since we request svg rasterize when size changed, and the size is floating value,
useless rasterization could be happened if visual size is not integer point.

To avoid this case, let we convert as integer scale before check re-rasterization.

Change-Id: Ic28f8ec10f2e4c3bca3bd2bc6eb4756a46ab9764
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
dali-toolkit/internal/visuals/svg/svg-visual.cpp

index 6169242..773e69b 100644 (file)
@@ -336,8 +336,8 @@ void SvgVisual::AddRasterizationTask(const Vector2& size)
       mRasterizingTask.Reset();
     }
 
-    unsigned int width  = static_cast<unsigned int>(size.width);
-    unsigned int height = static_cast<unsigned int>(size.height);
+    uint32_t width  = static_cast<uint32_t>(roundf(size.width));
+    uint32_t height = static_cast<uint32_t>(roundf(size.height));
 
     mRasterizingTask = new SvgRasterizingTask(mVectorRenderer, width, height, MakeCallback(this, &SvgVisual::ApplyRasterizedImage));
 
@@ -494,6 +494,10 @@ void SvgVisual::OnSetTransform()
       size = mImpl->mTransform.GetVisualSize(mImpl->mControlSize);
     }
 
+    // roundf and change as integer scale.
+    size.width  = static_cast<uint32_t>(roundf(size.width));
+    size.height = static_cast<uint32_t>(roundf(size.height));
+
     if(size != mRasterizedSize || mDefaultWidth == 0 || mDefaultHeight == 0)
     {
       mRasterizedSize = size;