SkSVGPresentationAttributes SkSVGPresentationAttributes::MakeInitial() { SkSVGPresentationAttributes result; result.fFill.set(SkSVGPaint(SkSVGColorType(SK_ColorBLACK))); result.fFillOpacity.set(SkSVGNumberType(1)); result.fStroke.set(SkSVGPaint(SkSVGPaint::Type::kNone)); result.fStrokeLineCap.set(SkSVGLineCap(SkSVGLineCap::Type::kButt)); result.fStrokeLineJoin.set(SkSVGLineJoin(SkSVGLineJoin::Type::kMiter)); result.fStrokeOpacity.set(SkSVGNumberType(1)); result.fStrokeWidth.set(SkSVGLength(1)); return result; }
// https://www.w3.org/TR/SVG/painting.html#StrokeLinecapProperty bool SkSVGAttributeParser::parseLineCap(SkSVGLineCap* cap) { static const struct { SkSVGLineCap::Type fType; const char* fName; } gCapInfo[] = { { SkSVGLineCap::Type::kButt , "butt" }, { SkSVGLineCap::Type::kRound , "round" }, { SkSVGLineCap::Type::kSquare , "square" }, { SkSVGLineCap::Type::kInherit, "inherit" }, }; bool parsedValue = false; for (size_t i = 0; i < SK_ARRAY_COUNT(gCapInfo); ++i) { if (this->parseExpectedStringToken(gCapInfo[i].fName)) { *cap = SkSVGLineCap(gCapInfo[i].fType); parsedValue = true; break; } } return parsedValue && this->parseEOSToken(); }