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

Side by Side Diff: experimental/svg/model/SkSVGAttributeParser.cpp

Issue 2337203002: [SVGDom] Linear gradient 'spreadMethod' support (Closed)
Patch Set: review Created 4 years, 3 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 | « experimental/svg/model/SkSVGAttributeParser.h ('k') | experimental/svg/model/SkSVGDOM.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 * 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 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 if (this->parseExpectedStringToken(gJoinInfo[i].fName)) { 484 if (this->parseExpectedStringToken(gJoinInfo[i].fName)) {
485 *join = SkSVGLineJoin(gJoinInfo[i].fType); 485 *join = SkSVGLineJoin(gJoinInfo[i].fType);
486 parsedValue = true; 486 parsedValue = true;
487 break; 487 break;
488 } 488 }
489 } 489 }
490 490
491 return parsedValue && this->parseEOSToken(); 491 return parsedValue && this->parseEOSToken();
492 } 492 }
493 493
494 // https://www.w3.org/TR/SVG/pservers.html#LinearGradientElementSpreadMethodAttr ibute
495 bool SkSVGAttributeParser::parseSpreadMethod(SkSVGSpreadMethod* spread) {
496 static const struct {
497 SkSVGSpreadMethod::Type fType;
498 const char* fName;
499 } gSpreadInfo[] = {
500 { SkSVGSpreadMethod::Type::kPad , "pad" },
501 { SkSVGSpreadMethod::Type::kReflect, "reflect" },
502 { SkSVGSpreadMethod::Type::kRepeat , "repeat" },
503 };
504
505 bool parsedValue = false;
506 for (size_t i = 0; i < SK_ARRAY_COUNT(gSpreadInfo); ++i) {
507 if (this->parseExpectedStringToken(gSpreadInfo[i].fName)) {
508 *spread = SkSVGSpreadMethod(gSpreadInfo[i].fType);
509 parsedValue = true;
510 break;
511 }
512 }
513
514 return parsedValue && this->parseEOSToken();
515 }
516
494 // https://www.w3.org/TR/SVG/shapes.html#PolygonElementPointsAttribute 517 // https://www.w3.org/TR/SVG/shapes.html#PolygonElementPointsAttribute
495 bool SkSVGAttributeParser::parsePoints(SkSVGPointsType* points) { 518 bool SkSVGAttributeParser::parsePoints(SkSVGPointsType* points) {
496 SkTDArray<SkPoint> pts; 519 SkTDArray<SkPoint> pts;
497 520
498 bool parsedValue = false; 521 bool parsedValue = false;
499 for (;;) { 522 for (;;) {
500 this->parseWSToken(); 523 this->parseWSToken();
501 524
502 SkScalar x, y; 525 SkScalar x, y;
503 if (!this->parseScalarToken(&x)) { 526 if (!this->parseScalarToken(&x)) {
(...skipping 17 matching lines...) Expand all
521 parsedValue = true; 544 parsedValue = true;
522 } 545 }
523 546
524 if (parsedValue && this->parseEOSToken()) { 547 if (parsedValue && this->parseEOSToken()) {
525 *points = pts; 548 *points = pts;
526 return true; 549 return true;
527 } 550 }
528 551
529 return false; 552 return false;
530 } 553 }
OLDNEW
« no previous file with comments | « experimental/svg/model/SkSVGAttributeParser.h ('k') | experimental/svg/model/SkSVGDOM.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698