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

Method finishAttributes

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

Source from the content-addressed store, hash-verified

941 }
942
943 bool finishAttributes() {
944 switch (curElement) {
945 case BEGINNING:
946 case IGNORED:
947 case SVG:
948 break;
949 case G:
950 transformationStack.push(transformation);
951 transformation = combineTransformation(flags, transformation, elem.transform.str().c_str(), elem.transformOrigin.str().c_str());
952 break;
953 case PATH:
954 case RECT:
955 case CIRCLE:
956 case ELLIPSE:
957 case POLYGON:
958 {
959 SkPath curPath;
960 switch (curElement) {
961 case PATH:
962 if (!SkParsePath::FromSVGString(elem.pathDef.str().c_str(), &curPath)) {
963 flags |= SVG_IMPORT_PARTIAL_FAILURE_FLAG;
964 return true;
965 }
966 break;
967 case RECT:
968 {
969 if (!(elem.dims.x && elem.dims.y))
970 return true;
971 SkRect rect = SkRect::MakeLTRB(elem.pos.x, elem.pos.y, elem.pos.x+elem.dims.x, elem.pos.y+elem.dims.y);
972 if (elem.radius.x || elem.radius.y) {
973 SkScalar rx = SkScalar(elem.radius.x), ry = SkScalar(elem.radius.y);
974 SkScalar radii[] = { rx, ry, rx, ry, rx, ry, rx, ry };
975 curPath.addRoundRect(rect, radii);
976 } else
977 curPath.addRect(rect);
978 }
979 break;
980 case CIRCLE:
981 if (!elem.radius.x)
982 return true;
983 curPath.addCircle(elem.pos.x, elem.pos.y, elem.radius.x);
984 break;
985 case ELLIPSE:
986 if (!(elem.radius.x && elem.radius.y))
987 return true;
988 curPath.addOval(SkRect::MakeLTRB(elem.pos.x-elem.radius.x, elem.pos.y-elem.radius.y, elem.pos.x+elem.radius.x, elem.pos.y+elem.radius.y));
989 break;
990 case POLYGON:
991 {
992 if (elem.pathDef.start == elem.pathDef.end) {
993 flags |= SVG_IMPORT_PARTIAL_FAILURE_FLAG;
994 return true;
995 }
996 std::string pdStr = elem.pathDef.str();
997 const char *pd = pdStr.c_str();
998 Point2 point;
999 if (!readCoord(point, pd))
1000 return true;

Callers

nothing calls this directly

Calls 7

combineTransformationFunction · 0.85
readCoordFunction · 0.85
strMethod · 0.80
moveToMethod · 0.80
pushMethod · 0.45
c_strMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected