From e932d4b3a99905a6272c5574f21ac651632f4e82 Mon Sep 17 00:00:00 2001 From: Florin Malita Date: Thu, 1 Dec 2016 13:35:11 -0500 Subject: [SVGDom] Add fill-rule support There's a bit of friction with this attribute, because per spec it is an inherited presentation attribute, but in Skia it is part of the actual SkPath state. So we must add some plumbing to SkSVGShape & friends to allow overriding the fill type at render-time. R=robertphillips@google.com,stephana@google.com Change-Id: I9c926d653c6211beb3914bffac50d4349dbdd2c0 Reviewed-on: https://skia-review.googlesource.com/5415 Reviewed-by: Mike Reed Commit-Queue: Florin Malita --- experimental/svg/model/SkSVGDOM.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'experimental/svg/model/SkSVGDOM.cpp') diff --git a/experimental/svg/model/SkSVGDOM.cpp b/experimental/svg/model/SkSVGDOM.cpp index c9745f1730..2120f80e36 100644 --- a/experimental/svg/model/SkSVGDOM.cpp +++ b/experimental/svg/model/SkSVGDOM.cpp @@ -173,6 +173,18 @@ bool SetPointsAttribute(const sk_sp& node, SkSVGAttribute attr, return true; } +bool SetFillRuleAttribute(const sk_sp& node, SkSVGAttribute attr, + const char* stringValue) { + SkSVGFillRule fillRule; + SkSVGAttributeParser parser(stringValue); + if (!parser.parseFillRule(&fillRule)) { + return false; + } + + node->setAttribute(attr, SkSVGFillRuleValue(fillRule)); + return true; +} + SkString TrimmedString(const char* first, const char* last) { SkASSERT(first); SkASSERT(last); @@ -256,6 +268,7 @@ SortedDictionaryEntry gAttributeParseInfo[] = { { "d" , { SkSVGAttribute::kD , SetPathDataAttribute }}, { "fill" , { SkSVGAttribute::kFill , SetPaintAttribute }}, { "fill-opacity" , { SkSVGAttribute::kFillOpacity , SetNumberAttribute }}, + { "fill-rule" , { SkSVGAttribute::kFillRule , SetFillRuleAttribute }}, { "gradientTransform", { SkSVGAttribute::kGradientTransform, SetTransformAttribute }}, { "height" , { SkSVGAttribute::kHeight , SetLengthAttribute }}, { "offset" , { SkSVGAttribute::kOffset , SetLengthAttribute }}, -- cgit v1.2.3