MCPcopy Create free account
hub / github.com/MyGUI/mygui / gatherPaths

Function gatherPaths

MyGUIEngine/src/msdfgen/ext/import-svg.cpp:683–749  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

681#ifdef MSDFGEN_USE_TINYXML2
682
683static void gatherPaths(SkPath &fullPath, int &flags, tinyxml2::XMLElement *parent, const SkMatrix &transformation) {
684 for (tinyxml2::XMLElement *cur = parent->FirstChildElement(); cur && !FLAGS_FINAL(flags); cur = cur->NextSiblingElement()) {
685 if (!strcmp(cur->Name(), "g"))
686 gatherPaths(fullPath, flags, cur, combineTransformation(flags, transformation, cur->Attribute("transform"), cur->Attribute("transform-origin")));
687 else if (!strcmp(cur->Name(), "mask") || !strcmp(cur->Name(), "use"))
688 flags |= SVG_IMPORT_UNSUPPORTED_FEATURE_FLAG;
689 else {
690 SkPath curPath;
691 if (!strcmp(cur->Name(), "path")) {
692 const char *pd = cur->Attribute("d");
693 if (!(pd && SkParsePath::FromSVGString(pd, &curPath))) {
694 flags |= SVG_IMPORT_PARTIAL_FAILURE_FLAG;
695 continue;
696 }
697 } else if (!strcmp(cur->Name(), "rect")) {
698 SkScalar x = SkScalar(cur->DoubleAttribute("x")), y = SkScalar(cur->DoubleAttribute("y"));
699 SkScalar width = SkScalar(cur->DoubleAttribute("width")), height = SkScalar(cur->DoubleAttribute("height"));
700 SkScalar rx = SkScalar(cur->DoubleAttribute("rx")), ry = SkScalar(cur->DoubleAttribute("ry"));
701 if (!(width && height))
702 continue;
703 SkRect rect = SkRect::MakeLTRB(x, y, x+width, y+height);
704 if (rx || ry) {
705 SkScalar radii[] = { rx, ry, rx, ry, rx, ry, rx, ry };
706 curPath.addRoundRect(rect, radii);
707 } else
708 curPath.addRect(rect);
709 } else if (!strcmp(cur->Name(), "circle")) {
710 SkScalar cx = SkScalar(cur->DoubleAttribute("cx")), cy = SkScalar(cur->DoubleAttribute("cy"));
711 SkScalar r = SkScalar(cur->DoubleAttribute("r"));
712 if (!r)
713 continue;
714 curPath.addCircle(cx, cy, r);
715 } else if (!strcmp(cur->Name(), "ellipse")) {
716 SkScalar cx = SkScalar(cur->DoubleAttribute("cx")), cy = SkScalar(cur->DoubleAttribute("cy"));
717 SkScalar rx = SkScalar(cur->DoubleAttribute("rx")), ry = SkScalar(cur->DoubleAttribute("ry"));
718 if (!(rx && ry))
719 continue;
720 curPath.addOval(SkRect::MakeLTRB(cx-rx, cy-ry, cx+rx, cy+ry));
721 } else if (!strcmp(cur->Name(), "polygon")) {
722 const char *pd = cur->Attribute("points");
723 if (!pd) {
724 flags |= SVG_IMPORT_PARTIAL_FAILURE_FLAG;
725 continue;
726 }
727 Point2 point;
728 if (!readCoord(point, pd))
729 continue;
730 curPath.moveTo(SkScalar(point.x), SkScalar(point.y));
731 if (!readCoord(point, pd))
732 continue;
733 do {
734 curPath.lineTo(SkScalar(point.x), SkScalar(point.y));
735 } while (readCoord(point, pd));
736 curPath.close();
737 } else
738 continue;
739 const char *fillRule = cur->Attribute("fill-rule");
740 if (fillRule && !strcmp(fillRule, "evenodd"))

Callers 1

loadSvgShapeFunction · 0.85

Calls 4

combineTransformationFunction · 0.85
readCoordFunction · 0.85
moveToMethod · 0.80
closeMethod · 0.45

Tested by

no test coverage detected