| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkParse.h" | 8 #include "SkParse.h" |
| 9 #include "SkSVGAttributeParser.h" | 9 #include "SkSVGAttributeParser.h" |
| 10 #include "SkSVGTypes.h" | 10 #include "SkSVGTypes.h" |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 for (size_t i = 0; i < SK_ARRAY_COUNT(gJoinInfo); ++i) { | 420 for (size_t i = 0; i < SK_ARRAY_COUNT(gJoinInfo); ++i) { |
| 421 if (this->parseExpectedStringToken(gJoinInfo[i].fName)) { | 421 if (this->parseExpectedStringToken(gJoinInfo[i].fName)) { |
| 422 *join = SkSVGLineJoin(gJoinInfo[i].fType); | 422 *join = SkSVGLineJoin(gJoinInfo[i].fType); |
| 423 parsedValue = true; | 423 parsedValue = true; |
| 424 break; | 424 break; |
| 425 } | 425 } |
| 426 } | 426 } |
| 427 | 427 |
| 428 return parsedValue && this->parseEOSToken(); | 428 return parsedValue && this->parseEOSToken(); |
| 429 } | 429 } |
| 430 |
| 431 // https://www.w3.org/TR/SVG/shapes.html#PolygonElementPointsAttribute |
| 432 bool SkSVGAttributeParser::parsePoints(SkSVGPointsType* points) { |
| 433 SkTDArray<SkPoint> pts; |
| 434 |
| 435 bool parsedValue = false; |
| 436 for (;;) { |
| 437 this->parseWSToken(); |
| 438 |
| 439 SkScalar x, y; |
| 440 if (!this->parseScalarToken(&x)) { |
| 441 break; |
| 442 } |
| 443 |
| 444 // comma-wsp: |
| 445 // (wsp+ comma? wsp*) | (comma wsp*) |
| 446 bool wsp = this->parseWSToken(); |
| 447 bool comma = this->parseExpectedStringToken(","); |
| 448 if (!(wsp || comma)) { |
| 449 break; |
| 450 } |
| 451 this->parseWSToken(); |
| 452 |
| 453 if (!this->parseScalarToken(&y)) { |
| 454 break; |
| 455 } |
| 456 |
| 457 pts.push(SkPoint::Make(x, y)); |
| 458 parsedValue = true; |
| 459 } |
| 460 |
| 461 if (parsedValue && this->parseEOSToken()) { |
| 462 *points = pts; |
| 463 return true; |
| 464 } |
| 465 |
| 466 return false; |
| 467 } |
| OLD | NEW |