| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 #include "SkGeometry.h" | 7 #include "SkGeometry.h" |
| 8 #include "SkLineParameters.h" | 8 #include "SkLineParameters.h" |
| 9 #include "SkPathOpsConic.h" | 9 #include "SkPathOpsConic.h" |
| 10 #include "SkPathOpsCubic.h" | 10 #include "SkPathOpsCubic.h" |
| (...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 double a = src[0]; | 467 double a = src[0]; |
| 468 double b = src[2]; | 468 double b = src[2]; |
| 469 double c = src[4]; | 469 double c = src[4]; |
| 470 double d = src[6]; | 470 double d = src[6]; |
| 471 return 3 * ((b - a) * one_t * one_t + 2 * (c - b) * t * one_t + (d - c) * t
* t); | 471 return 3 * ((b - a) * one_t * one_t + 2 * (c - b) * t * one_t + (d - c) * t
* t); |
| 472 } | 472 } |
| 473 | 473 |
| 474 // OPTIMIZE? compute t^2, t(1-t), and (1-t)^2 and pass them to another version o
f derivative at t? | 474 // OPTIMIZE? compute t^2, t(1-t), and (1-t)^2 and pass them to another version o
f derivative at t? |
| 475 SkDVector SkDCubic::dxdyAtT(double t) const { | 475 SkDVector SkDCubic::dxdyAtT(double t) const { |
| 476 SkDVector result = { derivative_at_t(&fPts[0].fX, t), derivative_at_t(&fPts[
0].fY, t) }; | 476 SkDVector result = { derivative_at_t(&fPts[0].fX, t), derivative_at_t(&fPts[
0].fY, t) }; |
| 477 if (result.fX == 0 && result.fY == 0) { |
| 478 if (t == 0) { |
| 479 result = fPts[2] - fPts[0]; |
| 480 } else if (t == 1) { |
| 481 result = fPts[3] - fPts[1]; |
| 482 } else { |
| 483 // incomplete |
| 484 SkDebugf("!c"); |
| 485 } |
| 486 if (result.fX == 0 && result.fY == 0 && zero_or_one(t)) { |
| 487 result = fPts[3] - fPts[0]; |
| 488 } |
| 489 } |
| 477 return result; | 490 return result; |
| 478 } | 491 } |
| 479 | 492 |
| 480 // OPTIMIZE? share code with formulate_F1DotF2 | 493 // OPTIMIZE? share code with formulate_F1DotF2 |
| 481 int SkDCubic::findInflections(double tValues[]) const { | 494 int SkDCubic::findInflections(double tValues[]) const { |
| 482 double Ax = fPts[1].fX - fPts[0].fX; | 495 double Ax = fPts[1].fX - fPts[0].fX; |
| 483 double Ay = fPts[1].fY - fPts[0].fY; | 496 double Ay = fPts[1].fY - fPts[0].fY; |
| 484 double Bx = fPts[2].fX - 2 * fPts[1].fX + fPts[0].fX; | 497 double Bx = fPts[2].fX - 2 * fPts[1].fX + fPts[0].fX; |
| 485 double By = fPts[2].fY - 2 * fPts[1].fY + fPts[0].fY; | 498 double By = fPts[2].fY - 2 * fPts[1].fY + fPts[0].fY; |
| 486 double Cx = fPts[3].fX + 3 * (fPts[1].fX - fPts[2].fX) - fPts[0].fX; | 499 double Cx = fPts[3].fX + 3 * (fPts[1].fX - fPts[2].fX) - fPts[0].fX; |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 for (int index = 0; index < roots; ++index) { | 692 for (int index = 0; index < roots; ++index) { |
| 680 double t = startT + (endT - startT) * extremeTs[index]; | 693 double t = startT + (endT - startT) * extremeTs[index]; |
| 681 SkDPoint mid = dCurve.ptAtT(t); | 694 SkDPoint mid = dCurve.ptAtT(t); |
| 682 if (topPt->fY > mid.fY || (topPt->fY == mid.fY && topPt->fX > mid.fX)) { | 695 if (topPt->fY > mid.fY || (topPt->fY == mid.fY && topPt->fX > mid.fX)) { |
| 683 topT = t; | 696 topT = t; |
| 684 *topPt = mid; | 697 *topPt = mid; |
| 685 } | 698 } |
| 686 } | 699 } |
| 687 return topT; | 700 return topT; |
| 688 } | 701 } |
| OLD | NEW |