| Index: experimental/svg/model/SkSVGDOM.cpp
|
| diff --git a/experimental/svg/model/SkSVGDOM.cpp b/experimental/svg/model/SkSVGDOM.cpp
|
| index df589230e0daa370a6fd82a999fc1a97466fae28..13d67b9cfe134a37417c097e35eccdd8acfc7732 100644
|
| --- a/experimental/svg/model/SkSVGDOM.cpp
|
| +++ b/experimental/svg/model/SkSVGDOM.cpp
|
| @@ -73,7 +73,7 @@ SkMatrix ParseTransform(const char* str) {
|
|
|
| bool SetPaintAttribute(const sk_sp<SkSVGNode>& node, SkSVGAttribute attr,
|
| const char* stringValue) {
|
| - SkSVGColor color;
|
| + SkSVGColorType color;
|
| SkSVGAttributeParser parser(stringValue);
|
| if (!parser.parseColor(&color)) {
|
| return false;
|
| @@ -112,6 +112,18 @@ bool SetLengthAttribute(const sk_sp<SkSVGNode>& node, SkSVGAttribute attr,
|
| return true;
|
| }
|
|
|
| +bool SetViewBoxAttribute(const sk_sp<SkSVGNode>& node, SkSVGAttribute attr,
|
| + const char* stringValue) {
|
| + SkSVGViewBoxType viewBox;
|
| + SkSVGAttributeParser parser(stringValue);
|
| + if (!parser.parseViewBox(&viewBox)) {
|
| + return false;
|
| + }
|
| +
|
| + node->setAttribute(attr, SkSVGViewBoxValue(viewBox));
|
| + return true;
|
| +}
|
| +
|
| // Breaks a "foo: bar; baz: ..." string into key:value pairs.
|
| class StyleIterator {
|
| public:
|
| @@ -184,6 +196,7 @@ SortedDictionaryEntry<AttrParseInfo> gAttributeParseInfo[] = {
|
| { "stroke" , { SkSVGAttribute::kStroke , SetPaintAttribute }},
|
| { "style" , { SkSVGAttribute::kUnknown , SetStyleAttributes }},
|
| { "transform", { SkSVGAttribute::kTransform, SetTransformAttribute }},
|
| + { "viewBox" , { SkSVGAttribute::kViewBox , SetViewBoxAttribute }},
|
| { "width" , { SkSVGAttribute::kWidth , SetLengthAttribute }},
|
| { "x" , { SkSVGAttribute::kX , SetLengthAttribute }},
|
| { "y" , { SkSVGAttribute::kY , SetLengthAttribute }},
|
| @@ -292,8 +305,10 @@ sk_sp<SkSVGDOM> SkSVGDOM::MakeFromStream(SkStream& svgStream, const SkSize& cont
|
|
|
| void SkSVGDOM::render(SkCanvas* canvas) const {
|
| if (fRoot) {
|
| - SkSVGRenderContext ctx(fContainerSize);
|
| - fRoot->render(canvas, ctx);
|
| + SkSVGRenderContext ctx(canvas,
|
| + SkSVGLengthContext(fContainerSize),
|
| + SkSVGPresentationContext());
|
| + fRoot->render(ctx);
|
| }
|
| }
|
|
|
|
|