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" |
11 #include "SkGeometry.h" | 11 #include "SkGeometry.h" |
12 #include "SkPath.h" | 12 #include "SkPath.h" |
13 #include "SkTSearch.h" | 13 #include "SkTSearch.h" |
14 | 14 |
15 // these must be 0,1,2 since they are in our 2-bit field | 15 // these must be 0,1,2 since they are in our 2-bit field |
16 enum { | 16 enum { |
17 kLine_SegType, | 17 kLine_SegType, |
18 kQuad_SegType, | 18 kQuad_SegType, |
19 kCubic_SegType | 19 kCubic_SegType |
20 }; | 20 }; |
21 | 21 |
22 #define kMaxTValue 32767 | 22 #define kMaxTValue 32767 |
23 | 23 |
24 static inline SkScalar tValue2Scalar(int t) { | 24 static inline SkScalar tValue2Scalar(int t) { |
25 SkASSERT((unsigned)t <= kMaxTValue); | 25 SkASSERT((unsigned)t <= kMaxTValue); |
26 | |
27 #ifdef SK_SCALAR_IS_FLOAT | |
28 return t * 3.05185e-5f; // t / 32767 | 26 return t * 3.05185e-5f; // t / 32767 |
29 #else | |
30 return (t + (t >> 14)) << 1; | |
31 #endif | |
32 } | 27 } |
33 | 28 |
34 SkScalar SkPathMeasure::Segment::getScalarT() const { | 29 SkScalar SkPathMeasure::Segment::getScalarT() const { |
35 return tValue2Scalar(fTValue); | 30 return tValue2Scalar(fTValue); |
36 } | 31 } |
37 | 32 |
38 const SkPathMeasure::Segment* SkPathMeasure::NextSegment(const Segment* seg) { | 33 const SkPathMeasure::Segment* SkPathMeasure::NextSegment(const Segment* seg) { |
39 unsigned ptIndex = seg->fPtIndex; | 34 unsigned ptIndex = seg->fPtIndex; |
40 | 35 |
41 do { | 36 do { |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 | 528 |
534 for (int i = 0; i < fSegments.count(); i++) { | 529 for (int i = 0; i < fSegments.count(); i++) { |
535 const Segment* seg = &fSegments[i]; | 530 const Segment* seg = &fSegments[i]; |
536 SkDebugf("pathmeas: seg[%d] distance=%g, point=%d, t=%g, type=%d\n", | 531 SkDebugf("pathmeas: seg[%d] distance=%g, point=%d, t=%g, type=%d\n", |
537 i, seg->fDistance, seg->fPtIndex, seg->getScalarT(), | 532 i, seg->fDistance, seg->fPtIndex, seg->getScalarT(), |
538 seg->fType); | 533 seg->fType); |
539 } | 534 } |
540 } | 535 } |
541 | 536 |
542 #endif | 537 #endif |
OLD | NEW |