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

Side by Side Diff: src/core/SkPath.cpp

Issue 151353006: Adding new 'extend' mode to SkPath::addPath (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: further improvements Created 6 years, 10 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
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 "SkBuffer.h" 10 #include "SkBuffer.h"
(...skipping 1425 matching lines...) Expand 10 before | Expand all | Expand 10 after
1436 this->incReserve(count); 1436 this->incReserve(count);
1437 // [xx,yy] == pts[0] 1437 // [xx,yy] == pts[0]
1438 this->lineTo(xx, yy); 1438 this->lineTo(xx, yy);
1439 for (int i = 1; i < count; i += 2) { 1439 for (int i = 1; i < count; i += 2) {
1440 this->quadTo(pts[i], pts[i+1]); 1440 this->quadTo(pts[i], pts[i+1]);
1441 } 1441 }
1442 } 1442 }
1443 1443
1444 /////////////////////////////////////////////////////////////////////////////// 1444 ///////////////////////////////////////////////////////////////////////////////
1445 1445
1446 void SkPath::addPath(const SkPath& path, SkScalar dx, SkScalar dy) { 1446 void SkPath::addPath(const SkPath& path, SkScalar dx, SkScalar dy, AddPathMode m ode) {
1447 SkMatrix matrix; 1447 SkMatrix matrix;
1448 1448
1449 matrix.setTranslate(dx, dy); 1449 matrix.setTranslate(dx, dy);
1450 this->addPath(path, matrix); 1450 this->addPath(path, matrix, mode);
1451 } 1451 }
1452 1452
1453 void SkPath::addPath(const SkPath& path, const SkMatrix& matrix) { 1453 void SkPath::addPath(const SkPath& path, const SkMatrix& matrix, AddPathMode mod e) {
1454 SkPathRef::Editor(&fPathRef, path.countVerbs(), path.countPoints()); 1454 SkPathRef::Editor(&fPathRef, path.countVerbs(), path.countPoints());
1455 1455
1456 RawIter iter(path); 1456 RawIter iter(path);
1457 SkPoint pts[4]; 1457 SkPoint pts[4];
1458 Verb verb; 1458 Verb verb;
1459 1459
1460 SkMatrix::MapPtsProc proc = matrix.getMapPtsProc(); 1460 SkMatrix::MapPtsProc proc = matrix.getMapPtsProc();
1461 1461 bool firstVerb = true;
reed1 2014/02/07 18:08:01 can we change this to: bool firstVerb = (kExtend
1462 while ((verb = iter.next(pts)) != kDone_Verb) { 1462 while ((verb = iter.next(pts)) != kDone_Verb) {
1463 switch (verb) { 1463 switch (verb) {
1464 case kMove_Verb: 1464 case kMove_Verb:
1465 proc(matrix, &pts[0], &pts[0], 1); 1465 proc(matrix, &pts[0], &pts[0], 1);
1466 this->moveTo(pts[0]); 1466 if (firstVerb && mode == kJoin_AddPathMode) {
1467 this->lineTo(pts[0]);
1468 } else {
1469 this->moveTo(pts[0]);
1470 }
1467 break; 1471 break;
1468 case kLine_Verb: 1472 case kLine_Verb:
1469 proc(matrix, &pts[1], &pts[1], 1); 1473 proc(matrix, &pts[1], &pts[1], 1);
1470 this->lineTo(pts[1]); 1474 this->lineTo(pts[1]);
1471 break; 1475 break;
1472 case kQuad_Verb: 1476 case kQuad_Verb:
1473 proc(matrix, &pts[1], &pts[1], 2); 1477 proc(matrix, &pts[1], &pts[1], 2);
1474 this->quadTo(pts[1], pts[2]); 1478 this->quadTo(pts[1], pts[2]);
1475 break; 1479 break;
1476 case kConic_Verb: 1480 case kConic_Verb:
1477 proc(matrix, &pts[1], &pts[1], 2); 1481 proc(matrix, &pts[1], &pts[1], 2);
1478 this->conicTo(pts[1], pts[2], iter.conicWeight()); 1482 this->conicTo(pts[1], pts[2], iter.conicWeight());
1479 break; 1483 break;
1480 case kCubic_Verb: 1484 case kCubic_Verb:
1481 proc(matrix, &pts[1], &pts[1], 3); 1485 proc(matrix, &pts[1], &pts[1], 3);
1482 this->cubicTo(pts[1], pts[2], pts[3]); 1486 this->cubicTo(pts[1], pts[2], pts[3]);
1483 break; 1487 break;
1484 case kClose_Verb: 1488 case kClose_Verb:
1485 this->close(); 1489 this->close();
1486 break; 1490 break;
1487 default: 1491 default:
1488 SkDEBUGFAIL("unknown verb"); 1492 SkDEBUGFAIL("unknown verb");
1489 } 1493 }
1494 firstVerb = false;
1490 } 1495 }
1491 } 1496 }
1492 1497
1493 /////////////////////////////////////////////////////////////////////////////// 1498 ///////////////////////////////////////////////////////////////////////////////
1494 1499
1495 static int pts_in_verb(unsigned verb) { 1500 static int pts_in_verb(unsigned verb) {
1496 static const uint8_t gPtsInVerb[] = { 1501 static const uint8_t gPtsInVerb[] = {
1497 1, // kMove 1502 1, // kMove
1498 1, // kLine 1503 1, // kLine
1499 2, // kQuad 1504 2, // kQuad
(...skipping 1381 matching lines...) Expand 10 before | Expand all | Expand 10 after
2881 switch (this->getFillType()) { 2886 switch (this->getFillType()) {
2882 case SkPath::kEvenOdd_FillType: 2887 case SkPath::kEvenOdd_FillType:
2883 case SkPath::kInverseEvenOdd_FillType: 2888 case SkPath::kInverseEvenOdd_FillType:
2884 w &= 1; 2889 w &= 1;
2885 break; 2890 break;
2886 default: 2891 default:
2887 break; 2892 break;
2888 } 2893 }
2889 return SkToBool(w); 2894 return SkToBool(w);
2890 } 2895 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698