}
+static void _inefficientNodeCheck(TVG_UNUSED SvgNode* node){
#ifdef THORVG_LOG_ENABLED
-static void _inefficientNodeCheck(SvgNode* node){
- if (!node->display && node->type != SvgNodeType::ClipPath) 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());
+ auto type = simpleXmlNodeTypeToString(node->type);
+
+ if (!node->display && node->type != SvgNodeType::ClipPath) printf("SVG: Inefficient elements used [Display is none][Node Type : %s]\n", type);
+ if (node->style->opacity == 0) printf("SVG: Inefficient elements used [Opacity is zero][Node Type : %s]\n", type);
+ 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", type);
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", simpleXmlNodeTypeToString(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", type);
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", simpleXmlNodeTypeToString(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", type);
break;
}
case SvgNodeType::Polygon:
case SvgNodeType::Polyline: {
- if (node->node.polygon.pointsCount < 2) printf("SVG: Inefficient elements used [Invalid Polygon][Node Type : %s]\n", simpleXmlNodeTypeToString(node->type).c_str());
+ if (node->node.polygon.pointsCount < 2) printf("SVG: Inefficient elements used [Invalid Polygon][Node Type : %s]\n", type);
break;
}
case SvgNodeType::Circle: {
- if (node->node.circle.r == 0) printf("SVG: Inefficient elements used [Size is zero][Node Type : %s]\n", simpleXmlNodeTypeToString(node->type).c_str());
+ if (node->node.circle.r == 0) printf("SVG: Inefficient elements used [Size is zero][Node Type : %s]\n", type);
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", simpleXmlNodeTypeToString(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", type);
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", simpleXmlNodeTypeToString(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", type);
break;
}
default: break;
}
-}
#endif
+}
+
static void _updateStyle(SvgNode* node, SvgStyleProperty* parentStyle)
{
_styleInherit(node->style, parentStyle);
-#ifdef THORVG_LOG_ENABLED
_inefficientNodeCheck(node);
-#endif
auto child = node->child.data;
for (uint32_t i = 0; i < node->child.count; ++i, ++child) {
/************************************************************************/
#ifdef THORVG_LOG_ENABLED
-
-#include <stdio.h>
-
-string simpleXmlNodeTypeToString(SvgNodeType type)
-{
- switch (type) {
- case SvgNodeType::Doc: return "Svg";
- case SvgNodeType::G: return "G";
- case SvgNodeType::Defs: return "Defs";
- case SvgNodeType::Animation: return "Animation";
- case SvgNodeType::Arc: return "Arc";
- case SvgNodeType::Circle: return "Circle";
- case SvgNodeType::Ellipse: return "Ellipse";
- case SvgNodeType::Image: return "Image";
- case SvgNodeType::Line: return "Line";
- case SvgNodeType::Path: return "Path";
- case SvgNodeType::Polygon: return "Polygon";
- case SvgNodeType::Polyline: return "Polyline";
- case SvgNodeType::Rect: return "Rect";
- case SvgNodeType::Text: return "Text";
- case SvgNodeType::TextArea: return "TextArea";
- case SvgNodeType::Tspan: return "Tspan";
- 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;
}
return false;
}
-
#endif
+
static const char* _simpleXmlFindWhiteSpace(const char* itr, const char* itrEnd)
{
for (; itr < itrEnd; itr++) {
/* External Class Implementation */
/************************************************************************/
+const char* simpleXmlNodeTypeToString(TVG_UNUSED SvgNodeType type)
+{
+#ifdef THORVG_LOG_ENABLED
+ static const char* TYPE_NAMES[] = {
+ "Svg",
+ "G",
+ "Defs",
+ "Animation",
+ "Arc",
+ "Circle",
+ "Ellipse",
+ "Image",
+ "Line",
+ "Path",
+ "Polygon",
+ "Polyline",
+ "Rect",
+ "Text",
+ "TextArea",
+ "Tspan",
+ "Use",
+ "Video",
+ "ClipPath",
+ "Mask",
+ "Unknown",
+ };
+ return TYPE_NAMES[(int) type];
+#endif
+ return nullptr;
+}
+
+
+bool isIgnoreUnsupportedLogElements(TVG_UNUSED const char* tagName)
+{
+#ifdef THORVG_LOG_ENABLED
+ 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;
+#else
+ return true;
+#endif
+}
+
bool simpleXmlParseAttributes(const char* buf, unsigned bufLength, simpleXMLAttributeCb func, const void* data)
{
#ifdef THORVG_LOG_ENABLED
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");
+ if (!_isIgnoreUnsupportedLogAttributes(tmpBuf, tval)) {
+ auto type = simpleXmlNodeTypeToString(((SvgLoaderData*)data)->svgParse->node->type);
+ auto id = ((SvgLoaderData*)data)->svgParse->node->id ? ((SvgLoaderData*)data)->svgParse->node->id->c_str() : "NO_ID";
+ printf("SVG: Unsupported attributes used [Elements type: %s][Id : %s][Attribute: %s][Value: %s]\n", type, id, tmpBuf, tval ? tval : "NONE");
+ }
}
#else
func((void*)data, tmpBuf, tval);
#ifdef THORVG_LOG_ENABLED
if (!func((void*)data, key, val)) {
- if (!_isIgnoreUnsupportedLogAttributes(key, val)) 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", key, val ? val : "NONE");
+ if (!_isIgnoreUnsupportedLogAttributes(key, val)) {
+ auto type = simpleXmlNodeTypeToString(((SvgLoaderData*)data)->svgParse->node->type);
+ auto id = ((SvgLoaderData*)data)->svgParse->node->id ? ((SvgLoaderData*)data)->svgParse->node->id->c_str() : "NO_ID";
+ printf("SVG: Unsupported attributes used [Elements type: %s][Id : %s][Attribute: %s][Value: %s]\n", type, id, key, val ? val : "NONE");
+ }
}
#else
func((void*)data, key, val);