OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2008 The Android Open Source Project | 3 * Copyright 2008 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 "SkPathMeasure.h" | 10 #include "SkPathMeasure.h" |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 } | 382 } |
383 | 383 |
384 const SkPathMeasure::Segment* SkPathMeasure::distanceToSegment( | 384 const SkPathMeasure::Segment* SkPathMeasure::distanceToSegment( |
385 SkScalar distance, SkScalar* t) { | 385 SkScalar distance, SkScalar* t) { |
386 SkDEBUGCODE(SkScalar length = ) this->getLength(); | 386 SkDEBUGCODE(SkScalar length = ) this->getLength(); |
387 SkASSERT(distance >= 0 && distance <= length); | 387 SkASSERT(distance >= 0 && distance <= length); |
388 | 388 |
389 const Segment* seg = fSegments.begin(); | 389 const Segment* seg = fSegments.begin(); |
390 int count = fSegments.count(); | 390 int count = fSegments.count(); |
391 | 391 |
392 int index = SkTSearch<SkScalar>(&seg->fDistance, count, distance, | 392 int index = SkTSearch<SkScalar>(&seg->fDistance, count, distance, sizeof(Seg
ment)); |
393 sizeof(Segment)); | |
394 // don't care if we hit an exact match or not, so we xor index if it is nega
tive | 393 // don't care if we hit an exact match or not, so we xor index if it is nega
tive |
395 index ^= (index >> 31); | 394 index ^= (index >> 31); |
396 seg = &seg[index]; | 395 seg = &seg[index]; |
397 | 396 |
398 // now interpolate t-values with the prev segment (if possible) | 397 // now interpolate t-values with the prev segment (if possible) |
399 SkScalar startT = 0, startD = 0; | 398 SkScalar startT = 0, startD = 0; |
400 // check if the prev segment is legal, and references the same set of points | 399 // check if the prev segment is legal, and references the same set of points |
401 if (index > 0) { | 400 if (index > 0) { |
402 startD = seg[-1].fDistance; | 401 startD = seg[-1].fDistance; |
403 if (seg[-1].fPtIndex == seg->fPtIndex) { | 402 if (seg[-1].fPtIndex == seg->fPtIndex) { |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 | 530 |
532 for (int i = 0; i < fSegments.count(); i++) { | 531 for (int i = 0; i < fSegments.count(); i++) { |
533 const Segment* seg = &fSegments[i]; | 532 const Segment* seg = &fSegments[i]; |
534 SkDebugf("pathmeas: seg[%d] distance=%g, point=%d, t=%g, type=%d\n", | 533 SkDebugf("pathmeas: seg[%d] distance=%g, point=%d, t=%g, type=%d\n", |
535 i, seg->fDistance, seg->fPtIndex, seg->getScalarT(), | 534 i, seg->fDistance, seg->fPtIndex, seg->getScalarT(), |
536 seg->fType); | 535 seg->fType); |
537 } | 536 } |
538 } | 537 } |
539 | 538 |
540 #endif | 539 #endif |
OLD | NEW |