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

Side by Side Diff: src/utils/SkParsePath.cpp

Issue 1613303002: Add svg path arcto (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: use enums for arcto's sweep and largeArc params Created 4 years, 11 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/core/SkPath.cpp ('k') | no next file » | 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 2011 Google Inc. 3 * Copyright 2011 Google Inc.
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 #include "SkParse.h" 8 #include "SkParse.h"
9 #include "SkParsePath.h" 9 #include "SkParsePath.h"
10 10
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 } 57 }
58 return str; 58 return str;
59 } 59 }
60 60
61 static const char* find_scalar(const char str[], SkScalar* value, 61 static const char* find_scalar(const char str[], SkScalar* value,
62 bool isRelative, SkScalar relative) { 62 bool isRelative, SkScalar relative) {
63 str = SkParse::FindScalar(str, value); 63 str = SkParse::FindScalar(str, value);
64 if (isRelative) { 64 if (isRelative) {
65 *value += relative; 65 *value += relative;
66 } 66 }
67 str = skip_sep(str);
67 return str; 68 return str;
68 } 69 }
69 70
70 bool SkParsePath::FromSVGString(const char data[], SkPath* result) { 71 bool SkParsePath::FromSVGString(const char data[], SkPath* result) {
71 SkPath path; 72 SkPath path;
72 SkPoint f = {0, 0}; 73 SkPoint f = {0, 0};
73 SkPoint c = {0, 0}; 74 SkPoint c = {0, 0};
74 SkPoint lastc = {0, 0}; 75 SkPoint lastc = {0, 0};
75 SkPoint points[3]; 76 SkPoint points[3];
76 char op = '\0'; 77 char op = '\0';
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 points[0] = points[1]; 150 points[0] = points[1];
150 if (previousOp == 'Q' || previousOp == 'T') { 151 if (previousOp == 'Q' || previousOp == 'T') {
151 points[0].fX = c.fX * 2 - lastc.fX; 152 points[0].fX = c.fX * 2 - lastc.fX;
152 points[0].fY = c.fY * 2 - lastc.fY; 153 points[0].fY = c.fY * 2 - lastc.fY;
153 } 154 }
154 quadraticCommon: 155 quadraticCommon:
155 path.quadTo(points[0], points[1]); 156 path.quadTo(points[0], points[1]);
156 lastc = points[0]; 157 lastc = points[0];
157 c = points[1]; 158 c = points[1];
158 break; 159 break;
160 case 'A': {
161 SkPoint radii;
162 data = find_points(data, &radii, 1, false, nullptr);
163 SkScalar angle, largeArc, sweep;
164 data = find_scalar(data, &angle, false, 0);
165 data = find_scalar(data, &largeArc, false, 0);
166 data = find_scalar(data, &sweep, false, 0);
167 data = find_points(data, &points[0], 1, relative, &c);
168 path.arcTo(radii, angle, (SkPath::ArcSize) SkToBool(largeArc),
169 (SkPath::Direction) !SkToBool(sweep), points[0]);
170 } break;
159 case 'Z': 171 case 'Z':
160 path.close(); 172 path.close();
161 #if 0 // !!! still a bug? 173 #if 0 // !!! still a bug?
162 if (fPath.isEmpty() && (f.fX != 0 || f.fY != 0)) { 174 if (fPath.isEmpty() && (f.fX != 0 || f.fY != 0)) {
163 c.fX -= SkScalar.Epsilon; // !!! enough? 175 c.fX -= SkScalar.Epsilon; // !!! enough?
164 fPath.moveTo(c); 176 fPath.moveTo(c);
165 fPath.lineTo(f); 177 fPath.lineTo(f);
166 fPath.close(); 178 fPath.close();
167 } 179 }
168 #endif 180 #endif
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 case SkPath::kClose_Verb: 258 case SkPath::kClose_Verb:
247 stream.write("Z", 1); 259 stream.write("Z", 1);
248 break; 260 break;
249 case SkPath::kDone_Verb: 261 case SkPath::kDone_Verb:
250 str->resize(stream.getOffset()); 262 str->resize(stream.getOffset());
251 stream.copyTo(str->writable_str()); 263 stream.copyTo(str->writable_str());
252 return; 264 return;
253 } 265 }
254 } 266 }
255 } 267 }
OLDNEW
« no previous file with comments | « src/core/SkPath.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698