From: JunsuChoi Date: Mon, 26 Apr 2021 06:25:45 +0000 (+0900) Subject: log SvgLoader: Enhance log message X-Git-Tag: accepted/tizen/unified/20210602.122549~26 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2189d1f9312d63f01b698aadf5ad99f845f9c891;hp=0de9d5081013a0cc785ed6ef3562a7933a536fb9;p=platform%2Fcore%2Fgraphics%2Ftizenvg.git log SvgLoader: Enhance log message - Change tag name "Doc" to "Svg" - Fix "Mask" tag name. - Add element to skip output - title - Add attribute to skip output - id, data-name, version, overflow=visible, xmlns*, xml:space Change-Id: I2d5900e46d810c243602cc93c35d25e1224e98d5 --- diff --git a/src/loaders/svg/tvgSvgLoader.cpp b/src/loaders/svg/tvgSvgLoader.cpp index a816053..89c0c61 100644 --- a/src/loaders/svg/tvgSvgLoader.cpp +++ b/src/loaders/svg/tvgSvgLoader.cpp @@ -36,8 +36,6 @@ typedef SvgNode* (*FactoryMethod)(SvgLoaderData* loader, SvgNode* parent, const typedef SvgStyleGradient* (*GradientFactoryMethod)(SvgLoaderData* loader, const char* buf, unsigned bufLength); - - static char* _skipSpace(const char* str, const char* end) { while (((end && str < end) || (!end && *str != '\0')) && isspace(*str)) { @@ -739,8 +737,8 @@ static bool _attrParseSvgNode(void* data, const char* key, const char* value) return simpleXmlParseW3CAttribute(value, _parseStyleAttr, loader); } #ifdef THORVG_LOG_ENABLED - else if (!strcmp(key, "xmlns") || !strcmp(key, "xmlns:xlink") || !strcmp(key, "xmlns:svg")) { - //No action + else if (!strcmp(key, "x") || !strcmp(key, "y")) { + if (0.0f == _parseLength(value, &type)) printf("SVG: Unsupported attributes used [Elements type: Svg][Attribute: %s][Value: %s]\n", key, value); } #endif else { @@ -1080,7 +1078,7 @@ static SvgNode* _createSvgNode(SvgLoaderData* loader, SvgNode* parent, const cha static SvgNode* _createMaskNode(SvgLoaderData* loader, SvgNode* parent, TVG_UNUSED const char* buf, TVG_UNUSED unsigned bufLength) { - loader->svgParse->node = _createNode(parent, SvgNodeType::Unknown); + loader->svgParse->node = _createNode(parent, SvgNodeType::Mask); if (!loader->svgParse->node) return nullptr; simpleXmlParseAttributes(buf, bufLength, _attrParseMaskNode, loader); @@ -2207,7 +2205,7 @@ static void _svgLoaderParserXmlOpen(SvgLoaderData* loader, const char* content, } #ifdef THORVG_LOG_ENABLED else { - printf("SVG: Unsupported elements used [Elements: %s]\n", tagName); + if (!isIgnoreUnsupportedLogElements(tagName)) printf("SVG: Unsupported elements used [Elements: %s]\n", tagName); } #endif } diff --git a/src/loaders/svg/tvgSvgLoaderCommon.h b/src/loaders/svg/tvgSvgLoaderCommon.h index bc44167..e5ed3d7 100644 --- a/src/loaders/svg/tvgSvgLoaderCommon.h +++ b/src/loaders/svg/tvgSvgLoaderCommon.h @@ -47,6 +47,7 @@ enum class SvgNodeType Use, Video, ClipPath, + Mask, //Custome_command, //Not support Unknown }; diff --git a/src/loaders/svg/tvgXmlParser.cpp b/src/loaders/svg/tvgXmlParser.cpp index 1fe223a..6694842 100644 --- a/src/loaders/svg/tvgXmlParser.cpp +++ b/src/loaders/svg/tvgXmlParser.cpp @@ -42,7 +42,7 @@ string simpleXmlNodeTypeToString(SvgNodeType type) { switch (type) { - case SvgNodeType::Doc: return "Doc"; + case SvgNodeType::Doc: return "Svg"; case SvgNodeType::G: return "G"; case SvgNodeType::Defs: return "Defs"; case SvgNodeType::Animation: return "Animation"; @@ -61,10 +61,55 @@ string simpleXmlNodeTypeToString(SvgNodeType type) case SvgNodeType::Use: return "Use"; case SvgNodeType::Video: return "Video"; case SvgNodeType::ClipPath: return "ClipPath"; + case SvgNodeType::Mask: return "Mask"; default: return "Unknown"; } return "Unknown"; } + +bool isIgnoreUnsupportedLogElements(const char* tagName) +{ + const auto elementsNum = 1; + const char* const elements[] = { "title" }; + + for (unsigned int i = 0; i < elementsNum; ++i) { + if (!strncmp(tagName, elements[i], strlen(tagName))) { + return true; + } + } + return false; +} + +bool _isIgnoreUnsupportedLogAttributes(const char* tagAttribute, const char* tagValue) +{ + const auto attributesNum = 6; + const struct + { + const char* tag; + bool tagWildcard; //If true, it is assumed that a wildcard is used after the tag. (ex: tagName*) + const char* value; + } attributes[] = { + {"id", false, nullptr}, + {"data-name", false, nullptr}, + {"overflow", false, "visible"}, + {"version", false, nullptr}, + {"xmlns", true, nullptr}, + {"xml:space", false, nullptr}, + }; + + for (unsigned int i = 0; i < attributesNum; ++i) { + if (!strncmp(tagAttribute, attributes[i].tag, attributes[i].tagWildcard ? strlen(attributes[i].tag) : strlen(tagAttribute))) { + if (attributes[i].value && tagValue) { + if (!strncmp(tagValue, attributes[i].value, strlen(tagValue))) { + return true; + } else continue; + } + return true; + } + } + return false; +} + #endif static const char* _simpleXmlFindWhiteSpace(const char* itr, const char* itrEnd) @@ -267,7 +312,9 @@ bool simpleXmlParseAttributes(const char* buf, unsigned bufLength, simpleXMLAttr tval[i] = '\0'; #ifdef THORVG_LOG_ENABLED - if (!func((void*)data, tmpBuf, tval)) printf("SVG: Unsupported attributes used [Elements type: %s][Attribute: %s]\n", simpleXmlNodeTypeToString(((SvgLoaderData*)data)->svgParse->node->type).c_str(), tmpBuf); + if (!func((void*)data, tmpBuf, tval)) { + if (!_isIgnoreUnsupportedLogAttributes(tmpBuf, tval)) printf("SVG: Unsupported attributes used [Elements type: %s][Id : %s][Attribute: %s][Value: %s]\n", simpleXmlNodeTypeToString(((SvgLoaderData*)data)->svgParse->node->type).c_str(), ((SvgLoaderData*)data)->svgParse->node->id ? ((SvgLoaderData*)data)->svgParse->node->id->c_str() : "NO_ID", tmpBuf, tval ? tval : "NONE"); + } #else func((void*)data, tmpBuf, tval); #endif diff --git a/src/loaders/svg/tvgXmlParser.h b/src/loaders/svg/tvgXmlParser.h index 621d72c..f775819 100644 --- a/src/loaders/svg/tvgXmlParser.h +++ b/src/loaders/svg/tvgXmlParser.h @@ -54,6 +54,8 @@ const char *simpleXmlFindAttributesTag(const char* buf, unsigned buflen); #ifdef THORVG_LOG_ENABLED string simpleXmlNodeTypeToString(SvgNodeType type); + +bool isIgnoreUnsupportedLogElements(const char* tagName); #endif #endif //_TVG_SIMPLE_XML_PARSER_H_