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

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

Issue 2220933003: [SVGDom] Improved transform parsing (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: review 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/SkSVGAttributeParser.cpp ('k') | experimental/svg/model/SkSVGTransformableNode.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 13d67b9cfe134a37417c097e35eccdd8acfc7732..9b67484fbc571ce5a6619c4ac64cb50a20cb742b 100644
--- a/experimental/svg/model/SkSVGDOM.cpp
+++ b/experimental/svg/model/SkSVGDOM.cpp
@@ -7,7 +7,6 @@
#include "SkCanvas.h"
#include "SkDOM.h"
-#include "SkParse.h"
#include "SkParsePath.h"
#include "SkString.h"
#include "SkSVGAttributeParser.h"
@@ -24,53 +23,6 @@
namespace {
-const char* ParseScalarPair(const char* str, SkScalar v[2]) {
- str = SkParse::FindScalar(str, v);
- if (str) {
- const char* second = SkParse::FindScalar(str, v + 1);
- if (!second) {
- v[1] = v[0];
- } else {
- str = second;
- }
- }
-
- return str;
-}
-
-SkMatrix ParseTransform(const char* str) {
- SkMatrix m = SkMatrix::I();
-
- // FIXME: real parser
- if (!strncmp(str, "matrix(", 7)) {
- SkScalar values[6];
- str = SkParse::FindScalars(str + 7, values, 6);
- if (str) {
- m.setAffine(values);
- }
- } else if (!strncmp(str, "scale(", 6)) {
- SkScalar values[2];
- str = ParseScalarPair(str + 6, values);
- if (str) {
- m.setScale(values[0], values[1]);
- }
- } else if (!strncmp(str, "translate(", 10)) {
- SkScalar values[2];
- str = ParseScalarPair(str + 10, values);
- if (str) {
- m.setTranslate(values[0], values[1]);
- }
- } else if (!strncmp(str, "rotate(", 7)) {
- SkScalar value;
- str = SkParse::FindScalar(str + 7, &value);
- if (str) {
- m.setRotate(value);
- }
- }
-
- return m;
-}
-
bool SetPaintAttribute(const sk_sp<SkSVGNode>& node, SkSVGAttribute attr,
const char* stringValue) {
SkSVGColorType color;
@@ -96,7 +48,13 @@ bool SetPathDataAttribute(const sk_sp<SkSVGNode>& node, SkSVGAttribute attr,
bool SetTransformAttribute(const sk_sp<SkSVGNode>& node, SkSVGAttribute attr,
const char* stringValue) {
- node->setAttribute(attr, SkSVGTransformValue(ParseTransform(stringValue)));
+ SkSVGTransformType transform;
+ SkSVGAttributeParser parser(stringValue);
+ if (!parser.parseTransform(&transform)) {
+ return false;
+ }
+
+ node->setAttribute(attr, SkSVGTransformValue(transform));
return true;
}
« no previous file with comments | « experimental/svg/model/SkSVGAttributeParser.cpp ('k') | experimental/svg/model/SkSVGTransformableNode.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698