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 "SkOpContour.h" | 7 #include "SkOpContour.h" |
8 #include "SkPath.h" | 8 #include "SkPath.h" |
9 | 9 |
| 10 #if SK_DEBUG |
| 11 #include "SkPathOpsPoint.h" |
| 12 #endif |
| 13 |
10 class SkIntersectionHelper { | 14 class SkIntersectionHelper { |
11 public: | 15 public: |
12 enum SegmentType { | 16 enum SegmentType { |
13 kHorizontalLine_Segment = -1, | 17 kHorizontalLine_Segment = -1, |
14 kVerticalLine_Segment = 0, | 18 kVerticalLine_Segment = 0, |
15 kLine_Segment = SkPath::kLine_Verb, | 19 kLine_Segment = SkPath::kLine_Verb, |
16 kQuad_Segment = SkPath::kQuad_Verb, | 20 kQuad_Segment = SkPath::kQuad_Verb, |
17 kCubic_Segment = SkPath::kCubic_Verb, | 21 kCubic_Segment = SkPath::kCubic_Verb, |
18 }; | 22 }; |
19 | 23 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 } | 78 } |
75 | 79 |
76 bool isNear(double t1, double t2, const SkDPoint& pt1, const SkDPoint& pt2)
const { | 80 bool isNear(double t1, double t2, const SkDPoint& pt1, const SkDPoint& pt2)
const { |
77 const SkOpSegment& segment = fContour->segments()[fIndex]; | 81 const SkOpSegment& segment = fContour->segments()[fIndex]; |
78 double mid = (t1 + t2) / 2; | 82 double mid = (t1 + t2) / 2; |
79 SkDPoint midPtByT = segment.dPtAtT(mid); | 83 SkDPoint midPtByT = segment.dPtAtT(mid); |
80 SkDPoint midPtByAvg = SkDPoint::Mid(pt1, pt2); | 84 SkDPoint midPtByAvg = SkDPoint::Mid(pt1, pt2); |
81 return midPtByT.approximatelyEqual(midPtByAvg); | 85 return midPtByT.approximatelyEqual(midPtByAvg); |
82 } | 86 } |
83 | 87 |
| 88 bool isPartial(double t1, double t2, const SkDPoint& pt1, const SkDPoint& pt
2) const { |
| 89 const SkOpSegment& segment = fContour->segments()[fIndex]; |
| 90 double mid = (t1 + t2) / 2; |
| 91 SkDPoint midPtByT = segment.dPtAtT(mid); |
| 92 SkDPoint midPtByAvg = SkDPoint::Mid(pt1, pt2); |
| 93 return midPtByT.approximatelyPEqual(midPtByAvg); |
| 94 } |
| 95 |
84 SkScalar left() const { | 96 SkScalar left() const { |
85 return bounds().fLeft; | 97 return bounds().fLeft; |
86 } | 98 } |
87 | 99 |
88 const SkPoint* pts() const { | 100 const SkPoint* pts() const { |
89 return fContour->segments()[fIndex].pts(); | 101 return fContour->segments()[fIndex].pts(); |
90 } | 102 } |
91 | 103 |
92 SkScalar right() const { | 104 SkScalar right() const { |
93 return bounds().fRight; | 105 return bounds().fRight; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 } | 142 } |
131 | 143 |
132 SkScalar y() const { | 144 SkScalar y() const { |
133 return bounds().fTop; | 145 return bounds().fTop; |
134 } | 146 } |
135 | 147 |
136 bool yFlipped() const { | 148 bool yFlipped() const { |
137 return y() != pts()[0].fY; | 149 return y() != pts()[0].fY; |
138 } | 150 } |
139 | 151 |
| 152 #ifdef SK_DEBUG |
| 153 void dump() { |
| 154 SkDPoint::dump(pts()[0]); |
| 155 SkDPoint::dump(pts()[1]); |
| 156 if (verb() >= SkPath::kQuad_Verb) { |
| 157 SkDPoint::dump(pts()[2]); |
| 158 } |
| 159 if (verb() >= SkPath::kCubic_Verb) { |
| 160 SkDPoint::dump(pts()[3]); |
| 161 } |
| 162 } |
| 163 #endif |
| 164 |
140 private: | 165 private: |
141 SkOpContour* fContour; | 166 SkOpContour* fContour; |
142 int fIndex; | 167 int fIndex; |
143 int fLast; | 168 int fLast; |
144 }; | 169 }; |
OLD | NEW |