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

Side by Side Diff: src/svg/parser/SkSVGSVG.cpp

Issue 2154193003: Delete the legacy SVG parser (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 4 years, 5 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 unified diff | Download patch
« no previous file with comments | « src/svg/parser/SkSVGSVG.h ('k') | src/svg/parser/SkSVGStop.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2006 The Android Open Source Project
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8
9 #include "SkSVGSVG.h"
10 #include "SkParse.h"
11 #include "SkRect.h"
12 #include "SkSVGParser.h"
13
14 const SkSVGAttribute SkSVGSVG::gAttributes[] = {
15 SVG_LITERAL_ATTRIBUTE(enable-background, f_enable_background),
16 SVG_ATTRIBUTE(height),
17 SVG_ATTRIBUTE(overflow),
18 SVG_ATTRIBUTE(width),
19 SVG_ATTRIBUTE(version),
20 SVG_ATTRIBUTE(viewBox),
21 SVG_ATTRIBUTE(x),
22 SVG_LITERAL_ATTRIBUTE(xml:space, f_xml_space),
23 SVG_ATTRIBUTE(xmlns),
24 SVG_LITERAL_ATTRIBUTE(xmlns:xlink, f_xml_xlink),
25 SVG_ATTRIBUTE(y),
26 };
27
28 DEFINE_SVG_INFO(SVG)
29
30
31 bool SkSVGSVG::isFlushable() {
32 return false;
33 }
34
35 void SkSVGSVG::translate(SkSVGParser& parser, bool defState) {
36 SkScalar height, width;
37 SkScalar viewBox[4];
38 const char* hSuffix = SkParse::FindScalar(f_height.c_str(), &height);
39 if (strcmp(hSuffix, "pt") == 0)
40 height = SkScalarMulDiv(height, SK_Scalar1 * 72, SK_Scalar1 * 96);
41 const char* wSuffix = SkParse::FindScalar(f_width.c_str(), &width);
42 if (strcmp(wSuffix, "pt") == 0)
43 width = SkScalarMulDiv(width, SK_Scalar1 * 72, SK_Scalar1 * 96);
44 SkParse::FindScalars(f_viewBox.c_str(), viewBox, 4);
45 SkRect box = SkRect::MakeLTRB(viewBox[0] / width, viewBox[1] / height,
46 viewBox[2] / width, viewBox[3] / height);
47 if (box.fLeft == 0 && box.fTop == 0 &&
48 box.fRight == SK_Scalar1 && box.fBottom == SK_Scalar1)
49 return;
50 parser._startElement("matrix");
51 if (box.fLeft != 0) {
52 SkString x;
53 x.appendScalar(box.fLeft);
54 parser._addAttributeLen("translateX", x.c_str(), x.size());
55 }
56 if (box.fTop != 0) {
57 SkString y;
58 y.appendScalar(box.fTop);
59 parser._addAttributeLen("translateY", y.c_str(), y.size());
60 }
61 if (box.fRight != SK_Scalar1) {
62 SkString x;
63 x.appendScalar(box.fRight);
64 parser._addAttributeLen("scaleX", x.c_str(), x.size());
65 }
66 if (box.fBottom != SK_Scalar1) {
67 SkString y;
68 y.appendScalar(box.fBottom);
69 parser._addAttributeLen("scaleY", y.c_str(), y.size());
70 }
71 parser._endElement();
72 }
OLDNEW
« no previous file with comments | « src/svg/parser/SkSVGSVG.h ('k') | src/svg/parser/SkSVGStop.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698