| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
| 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 | 7 |
| 8 #ifndef SkPathMeasure_DEFINED | 8 #ifndef SkPathMeasure_DEFINED |
| 9 #define SkPathMeasure_DEFINED | 9 #define SkPathMeasure_DEFINED |
| 10 | 10 |
| 11 #include "SkPath.h" | 11 #include "SkPath.h" |
| 12 #include "SkTDArray.h" | 12 #include "SkTDArray.h" |
| 13 | 13 |
| 14 struct SkConic; | 14 struct SkConic; |
| 15 | 15 |
| 16 class SK_API SkPathMeasure : SkNoncopyable { | 16 class SK_API SkPathMeasure : SkNoncopyable { |
| 17 public: | 17 public: |
| 18 SkPathMeasure(); | 18 SkPathMeasure(); |
| 19 /** Initialize the pathmeasure with the specified path. The path must remain
valid | 19 /** Initialize the pathmeasure with the specified path. The path must remain
valid |
| 20 for the lifetime of the measure object, or until setPath() is called wit
h | 20 for the lifetime of the measure object, or until setPath() is called wit
h |
| 21 a different path (or null), since the measure object keeps a pointer to
the | 21 a different path (or null), since the measure object keeps a pointer to
the |
| 22 path object (does not copy its data). | 22 path object (does not copy its data). |
| 23 |
| 24 resScale controls the precision of the measure. values > 1 increase the |
| 25 precision (and possible slow down the computation). |
| 23 */ | 26 */ |
| 24 SkPathMeasure(const SkPath& path, bool forceClosed); | 27 SkPathMeasure(const SkPath& path, bool forceClosed, SkScalar resScale = 1); |
| 25 ~SkPathMeasure(); | 28 ~SkPathMeasure(); |
| 26 | 29 |
| 27 /** Reset the pathmeasure with the specified path. The path must remain vali
d | 30 /** Reset the pathmeasure with the specified path. The path must remain vali
d |
| 28 for the lifetime of the measure object, or until setPath() is called wit
h | 31 for the lifetime of the measure object, or until setPath() is called wit
h |
| 29 a different path (or null), since the measure object keeps a pointer to
the | 32 a different path (or null), since the measure object keeps a pointer to
the |
| 30 path object (does not copy its data). | 33 path object (does not copy its data). |
| 31 */ | 34 */ |
| 32 void setPath(const SkPath*, bool forceClosed); | 35 void setPath(const SkPath*, bool forceClosed); |
| 33 | 36 |
| 34 /** Return the total length of the current contour, or 0 if no path | 37 /** Return the total length of the current contour, or 0 if no path |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 */ | 78 */ |
| 76 bool nextContour(); | 79 bool nextContour(); |
| 77 | 80 |
| 78 #ifdef SK_DEBUG | 81 #ifdef SK_DEBUG |
| 79 void dump(); | 82 void dump(); |
| 80 #endif | 83 #endif |
| 81 | 84 |
| 82 private: | 85 private: |
| 83 SkPath::Iter fIter; | 86 SkPath::Iter fIter; |
| 84 const SkPath* fPath; | 87 const SkPath* fPath; |
| 88 SkScalar fTolerance; |
| 85 SkScalar fLength; // relative to the current contour | 89 SkScalar fLength; // relative to the current contour |
| 86 int fFirstPtIndex; // relative to the current contour | 90 int fFirstPtIndex; // relative to the current contour |
| 87 bool fIsClosed; // relative to the current contour | 91 bool fIsClosed; // relative to the current contour |
| 88 bool fForceClosed; | 92 bool fForceClosed; |
| 89 | 93 |
| 90 struct Segment { | 94 struct Segment { |
| 91 SkScalar fDistance; // total distance up to this point | 95 SkScalar fDistance; // total distance up to this point |
| 92 unsigned fPtIndex; // index into the fPts array | 96 unsigned fPtIndex; // index into the fPts array |
| 93 #ifdef SK_SUPPORT_LEGACY_PATH_MEASURE_TVALUE | 97 #ifdef SK_SUPPORT_LEGACY_PATH_MEASURE_TVALUE |
| 94 unsigned fTValue : 15; | 98 unsigned fTValue : 15; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 110 #ifdef SK_SUPPORT_LEGACY_CONIC_MEASURE | 114 #ifdef SK_SUPPORT_LEGACY_CONIC_MEASURE |
| 111 SkScalar compute_conic_segs(const SkConic&, SkScalar distance, int mint, int
maxt, int ptIndex); | 115 SkScalar compute_conic_segs(const SkConic&, SkScalar distance, int mint, int
maxt, int ptIndex); |
| 112 #else | 116 #else |
| 113 SkScalar compute_conic_segs(const SkConic&, SkScalar distance, | 117 SkScalar compute_conic_segs(const SkConic&, SkScalar distance, |
| 114 int mint, const SkPoint& minPt, | 118 int mint, const SkPoint& minPt, |
| 115 int maxt, const SkPoint& maxPt, int ptIndex); | 119 int maxt, const SkPoint& maxPt, int ptIndex); |
| 116 #endif | 120 #endif |
| 117 SkScalar compute_cubic_segs(const SkPoint pts[3], SkScalar distance, | 121 SkScalar compute_cubic_segs(const SkPoint pts[3], SkScalar distance, |
| 118 int mint, int maxt, int ptIndex); | 122 int mint, int maxt, int ptIndex); |
| 119 const Segment* distanceToSegment(SkScalar distance, SkScalar* t); | 123 const Segment* distanceToSegment(SkScalar distance, SkScalar* t); |
| 124 bool quad_too_curvy(const SkPoint pts[3]); |
| 125 #ifndef SK_SUPPORT_LEGACY_CONIC_MEASURE |
| 126 bool conic_too_curvy(const SkPoint& firstPt, const SkPoint& midTPt,const SkP
oint& lastPt); |
| 127 #endif |
| 128 bool cheap_dist_exceeds_limit(const SkPoint& pt, SkScalar x, SkScalar y); |
| 129 bool cubic_too_curvy(const SkPoint pts[4]); |
| 120 }; | 130 }; |
| 121 | 131 |
| 122 #endif | 132 #endif |
| OLD | NEW |