| 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 18 matching lines...) Expand all Loading... |
| 29 // also, copy point rather than recompute it when it does change | 29 // also, copy point rather than recompute it when it does change |
| 30 double SkDCubic::binarySearch(double min, double max, double axisIntercept, | 30 double SkDCubic::binarySearch(double min, double max, double axisIntercept, |
| 31 SearchAxis xAxis) const { | 31 SearchAxis xAxis) const { |
| 32 double t = (min + max) / 2; | 32 double t = (min + max) / 2; |
| 33 double step = (t - min) / 2; | 33 double step = (t - min) / 2; |
| 34 SkDPoint cubicAtT = ptAtT(t); | 34 SkDPoint cubicAtT = ptAtT(t); |
| 35 double calcPos = (&cubicAtT.fX)[xAxis]; | 35 double calcPos = (&cubicAtT.fX)[xAxis]; |
| 36 double calcDist = calcPos - axisIntercept; | 36 double calcDist = calcPos - axisIntercept; |
| 37 do { | 37 do { |
| 38 double priorT = t - step; | 38 double priorT = t - step; |
| 39 SkASSERT(priorT >= min); | 39 SkOPASSERT(priorT >= min); |
| 40 SkDPoint lessPt = ptAtT(priorT); | 40 SkDPoint lessPt = ptAtT(priorT); |
| 41 if (approximately_equal_half(lessPt.fX, cubicAtT.fX) | 41 if (approximately_equal_half(lessPt.fX, cubicAtT.fX) |
| 42 && approximately_equal_half(lessPt.fY, cubicAtT.fY)) { | 42 && approximately_equal_half(lessPt.fY, cubicAtT.fY)) { |
| 43 return -1; // binary search found no point at this axis intercept | 43 return -1; // binary search found no point at this axis intercept |
| 44 } | 44 } |
| 45 double lessDist = (&lessPt.fX)[xAxis] - axisIntercept; | 45 double lessDist = (&lessPt.fX)[xAxis] - axisIntercept; |
| 46 #if DEBUG_CUBIC_BINARY_SEARCH | 46 #if DEBUG_CUBIC_BINARY_SEARCH |
| 47 SkDebugf("t=%1.9g calc=%1.9g dist=%1.9g step=%1.9g less=%1.9g\n", t, cal
cPos, calcDist, | 47 SkDebugf("t=%1.9g calc=%1.9g dist=%1.9g step=%1.9g less=%1.9g\n", t, cal
cPos, calcDist, |
| 48 step, lessDist); | 48 step, lessDist); |
| 49 #endif | 49 #endif |
| (...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 697 for (int index = 0; index < roots; ++index) { | 697 for (int index = 0; index < roots; ++index) { |
| 698 double t = startT + (endT - startT) * extremeTs[index]; | 698 double t = startT + (endT - startT) * extremeTs[index]; |
| 699 SkDPoint mid = dCurve.ptAtT(t); | 699 SkDPoint mid = dCurve.ptAtT(t); |
| 700 if (topPt->fY > mid.fY || (topPt->fY == mid.fY && topPt->fX > mid.fX)) { | 700 if (topPt->fY > mid.fY || (topPt->fY == mid.fY && topPt->fX > mid.fX)) { |
| 701 topT = t; | 701 topT = t; |
| 702 *topPt = mid; | 702 *topPt = mid; |
| 703 } | 703 } |
| 704 } | 704 } |
| 705 return topT; | 705 return topT; |
| 706 } | 706 } |
| OLD | NEW |