OLD | NEW |
1 | |
2 /* | 1 /* |
3 * Copyright 2008 The Android Open Source Project | 2 * Copyright 2008 The Android Open Source Project |
4 * | 3 * |
5 * 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 |
6 * found in the LICENSE file. | 5 * found in the LICENSE file. |
7 */ | 6 */ |
8 | 7 |
9 | 8 |
10 #include "SkPathMeasure.h" | 9 #include "SkPathMeasure.h" |
11 #include "SkGeometry.h" | 10 #include "SkGeometry.h" |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 SkASSERT(fLength >= 0); | 519 SkASSERT(fLength >= 0); |
521 return fLength; | 520 return fLength; |
522 } | 521 } |
523 | 522 |
524 template <typename T, typename K> | 523 template <typename T, typename K> |
525 int SkTKSearch(const T base[], int count, const K& key) { | 524 int SkTKSearch(const T base[], int count, const K& key) { |
526 SkASSERT(count >= 0); | 525 SkASSERT(count >= 0); |
527 if (count <= 0) { | 526 if (count <= 0) { |
528 return ~0; | 527 return ~0; |
529 } | 528 } |
530 | 529 |
531 SkASSERT(base != nullptr); // base may be nullptr if count is zero | 530 SkASSERT(base != nullptr); // base may be nullptr if count is zero |
532 | 531 |
533 int lo = 0; | 532 int lo = 0; |
534 int hi = count - 1; | 533 int hi = count - 1; |
535 | 534 |
536 while (lo < hi) { | 535 while (lo < hi) { |
537 int mid = (hi + lo) >> 1; | 536 int mid = (hi + lo) >> 1; |
538 if (base[mid].fDistance < key) { | 537 if (base[mid].fDistance < key) { |
539 lo = mid + 1; | 538 lo = mid + 1; |
540 } else { | 539 } else { |
541 hi = mid; | 540 hi = mid; |
542 } | 541 } |
543 } | 542 } |
544 | 543 |
545 if (base[hi].fDistance < key) { | 544 if (base[hi].fDistance < key) { |
546 hi += 1; | 545 hi += 1; |
547 hi = ~hi; | 546 hi = ~hi; |
548 } else if (key < base[hi].fDistance) { | 547 } else if (key < base[hi].fDistance) { |
549 hi = ~hi; | 548 hi = ~hi; |
550 } | 549 } |
551 return hi; | 550 return hi; |
552 } | 551 } |
553 | 552 |
554 const SkPathMeasure::Segment* SkPathMeasure::distanceToSegment( | 553 const SkPathMeasure::Segment* SkPathMeasure::distanceToSegment( |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 | 702 |
704 for (int i = 0; i < fSegments.count(); i++) { | 703 for (int i = 0; i < fSegments.count(); i++) { |
705 const Segment* seg = &fSegments[i]; | 704 const Segment* seg = &fSegments[i]; |
706 SkDebugf("pathmeas: seg[%d] distance=%g, point=%d, t=%g, type=%d\n", | 705 SkDebugf("pathmeas: seg[%d] distance=%g, point=%d, t=%g, type=%d\n", |
707 i, seg->fDistance, seg->fPtIndex, seg->getScalarT(), | 706 i, seg->fDistance, seg->fPtIndex, seg->getScalarT(), |
708 seg->fType); | 707 seg->fType); |
709 } | 708 } |
710 } | 709 } |
711 | 710 |
712 #endif | 711 #endif |
OLD | NEW |