| 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 #ifdef SK_DEBUG | 10 #ifdef SK_DEBUG |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 bool swap) { | 35 bool swap) { |
| 36 return fContour->addPartialCoincident(fIndex, other.fContour, other.fInd
ex, ts, index, | 36 return fContour->addPartialCoincident(fIndex, other.fContour, other.fInd
ex, ts, index, |
| 37 swap); | 37 swap); |
| 38 } | 38 } |
| 39 | 39 |
| 40 // Avoid collapsing t values that are close to the same since | 40 // Avoid collapsing t values that are close to the same since |
| 41 // we walk ts to describe consecutive intersections. Since a pair of ts can | 41 // we walk ts to describe consecutive intersections. Since a pair of ts can |
| 42 // be nearly equal, any problems caused by this should be taken care | 42 // be nearly equal, any problems caused by this should be taken care |
| 43 // of later. | 43 // of later. |
| 44 // On the edge or out of range values are negative; add 2 to get end | 44 // On the edge or out of range values are negative; add 2 to get end |
| 45 int addT(const SkIntersectionHelper& other, const SkPoint& pt, double newT,
bool isNear) { | 45 int addT(const SkIntersectionHelper& other, const SkPoint& pt, double newT)
{ |
| 46 return fContour->addT(fIndex, other.fContour, other.fIndex, pt, newT, is
Near); | 46 return fContour->addT(fIndex, other.fContour, other.fIndex, pt, newT); |
| 47 } | 47 } |
| 48 | 48 |
| 49 int addSelfT(const SkIntersectionHelper& other, const SkPoint& pt, double ne
wT) { | 49 int addSelfT(const SkIntersectionHelper& other, const SkPoint& pt, double ne
wT) { |
| 50 return fContour->addSelfT(fIndex, other.fContour, other.fIndex, pt, newT
); | 50 return fContour->addSelfT(fIndex, other.fContour, other.fIndex, pt, newT
); |
| 51 } | 51 } |
| 52 | 52 |
| 53 bool advance() { | 53 bool advance() { |
| 54 return ++fIndex < fLast; | 54 return ++fIndex < fLast; |
| 55 } | 55 } |
| 56 | 56 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 70 | 70 |
| 71 bool isAdjacent(const SkIntersectionHelper& next) { | 71 bool isAdjacent(const SkIntersectionHelper& next) { |
| 72 return fContour == next.fContour && fIndex + 1 == next.fIndex; | 72 return fContour == next.fContour && fIndex + 1 == next.fIndex; |
| 73 } | 73 } |
| 74 | 74 |
| 75 bool isFirstLast(const SkIntersectionHelper& next) { | 75 bool isFirstLast(const SkIntersectionHelper& next) { |
| 76 return fContour == next.fContour && fIndex == 0 | 76 return fContour == next.fContour && fIndex == 0 |
| 77 && next.fIndex == fLast - 1; | 77 && next.fIndex == fLast - 1; |
| 78 } | 78 } |
| 79 | 79 |
| 80 bool isNear(double t1, double t2, const SkDPoint& pt1, const SkDPoint& pt2)
const { | |
| 81 const SkOpSegment& segment = fContour->segments()[fIndex]; | |
| 82 double mid = (t1 + t2) / 2; | |
| 83 SkDPoint midPtByT = segment.dPtAtT(mid); | |
| 84 SkDPoint midPtByAvg = SkDPoint::Mid(pt1, pt2); | |
| 85 return midPtByT.approximatelyEqual(midPtByAvg); | |
| 86 } | |
| 87 | |
| 88 bool isPartial(double t1, double t2, const SkDPoint& pt1, const SkDPoint& pt
2) const { | 80 bool isPartial(double t1, double t2, const SkDPoint& pt1, const SkDPoint& pt
2) const { |
| 89 const SkOpSegment& segment = fContour->segments()[fIndex]; | 81 const SkOpSegment& segment = fContour->segments()[fIndex]; |
| 90 double mid = (t1 + t2) / 2; | 82 double mid = (t1 + t2) / 2; |
| 91 SkDPoint midPtByT = segment.dPtAtT(mid); | 83 SkDPoint midPtByT = segment.dPtAtT(mid); |
| 92 SkDPoint midPtByAvg = SkDPoint::Mid(pt1, pt2); | 84 SkDPoint midPtByAvg = SkDPoint::Mid(pt1, pt2); |
| 93 return midPtByT.approximatelyPEqual(midPtByAvg); | 85 return midPtByT.approximatelyPEqual(midPtByAvg); |
| 94 } | 86 } |
| 95 | 87 |
| 96 SkScalar left() const { | 88 SkScalar left() const { |
| 97 return bounds().fLeft; | 89 return bounds().fLeft; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 SkDPoint::dump(pts()[3]); | 152 SkDPoint::dump(pts()[3]); |
| 161 } | 153 } |
| 162 } | 154 } |
| 163 #endif | 155 #endif |
| 164 | 156 |
| 165 private: | 157 private: |
| 166 SkOpContour* fContour; | 158 SkOpContour* fContour; |
| 167 int fIndex; | 159 int fIndex; |
| 168 int fLast; | 160 int fLast; |
| 169 }; | 161 }; |
| OLD | NEW |