Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2089)

Unified Diff: experimental/svg/model/SkSVGDOM.cpp

Issue 2222793002: [SVGDom] Add <svg> viewBox support (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: typo Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « experimental/svg/model/SkSVGContainer.cpp ('k') | experimental/svg/model/SkSVGNode.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
}
« no previous file with comments | « experimental/svg/model/SkSVGContainer.cpp ('k') | experimental/svg/model/SkSVGNode.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698