Lines Matching +full:- +full:r

2  * Copyright (c) 2020 - 2024 the ThorVG project. All rights reserved.
71 * and: https://www.w3.org/TR/css-values-4/#absolute-lengths
74 #define PX_PER_PC 16 //1 pc = 1/6 in -> PX_PER_IN/6
75 #define PX_PER_PT 1.333333f //1 pt = 1/72 in -> PX_PER_IN/72
76 #define PX_PER_MM 3.779528f //1 in = 25.4 mm -> PX_PER_IN/25.4
77 #define PX_PER_CM 37.79528f //1 in = 2.54 cm -> PX_PER_IN/2.54
181 …if (type == SvgParserLengthType::Vertical) parsedValue = (parsedValue / 100.0f) * svgParse->global… in _toFloat()
182 …type == SvgParserLengthType::Horizontal) parsedValue = (parsedValue / 100.0f) * svgParse->global.w; in _toFloat()
183 …arserLengthType::Diagonal) parsedValue = (sqrtf(powf(svgParse->global.w, 2) + powf(svgParse->globa… in _toFloat()
186 float max = svgParse->global.w; in _toFloat()
187 if (max < svgParse->global.h) in _toFloat()
188 max = svgParse->global.h; in _toFloat()
377 …parsedValue = (sqrtf(powf(loader->svgParse->global.w, 2) + powf(loader->svgParse->global.h, 2)) / … in _PARSE_TAG()
397 --close; in _idFromUrl()
400 while (open < close && *close == ' ') --close; in _idFromUrl()
407 return strDuplicate(open, (close - open + 1)); in _idFromUrl()
413 float r; in _parseColor() local
415 r = strToFloat(value, end); in _parseColor()
418 r = 255 * r / 100; in _parseColor()
423 if (r < 0 || r > 255) { in _parseColor()
428 return lrint(r); in _parseColor()
605 …v = (brightness <= 0.5f) ? (brightness * (1.0f + saturation)) : (brightness + saturation - (bright… in _hslToRgb()
606 p = brightness + brightness - v; in _hslToRgb()
608 if (!tvg::zero(v)) sv = (v - p) / v; in _hslToRgb()
612 f = hue - i; in _hslToRgb()
617 q = v - vsf; in _hslToRgb()
667 static bool _toColor(const char* str, uint8_t* r, uint8_t* g, uint8_t* b, char** ref) in _toColor() argument
679 *r = strtol(tmp, nullptr, 16); in _toColor()
693 *r = strtol(tmp, nullptr, 16); in _toColor()
702 …&& (str[0] == 'r' || str[0] == 'R') && (str[1] == 'g' || str[1] == 'G') && (str[2] == 'b' || str[2… in _toColor()
709 *r = tr; in _toColor()
720 …s' || str[1] == 'S') && (str[2] == 'l' || str[2] == 'L') && str[3] == '(' && str[len - 1] == ')') { in _toColor()
739 return _hslToRgb(th, ts, tb, r, g, b); in _toColor()
748 *r = (((uint8_t*)(&(colors[i].value)))[2]); in _toColor()
765 while ((count < len) && (isdigit(*str) || *str == '-' || *str == '+' || *str == '.')) { in _parseNumbersArray()
834 if (!strncmp(matrixTags[i].tag, str, matrixTags[i].sz - 1)) { in _parseTransformationMatrix()
836 str += (matrixTags[i].sz - 1); in _parseTransformationMatrix()
868 Matrix tmp = { c, -s, 0, s, c, 0, 0, 0, 1 }; in _parseTransformationMatrix()
873 tmp = { c, -s, 0, s, c, 0, 0, 0, 1 }; in _parseTransformationMatrix()
875 tmp = { 1, 0, -points[1], 0, 1, -points[2], 0, 0, 1 }; in _parseTransformationMatrix()
919 // TODO - remove?
942 …if (lengthTags[i].sz - 1 == sz && !strncmp(lengthTags[i].tag, str, sz)) *type = lengthTags[i].type;
956 SvgNode* node = loader->svgParse->node; in _attrParseSvgNode()
957 SvgDocNode* doc = &(node->node.doc); in _attrParseSvgNode()
960 doc->w = _toFloat(loader->svgParse, value, SvgParserLengthType::Horizontal); in _attrParseSvgNode()
961 if (strstr(value, "%") && !(doc->viewFlag & SvgViewFlag::Viewbox)) { in _attrParseSvgNode()
962 doc->viewFlag = (doc->viewFlag | SvgViewFlag::WidthInPercent); in _attrParseSvgNode()
964 doc->viewFlag = (doc->viewFlag | SvgViewFlag::Width); in _attrParseSvgNode()
967 doc->h = _toFloat(loader->svgParse, value, SvgParserLengthType::Vertical); in _attrParseSvgNode()
968 if (strstr(value, "%") && !(doc->viewFlag & SvgViewFlag::Viewbox)) { in _attrParseSvgNode()
969 doc->viewFlag = (doc->viewFlag | SvgViewFlag::HeightInPercent); in _attrParseSvgNode()
971 doc->viewFlag = (doc->viewFlag | SvgViewFlag::Height); in _attrParseSvgNode()
974 if (_parseNumber(&value, nullptr, &doc->vx)) { in _attrParseSvgNode()
975 if (_parseNumber(&value, nullptr, &doc->vy)) { in _attrParseSvgNode()
976 if (_parseNumber(&value, nullptr, &doc->vw)) { in _attrParseSvgNode()
977 if (_parseNumber(&value, nullptr, &doc->vh)) { in _attrParseSvgNode()
978 doc->viewFlag = (doc->viewFlag | SvgViewFlag::Viewbox); in _attrParseSvgNode()
979 loader->svgParse->global.h = doc->vh; in _attrParseSvgNode()
981 loader->svgParse->global.w = doc->vw; in _attrParseSvgNode()
983 loader->svgParse->global.y = doc->vy; in _attrParseSvgNode()
985 loader->svgParse->global.x = doc->vx; in _attrParseSvgNode()
987 if ((doc->viewFlag & SvgViewFlag::Viewbox) && (doc->vw < 0.0f || doc->vh < 0.0f)) { in _attrParseSvgNode()
988 … doc->viewFlag = (SvgViewFlag)((uint32_t)doc->viewFlag & ~(uint32_t)SvgViewFlag::Viewbox); in _attrParseSvgNode()
989 …TVGLOG("SVG", "Negative values of the <viewBox> width and/or height - the attribute invalidated."); in _attrParseSvgNode()
991 if (!(doc->viewFlag & SvgViewFlag::Viewbox)) { in _attrParseSvgNode()
992 loader->svgParse->global.x = loader->svgParse->global.y = 0.0f; in _attrParseSvgNode()
993 loader->svgParse->global.w = loader->svgParse->global.h = 1.0f; in _attrParseSvgNode()
996 _parseAspectRatio(&value, &doc->align, &doc->meetOrSlice); in _attrParseSvgNode()
1015 paint->none = true; in _handlePaintAttr()
1019 paint->curColor = true; in _handlePaintAttr()
1020 paint->none = false; in _handlePaintAttr()
1023 …if (_toColor(value, &paint->color.r, &paint->color.g, &paint->color.b, &paint->url)) paint->none =… in _handlePaintAttr()
1029 SvgStyleProperty* style = node->style; in _handleColorAttr()
1030 if (_toColor(value, &style->color.r, &style->color.g, &style->color.b, nullptr)) { in _handleColorAttr()
1031 style->curColorSet = true; in _handleColorAttr()
1038 SvgStyleProperty* style = node->style; in _handleFillAttr()
1039 style->fill.flags = (style->fill.flags | SvgFillFlags::Paint); in _handleFillAttr()
1040 _handlePaintAttr(&style->fill.paint, value); in _handleFillAttr()
1046 SvgStyleProperty* style = node->style; in _handleStrokeAttr()
1047 style->stroke.flags = (style->stroke.flags | SvgStrokeFlags::Paint); in _handleStrokeAttr()
1048 _handlePaintAttr(&style->stroke.paint, value); in _handleStrokeAttr()
1054 node->style->stroke.flags = (node->style->stroke.flags | SvgStrokeFlags::Opacity); in _handleStrokeOpacityAttr()
1055 node->style->stroke.opacity = _toOpacity(value); in _handleStrokeOpacityAttr()
1060 node->style->stroke.flags = (node->style->stroke.flags | SvgStrokeFlags::Dash); in _handleStrokeDashArrayAttr()
1061 _parseDashArray(loader, value, &node->style->stroke.dash); in _handleStrokeDashArrayAttr()
1066 node->style->stroke.flags = (node->style->stroke.flags | SvgStrokeFlags::DashOffset); in _handleStrokeDashOffsetAttr()
1067 …node->style->stroke.dash.offset = _toFloat(loader->svgParse, value, SvgParserLengthType::Horizonta… in _handleStrokeDashOffsetAttr()
1072 node->style->stroke.flags = (node->style->stroke.flags | SvgStrokeFlags::Width); in _handleStrokeWidthAttr()
1073 node->style->stroke.width = _toFloat(loader->svgParse, value, SvgParserLengthType::Diagonal); in _handleStrokeWidthAttr()
1079 node->style->stroke.flags = (node->style->stroke.flags | SvgStrokeFlags::Cap); in _handleStrokeLineCapAttr()
1080 node->style->stroke.cap = _toLineCap(value); in _handleStrokeLineCapAttr()
1086 node->style->stroke.flags = (node->style->stroke.flags | SvgStrokeFlags::Join); in _handleStrokeLineJoinAttr()
1087 node->style->stroke.join = _toLineJoin(value); in _handleStrokeLineJoinAttr()
1096 // - A negative value for stroke-miterlimit must be treated as an illegal value. in _handleStrokeMiterlimitAttr()
1098 TVGERR("SVG", "A stroke-miterlimit change (%f <- %f) with a negative value is omitted.", in _handleStrokeMiterlimitAttr()
1099 node->style->stroke.miterlimit, miterlimit); in _handleStrokeMiterlimitAttr()
1103 node->style->stroke.flags = (node->style->stroke.flags | SvgStrokeFlags::Miterlimit); in _handleStrokeMiterlimitAttr()
1104 node->style->stroke.miterlimit = miterlimit; in _handleStrokeMiterlimitAttr()
1109 node->style->fill.flags = (node->style->fill.flags | SvgFillFlags::FillRule); in _handleFillRuleAttr()
1110 node->style->fill.fillRule = _toFillRule(value); in _handleFillRuleAttr()
1116 node->style->flags = (node->style->flags | SvgStyleFlags::Opacity); in _handleOpacityAttr()
1117 node->style->opacity = _toOpacity(value); in _handleOpacityAttr()
1123 node->style->fill.flags = (node->style->fill.flags | SvgFillFlags::Opacity); in _handleFillOpacityAttr()
1124 node->style->fill.opacity = _toOpacity(value); in _handleFillOpacityAttr()
1130 node->transform = _parseTransformationMatrix(value); in _handleTransformAttr()
1136 SvgStyleProperty* style = node->style; in _handleClipPathAttr()
1139 if (style->clipPath.url) free(style->clipPath.url); in _handleClipPathAttr()
1140 style->clipPath.url = _idFromUrl((const char*)(value + 3)); in _handleClipPathAttr()
1147 SvgStyleProperty* style = node->style; in _handleMaskAttr()
1150 if (style->mask.url) free(style->mask.url); in _handleMaskAttr()
1151 style->mask.url = _idFromUrl((const char*)(value + 3)); in _handleMaskAttr()
1158 node->node.mask.type = _toMaskType(value); in _handleMaskTypeAttr()
1167 // refer to https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/display in _handleDisplayAttr()
1168 node->style->flags = (node->style->flags | SvgStyleFlags::Display); in _handleDisplayAttr()
1169 if (!strcmp(value, "none")) node->style->display = false; in _handleDisplayAttr()
1170 else node->style->display = true; in _handleDisplayAttr()
1176 node->style->flags = (node->style->flags | SvgStyleFlags::PaintOrder); in _handlePaintOrderAttr()
1177 node->style->paintOrder = _toPaintOrder(value); in _handlePaintOrderAttr()
1183 auto cssClass = &node->style->cssClass; in _handleCssClassAttr()
1191 if (auto cssNode = cssFindStyleNode(loader->cssStyle, *cssClass, node->type)) { in _handleCssClassAttr()
1195 if (auto cssNode = cssFindStyleNode(loader->cssStyle, *cssClass)) { in _handleCssClassAttr()
1200 if (!cssClassFound) _postpone(loader->nodesToStyle, node, *cssClass); in _handleCssClassAttr()
1218 STYLE_DEF(fill-rule, FillRule, SvgStyleFlags::FillRule),
1219 STYLE_DEF(fill-opacity, FillOpacity, SvgStyleFlags::FillOpacity),
1222 STYLE_DEF(stroke-width, StrokeWidth, SvgStyleFlags::StrokeWidth),
1223 STYLE_DEF(stroke-linejoin, StrokeLineJoin, SvgStyleFlags::StrokeLineJoin),
1224 STYLE_DEF(stroke-miterlimit, StrokeMiterlimit, SvgStyleFlags::StrokeMiterlimit),
1225 STYLE_DEF(stroke-linecap, StrokeLineCap, SvgStyleFlags::StrokeLineCap),
1226 STYLE_DEF(stroke-opacity, StrokeOpacity, SvgStyleFlags::StrokeOpacity),
1227 STYLE_DEF(stroke-dasharray, StrokeDashArray, SvgStyleFlags::StrokeDashArray),
1228 STYLE_DEF(stroke-dashoffset, StrokeDashOffset, SvgStyleFlags::StrokeDashOffset),
1230 STYLE_DEF(clip-path, ClipPath, SvgStyleFlags::ClipPath),
1232 STYLE_DEF(mask-type, MaskType, SvgStyleFlags::MaskType),
1234 STYLE_DEF(paint-order, PaintOrder, SvgStyleFlags::PaintOrder)
1241 SvgNode* node = loader->svgParse->node; in _parseStyleAttr()
1251 if (styleTags[i].sz - 1 == sz && !strncmp(styleTags[i].tag, key, sz)) { in _parseStyleAttr()
1254 size_t size = ptr - value; in _parseStyleAttr()
1255 while (size > 0 && isspace(value[size - 1])) { in _parseStyleAttr()
1256 size--; in _parseStyleAttr()
1262 if (importance || !(node->style->flagsImportance & styleTags[i].flag)) { in _parseStyleAttr()
1264 node->style->flags = (node->style->flags | styleTags[i].flag); in _parseStyleAttr()
1266 } else if (!(node->style->flags & styleTags[i].flag)) { in _parseStyleAttr()
1270 node->style->flagsImportance = (node->style->flags | styleTags[i].flag); in _parseStyleAttr()
1293 SvgNode* node = loader->svgParse->node; in _attrParseGNode()
1298 node->transform = _parseTransformationMatrix(value); in _attrParseGNode()
1300 if (node->id && value) free(node->id); in _attrParseGNode()
1301 node->id = _copyId(value); in _attrParseGNode()
1304 } else if (!strcmp(key, "clip-path")) { in _attrParseGNode()
1321 SvgNode* node = loader->svgParse->node; in _attrParseClipPathNode()
1322 SvgClipNode* clip = &(node->node.clip); in _attrParseClipPathNode()
1327 node->transform = _parseTransformationMatrix(value); in _attrParseClipPathNode()
1329 if (node->id && value) free(node->id); in _attrParseClipPathNode()
1330 node->id = _copyId(value); in _attrParseClipPathNode()
1334 if (!strcmp(value, "objectBoundingBox")) clip->userSpace = false; in _attrParseClipPathNode()
1345 SvgNode* node = loader->svgParse->node; in _attrParseMaskNode()
1346 SvgMaskNode* mask = &(node->node.mask); in _attrParseMaskNode()
1351 node->transform = _parseTransformationMatrix(value); in _attrParseMaskNode()
1353 if (node->id && value) free(node->id); in _attrParseMaskNode()
1354 node->id = _copyId(value); in _attrParseMaskNode()
1358 if (!strcmp(value, "objectBoundingBox")) mask->userSpace = false; in _attrParseMaskNode()
1359 } else if (!strcmp(key, "mask-type")) { in _attrParseMaskNode()
1360 mask->type = _toMaskType(value); in _attrParseMaskNode()
1371 SvgNode* node = loader->svgParse->node; in _attrParseCssStyleNode()
1374 if (node->id && value) free(node->id); in _attrParseCssStyleNode()
1375 node->id = _copyId(value); in _attrParseCssStyleNode()
1386 SvgNode* node = loader->svgParse->node; in _attrParseSymbolNode()
1387 SvgSymbolNode* symbol = &(node->node.symbol); in _attrParseSymbolNode()
1390 …if (!_parseNumber(&value, nullptr, &symbol->vx) || !_parseNumber(&value, nullptr, &symbol->vy)) re… in _attrParseSymbolNode()
1391 …if (!_parseNumber(&value, nullptr, &symbol->vw) || !_parseNumber(&value, nullptr, &symbol->vh)) re… in _attrParseSymbolNode()
1392 symbol->hasViewBox = true; in _attrParseSymbolNode()
1394 symbol->w = _toFloat(loader->svgParse, value, SvgParserLengthType::Horizontal); in _attrParseSymbolNode()
1395 symbol->hasWidth = true; in _attrParseSymbolNode()
1397 symbol->h = _toFloat(loader->svgParse, value, SvgParserLengthType::Vertical); in _attrParseSymbolNode()
1398 symbol->hasHeight = true; in _attrParseSymbolNode()
1400 _parseAspectRatio(&value, &symbol->align, &symbol->meetOrSlice); in _attrParseSymbolNode()
1402 if (!strcmp(value, "visible")) symbol->overflowVisible = true; in _attrParseSymbolNode()
1418 node->style = (SvgStyleProperty*)calloc(1, sizeof(SvgStyleProperty)); in _createNode()
1420 if (!node->style) { in _createNode()
1427 node->style->fill.paint.none = false; in _createNode()
1429 node->style->fill.opacity = 255; in _createNode()
1430 node->style->opacity = 255; in _createNode()
1432 node->style->fill.paint.curColor = false; in _createNode()
1433 node->style->curColorSet = false; in _createNode()
1435 node->style->fill.fillRule = FillRule::Winding; in _createNode()
1438 node->style->stroke.paint.none = true; in _createNode()
1440 node->style->stroke.opacity = 255; in _createNode()
1442 node->style->stroke.paint.curColor = false; in _createNode()
1444 node->style->stroke.width = 1; in _createNode()
1446 node->style->stroke.cap = StrokeCap::Butt; in _createNode()
1448 node->style->stroke.join = StrokeJoin::Miter; in _createNode()
1449 node->style->stroke.miterlimit = 4.0f; in _createNode()
1450 node->style->stroke.scale = 1.0; in _createNode()
1452 node->style->paintOrder = _toPaintOrder("fill stroke"); in _createNode()
1455 node->style->display = true; in _createNode()
1457 node->parent = parent; in _createNode()
1458 node->type = type; in _createNode()
1460 if (parent) parent->child.push(node); in _createNode()
1467 if (loader->def && loader->doc->node.doc.defs) return loader->def; in _createDefsNode()
1470 loader->def = node; in _createDefsNode()
1471 loader->doc->node.doc.defs = node; in _createDefsNode()
1478 loader->svgParse->node = _createNode(parent, SvgNodeType::G); in _createGNode()
1479 if (!loader->svgParse->node) return nullptr; in _createGNode()
1482 return loader->svgParse->node; in _createGNode()
1488 loader->svgParse->node = _createNode(parent, SvgNodeType::Doc); in _createSvgNode()
1489 if (!loader->svgParse->node) return nullptr; in _createSvgNode()
1490 SvgDocNode* doc = &(loader->svgParse->node->node.doc); in _createSvgNode()
1492 loader->svgParse->global.w = 1.0f; in _createSvgNode()
1493 loader->svgParse->global.h = 1.0f; in _createSvgNode()
1495 doc->align = AspectRatioAlign::XMidYMid; in _createSvgNode()
1496 doc->meetOrSlice = AspectRatioMeetOrSlice::Meet; in _createSvgNode()
1497 doc->viewFlag = SvgViewFlag::None; in _createSvgNode()
1500 if (!(doc->viewFlag & SvgViewFlag::Viewbox)) { in _createSvgNode()
1501 if (doc->viewFlag & SvgViewFlag::Width) { in _createSvgNode()
1502 loader->svgParse->global.w = doc->w; in _createSvgNode()
1504 if (doc->viewFlag & SvgViewFlag::Height) { in _createSvgNode()
1505 loader->svgParse->global.h = doc->h; in _createSvgNode()
1508 return loader->svgParse->node; in _createSvgNode()
1514 loader->svgParse->node = _createNode(parent, SvgNodeType::Mask); in _createMaskNode()
1515 if (!loader->svgParse->node) return nullptr; in _createMaskNode()
1517 loader->svgParse->node->node.mask.userSpace = true; in _createMaskNode()
1518 loader->svgParse->node->node.mask.type = SvgMaskType::Luminance; in _createMaskNode()
1522 return loader->svgParse->node; in _createMaskNode()
1528 loader->svgParse->node = _createNode(parent, SvgNodeType::ClipPath); in _createClipPathNode()
1529 if (!loader->svgParse->node) return nullptr; in _createClipPathNode()
1531 loader->svgParse->node->style->display = false; in _createClipPathNode()
1532 loader->svgParse->node->node.clip.userSpace = true; in _createClipPathNode()
1536 return loader->svgParse->node; in _createClipPathNode()
1542 loader->svgParse->node = _createNode(parent, SvgNodeType::CssStyle); in _createCssStyleNode()
1543 if (!loader->svgParse->node) return nullptr; in _createCssStyleNode()
1547 return loader->svgParse->node; in _createCssStyleNode()
1553 loader->svgParse->node = _createNode(parent, SvgNodeType::Symbol); in _createSymbolNode()
1554 if (!loader->svgParse->node) return nullptr; in _createSymbolNode()
1556 loader->svgParse->node->node.symbol.align = AspectRatioAlign::XMidYMid; in _createSymbolNode()
1557 loader->svgParse->node->node.symbol.meetOrSlice = AspectRatioMeetOrSlice::Meet; in _createSymbolNode()
1558 loader->svgParse->node->node.symbol.overflowVisible = false; in _createSymbolNode()
1560 loader->svgParse->node->node.symbol.hasViewBox = false; in _createSymbolNode()
1561 loader->svgParse->node->node.symbol.hasWidth = false; in _createSymbolNode()
1562 loader->svgParse->node->node.symbol.hasHeight = false; in _createSymbolNode()
1563 loader->svgParse->node->node.symbol.vx = 0.0f; in _createSymbolNode()
1564 loader->svgParse->node->node.symbol.vy = 0.0f; in _createSymbolNode()
1568 return loader->svgParse->node; in _createSymbolNode()
1575 SvgNode* node = loader->svgParse->node; in _attrParsePathNode()
1576 SvgPathNode* path = &(node->node.path); in _attrParsePathNode()
1579 if (path->path) free(path->path); in _attrParsePathNode()
1581 path->path = _copyId(value); in _attrParsePathNode()
1584 } else if (!strcmp(key, "clip-path")) { in _attrParsePathNode()
1589 if (node->id && value) free(node->id); in _attrParsePathNode()
1590 node->id = _copyId(value); in _attrParsePathNode()
1602 loader->svgParse->node = _createNode(parent, SvgNodeType::Path); in _createPathNode()
1604 if (!loader->svgParse->node) return nullptr; in _createPathNode()
1608 return loader->svgParse->node; in _createPathNode()
1621 {"r", SvgParserLengthType::Diagonal, sizeof("r"), offsetof(SvgCircleNode, r)}
1631 SvgNode* node = loader->svgParse->node; in _attrParseCircleNode()
1632 SvgCircleNode* circle = &(node->node.circle); in _attrParseCircleNode()
1638 if (circleTags[i].sz - 1 == sz && !strncmp(circleTags[i].tag, key, sz)) { in _attrParseCircleNode()
1639 … *((float*)(array + circleTags[i].offset)) = _toFloat(loader->svgParse, value, circleTags[i].type); in _attrParseCircleNode()
1646 } else if (!strcmp(key, "clip-path")) { in _attrParseCircleNode()
1651 if (node->id && value) free(node->id); in _attrParseCircleNode()
1652 node->id = _copyId(value); in _attrParseCircleNode()
1664 loader->svgParse->node = _createNode(parent, SvgNodeType::Circle); in _createCircleNode()
1666 if (!loader->svgParse->node) return nullptr; in _createCircleNode()
1669 return loader->svgParse->node; in _createCircleNode()
1693 SvgNode* node = loader->svgParse->node; in _attrParseEllipseNode()
1694 SvgEllipseNode* ellipse = &(node->node.ellipse); in _attrParseEllipseNode()
1700 if (ellipseTags[i].sz - 1 == sz && !strncmp(ellipseTags[i].tag, key, sz)) { in _attrParseEllipseNode()
1701 …*((float*)(array + ellipseTags[i].offset)) = _toFloat(loader->svgParse, value, ellipseTags[i].type… in _attrParseEllipseNode()
1707 if (node->id && value) free(node->id); in _attrParseEllipseNode()
1708 node->id = _copyId(value); in _attrParseEllipseNode()
1713 } else if (!strcmp(key, "clip-path")) { in _attrParseEllipseNode()
1726 loader->svgParse->node = _createNode(parent, SvgNodeType::Ellipse); in _createEllipseNode()
1728 if (!loader->svgParse->node) return nullptr; in _createEllipseNode()
1731 return loader->svgParse->node; in _createEllipseNode()
1739 polygon->pts.push(num_x); in _attrParsePolygonPoints()
1740 polygon->pts.push(num_y); in _attrParsePolygonPoints()
1752 SvgNode* node = loader->svgParse->node; in _attrParsePolygonNode()
1755 if (node->type == SvgNodeType::Polygon) polygon = &(node->node.polygon); in _attrParsePolygonNode()
1756 else polygon = &(node->node.polyline); in _attrParsePolygonNode()
1762 } else if (!strcmp(key, "clip-path")) { in _attrParsePolygonNode()
1767 if (node->id && value) free(node->id); in _attrParsePolygonNode()
1768 node->id = _copyId(value); in _attrParsePolygonNode()
1780 loader->svgParse->node = _createNode(parent, SvgNodeType::Polygon); in _createPolygonNode()
1782 if (!loader->svgParse->node) return nullptr; in _createPolygonNode()
1785 return loader->svgParse->node; in _createPolygonNode()
1791 loader->svgParse->node = _createNode(parent, SvgNodeType::Polyline); in _createPolylineNode()
1793 if (!loader->svgParse->node) return nullptr; in _createPolylineNode()
1796 return loader->svgParse->node; in _createPolylineNode()
1821 SvgNode* node = loader->svgParse->node; in _attrParseRectNode()
1822 SvgRectNode* rect = &(node->node.rect); in _attrParseRectNode()
1829 if (rectTags[i].sz - 1 == sz && !strncmp(rectTags[i].tag, key, sz)) { in _attrParseRectNode()
1830 … *((float*)(array + rectTags[i].offset)) = _toFloat(loader->svgParse, value, rectTags[i].type); in _attrParseRectNode()
1833 if (!strncmp(rectTags[i].tag, "rx", sz)) rect->hasRx = true; in _attrParseRectNode()
1834 if (!strncmp(rectTags[i].tag, "ry", sz)) rect->hasRy = true; in _attrParseRectNode()
1836 …if ((rect->rx >= FLOAT_EPSILON) && (rect->ry < FLOAT_EPSILON) && rect->hasRx && !rect->hasRy) rect in _attrParseRectNode()
1837 …if ((rect->ry >= FLOAT_EPSILON) && (rect->rx < FLOAT_EPSILON) && !rect->hasRx && rect->hasRy) rect in _attrParseRectNode()
1843 if (node->id && value) free(node->id); in _attrParseRectNode()
1844 node->id = _copyId(value); in _attrParseRectNode()
1849 } else if (!strcmp(key, "clip-path")) { in _attrParseRectNode()
1863 loader->svgParse->node = _createNode(parent, SvgNodeType::Rect); in _createRectNode()
1865 if (!loader->svgParse->node) return nullptr; in _createRectNode()
1867 loader->svgParse->node->node.rect.hasRx = loader->svgParse->node->node.rect.hasRy = false; in _createRectNode()
1870 return loader->svgParse->node; in _createRectNode()
1894 SvgNode* node = loader->svgParse->node; in _attrParseLineNode()
1895 SvgLineNode* line = &(node->node.line); in _attrParseLineNode()
1901 if (lineTags[i].sz - 1 == sz && !strncmp(lineTags[i].tag, key, sz)) { in _attrParseLineNode()
1902 … *((float*)(array + lineTags[i].offset)) = _toFloat(loader->svgParse, value, lineTags[i].type); in _attrParseLineNode()
1908 if (node->id && value) free(node->id); in _attrParseLineNode()
1909 node->id = _copyId(value); in _attrParseLineNode()
1914 } else if (!strcmp(key, "clip-path")) { in _attrParseLineNode()
1927 loader->svgParse->node = _createNode(parent, SvgNodeType::Line); in _createLineNode()
1929 if (!loader->svgParse->node) return nullptr; in _createLineNode()
1932 return loader->svgParse->node; in _createLineNode()
1964 SvgNode* node = loader->svgParse->node; in _attrParseImageNode()
1965 SvgImageNode* image = &(node->node.image); in _attrParseImageNode()
1971 if (imageTags[i].sz - 1 == sz && !strncmp(imageTags[i].tag, key, sz)) { in _attrParseImageNode()
1972 … *((float*)(array + imageTags[i].offset)) = _toFloat(loader->svgParse, value, imageTags[i].type); in _attrParseImageNode()
1978 if (image->href && value) free(image->href); in _attrParseImageNode()
1979 image->href = _idFromHref(value); in _attrParseImageNode()
1981 if (node->id && value) free(node->id); in _attrParseImageNode()
1982 node->id = _copyId(value); in _attrParseImageNode()
1987 } else if (!strcmp(key, "clip-path")) { in _attrParseImageNode()
1992 node->transform = _parseTransformationMatrix(value); in _attrParseImageNode()
2002 loader->svgParse->node = _createNode(parent, SvgNodeType::Image); in _createImageNode()
2004 if (!loader->svgParse->node) return nullptr; in _createImageNode()
2007 return loader->svgParse->node; in _createImageNode()
2015 while (node->parent != nullptr) { in _getDefsNode()
2016 node = node->parent; in _getDefsNode()
2019 if (node->type == SvgNodeType::Doc) return node->node.doc.defs; in _getDefsNode()
2020 if (node->type == SvgNodeType::Defs) return node; in _getDefsNode()
2031 if (node->id && !strcmp(node->id, id)) return node; in _findNodeById()
2033 if (node->child.count > 0) { in _findNodeById()
2034 auto child = node->child.data; in _findNodeById()
2035 for (uint32_t i = 0; i < node->child.count; ++i, ++child) { in _findNodeById()
2046 SvgNode *parent = node->parent; in _findParentById()
2048 if (parent->id && !strcmp(parent->id, id)) { in _findParentById()
2051 parent = parent->parent; in _findParentById()
2075 SvgNode *defs, *nodeFrom, *node = loader->svgParse->node; in _attrParseUseNode()
2078 SvgUseNode* use = &(node->node.use); in _attrParseUseNode()
2082 if (useTags[i].sz - 1 == sz && !strncmp(useTags[i].tag, key, sz)) { in _attrParseUseNode()
2083 … *((float*)(array + useTags[i].offset)) = _toFloat(loader->svgParse, value, useTags[i].type); in _attrParseUseNode()
2085 if (useTags[i].offset == offsetof(SvgUseNode, w)) use->isWidthSet = true; in _attrParseUseNode()
2086 else if (useTags[i].offset == offsetof(SvgUseNode, h)) use->isHeightSet = true; in _attrParseUseNode()
2097 if (!_findParentById(node, id, loader->doc)) { in _attrParseUseNode()
2099 if (nodeFrom->type == SvgNodeType::Symbol) use->symbol = nodeFrom; in _attrParseUseNode()
2108 _postpone(loader->cloneNodes, node, id); in _attrParseUseNode()
2119 loader->svgParse->node = _createNode(parent, SvgNodeType::Use); in _createUseNode()
2121 if (!loader->svgParse->node) return nullptr; in _createUseNode()
2123 loader->svgParse->node->node.use.isWidthSet = false; in _createUseNode()
2124 loader->svgParse->node->node.use.isHeightSet = false; in _createUseNode()
2127 return loader->svgParse->node; in _createUseNode()
2140 … {"font-size", SvgParserLengthType::Vertical, sizeof("font-size"), offsetof(SvgTextNode, fontSize)}
2147 SvgNode* node = loader->svgParse->node; in _attrParseTextNode()
2148 SvgTextNode* text = &(node->node.text); in _attrParseTextNode()
2155 if (textTags[i].sz - 1 == sz && !strncmp(textTags[i].tag, key, sz)) { in _attrParseTextNode()
2156 … *((float*)(array + textTags[i].offset)) = _toFloat(loader->svgParse, value, textTags[i].type); in _attrParseTextNode()
2161 if (!strcmp(key, "font-family")) { in _attrParseTextNode()
2162 if (text->fontFamily && value) free(text->fontFamily); in _attrParseTextNode()
2163 text->fontFamily = strdup(value); in _attrParseTextNode()
2166 } else if (!strcmp(key, "clip-path")) { in _attrParseTextNode()
2171 if (node->id && value) free(node->id); in _attrParseTextNode()
2172 node->id = _copyId(value); in _attrParseTextNode()
2184 loader->svgParse->node = _createNode(parent, SvgNodeType::Text); in _createTextNode()
2185 if (!loader->svgParse->node) return nullptr; in _createTextNode()
2188 loader->svgParse->node->node.text.fontSize = 10.0f; in _createTextNode()
2189 loader->svgParse->node->node.text.fontFamily = nullptr; in _createTextNode()
2190 loader->svgParse->node->node.text.text = nullptr; in _createTextNode()
2194 return loader->svgParse->node; in _createTextNode()
2241 if (Tags_Array[i].sz - 1 == sz && !strncmp(Tags_Array[i].tag, name, sz)) { \
2268 radial->cx = _gradientToFloat(loader->svgParse, value, radial->isCxPercentage); in _handleRadialCxAttr()
2269 if (!loader->svgParse->gradient.parsedFx) { in _handleRadialCxAttr()
2270 radial->fx = radial->cx; in _handleRadialCxAttr()
2271 radial->isFxPercentage = radial->isCxPercentage; in _handleRadialCxAttr()
2278 radial->cy = _gradientToFloat(loader->svgParse, value, radial->isCyPercentage); in _handleRadialCyAttr()
2279 if (!loader->svgParse->gradient.parsedFy) { in _handleRadialCyAttr()
2280 radial->fy = radial->cy; in _handleRadialCyAttr()
2281 radial->isFyPercentage = radial->isCyPercentage; in _handleRadialCyAttr()
2288 radial->fx = _gradientToFloat(loader->svgParse, value, radial->isFxPercentage); in _handleRadialFxAttr()
2289 loader->svgParse->gradient.parsedFx = true; in _handleRadialFxAttr()
2295 radial->fy = _gradientToFloat(loader->svgParse, value, radial->isFyPercentage); in _handleRadialFyAttr()
2296 loader->svgParse->gradient.parsedFy = true; in _handleRadialFyAttr()
2302 radial->fr = _gradientToFloat(loader->svgParse, value, radial->isFrPercentage); in _handleRadialFrAttr()
2308 radial->r = _gradientToFloat(loader->svgParse, value, radial->isRPercentage); in _handleRadialRAttr()
2314 if (userSpace && !radial->isCxPercentage) radial->cx = radial->cx / loader->svgParse->global.w; in _recalcRadialCxAttr()
2320 if (userSpace && !radial->isCyPercentage) radial->cy = radial->cy / loader->svgParse->global.h; in _recalcRadialCyAttr()
2326 if (userSpace && !radial->isFxPercentage) radial->fx = radial->fx / loader->svgParse->global.w; in _recalcRadialFxAttr()
2332 if (userSpace && !radial->isFyPercentage) radial->fy = radial->fy / loader->svgParse->global.h; in _recalcRadialFyAttr()
2338 …// scaling factor based on the Units paragraph from : https://www.w3.org/TR/2015/WD-SVG2-20150915/… in _recalcRadialFrAttr()
2339 …(userSpace && !radial->isFrPercentage) radial->fr = radial->fr / (sqrtf(powf(loader->svgParse->glo… in _recalcRadialFrAttr()
2345 …// scaling factor based on the Units paragraph from : https://www.w3.org/TR/2015/WD-SVG2-20150915/… in _recalcRadialRAttr()
2346 … (userSpace && !radial->isRPercentage) radial->r = radial->r / (sqrtf(powf(loader->svgParse->globa… in _recalcRadialRAttr()
2352 if (!radial->isCxPercentage) { in _recalcInheritedRadialCxAttr()
2353 if (userSpace) radial->cx /= loader->svgParse->global.w; in _recalcInheritedRadialCxAttr()
2354 else radial->cx *= loader->svgParse->global.w; in _recalcInheritedRadialCxAttr()
2361 if (!radial->isCyPercentage) { in _recalcInheritedRadialCyAttr()
2362 if (userSpace) radial->cy /= loader->svgParse->global.h; in _recalcInheritedRadialCyAttr()
2363 else radial->cy *= loader->svgParse->global.h; in _recalcInheritedRadialCyAttr()
2370 if (!radial->isFxPercentage) { in _recalcInheritedRadialFxAttr()
2371 if (userSpace) radial->fx /= loader->svgParse->global.w; in _recalcInheritedRadialFxAttr()
2372 else radial->fx *= loader->svgParse->global.w; in _recalcInheritedRadialFxAttr()
2379 if (!radial->isFyPercentage) { in _recalcInheritedRadialFyAttr()
2380 if (userSpace) radial->fy /= loader->svgParse->global.h; in _recalcInheritedRadialFyAttr()
2381 else radial->fy *= loader->svgParse->global.h; in _recalcInheritedRadialFyAttr()
2388 if (!radial->isFrPercentage) { in _recalcInheritedRadialFrAttr()
2389 …if (userSpace) radial->fr /= sqrtf(powf(loader->svgParse->global.h, 2) + powf(loader->svgParse->gl… in _recalcInheritedRadialFrAttr()
2390 …else radial->fr *= sqrtf(powf(loader->svgParse->global.h, 2) + powf(loader->svgParse->global.w, 2)… in _recalcInheritedRadialFrAttr()
2397 if (!radial->isRPercentage) { in _recalcInheritedRadialRAttr()
2398 …if (userSpace) radial->r /= sqrtf(powf(loader->svgParse->global.h, 2) + powf(loader->svgParse->glo… in _recalcInheritedRadialRAttr()
2399 …else radial->r *= sqrtf(powf(loader->svgParse->global.h, 2) + powf(loader->svgParse->global.w, 2))… in _recalcInheritedRadialRAttr()
2406 to->radial->cx = from->radial->cx; in _inheritRadialCxAttr()
2407 to->radial->isCxPercentage = from->radial->isCxPercentage; in _inheritRadialCxAttr()
2408 to->flags = (to->flags | SvgGradientFlags::Cx); in _inheritRadialCxAttr()
2414 to->radial->cy = from->radial->cy; in _inheritRadialCyAttr()
2415 to->radial->isCyPercentage = from->radial->isCyPercentage; in _inheritRadialCyAttr()
2416 to->flags = (to->flags | SvgGradientFlags::Cy); in _inheritRadialCyAttr()
2422 to->radial->fx = from->radial->fx; in _inheritRadialFxAttr()
2423 to->radial->isFxPercentage = from->radial->isFxPercentage; in _inheritRadialFxAttr()
2424 to->flags = (to->flags | SvgGradientFlags::Fx); in _inheritRadialFxAttr()
2430 to->radial->fy = from->radial->fy; in _inheritRadialFyAttr()
2431 to->radial->isFyPercentage = from->radial->isFyPercentage; in _inheritRadialFyAttr()
2432 to->flags = (to->flags | SvgGradientFlags::Fy); in _inheritRadialFyAttr()
2438 to->radial->fr = from->radial->fr; in _inheritRadialFrAttr()
2439 to->radial->isFrPercentage = from->radial->isFrPercentage; in _inheritRadialFrAttr()
2440 to->flags = (to->flags | SvgGradientFlags::Fr); in _inheritRadialFrAttr()
2446 to->radial->r = from->radial->r; in _inheritRadialRAttr()
2447 to->radial->isRPercentage = from->radial->isRPercentage; in _inheritRadialRAttr()
2448 to->flags = (to->flags | SvgGradientFlags::R); in _inheritRadialRAttr()
2477 RADIAL_DEF(r, R, SvgGradientFlags::R),
2485 SvgStyleGradient* grad = loader->svgParse->styleGrad; in _attrParseRadialGradientNode()
2486 SvgRadialGradient* radial = grad->radial; in _attrParseRadialGradientNode()
2490 if (radialTags[i].sz - 1 == sz && !strncmp(radialTags[i].tag, key, sz)) { in _attrParseRadialGradientNode()
2492 grad->flags = (grad->flags | radialTags[i].flag); in _attrParseRadialGradientNode()
2498 if (grad->id && value) free(grad->id); in _attrParseRadialGradientNode()
2499 grad->id = _copyId(value); in _attrParseRadialGradientNode()
2501 grad->spread = _parseSpreadValue(value); in _attrParseRadialGradientNode()
2502 grad->flags = (grad->flags | SvgGradientFlags::SpreadMethod); in _attrParseRadialGradientNode()
2504 if (grad->ref && value) free(grad->ref); in _attrParseRadialGradientNode()
2505 grad->ref = _idFromHref(value); in _attrParseRadialGradientNode()
2507 if (!strcmp(value, "userSpaceOnUse")) grad->userSpace = true; in _attrParseRadialGradientNode()
2508 grad->flags = (grad->flags | SvgGradientFlags::GradientUnits); in _attrParseRadialGradientNode()
2510 grad->transform = _parseTransformationMatrix(value); in _attrParseRadialGradientNode()
2522 loader->svgParse->styleGrad = grad; in _createRadialGradient()
2524 grad->flags = SvgGradientFlags::None; in _createRadialGradient()
2525 grad->type = SvgGradientType::Radial; in _createRadialGradient()
2526 grad->userSpace = false; in _createRadialGradient()
2527 grad->radial = (SvgRadialGradient*)calloc(1, sizeof(SvgRadialGradient)); in _createRadialGradient()
2528 if (!grad->radial) { in _createRadialGradient()
2529 grad->clear(); in _createRadialGradient()
2536 grad->radial->cx = 0.5f; in _createRadialGradient()
2537 grad->radial->cy = 0.5f; in _createRadialGradient()
2538 grad->radial->fx = 0.5f; in _createRadialGradient()
2539 grad->radial->fy = 0.5f; in _createRadialGradient()
2540 grad->radial->r = 0.5f; in _createRadialGradient()
2541 grad->radial->isCxPercentage = true; in _createRadialGradient()
2542 grad->radial->isCyPercentage = true; in _createRadialGradient()
2543 grad->radial->isFxPercentage = true; in _createRadialGradient()
2544 grad->radial->isFyPercentage = true; in _createRadialGradient()
2545 grad->radial->isRPercentage = true; in _createRadialGradient()
2546 grad->radial->isFrPercentage = true; in _createRadialGradient()
2548 loader->svgParse->gradient.parsedFx = false; in _createRadialGradient()
2549 loader->svgParse->gradient.parsedFy = false; in _createRadialGradient()
2554 radialTags[i].tagRecalc(loader, grad->radial, grad->userSpace); in _createRadialGradient()
2557 return loader->svgParse->styleGrad; in _createRadialGradient()
2564 auto stop = &loader->svgParse->gradStop; in _attrParseStopsStyle()
2566 if (!strcmp(key, "stop-opacity")) { in _attrParseStopsStyle()
2567 stop->a = _toOpacity(value); in _attrParseStopsStyle()
2568 loader->svgParse->flags = (loader->svgParse->flags | SvgStopStyleFlags::StopOpacity); in _attrParseStopsStyle()
2569 } else if (!strcmp(key, "stop-color")) { in _attrParseStopsStyle()
2570 if (_toColor(value, &stop->r, &stop->g, &stop->b, nullptr)) { in _attrParseStopsStyle()
2571 loader->svgParse->flags = (loader->svgParse->flags | SvgStopStyleFlags::StopColor); in _attrParseStopsStyle()
2584 auto stop = &loader->svgParse->gradStop; in _attrParseStops()
2587 stop->offset = _toOffset(value); in _attrParseStops()
2588 } else if (!strcmp(key, "stop-opacity")) { in _attrParseStops()
2589 if (!(loader->svgParse->flags & SvgStopStyleFlags::StopOpacity)) { in _attrParseStops()
2590 stop->a = _toOpacity(value); in _attrParseStops()
2592 } else if (!strcmp(key, "stop-color")) { in _attrParseStops()
2593 if (!(loader->svgParse->flags & SvgStopStyleFlags::StopColor)) { in _attrParseStops()
2594 _toColor(value, &stop->r, &stop->g, &stop->b, nullptr); in _attrParseStops()
2608 linear->x1 = _gradientToFloat(loader->svgParse, value, linear->isX1Percentage); in _handleLinearX1Attr()
2614 linear->y1 = _gradientToFloat(loader->svgParse, value, linear->isY1Percentage); in _handleLinearY1Attr()
2620 linear->x2 = _gradientToFloat(loader->svgParse, value, linear->isX2Percentage); in _handleLinearX2Attr()
2626 linear->y2 = _gradientToFloat(loader->svgParse, value, linear->isY2Percentage); in _handleLinearY2Attr()
2632 if (userSpace && !linear->isX1Percentage) linear->x1 = linear->x1 / loader->svgParse->global.w; in _recalcLinearX1Attr()
2638 if (userSpace && !linear->isY1Percentage) linear->y1 = linear->y1 / loader->svgParse->global.h; in _recalcLinearY1Attr()
2644 if (userSpace && !linear->isX2Percentage) linear->x2 = linear->x2 / loader->svgParse->global.w; in _recalcLinearX2Attr()
2650 if (userSpace && !linear->isY2Percentage) linear->y2 = linear->y2 / loader->svgParse->global.h; in _recalcLinearY2Attr()
2656 if (!linear->isX1Percentage) { in _recalcInheritedLinearX1Attr()
2657 if (userSpace) linear->x1 /= loader->svgParse->global.w; in _recalcInheritedLinearX1Attr()
2658 else linear->x1 *= loader->svgParse->global.w; in _recalcInheritedLinearX1Attr()
2665 if (!linear->isX2Percentage) { in _recalcInheritedLinearX2Attr()
2666 if (userSpace) linear->x2 /= loader->svgParse->global.w; in _recalcInheritedLinearX2Attr()
2667 else linear->x2 *= loader->svgParse->global.w; in _recalcInheritedLinearX2Attr()
2674 if (!linear->isY1Percentage) { in _recalcInheritedLinearY1Attr()
2675 if (userSpace) linear->y1 /= loader->svgParse->global.h; in _recalcInheritedLinearY1Attr()
2676 else linear->y1 *= loader->svgParse->global.h; in _recalcInheritedLinearY1Attr()
2683 if (!linear->isY2Percentage) { in _recalcInheritedLinearY2Attr()
2684 if (userSpace) linear->y2 /= loader->svgParse->global.h; in _recalcInheritedLinearY2Attr()
2685 else linear->y2 *= loader->svgParse->global.h; in _recalcInheritedLinearY2Attr()
2692 to->linear->x1 = from->linear->x1; in _inheritLinearX1Attr()
2693 to->linear->isX1Percentage = from->linear->isX1Percentage; in _inheritLinearX1Attr()
2694 to->flags = (to->flags | SvgGradientFlags::X1); in _inheritLinearX1Attr()
2700 to->linear->x2 = from->linear->x2; in _inheritLinearX2Attr()
2701 to->linear->isX2Percentage = from->linear->isX2Percentage; in _inheritLinearX2Attr()
2702 to->flags = (to->flags | SvgGradientFlags::X2); in _inheritLinearX2Attr()
2708 to->linear->y1 = from->linear->y1; in _inheritLinearY1Attr()
2709 to->linear->isY1Percentage = from->linear->isY1Percentage; in _inheritLinearY1Attr()
2710 to->flags = (to->flags | SvgGradientFlags::Y1); in _inheritLinearY1Attr()
2716 to->linear->y2 = from->linear->y2; in _inheritLinearY2Attr()
2717 to->linear->isY2Percentage = from->linear->isY2Percentage; in _inheritLinearY2Attr()
2718 to->flags = (to->flags | SvgGradientFlags::Y2); in _inheritLinearY2Attr()
2753 SvgStyleGradient* grad = loader->svgParse->styleGrad; in _attrParseLinearGradientNode()
2754 SvgLinearGradient* linear = grad->linear; in _attrParseLinearGradientNode()
2758 if (linear_tags[i].sz - 1 == sz && !strncmp(linear_tags[i].tag, key, sz)) { in _attrParseLinearGradientNode()
2760 grad->flags = (grad->flags | linear_tags[i].flag); in _attrParseLinearGradientNode()
2766 if (grad->id && value) free(grad->id); in _attrParseLinearGradientNode()
2767 grad->id = _copyId(value); in _attrParseLinearGradientNode()
2769 grad->spread = _parseSpreadValue(value); in _attrParseLinearGradientNode()
2770 grad->flags = (grad->flags | SvgGradientFlags::SpreadMethod); in _attrParseLinearGradientNode()
2772 if (grad->ref && value) free(grad->ref); in _attrParseLinearGradientNode()
2773 grad->ref = _idFromHref(value); in _attrParseLinearGradientNode()
2775 if (!strcmp(value, "userSpaceOnUse")) grad->userSpace = true; in _attrParseLinearGradientNode()
2776 grad->flags = (grad->flags | SvgGradientFlags::GradientUnits); in _attrParseLinearGradientNode()
2778 grad->transform = _parseTransformationMatrix(value); in _attrParseLinearGradientNode()
2790 loader->svgParse->styleGrad = grad; in _createLinearGradient()
2792 grad->flags = SvgGradientFlags::None; in _createLinearGradient()
2793 grad->type = SvgGradientType::Linear; in _createLinearGradient()
2794 grad->userSpace = false; in _createLinearGradient()
2795 grad->linear = (SvgLinearGradient*)calloc(1, sizeof(SvgLinearGradient)); in _createLinearGradient()
2796 if (!grad->linear) { in _createLinearGradient()
2797 grad->clear(); in _createLinearGradient()
2802 * Default value of x2 is 100% - transformed to the global percentage in _createLinearGradient()
2804 grad->linear->x2 = 1.0f; in _createLinearGradient()
2805 grad->linear->isX2Percentage = true; in _createLinearGradient()
2810 linear_tags[i].tagRecalc(loader, grad->linear, grad->userSpace); in _createLinearGradient()
2813 return loader->svgParse->styleGrad; in _createLinearGradient()
2844 if (gradientTags[i].sz - 1 == sz && !strncmp(gradientTags[i].tag, name, sz)) { in _findGradientFactory()
2864 …if (!(to->flags & SvgGradientFlags::SpreadMethod) && (from->flags & SvgGradientFlags::SpreadMethod… in _inheritGradient()
2865 to->spread = from->spread; in _inheritGradient()
2866 to->flags = (to->flags | SvgGradientFlags::SpreadMethod); in _inheritGradient()
2868 bool gradUnitSet = (to->flags & SvgGradientFlags::GradientUnits); in _inheritGradient()
2869 …if (!(to->flags & SvgGradientFlags::GradientUnits) && (from->flags & SvgGradientFlags::GradientUni… in _inheritGradient()
2870 to->userSpace = from->userSpace; in _inheritGradient()
2871 to->flags = (to->flags | SvgGradientFlags::GradientUnits); in _inheritGradient()
2874 if (!to->transform && from->transform) { in _inheritGradient()
2875 to->transform = (Matrix*)malloc(sizeof(Matrix)); in _inheritGradient()
2876 if (to->transform) memcpy(to->transform, from->transform, sizeof(Matrix)); in _inheritGradient()
2879 if (to->type == SvgGradientType::Linear) { in _inheritGradient()
2881 bool coordSet = to->flags & linear_tags[i].flag; in _inheritGradient()
2882 if (!(to->flags & linear_tags[i].flag) && (from->flags & linear_tags[i].flag)) { in _inheritGradient()
2888 linear_tags[i].tagRecalc(loader, to->linear, to->userSpace); in _inheritGradient()
2891 if (to->userSpace == from->userSpace) continue; in _inheritGradient()
2893 linear_tags[i].tagInheritedRecalc(loader, to->linear, to->userSpace); in _inheritGradient()
2896 } else if (to->type == SvgGradientType::Radial) { in _inheritGradient()
2898 bool coordSet = (to->flags & radialTags[i].flag); in _inheritGradient()
2899 if (!(to->flags & radialTags[i].flag) && (from->flags & radialTags[i].flag)) { in _inheritGradient()
2905 radialTags[i].tagRecalc(loader, to->radial, to->userSpace); in _inheritGradient()
2907 …if (!strcmp(radialTags[i].tag, "cx") && !(to->flags & SvgGradientFlags::Fx)) to->radial->fx = to->… in _inheritGradient()
2908 …if (!strcmp(radialTags[i].tag, "cy") && !(to->flags & SvgGradientFlags::Fy)) to->radial->fy = to->… in _inheritGradient()
2911 if (to->userSpace == from->userSpace) continue; in _inheritGradient()
2914 … if (!strcmp(radialTags[i].tag, "fx") && !(to->flags & SvgGradientFlags::Fx)) continue; in _inheritGradient()
2915 … if (!strcmp(radialTags[i].tag, "fy") && !(to->flags & SvgGradientFlags::Fy)) continue; in _inheritGradient()
2916 radialTags[i].tagInheritedRecalc(loader, to->radial, to->userSpace); in _inheritGradient()
2921 if (to->stops.empty()) _cloneGradStops(to->stops, from->stops); in _inheritGradient()
2932 grad->type = from->type; in _cloneGradient()
2933 grad->id = from->id ? _copyId(from->id) : nullptr; in _cloneGradient()
2934 grad->ref = from->ref ? _copyId(from->ref) : nullptr; in _cloneGradient()
2935 grad->spread = from->spread; in _cloneGradient()
2936 grad->userSpace = from->userSpace; in _cloneGradient()
2937 grad->flags = from->flags; in _cloneGradient()
2939 if (from->transform) { in _cloneGradient()
2940 grad->transform = (Matrix*)calloc(1, sizeof(Matrix)); in _cloneGradient()
2941 if (grad->transform) memcpy(grad->transform, from->transform, sizeof(Matrix)); in _cloneGradient()
2944 if (grad->type == SvgGradientType::Linear) { in _cloneGradient()
2945 grad->linear = (SvgLinearGradient*)calloc(1, sizeof(SvgLinearGradient)); in _cloneGradient()
2946 if (!grad->linear) goto error_grad_alloc; in _cloneGradient()
2947 memcpy(grad->linear, from->linear, sizeof(SvgLinearGradient)); in _cloneGradient()
2948 } else if (grad->type == SvgGradientType::Radial) { in _cloneGradient()
2949 grad->radial = (SvgRadialGradient*)calloc(1, sizeof(SvgRadialGradient)); in _cloneGradient()
2950 if (!grad->radial) goto error_grad_alloc; in _cloneGradient()
2951 memcpy(grad->radial, from->radial, sizeof(SvgRadialGradient)); in _cloneGradient()
2954 _cloneGradStops(grad->stops, from->stops); in _cloneGradient()
2960 grad->clear(); in _cloneGradient()
2971 if (!child->curColorSet) { in _styleInherit()
2972 child->color = parent->color; in _styleInherit()
2973 child->curColorSet = parent->curColorSet; in _styleInherit()
2975 if (!(child->flags & SvgStyleFlags::PaintOrder)) { in _styleInherit()
2976 child->paintOrder = parent->paintOrder; in _styleInherit()
2979 if (!(child->fill.flags & SvgFillFlags::Paint)) { in _styleInherit()
2980 child->fill.paint.color = parent->fill.paint.color; in _styleInherit()
2981 child->fill.paint.none = parent->fill.paint.none; in _styleInherit()
2982 child->fill.paint.curColor = parent->fill.paint.curColor; in _styleInherit()
2983 if (parent->fill.paint.url) { in _styleInherit()
2984 if (child->fill.paint.url) free(child->fill.paint.url); in _styleInherit()
2985 child->fill.paint.url = _copyId(parent->fill.paint.url); in _styleInherit()
2988 if (!(child->fill.flags & SvgFillFlags::Opacity)) { in _styleInherit()
2989 child->fill.opacity = parent->fill.opacity; in _styleInherit()
2991 if (!(child->fill.flags & SvgFillFlags::FillRule)) { in _styleInherit()
2992 child->fill.fillRule = parent->fill.fillRule; in _styleInherit()
2995 if (!(child->stroke.flags & SvgStrokeFlags::Paint)) { in _styleInherit()
2996 child->stroke.paint.color = parent->stroke.paint.color; in _styleInherit()
2997 child->stroke.paint.none = parent->stroke.paint.none; in _styleInherit()
2998 child->stroke.paint.curColor = parent->stroke.paint.curColor; in _styleInherit()
2999 if (parent->stroke.paint.url) { in _styleInherit()
3000 if (child->stroke.paint.url) free(child->stroke.paint.url); in _styleInherit()
3001 child->stroke.paint.url = _copyId(parent->stroke.paint.url); in _styleInherit()
3004 if (!(child->stroke.flags & SvgStrokeFlags::Opacity)) { in _styleInherit()
3005 child->stroke.opacity = parent->stroke.opacity; in _styleInherit()
3007 if (!(child->stroke.flags & SvgStrokeFlags::Width)) { in _styleInherit()
3008 child->stroke.width = parent->stroke.width; in _styleInherit()
3010 if (!(child->stroke.flags & SvgStrokeFlags::Dash)) { in _styleInherit()
3011 if (parent->stroke.dash.array.count > 0) { in _styleInherit()
3012 child->stroke.dash.array.clear(); in _styleInherit()
3013 child->stroke.dash.array.reserve(parent->stroke.dash.array.count); in _styleInherit()
3014 for (uint32_t i = 0; i < parent->stroke.dash.array.count; ++i) { in _styleInherit()
3015 child->stroke.dash.array.push(parent->stroke.dash.array[i]); in _styleInherit()
3019 if (!(child->stroke.flags & SvgStrokeFlags::DashOffset)) { in _styleInherit()
3020 child->stroke.dash.offset = parent->stroke.dash.offset; in _styleInherit()
3022 if (!(child->stroke.flags & SvgStrokeFlags::Cap)) { in _styleInherit()
3023 child->stroke.cap = parent->stroke.cap; in _styleInherit()
3025 if (!(child->stroke.flags & SvgStrokeFlags::Join)) { in _styleInherit()
3026 child->stroke.join = parent->stroke.join; in _styleInherit()
3028 if (!(child->stroke.flags & SvgStrokeFlags::Miterlimit)) { in _styleInherit()
3029 child->stroke.miterlimit = parent->stroke.miterlimit; in _styleInherit()
3038 if (from->curColorSet) { in _styleCopy()
3039 to->color = from->color; in _styleCopy()
3040 to->curColorSet = true; in _styleCopy()
3042 if (from->flags & SvgStyleFlags::Opacity) { in _styleCopy()
3043 to->opacity = from->opacity; in _styleCopy()
3045 if (from->flags & SvgStyleFlags::PaintOrder) { in _styleCopy()
3046 to->paintOrder = from->paintOrder; in _styleCopy()
3048 if (from->flags & SvgStyleFlags::Display) { in _styleCopy()
3049 to->display = from->display; in _styleCopy()
3052 to->fill.flags = (to->fill.flags | from->fill.flags); in _styleCopy()
3053 if (from->fill.flags & SvgFillFlags::Paint) { in _styleCopy()
3054 to->fill.paint.color = from->fill.paint.color; in _styleCopy()
3055 to->fill.paint.none = from->fill.paint.none; in _styleCopy()
3056 to->fill.paint.curColor = from->fill.paint.curColor; in _styleCopy()
3057 if (from->fill.paint.url) { in _styleCopy()
3058 if (to->fill.paint.url) free(to->fill.paint.url); in _styleCopy()
3059 to->fill.paint.url = _copyId(from->fill.paint.url); in _styleCopy()
3062 if (from->fill.flags & SvgFillFlags::Opacity) { in _styleCopy()
3063 to->fill.opacity = from->fill.opacity; in _styleCopy()
3065 if (from->fill.flags & SvgFillFlags::FillRule) { in _styleCopy()
3066 to->fill.fillRule = from->fill.fillRule; in _styleCopy()
3069 to->stroke.flags = (to->stroke.flags | from->stroke.flags); in _styleCopy()
3070 if (from->stroke.flags & SvgStrokeFlags::Paint) { in _styleCopy()
3071 to->stroke.paint.color = from->stroke.paint.color; in _styleCopy()
3072 to->stroke.paint.none = from->stroke.paint.none; in _styleCopy()
3073 to->stroke.paint.curColor = from->stroke.paint.curColor; in _styleCopy()
3074 if (from->stroke.paint.url) { in _styleCopy()
3075 if (to->stroke.paint.url) free(to->stroke.paint.url); in _styleCopy()
3076 to->stroke.paint.url = _copyId(from->stroke.paint.url); in _styleCopy()
3079 if (from->stroke.flags & SvgStrokeFlags::Opacity) { in _styleCopy()
3080 to->stroke.opacity = from->stroke.opacity; in _styleCopy()
3082 if (from->stroke.flags & SvgStrokeFlags::Width) { in _styleCopy()
3083 to->stroke.width = from->stroke.width; in _styleCopy()
3085 if (from->stroke.flags & SvgStrokeFlags::Dash) { in _styleCopy()
3086 if (from->stroke.dash.array.count > 0) { in _styleCopy()
3087 to->stroke.dash.array.clear(); in _styleCopy()
3088 to->stroke.dash.array.reserve(from->stroke.dash.array.count); in _styleCopy()
3089 for (uint32_t i = 0; i < from->stroke.dash.array.count; ++i) { in _styleCopy()
3090 to->stroke.dash.array.push(from->stroke.dash.array[i]); in _styleCopy()
3094 if (from->stroke.flags & SvgStrokeFlags::DashOffset) { in _styleCopy()
3095 to->stroke.dash.offset = from->stroke.dash.offset; in _styleCopy()
3097 if (from->stroke.flags & SvgStrokeFlags::Cap) { in _styleCopy()
3098 to->stroke.cap = from->stroke.cap; in _styleCopy()
3100 if (from->stroke.flags & SvgStrokeFlags::Join) { in _styleCopy()
3101 to->stroke.join = from->stroke.join; in _styleCopy()
3103 if (from->stroke.flags & SvgStrokeFlags::Miterlimit) { in _styleCopy()
3104 to->stroke.miterlimit = from->stroke.miterlimit; in _styleCopy()
3112 if (from->transform) { in _copyAttr()
3113 to->transform = (Matrix*)malloc(sizeof(Matrix)); in _copyAttr()
3114 if (to->transform) *to->transform = *from->transform; in _copyAttr()
3117 _styleCopy(to->style, from->style); in _copyAttr()
3118 to->style->flags = (to->style->flags | from->style->flags); in _copyAttr()
3119 if (from->style->clipPath.url) { in _copyAttr()
3120 if (to->style->clipPath.url) free(to->style->clipPath.url); in _copyAttr()
3121 to->style->clipPath.url = strdup(from->style->clipPath.url); in _copyAttr()
3123 if (from->style->mask.url) { in _copyAttr()
3124 if (to->style->mask.url) free(to->style->mask.url); in _copyAttr()
3125 to->style->mask.url = strdup(from->style->mask.url); in _copyAttr()
3129 switch (from->type) { in _copyAttr()
3131 to->node.circle.cx = from->node.circle.cx; in _copyAttr()
3132 to->node.circle.cy = from->node.circle.cy; in _copyAttr()
3133 to->node.circle.r = from->node.circle.r; in _copyAttr()
3137 to->node.ellipse.cx = from->node.ellipse.cx; in _copyAttr()
3138 to->node.ellipse.cy = from->node.ellipse.cy; in _copyAttr()
3139 to->node.ellipse.rx = from->node.ellipse.rx; in _copyAttr()
3140 to->node.ellipse.ry = from->node.ellipse.ry; in _copyAttr()
3144 to->node.rect.x = from->node.rect.x; in _copyAttr()
3145 to->node.rect.y = from->node.rect.y; in _copyAttr()
3146 to->node.rect.w = from->node.rect.w; in _copyAttr()
3147 to->node.rect.h = from->node.rect.h; in _copyAttr()
3148 to->node.rect.rx = from->node.rect.rx; in _copyAttr()
3149 to->node.rect.ry = from->node.rect.ry; in _copyAttr()
3150 to->node.rect.hasRx = from->node.rect.hasRx; in _copyAttr()
3151 to->node.rect.hasRy = from->node.rect.hasRy; in _copyAttr()
3155 to->node.line.x1 = from->node.line.x1; in _copyAttr()
3156 to->node.line.y1 = from->node.line.y1; in _copyAttr()
3157 to->node.line.x2 = from->node.line.x2; in _copyAttr()
3158 to->node.line.y2 = from->node.line.y2; in _copyAttr()
3162 if (from->node.path.path) { in _copyAttr()
3163 if (to->node.path.path) free(to->node.path.path); in _copyAttr()
3164 to->node.path.path = strdup(from->node.path.path); in _copyAttr()
3169 if ((to->node.polygon.pts.count = from->node.polygon.pts.count)) { in _copyAttr()
3170 to->node.polygon.pts = from->node.polygon.pts; in _copyAttr()
3175 if ((to->node.polyline.pts.count = from->node.polyline.pts.count)) { in _copyAttr()
3176 to->node.polyline.pts = from->node.polyline.pts; in _copyAttr()
3181 to->node.image.x = from->node.image.x; in _copyAttr()
3182 to->node.image.y = from->node.image.y; in _copyAttr()
3183 to->node.image.w = from->node.image.w; in _copyAttr()
3184 to->node.image.h = from->node.image.h; in _copyAttr()
3185 if (from->node.image.href) { in _copyAttr()
3186 if (to->node.image.href) free(to->node.image.href); in _copyAttr()
3187 to->node.image.href = strdup(from->node.image.href); in _copyAttr()
3192 to->node.use.x = from->node.use.x; in _copyAttr()
3193 to->node.use.y = from->node.use.y; in _copyAttr()
3194 to->node.use.w = from->node.use.w; in _copyAttr()
3195 to->node.use.h = from->node.use.h; in _copyAttr()
3196 to->node.use.isWidthSet = from->node.use.isWidthSet; in _copyAttr()
3197 to->node.use.isHeightSet = from->node.use.isHeightSet; in _copyAttr()
3198 to->node.use.symbol = from->node.use.symbol; in _copyAttr()
3202 to->node.text.x = from->node.text.x; in _copyAttr()
3203 to->node.text.y = from->node.text.y; in _copyAttr()
3204 to->node.text.fontSize = from->node.text.fontSize; in _copyAttr()
3205 if (from->node.text.text) { in _copyAttr()
3206 if (to->node.text.text) free(to->node.text.text); in _copyAttr()
3207 to->node.text.text = strdup(from->node.text.text); in _copyAttr()
3209 if (from->node.text.fontFamily) { in _copyAttr()
3210 if (to->node.text.fontFamily) free(to->node.text.fontFamily); in _copyAttr()
3211 to->node.text.fontFamily = strdup(from->node.text.fontFamily); in _copyAttr()
3227 …TVGERR("SVG", "Infinite recursive call - stopped after %d calls! Svg file may be incorrectly forma… in _cloneNode()
3234 newNode = _createNode(parent, from->type); in _cloneNode()
3237 _styleInherit(newNode->style, parent->style); in _cloneNode()
3240 auto child = from->child.data; in _cloneNode()
3241 for (uint32_t i = 0; i < from->child.count; ++i, ++child) { in _cloneNode()
3249 for (uint32_t i = 0; i < cloneNodes->count; ++i) { in _clonePostponedNodes()
3256 …if (nodeFrom && nodeFrom->type == SvgNodeType::Symbol && nodeIdPair.node->type == SvgNodeType::Use… in _clonePostponedNodes()
3257 nodeIdPair.node->node.use.symbol = nodeFrom; in _clonePostponedNodes()
3278 sz = itr - content; in _svgLoaderParserXmlClose()
3279 while ((sz > 0) && (isspace(content[sz - 1]))) sz--; in _svgLoaderParserXmlClose()
3280 if ((unsigned int)sz >= sizeof(tagName)) sz = sizeof(tagName) - 1; in _svgLoaderParserXmlClose()
3288 loader->stack.pop(); in _svgLoaderParserXmlClose()
3295 loader->currentGraphicsNode = nullptr; in _svgLoaderParserXmlClose()
3296 if (!strncmp(tagName, "text", 4)) loader->openedTag = OpenedTagType::Other; in _svgLoaderParserXmlClose()
3297 loader->stack.pop(); in _svgLoaderParserXmlClose()
3302 loader->level--; in _svgLoaderParserXmlClose()
3315 loader->level++; in _svgLoaderParserXmlOpen()
3322 if (empty) attrs--; in _svgLoaderParserXmlOpen()
3327 sz = attrs - content; in _svgLoaderParserXmlOpen()
3328 while ((sz > 0) && (isspace(content[sz - 1]))) sz--; in _svgLoaderParserXmlOpen()
3332 attrsLength = length - sz; in _svgLoaderParserXmlOpen()
3338 if (!loader->doc) { in _svgLoaderParserXmlOpen()
3341 loader->doc = node; in _svgLoaderParserXmlOpen()
3344 if (loader->stack.count > 0) parent = loader->stack.last(); in _svgLoaderParserXmlOpen()
3345 else parent = loader->doc; in _svgLoaderParserXmlOpen()
3349 if (!loader->cssStyle) { in _svgLoaderParserXmlOpen()
3351 loader->cssStyle = node; in _svgLoaderParserXmlOpen()
3352 loader->doc->node.doc.style = node; in _svgLoaderParserXmlOpen()
3353 loader->openedTag = OpenedTagType::Style; in _svgLoaderParserXmlOpen()
3361 if (node->type != SvgNodeType::Defs || !empty) { in _svgLoaderParserXmlOpen()
3362 loader->stack.push(node); in _svgLoaderParserXmlOpen()
3365 if (loader->stack.count > 0) parent = loader->stack.last(); in _svgLoaderParserXmlOpen()
3366 else parent = loader->doc; in _svgLoaderParserXmlOpen()
3369 if (!strcmp(tagName, "text")) loader->openedTag = OpenedTagType::Text; in _svgLoaderParserXmlOpen()
3371 loader->stack.push(defs); in _svgLoaderParserXmlOpen()
3372 loader->currentGraphicsNode = node; in _svgLoaderParserXmlOpen()
3382 // refer to: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/defs in _svgLoaderParserXmlOpen()
3383 if (loader->def && loader->doc->node.doc.defs) { in _svgLoaderParserXmlOpen()
3384 loader->def->node.defs.gradients.push(gradient); in _svgLoaderParserXmlOpen()
3386 loader->gradients.push(gradient); in _svgLoaderParserXmlOpen()
3388 loader->latestGradient = gradient; in _svgLoaderParserXmlOpen()
3390 if (!loader->latestGradient) { in _svgLoaderParserXmlOpen()
3395 loader->svgParse->gradStop = {0.0f, 0, 0, 0, 255}; in _svgLoaderParserXmlOpen()
3396 loader->svgParse->flags = SvgStopStyleFlags::StopDefault; in _svgLoaderParserXmlOpen()
3398 loader->latestGradient->stops.push(loader->svgParse->gradStop); in _svgLoaderParserXmlOpen()
3407 auto text = &loader->svgParse->node->node.text; in _svgLoaderParserText()
3408 text->text = strAppend(text->text, content, length); in _svgLoaderParserText()
3425 …if ((node = method(loader, loader->cssStyle, attrs, attrsLength, simpleXmlParseW3CAttribute))) nod… in _svgLoaderParserXmlCssStyle()
3427 …if ((node = method(loader, loader->cssStyle, attrs, attrsLength, simpleXmlParseW3CAttribute))) nod… in _svgLoaderParserXmlCssStyle()
3433 …((node = _createCssStyleNode(loader, loader->cssStyle, attrs, attrsLength, simpleXmlParseW3CAttrib… in _svgLoaderParserXmlCssStyle()
3438 length -= next - content; in _svgLoaderParserXmlCssStyle()
3444 loader->openedTag = OpenedTagType::Other; in _svgLoaderParserXmlCssStyle()
3467 …if (loader->openedTag == OpenedTagType::Style) _svgLoaderParserXmlCssStyle(loader, content, length… in _svgLoaderParser()
3468 … else if (loader->openedTag == OpenedTagType::Text) _svgLoaderParserText(loader, content, length); in _svgLoaderParser()
3491 auto type = simpleXmlNodeTypeToString(node->type); in _inefficientNodeCheck()
3493 …if (!node->style->display && node->type != SvgNodeType::ClipPath) TVGLOG("SVG", "Inefficient eleme… in _inefficientNodeCheck()
3494 …if (node->style->opacity == 0) TVGLOG("SVG", "Inefficient elements used [Opacity is zero][Node Typ… in _inefficientNodeCheck()
3495 …if (node->style->fill.opacity == 0 && node->style->stroke.opacity == 0) TVGLOG("SVG", "Inefficient… in _inefficientNodeCheck()
3497 switch (node->type) { in _inefficientNodeCheck()
3499 …if (!node->node.path.path) TVGLOG("SVG", "Inefficient elements used [Empty path][Node Type : %s]",… in _inefficientNodeCheck()
3503 …if (node->node.ellipse.rx == 0 && node->node.ellipse.ry == 0) TVGLOG("SVG", "Inefficient elements … in _inefficientNodeCheck()
3508 …if (node->node.polygon.pts.count < 2) TVGLOG("SVG", "Inefficient elements used [Invalid Polygon][N… in _inefficientNodeCheck()
3512 …if (node->node.circle.r == 0) TVGLOG("SVG", "Inefficient elements used [Size is zero][Node Type : … in _inefficientNodeCheck()
3516 …if (node->node.rect.w == 0 && node->node.rect.h) TVGLOG("SVG", "Inefficient elements used [Size is… in _inefficientNodeCheck()
3520 …if (node->node.line.x1 == node->node.line.x2 && node->node.line.y1 == node->node.line.y2) TVGLOG("… in _inefficientNodeCheck()
3531 _styleInherit(node->style, parentStyle); in _updateStyle()
3534 auto child = node->child.data; in _updateStyle()
3535 for (uint32_t i = 0; i < node->child.count; ++i, ++child) { in _updateStyle()
3536 _updateStyle(*child, node->style); in _updateStyle()
3545 auto gradList = gradients->data; in _gradientDup()
3547 for (uint32_t i = 0; i < gradients->count; ++i) { in _gradientDup()
3548 if ((*gradList)->id && !strcmp((*gradList)->id, id)) { in _gradientDup()
3555 if (result && result->ref) { in _gradientDup()
3556 gradList = gradients->data; in _gradientDup()
3557 for (uint32_t i = 0; i < gradients->count; ++i) { in _gradientDup()
3558 if ((*gradList)->id && !strcmp((*gradList)->id, result->ref)) { in _gradientDup()
3572 if (node->child.count > 0) { in _updateGradient()
3573 auto child = node->child.data; in _updateGradient()
3574 for (uint32_t i = 0; i < node->child.count; ++i, ++child) { in _updateGradient()
3578 if (node->style->fill.paint.url) { in _updateGradient()
3579 auto newGrad = _gradientDup(loader, gradients, node->style->fill.paint.url); in _updateGradient()
3581 if (node->style->fill.paint.gradient) { in _updateGradient()
3582 node->style->fill.paint.gradient->clear(); in _updateGradient()
3583 free(node->style->fill.paint.gradient); in _updateGradient()
3585 node->style->fill.paint.gradient = newGrad; in _updateGradient()
3588 if (node->style->stroke.paint.url) { in _updateGradient()
3589 auto newGrad = _gradientDup(loader, gradients, node->style->stroke.paint.url); in _updateGradient()
3591 if (node->style->stroke.paint.gradient) { in _updateGradient()
3592 node->style->stroke.paint.gradient->clear(); in _updateGradient()
3593 free(node->style->stroke.paint.gradient); in _updateGradient()
3595 node->style->stroke.paint.gradient = newGrad; in _updateGradient()
3604 if (node->style->clipPath.url && !node->style->clipPath.node) { in _updateComposite()
3605 SvgNode* findResult = _findNodeById(root, node->style->clipPath.url); in _updateComposite()
3606 if (findResult) node->style->clipPath.node = findResult; in _updateComposite()
3608 if (node->style->mask.url && !node->style->mask.node) { in _updateComposite()
3609 SvgNode* findResult = _findNodeById(root, node->style->mask.url); in _updateComposite()
3610 if (findResult) node->style->mask.node = findResult; in _updateComposite()
3612 if (node->child.count > 0) { in _updateComposite()
3613 auto child = node->child.data; in _updateComposite()
3614 for (uint32_t i = 0; i < node->child.count; ++i, ++child) { in _updateComposite()
3625 …//style->clipPath.node and style->mask.node has only the addresses of node. Therefore, node is rel… in _freeNodeStyle()
3626 free(style->clipPath.url); in _freeNodeStyle()
3627 free(style->mask.url); in _freeNodeStyle()
3628 free(style->cssClass); in _freeNodeStyle()
3630 if (style->fill.paint.gradient) { in _freeNodeStyle()
3631 style->fill.paint.gradient->clear(); in _freeNodeStyle()
3632 free(style->fill.paint.gradient); in _freeNodeStyle()
3634 if (style->stroke.paint.gradient) { in _freeNodeStyle()
3635 style->stroke.paint.gradient->clear(); in _freeNodeStyle()
3636 free(style->stroke.paint.gradient); in _freeNodeStyle()
3638 free(style->fill.paint.url); in _freeNodeStyle()
3639 free(style->stroke.paint.url); in _freeNodeStyle()
3640 style->stroke.dash.array.reset(); in _freeNodeStyle()
3649 auto child = node->child.data; in _freeNode()
3650 for (uint32_t i = 0; i < node->child.count; ++i, ++child) { in _freeNode()
3653 node->child.reset(); in _freeNode()
3655 free(node->id); in _freeNode()
3656 free(node->transform); in _freeNode()
3657 _freeNodeStyle(node->style); in _freeNode()
3658 switch (node->type) { in _freeNode()
3660 free(node->node.path.path); in _freeNode()
3664 free(node->node.polygon.pts.data); in _freeNode()
3668 free(node->node.polyline.pts.data); in _freeNode()
3672 _freeNode(node->node.doc.defs); in _freeNode()
3673 _freeNode(node->node.doc.style); in _freeNode()
3677 auto gradients = node->node.defs.gradients.data; in _freeNode()
3678 for (size_t i = 0; i < node->node.defs.gradients.count; ++i) { in _freeNode()
3679 (*gradients)->clear(); in _freeNode()
3683 node->node.defs.gradients.reset(); in _freeNode()
3687 free(node->node.image.href); in _freeNode()
3691 free(node->node.text.text); in _freeNode()
3692 free(node->node.text.fontFamily); in _freeNode()
3711 loader->level++; in _svgLoaderParserForValidCheckXmlOpen()
3721 sz = attrs - content; in _svgLoaderParserForValidCheckXmlOpen()
3722 while ((sz > 0) && (isspace(content[sz - 1]))) sz--; in _svgLoaderParserForValidCheckXmlOpen()
3726 attrsLength = length - sz; in _svgLoaderParserForValidCheckXmlOpen()
3730 if (!loader->doc) { in _svgLoaderParserForValidCheckXmlOpen()
3733 loader->doc = node; in _svgLoaderParserForValidCheckXmlOpen()
3734 loader->stack.push(node); in _svgLoaderParserForValidCheckXmlOpen()
3770 (*gradient)->clear(); in clear()
3808 this->done(); in ~SvgLoader()
3817 TVGLOG("SVG", "The <viewBox> width and/or height set to 0 - rendering disabled."); in run()
3825 auto defs = loaderData.doc->node.doc.defs; in run()
3839 if (defs) _updateGradient(&loaderData, loaderData.doc, &defs->node.defs.gradients); in run()
3847 vx = loaderData.doc->node.doc.vx; in run()
3848 vy = loaderData.doc->node.doc.vy; in run()
3849 vw = loaderData.doc->node.doc.vw; in run()
3850 vh = loaderData.doc->node.doc.vh; in run()
3851 w = loaderData.doc->node.doc.w; in run()
3852 h = loaderData.doc->node.doc.h; in run()
3867 loaderData.svgParse->flags = SvgStopStyleFlags::StopDefault; in header()
3872 if (loaderData.doc && loaderData.doc->type == SvgNodeType::Doc) { in header()
3873 viewFlag = loaderData.doc->node.doc.viewFlag; in header()
3874 align = loaderData.doc->node.doc.align; in header()
3875 meetOrSlice = loaderData.doc->node.doc.meetOrSlice; in header()
3878 vx = loaderData.doc->node.doc.vx; in header()
3879 vy = loaderData.doc->node.doc.vy; in header()
3880 vw = loaderData.doc->node.doc.vw; in header()
3881 vh = loaderData.doc->node.doc.vh; in header()
3883 if (viewFlag & SvgViewFlag::Width) w = loaderData.doc->node.doc.w; in header()
3885 w = loaderData.doc->node.doc.vw; in header()
3887 w *= loaderData.doc->node.doc.w; in header()
3892 if (viewFlag & SvgViewFlag::Height) h = loaderData.doc->node.doc.h; in header()
3894 h = loaderData.doc->node.doc.vh; in header()
3896 h *= loaderData.doc->node.doc.h; in header()
3907 vw = w = loaderData.doc->node.doc.w; in header()
3911 w = loaderData.doc->node.doc.w; in header()
3916 vh = h = loaderData.doc->node.doc.h; in header()
3920 h = loaderData.doc->node.doc.h; in header()
3946 this->size = size; in open()
3947 this->copy = copy; in open()
3979 auto sx = w / this->w; in resize()
3980 auto sy = h / this->h; in resize()
3982 paint->transform(m); in resize()
4004 this->done(); in close()
4012 this->done(); in paint()