svg_loader: handling zero width/height viewbox 37/290637/1
authorMira Grudzinska <veleveta@gmail.com>
Wed, 15 Mar 2023 23:47:11 +0000 (00:47 +0100)
committerjykeon <jykeon@samsung.com>
Thu, 30 Mar 2023 04:53:59 +0000 (13:53 +0900)
For svgs with the width and/or height value set to zero
rendering was disabled - the load api return Result:Unknown
and draw - Result::InsufficientCondition.
Now an empty scene is added, so that both, load and draw,
return Result::Success.

Change-Id: I3b47acea33f49eca8d0d213a47d88cd57146027b
Signed-off-by: jykeon <jykeon@samsung.com>
src/loaders/svg/tvgSvgLoader.cpp
src/loaders/svg/tvgSvgLoader.h

index e05aa49..1365663 100644 (file)
@@ -3186,6 +3186,12 @@ SvgLoader::~SvgLoader()
 
 void SvgLoader::run(unsigned tid)
 {
+    //According to the SVG standard the value of the width/height of the viewbox set to 0 disables rendering
+    if (renderingDisabled) {
+        root = Scene::gen();
+        return;
+    }
+
     if (!simpleXmlParse(content, size, true, _svgLoaderParser, &(loaderData))) return;
 
     if (loaderData.doc) {
@@ -3316,7 +3322,7 @@ bool SvgLoader::read()
     if (((uint32_t)viewFlag & (uint32_t)SvgViewFlag::Viewbox) &&
         (fabsf(vw) <= FLT_EPSILON || fabsf(vh) <= FLT_EPSILON)) {
         TVGLOG("SVG", "The <viewBox> width and/or height set to 0 - rendering disabled.");
-        return false;
+        renderingDisabled = true;
     }
 
     TaskScheduler::request(this);
index 5c74184..43882b7 100644 (file)
@@ -54,6 +54,7 @@ private:
     SvgViewFlag viewFlag = SvgViewFlag::None;
     AspectRatioAlign align = AspectRatioAlign::XMidYMid;
     AspectRatioMeetOrSlice meetOrSlice = AspectRatioMeetOrSlice::Meet;
+    bool renderingDisabled = false;
 
     bool header();
     void clear();