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

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

Issue 1135053002: stop calling SkScalarDiv (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix xpsdevice Created 5 years, 7 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/ports/SkFontHost_FreeType.cpp ('k') | src/utils/SkInterpolator.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "SkSVGSVG.h" 10 #include "SkSVGSVG.h"
(...skipping 25 matching lines...) Expand all
36 void SkSVGSVG::translate(SkSVGParser& parser, bool defState) { 36 void SkSVGSVG::translate(SkSVGParser& parser, bool defState) {
37 SkScalar height, width; 37 SkScalar height, width;
38 SkScalar viewBox[4]; 38 SkScalar viewBox[4];
39 const char* hSuffix = SkParse::FindScalar(f_height.c_str(), &height); 39 const char* hSuffix = SkParse::FindScalar(f_height.c_str(), &height);
40 if (strcmp(hSuffix, "pt") == 0) 40 if (strcmp(hSuffix, "pt") == 0)
41 height = SkScalarMulDiv(height, SK_Scalar1 * 72, SK_Scalar1 * 96); 41 height = SkScalarMulDiv(height, SK_Scalar1 * 72, SK_Scalar1 * 96);
42 const char* wSuffix = SkParse::FindScalar(f_width.c_str(), &width); 42 const char* wSuffix = SkParse::FindScalar(f_width.c_str(), &width);
43 if (strcmp(wSuffix, "pt") == 0) 43 if (strcmp(wSuffix, "pt") == 0)
44 width = SkScalarMulDiv(width, SK_Scalar1 * 72, SK_Scalar1 * 96); 44 width = SkScalarMulDiv(width, SK_Scalar1 * 72, SK_Scalar1 * 96);
45 SkParse::FindScalars(f_viewBox.c_str(), viewBox, 4); 45 SkParse::FindScalars(f_viewBox.c_str(), viewBox, 4);
46 SkRect box; 46 SkRect box = SkRect::MakeLTRB(viewBox[0] / width, viewBox[1] / height,
47 box.fLeft = SkScalarDiv(viewBox[0], width); 47 viewBox[2] / width, viewBox[3] / height);
48 box.fTop = SkScalarDiv(viewBox[1], height);
49 box.fRight = SkScalarDiv(viewBox[2], width);
50 box.fBottom = SkScalarDiv(viewBox[3], height);
51 if (box.fLeft == 0 && box.fTop == 0 && 48 if (box.fLeft == 0 && box.fTop == 0 &&
52 box.fRight == SK_Scalar1 && box.fBottom == SK_Scalar1) 49 box.fRight == SK_Scalar1 && box.fBottom == SK_Scalar1)
53 return; 50 return;
54 parser._startElement("matrix"); 51 parser._startElement("matrix");
55 if (box.fLeft != 0) { 52 if (box.fLeft != 0) {
56 SkString x; 53 SkString x;
57 x.appendScalar(box.fLeft); 54 x.appendScalar(box.fLeft);
58 parser._addAttributeLen("translateX", x.c_str(), x.size()); 55 parser._addAttributeLen("translateX", x.c_str(), x.size());
59 } 56 }
60 if (box.fTop != 0) { 57 if (box.fTop != 0) {
61 SkString y; 58 SkString y;
62 y.appendScalar(box.fTop); 59 y.appendScalar(box.fTop);
63 parser._addAttributeLen("translateY", y.c_str(), y.size()); 60 parser._addAttributeLen("translateY", y.c_str(), y.size());
64 } 61 }
65 if (box.fRight != SK_Scalar1) { 62 if (box.fRight != SK_Scalar1) {
66 SkString x; 63 SkString x;
67 x.appendScalar(box.fRight); 64 x.appendScalar(box.fRight);
68 parser._addAttributeLen("scaleX", x.c_str(), x.size()); 65 parser._addAttributeLen("scaleX", x.c_str(), x.size());
69 } 66 }
70 if (box.fBottom != SK_Scalar1) { 67 if (box.fBottom != SK_Scalar1) {
71 SkString y; 68 SkString y;
72 y.appendScalar(box.fBottom); 69 y.appendScalar(box.fBottom);
73 parser._addAttributeLen("scaleY", y.c_str(), y.size()); 70 parser._addAttributeLen("scaleY", y.c_str(), y.size());
74 } 71 }
75 parser._endElement(); 72 parser._endElement();
76 } 73 }
OLDNEW
« no previous file with comments | « src/ports/SkFontHost_FreeType.cpp ('k') | src/utils/SkInterpolator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698