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

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

Issue 785933003: change SkPoint::setLength to set itself to (0,0) if it starting length is degenerate (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years 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 | « include/core/SkPoint.h ('k') | src/core/SkPoint.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 "SkBuffer.h" 10 #include "SkBuffer.h"
(...skipping 1269 matching lines...) Expand 10 before | Expand all | Expand 10 after
1280 DIRTY_AFTER_EDIT; 1280 DIRTY_AFTER_EDIT;
1281 SkDEBUGCODE(this->validate();) 1281 SkDEBUGCODE(this->validate();)
1282 } 1282 }
1283 1283
1284 /* 1284 /*
1285 Need to handle the case when the angle is sharp, and our computed end-points 1285 Need to handle the case when the angle is sharp, and our computed end-points
1286 for the arc go behind pt1 and/or p2... 1286 for the arc go behind pt1 and/or p2...
1287 */ 1287 */
1288 void SkPath::arcTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, 1288 void SkPath::arcTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2,
1289 SkScalar radius) { 1289 SkScalar radius) {
1290 SkVector before, after; 1290 if (radius == 0) {
1291 this->lineTo(x1, y1);
1292 return;
1293 }
1294
1295 SkVector before, after;
1291 1296
1292 // need to know our prev pt so we can construct tangent vectors 1297 // need to know our prev pt so we can construct tangent vectors
1293 { 1298 {
1294 SkPoint start; 1299 SkPoint start;
1295 this->getLastPt(&start); 1300 this->getLastPt(&start);
1296 // Handle degenerate cases by adding a line to the first point and 1301 // Handle degenerate cases by adding a line to the first point and
1297 // bailing out. 1302 // bailing out.
1298 if ((x1 == start.fX && y1 == start.fY) ||
1299 (x1 == x2 && y1 == y2) ||
1300 radius == 0) {
1301 this->lineTo(x1, y1);
1302 return;
1303 }
1304 before.setNormalize(x1 - start.fX, y1 - start.fY); 1303 before.setNormalize(x1 - start.fX, y1 - start.fY);
1305 after.setNormalize(x2 - x1, y2 - y1); 1304 after.setNormalize(x2 - x1, y2 - y1);
1306 } 1305 }
1307 1306
1308 SkScalar cosh = SkPoint::DotProduct(before, after); 1307 SkScalar cosh = SkPoint::DotProduct(before, after);
1309 SkScalar sinh = SkPoint::CrossProduct(before, after); 1308 SkScalar sinh = SkPoint::CrossProduct(before, after);
1310 1309
1311 if (SkScalarNearlyZero(sinh)) { // angle is too tight 1310 if (SkScalarNearlyZero(sinh)) { // angle is too tight
1312 this->lineTo(x1, y1); 1311 this->lineTo(x1, y1);
1313 return; 1312 return;
(...skipping 1565 matching lines...) Expand 10 before | Expand all | Expand 10 after
2879 switch (this->getFillType()) { 2878 switch (this->getFillType()) {
2880 case SkPath::kEvenOdd_FillType: 2879 case SkPath::kEvenOdd_FillType:
2881 case SkPath::kInverseEvenOdd_FillType: 2880 case SkPath::kInverseEvenOdd_FillType:
2882 w &= 1; 2881 w &= 1;
2883 break; 2882 break;
2884 default: 2883 default:
2885 break; 2884 break;
2886 } 2885 }
2887 return SkToBool(w); 2886 return SkToBool(w);
2888 } 2887 }
OLDNEW
« no previous file with comments | « include/core/SkPoint.h ('k') | src/core/SkPoint.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698