From: Mira Grudzinska Date: Wed, 15 Mar 2023 23:47:11 +0000 (+0100) Subject: svg_loader: handling zero width/height viewbox X-Git-Tag: accepted/tizen/unified/20230404.025051~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c266abaf3d093696f817d2bffcd840f8826fbf70;p=platform%2Fcore%2Fgraphics%2Ftizenvg.git svg_loader: handling zero width/height viewbox 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 --- diff --git a/src/loaders/svg/tvgSvgLoader.cpp b/src/loaders/svg/tvgSvgLoader.cpp index e05aa49..1365663 100644 --- a/src/loaders/svg/tvgSvgLoader.cpp +++ b/src/loaders/svg/tvgSvgLoader.cpp @@ -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 width and/or height set to 0 - rendering disabled."); - return false; + renderingDisabled = true; } TaskScheduler::request(this); diff --git a/src/loaders/svg/tvgSvgLoader.h b/src/loaders/svg/tvgSvgLoader.h index 5c74184..43882b7 100644 --- a/src/loaders/svg/tvgSvgLoader.h +++ b/src/loaders/svg/tvgSvgLoader.h @@ -54,6 +54,7 @@ private: SvgViewFlag viewFlag = SvgViewFlag::None; AspectRatioAlign align = AspectRatioAlign::XMidYMid; AspectRatioMeetOrSlice meetOrSlice = AspectRatioMeetOrSlice::Meet; + bool renderingDisabled = false; bool header(); void clear();