mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-07 21:23:32 +00:00
svg_loader XmlParser: code refactoring.
just renamed _nodeTypeToString() -> xmlParserNodeTypeToString() + print meson message if log is enabled.
This commit is contained in:
parent
23331cf8d4
commit
cee1348a44
5 changed files with 19 additions and 19 deletions
|
@ -30,6 +30,7 @@ endif
|
|||
|
||||
if get_option('log') == true
|
||||
config_h.set10('THORVG_LOG_ENABLED', true)
|
||||
message('Enable Log')
|
||||
endif
|
||||
|
||||
configure_file(
|
||||
|
|
|
@ -2227,34 +2227,34 @@ static void _styleInherit(SvgStyleProperty* child, SvgStyleProperty* parent)
|
|||
|
||||
#ifdef THORVG_LOG_ENABLED
|
||||
static void _inefficientNodeCheck(SvgNode* node){
|
||||
if (!node->display) printf("SVG: Inefficient elements used [Display is none][Node Type : %s]\n", _nodeTypeToString(node->type).c_str());
|
||||
if (node->style->opacity == 0) printf("SVG: Inefficient elements used [Opacity is zero][Node Type : %s]\n", _nodeTypeToString(node->type).c_str());
|
||||
if (node->style->fill.opacity == 0 && node->style->stroke.opacity == 0) printf("SVG: Inefficient elements used [Fill opacity and stroke opacity are zero][Node Type : %s]\n", _nodeTypeToString(node->type).c_str());
|
||||
if (!node->display) printf("SVG: Inefficient elements used [Display is none][Node Type : %s]\n", simpleXmlNodeTypeToString(node->type).c_str());
|
||||
if (node->style->opacity == 0) printf("SVG: Inefficient elements used [Opacity is zero][Node Type : %s]\n", simpleXmlNodeTypeToString(node->type).c_str());
|
||||
if (node->style->fill.opacity == 0 && node->style->stroke.opacity == 0) printf("SVG: Inefficient elements used [Fill opacity and stroke opacity are zero][Node Type : %s]\n", simpleXmlNodeTypeToString(node->type).c_str());
|
||||
|
||||
switch (node->type) {
|
||||
case SvgNodeType::Path: {
|
||||
if (!node->node.path.path || node->node.path.path->empty()) printf("SVG: Inefficient elements used [Empty path][Node Type : %s]\n", _nodeTypeToString(node->type).c_str());
|
||||
if (!node->node.path.path || node->node.path.path->empty()) printf("SVG: Inefficient elements used [Empty path][Node Type : %s]\n", simpleXmlNodeTypeToString(node->type).c_str());
|
||||
break;
|
||||
}
|
||||
case SvgNodeType::Ellipse: {
|
||||
if (node->node.ellipse.rx == 0 && node->node.ellipse.ry == 0) printf("SVG: Inefficient elements used [Size is zero][Node Type : %s]\n", _nodeTypeToString(node->type).c_str());
|
||||
if (node->node.ellipse.rx == 0 && node->node.ellipse.ry == 0) printf("SVG: Inefficient elements used [Size is zero][Node Type : %s]\n", simpleXmlNodeTypeToString(node->type).c_str());
|
||||
break;
|
||||
}
|
||||
case SvgNodeType::Polygon:
|
||||
case SvgNodeType::Polyline: {
|
||||
if (node->node.polygon.pointsCount < 2) printf("SVG: Inefficient elements used [Invalid Polygon][Node Type : %s]\n", _nodeTypeToString(node->type).c_str());
|
||||
if (node->node.polygon.pointsCount < 2) printf("SVG: Inefficient elements used [Invalid Polygon][Node Type : %s]\n", simpleXmlNodeTypeToString(node->type).c_str());
|
||||
break;
|
||||
}
|
||||
case SvgNodeType::Circle: {
|
||||
if (node->node.circle.r == 0) printf("SVG: Inefficient elements used [Size is zero][Node Type : %s]\n", _nodeTypeToString(node->type).c_str());
|
||||
if (node->node.circle.r == 0) printf("SVG: Inefficient elements used [Size is zero][Node Type : %s]\n", simpleXmlNodeTypeToString(node->type).c_str());
|
||||
break;
|
||||
}
|
||||
case SvgNodeType::Rect: {
|
||||
if (node->node.rect.w == 0 && node->node.rect.h) printf("SVG: Inefficient elements used [Size is zero][Node Type : %s]\n", _nodeTypeToString(node->type).c_str());
|
||||
if (node->node.rect.w == 0 && node->node.rect.h) printf("SVG: Inefficient elements used [Size is zero][Node Type : %s]\n", simpleXmlNodeTypeToString(node->type).c_str());
|
||||
break;
|
||||
}
|
||||
case SvgNodeType::Line: {
|
||||
if (node->node.line.x1 == node->node.line.x2 && node->node.line.y1 == node->node.line.y2) printf("SVG: Inefficient elements used [Size is zero][Node Type : %s]\n", _nodeTypeToString(node->type).c_str());
|
||||
if (node->node.line.x1 == node->node.line.x2 && node->node.line.y1 == node->node.line.y2) printf("SVG: Inefficient elements used [Size is zero][Node Type : %s]\n", simpleXmlNodeTypeToString(node->type).c_str());
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
|
|
|
@ -347,8 +347,4 @@ struct SvgLoaderData
|
|||
bool result = false;
|
||||
};
|
||||
|
||||
#ifdef THORVG_LOG_ENABLED
|
||||
string _nodeTypeToString(SvgNodeType type);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -28,14 +28,13 @@
|
|||
#include <alloca.h>
|
||||
#endif
|
||||
|
||||
#ifdef THORVG_LOG_ENABLED
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#include "tvgXmlParser.h"
|
||||
|
||||
#ifdef THORVG_LOG_ENABLED
|
||||
string _nodeTypeToString(SvgNodeType type)
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
string simpleXmlNodeTypeToString(SvgNodeType type)
|
||||
{
|
||||
switch (type) {
|
||||
case SvgNodeType::Doc: return "Doc";
|
||||
|
@ -186,7 +185,7 @@ bool simpleXmlParseAttributes(const char* buf, unsigned bufLength, simpleXMLAttr
|
|||
tval[valueEnd - value] = '\0';
|
||||
|
||||
#ifdef THORVG_LOG_ENABLED
|
||||
if (!func((void*)data, tmpBuf, tval)) printf("SVG: Unsupported attributes used [Elements type: %s][Attribute: %s]\n", _nodeTypeToString(((SvgLoaderData*)data)->svgParse->node->type).c_str(), tmpBuf);
|
||||
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);
|
||||
#else
|
||||
func((void*)data, tmpBuf, tval);
|
||||
#endif
|
||||
|
|
|
@ -48,4 +48,8 @@ bool simpleXmlParse(const char* buf, unsigned buflen, bool strip, simpleXMLCb fu
|
|||
bool simpleXmlParseW3CAttribute(const char* buf, simpleXMLAttributeCb func, const void* data);
|
||||
const char *simpleXmlFindAttributesTag(const char* buf, unsigned buflen);
|
||||
|
||||
#ifdef THORVG_LOG_ENABLED
|
||||
string simpleXmlNodeTypeToString(SvgNodeType type);
|
||||
#endif
|
||||
|
||||
#endif //_TVG_SIMPLE_XML_PARSER_H_
|
||||
|
|
Loading…
Add table
Reference in a new issue