| 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 "SkIntersections.h" | 7 #include "SkIntersections.h" |
| 8 #include "SkOpAngle.h" | 8 #include "SkOpAngle.h" |
| 9 #include "SkPathOpsCurve.h" | 9 #include "SkPathOpsCurve.h" |
| 10 #include "TSearch.h" | 10 #include "SkTSort.h" |
| 11 | 11 |
| 12 // FIXME: this is bogus for quads and cubics | 12 // FIXME: this is bogus for quads and cubics |
| 13 // if the quads and cubics' line from end pt to ctrl pt are coincident, | 13 // if the quads and cubics' line from end pt to ctrl pt are coincident, |
| 14 // there's no obvious way to determine the curve ordering from the | 14 // there's no obvious way to determine the curve ordering from the |
| 15 // derivatives alone. In particular, if one quadratic's coincident tangent | 15 // derivatives alone. In particular, if one quadratic's coincident tangent |
| 16 // is longer than the other curve, the final control point can place the | 16 // is longer than the other curve, the final control point can place the |
| 17 // longer curve on either side of the shorter one. | 17 // longer curve on either side of the shorter one. |
| 18 // Using Bezier curve focus http://cagd.cs.byu.edu/~tom/papers/bezclip.pdf | 18 // Using Bezier curve focus http://cagd.cs.byu.edu/~tom/papers/bezclip.pdf |
| 19 // may provide some help, but nothing has been figured out yet. | 19 // may provide some help, but nothing has been figured out yet. |
| 20 | 20 |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 int testCount = SkDCubic::FindInflections(fPts, testTs); | 214 int testCount = SkDCubic::FindInflections(fPts, testTs); |
| 215 double limitT = endT; | 215 double limitT = endT; |
| 216 int index; | 216 int index; |
| 217 for (index = 0; index < testCount; ++index) { | 217 for (index = 0; index < testCount; ++index) { |
| 218 if (!between(startT, testTs[index], limitT)) { | 218 if (!between(startT, testTs[index], limitT)) { |
| 219 testTs[index] = -1; | 219 testTs[index] = -1; |
| 220 } | 220 } |
| 221 } | 221 } |
| 222 testTs[testCount++] = startT; | 222 testTs[testCount++] = startT; |
| 223 testTs[testCount++] = endT; | 223 testTs[testCount++] = endT; |
| 224 QSort<double>(testTs, &testTs[testCount - 1]); | 224 SkTQSort<double>(testTs, &testTs[testCount - 1]); |
| 225 double bestSide = 0; | 225 double bestSide = 0; |
| 226 int testCases = (testCount << 1) - 1; | 226 int testCases = (testCount << 1) - 1; |
| 227 index = 0; | 227 index = 0; |
| 228 while (testTs[index] < 0) { | 228 while (testTs[index] < 0) { |
| 229 ++index; | 229 ++index; |
| 230 } | 230 } |
| 231 index <<= 1; | 231 index <<= 1; |
| 232 for (; index < testCases; ++index) { | 232 for (; index < testCases; ++index) { |
| 233 int testIndex = index >> 1; | 233 int testIndex = index >> 1; |
| 234 double testT = testTs[testIndex]; | 234 double testT = testTs[testIndex]; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 #if 1 | 280 #if 1 |
| 281 #if DEBUG_UNSORTABLE | 281 #if DEBUG_UNSORTABLE |
| 282 SkPoint iPt = (*CurvePointAtT[fVerb])(fPts, startT); | 282 SkPoint iPt = (*CurvePointAtT[fVerb])(fPts, startT); |
| 283 SkPoint ePt = (*CurvePointAtT[fVerb])(fPts, endT); | 283 SkPoint ePt = (*CurvePointAtT[fVerb])(fPts, endT); |
| 284 SkDebugf("%s all tiny unsortable [%d] (%1.9g,%1.9g) [%d] (%1.9g,%1.9g)\n", _
_FUNCTION__, | 284 SkDebugf("%s all tiny unsortable [%d] (%1.9g,%1.9g) [%d] (%1.9g,%1.9g)\n", _
_FUNCTION__, |
| 285 fStart, iPt.fX, iPt.fY, fEnd, ePt.fX, ePt.fY); | 285 fStart, iPt.fX, iPt.fY, fEnd, ePt.fX, ePt.fY); |
| 286 #endif | 286 #endif |
| 287 fUnsortable = true; | 287 fUnsortable = true; |
| 288 #endif | 288 #endif |
| 289 } | 289 } |
| OLD | NEW |