aboutsummaryrefslogtreecommitdiffhomepage
path: root/experimental/svg/model/SkSVGDOM.cpp
diff options
context:
space:
mode:
authorGravatar fmalita <fmalita@chromium.org>2016-09-13 12:56:11 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-09-13 12:56:11 -0700
commitcecd617a4297ffdcec632ca7e2ed1e6b61665e04 (patch)
tree48e32288114528e7085bf6aa0190653e7ad0bf99 /experimental/svg/model/SkSVGDOM.cpp
parent649985a530c39afcda23d1f188fa2fc92df3ac56 (diff)
[SVGDom] Linear gradient 'spreadMethod' support
R=stephana@google.com,robertphillips@google.com GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2337203002 Review-Url: https://codereview.chromium.org/2337203002
Diffstat (limited to 'experimental/svg/model/SkSVGDOM.cpp')
-rw-r--r--experimental/svg/model/SkSVGDOM.cpp73
1 files changed, 43 insertions, 30 deletions
diff --git a/experimental/svg/model/SkSVGDOM.cpp b/experimental/svg/model/SkSVGDOM.cpp
index d6e4f4c9bd..26944737f1 100644
--- a/experimental/svg/model/SkSVGDOM.cpp
+++ b/experimental/svg/model/SkSVGDOM.cpp
@@ -149,6 +149,18 @@ bool SetLineJoinAttribute(const sk_sp<SkSVGNode>& node, SkSVGAttribute attr,
return true;
}
+bool SetSpreadMethodAttribute(const sk_sp<SkSVGNode>& node, SkSVGAttribute attr,
+ const char* stringValue) {
+ SkSVGSpreadMethod spread;
+ SkSVGAttributeParser parser(stringValue);
+ if (!parser.parseSpreadMethod(&spread)) {
+ return false;
+ }
+
+ node->setAttribute(attr, SkSVGSpreadMethodValue(spread));
+ return true;
+}
+
bool SetPointsAttribute(const sk_sp<SkSVGNode>& node, SkSVGAttribute attr,
const char* stringValue) {
SkSVGPointsType points;
@@ -239,36 +251,37 @@ struct AttrParseInfo {
};
SortedDictionaryEntry<AttrParseInfo> gAttributeParseInfo[] = {
- { "cx" , { SkSVGAttribute::kCx , SetLengthAttribute }},
- { "cy" , { SkSVGAttribute::kCy , SetLengthAttribute }},
- { "d" , { SkSVGAttribute::kD , SetPathDataAttribute }},
- { "fill" , { SkSVGAttribute::kFill , SetPaintAttribute }},
- { "fill-opacity" , { SkSVGAttribute::kFillOpacity , SetNumberAttribute }},
- { "height" , { SkSVGAttribute::kHeight , SetLengthAttribute }},
- { "offset" , { SkSVGAttribute::kOffset , SetLengthAttribute }},
- { "opacity" , { SkSVGAttribute::kOpacity , SetNumberAttribute }},
- { "points" , { SkSVGAttribute::kPoints , SetPointsAttribute }},
- { "r" , { SkSVGAttribute::kR , SetLengthAttribute }},
- { "rx" , { SkSVGAttribute::kRx , SetLengthAttribute }},
- { "ry" , { SkSVGAttribute::kRy , SetLengthAttribute }},
- { "stop-color" , { SkSVGAttribute::kStopColor , SetColorAttribute }},
- { "stop-opacity" , { SkSVGAttribute::kStopOpacity , SetNumberAttribute }},
- { "stroke" , { SkSVGAttribute::kStroke , SetPaintAttribute }},
- { "stroke-linecap" , { SkSVGAttribute::kStrokeLineCap , SetLineCapAttribute }},
- { "stroke-linejoin", { SkSVGAttribute::kStrokeLineJoin, SetLineJoinAttribute }},
- { "stroke-opacity" , { SkSVGAttribute::kStrokeOpacity , SetNumberAttribute }},
- { "stroke-width" , { SkSVGAttribute::kStrokeWidth , SetLengthAttribute }},
- { "style" , { SkSVGAttribute::kUnknown , SetStyleAttributes }},
- { "transform" , { SkSVGAttribute::kTransform , SetTransformAttribute }},
- { "viewBox" , { SkSVGAttribute::kViewBox , SetViewBoxAttribute }},
- { "width" , { SkSVGAttribute::kWidth , SetLengthAttribute }},
- { "x" , { SkSVGAttribute::kX , SetLengthAttribute }},
- { "x1" , { SkSVGAttribute::kX1 , SetLengthAttribute }},
- { "x2" , { SkSVGAttribute::kX2 , SetLengthAttribute }},
- { "xlink:href" , { SkSVGAttribute::kHref , SetIRIAttribute }},
- { "y" , { SkSVGAttribute::kY , SetLengthAttribute }},
- { "y1" , { SkSVGAttribute::kY1 , SetLengthAttribute }},
- { "y2" , { SkSVGAttribute::kY2 , SetLengthAttribute }},
+ { "cx" , { SkSVGAttribute::kCx , SetLengthAttribute }},
+ { "cy" , { SkSVGAttribute::kCy , SetLengthAttribute }},
+ { "d" , { SkSVGAttribute::kD , SetPathDataAttribute }},
+ { "fill" , { SkSVGAttribute::kFill , SetPaintAttribute }},
+ { "fill-opacity" , { SkSVGAttribute::kFillOpacity , SetNumberAttribute }},
+ { "height" , { SkSVGAttribute::kHeight , SetLengthAttribute }},
+ { "offset" , { SkSVGAttribute::kOffset , SetLengthAttribute }},
+ { "opacity" , { SkSVGAttribute::kOpacity , SetNumberAttribute }},
+ { "points" , { SkSVGAttribute::kPoints , SetPointsAttribute }},
+ { "r" , { SkSVGAttribute::kR , SetLengthAttribute }},
+ { "rx" , { SkSVGAttribute::kRx , SetLengthAttribute }},
+ { "ry" , { SkSVGAttribute::kRy , SetLengthAttribute }},
+ { "spreadMethod" , { SkSVGAttribute::kSpreadMethod , SetSpreadMethodAttribute }},
+ { "stop-color" , { SkSVGAttribute::kStopColor , SetColorAttribute }},
+ { "stop-opacity" , { SkSVGAttribute::kStopOpacity , SetNumberAttribute }},
+ { "stroke" , { SkSVGAttribute::kStroke , SetPaintAttribute }},
+ { "stroke-linecap" , { SkSVGAttribute::kStrokeLineCap , SetLineCapAttribute }},
+ { "stroke-linejoin", { SkSVGAttribute::kStrokeLineJoin, SetLineJoinAttribute }},
+ { "stroke-opacity" , { SkSVGAttribute::kStrokeOpacity , SetNumberAttribute }},
+ { "stroke-width" , { SkSVGAttribute::kStrokeWidth , SetLengthAttribute }},
+ { "style" , { SkSVGAttribute::kUnknown , SetStyleAttributes }},
+ { "transform" , { SkSVGAttribute::kTransform , SetTransformAttribute }},
+ { "viewBox" , { SkSVGAttribute::kViewBox , SetViewBoxAttribute }},
+ { "width" , { SkSVGAttribute::kWidth , SetLengthAttribute }},
+ { "x" , { SkSVGAttribute::kX , SetLengthAttribute }},
+ { "x1" , { SkSVGAttribute::kX1 , SetLengthAttribute }},
+ { "x2" , { SkSVGAttribute::kX2 , SetLengthAttribute }},
+ { "xlink:href" , { SkSVGAttribute::kHref , SetIRIAttribute }},
+ { "y" , { SkSVGAttribute::kY , SetLengthAttribute }},
+ { "y1" , { SkSVGAttribute::kY1 , SetLengthAttribute }},
+ { "y2" , { SkSVGAttribute::kY2 , SetLengthAttribute }},
};
SortedDictionaryEntry<sk_sp<SkSVGNode>(*)()> gTagFactories[] = {