diff options
author | 2016-12-08 09:26:47 -0500 | |
---|---|---|
committer | 2016-12-08 15:00:18 +0000 | |
commit | ce8840e3842f3a702c5d7bf440ff730bdfaf8e70 (patch) | |
tree | 0a94cdeb3d2d8632644490b70fdb0c40d185b8ec /experimental/svg/model/SkSVGDOM.cpp | |
parent | c5a8366d9922902cffbd351fdd15755dd2ac99bf (diff) |
[SVGDom] ClipPath support
* clip-path attribute handling
* clipPath container element
* asPath() SkSVGNode virtual for capturing subtree geometry
R=robertphillips@google.com,stephana@google.com
Change-Id: I9597534fe3047b631da6309eafac055dff5696e9
Reviewed-on: https://skia-review.googlesource.com/5650
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
Diffstat (limited to 'experimental/svg/model/SkSVGDOM.cpp')
-rw-r--r-- | experimental/svg/model/SkSVGDOM.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/experimental/svg/model/SkSVGDOM.cpp b/experimental/svg/model/SkSVGDOM.cpp index 2120f80e36..cea1ae69fe 100644 --- a/experimental/svg/model/SkSVGDOM.cpp +++ b/experimental/svg/model/SkSVGDOM.cpp @@ -11,6 +11,7 @@ #include "SkString.h" #include "SkSVGAttributeParser.h" #include "SkSVGCircle.h" +#include "SkSVGClipPath.h" #include "SkSVGDefs.h" #include "SkSVGDOM.h" #include "SkSVGEllipse.h" @@ -66,6 +67,19 @@ bool SetIRIAttribute(const sk_sp<SkSVGNode>& node, SkSVGAttribute attr, return true; } +bool SetClipPathAttribute(const sk_sp<SkSVGNode>& node, SkSVGAttribute attr, + const char* stringValue) { + SkSVGClip clip; + SkSVGAttributeParser parser(stringValue); + if (!parser.parseClipPath(&clip)) { + return false; + } + + node->setAttribute(attr, SkSVGClipValue(clip)); + return true; +} + + bool SetPathDataAttribute(const sk_sp<SkSVGNode>& node, SkSVGAttribute attr, const char* stringValue) { SkPath path; @@ -263,6 +277,7 @@ struct AttrParseInfo { }; SortedDictionaryEntry<AttrParseInfo> gAttributeParseInfo[] = { + { "clip-path" , { SkSVGAttribute::kClipPath , SetClipPathAttribute }}, { "cx" , { SkSVGAttribute::kCx , SetLengthAttribute }}, { "cy" , { SkSVGAttribute::kCy , SetLengthAttribute }}, { "d" , { SkSVGAttribute::kD , SetPathDataAttribute }}, @@ -300,6 +315,7 @@ SortedDictionaryEntry<AttrParseInfo> gAttributeParseInfo[] = { SortedDictionaryEntry<sk_sp<SkSVGNode>(*)()> gTagFactories[] = { { "circle" , []() -> sk_sp<SkSVGNode> { return SkSVGCircle::Make(); }}, + { "clipPath" , []() -> sk_sp<SkSVGNode> { return SkSVGClipPath::Make(); }}, { "defs" , []() -> sk_sp<SkSVGNode> { return SkSVGDefs::Make(); }}, { "ellipse" , []() -> sk_sp<SkSVGNode> { return SkSVGEllipse::Make(); }}, { "g" , []() -> sk_sp<SkSVGNode> { return SkSVGG::Make(); }}, |