diff options
author | fmalita <fmalita@chromium.org> | 2016-08-12 12:15:33 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-08-12 12:15:33 -0700 |
commit | 5b31f321fcc3bb7f2ed7cf31ff4b03901228594b (patch) | |
tree | f3c65b2e0db3a9d36c448296e745d72832fe6034 /experimental/svg/model/SkSVGDOM.cpp | |
parent | 3602d4f16a01da860d16eb36fb52eb62487495cc (diff) |
[SVGDom] <polygon> & <polyline> support
R=robertphillips@google.com,stephana@google.com
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2235273003
Review-Url: https://codereview.chromium.org/2235273003
Diffstat (limited to 'experimental/svg/model/SkSVGDOM.cpp')
-rw-r--r-- | experimental/svg/model/SkSVGDOM.cpp | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/experimental/svg/model/SkSVGDOM.cpp b/experimental/svg/model/SkSVGDOM.cpp index 6e4bc49a9f..4ae5fedd3e 100644 --- a/experimental/svg/model/SkSVGDOM.cpp +++ b/experimental/svg/model/SkSVGDOM.cpp @@ -14,6 +14,7 @@ #include "SkSVGG.h" #include "SkSVGNode.h" #include "SkSVGPath.h" +#include "SkSVGPoly.h" #include "SkSVGRect.h" #include "SkSVGRenderContext.h" #include "SkSVGSVG.h" @@ -122,6 +123,18 @@ bool SetLineJoinAttribute(const sk_sp<SkSVGNode>& node, SkSVGAttribute attr, return true; } +bool SetPointsAttribute(const sk_sp<SkSVGNode>& node, SkSVGAttribute attr, + const char* stringValue) { + SkSVGPointsType points; + SkSVGAttributeParser parser(stringValue); + if (!parser.parsePoints(&points)) { + return false; + } + + node->setAttribute(attr, SkSVGPointsValue(points)); + return true; +} + SkString TrimmedString(const char* first, const char* last) { SkASSERT(first); SkASSERT(last); @@ -204,6 +217,7 @@ SortedDictionaryEntry<AttrParseInfo> gAttributeParseInfo[] = { { "fill" , { SkSVGAttribute::kFill , SetPaintAttribute }}, { "fill-opacity" , { SkSVGAttribute::kFillOpacity , SetNumberAttribute }}, { "height" , { SkSVGAttribute::kHeight , SetLengthAttribute }}, + { "points" , { SkSVGAttribute::kPoints , SetPointsAttribute }}, { "rx" , { SkSVGAttribute::kRx , SetLengthAttribute }}, { "ry" , { SkSVGAttribute::kRy , SetLengthAttribute }}, { "stroke" , { SkSVGAttribute::kStroke , SetPaintAttribute }}, @@ -220,10 +234,12 @@ SortedDictionaryEntry<AttrParseInfo> gAttributeParseInfo[] = { }; SortedDictionaryEntry<sk_sp<SkSVGNode>(*)()> gTagFactories[] = { - { "g" , []() -> sk_sp<SkSVGNode> { return SkSVGG::Make(); }}, - { "path", []() -> sk_sp<SkSVGNode> { return SkSVGPath::Make(); }}, - { "rect", []() -> sk_sp<SkSVGNode> { return SkSVGRect::Make(); }}, - { "svg" , []() -> sk_sp<SkSVGNode> { return SkSVGSVG::Make(); }}, + { "g" , []() -> sk_sp<SkSVGNode> { return SkSVGG::Make(); }}, + { "path" , []() -> sk_sp<SkSVGNode> { return SkSVGPath::Make(); }}, + { "polygon" , []() -> sk_sp<SkSVGNode> { return SkSVGPoly::MakePolygon(); }}, + { "polyline", []() -> sk_sp<SkSVGNode> { return SkSVGPoly::MakePolyline(); }}, + { "rect" , []() -> sk_sp<SkSVGNode> { return SkSVGRect::Make(); }}, + { "svg" , []() -> sk_sp<SkSVGNode> { return SkSVGSVG::Make(); }}, }; struct ConstructionContext { |