| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 #ifndef SkOpContour_DEFINED | 7 #ifndef SkOpContour_DEFINED |
| 8 #define SkOpContour_DEFINED | 8 #define SkOpContour_DEFINED |
| 9 | 9 |
| 10 #include "SkOpSegment.h" | 10 #include "SkOpSegment.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 fID = ++SkPathOpsDebug::gContourID; | 29 fID = ++SkPathOpsDebug::gContourID; |
| 30 #endif | 30 #endif |
| 31 } | 31 } |
| 32 | 32 |
| 33 bool operator<(const SkOpContour& rh) const { | 33 bool operator<(const SkOpContour& rh) const { |
| 34 return fBounds.fTop == rh.fBounds.fTop | 34 return fBounds.fTop == rh.fBounds.fTop |
| 35 ? fBounds.fLeft < rh.fBounds.fLeft | 35 ? fBounds.fLeft < rh.fBounds.fLeft |
| 36 : fBounds.fTop < rh.fBounds.fTop; | 36 : fBounds.fTop < rh.fBounds.fTop; |
| 37 } | 37 } |
| 38 | 38 |
| 39 void addCoincident(int index, SkOpContour* other, int otherIndex, | 39 bool addCoincident(int index, SkOpContour* other, int otherIndex, |
| 40 const SkIntersections& ts, bool swap); | 40 const SkIntersections& ts, bool swap); |
| 41 void addCoincidentPoints(); | 41 void addCoincidentPoints(); |
| 42 | 42 |
| 43 void addCross(const SkOpContour* crosser) { | 43 void addCross(const SkOpContour* crosser) { |
| 44 #ifdef DEBUG_CROSS | 44 #ifdef DEBUG_CROSS |
| 45 for (int index = 0; index < fCrosses.count(); ++index) { | 45 for (int index = 0; index < fCrosses.count(); ++index) { |
| 46 SkASSERT(fCrosses[index] != crosser); | 46 SkASSERT(fCrosses[index] != crosser); |
| 47 } | 47 } |
| 48 #endif | 48 #endif |
| 49 fCrosses.push_back(crosser); | 49 fCrosses.push_back(crosser); |
| 50 } | 50 } |
| 51 | 51 |
| 52 void addCubic(const SkPoint pts[4]) { | 52 void addCubic(const SkPoint pts[4]) { |
| 53 fSegments.push_back().addCubic(pts, fOperand, fXor); | 53 fSegments.push_back().addCubic(pts, fOperand, fXor); |
| 54 fContainsCurves = fContainsCubics = true; | 54 fContainsCurves = fContainsCubics = true; |
| 55 } | 55 } |
| 56 | 56 |
| 57 int addLine(const SkPoint pts[2]) { | 57 int addLine(const SkPoint pts[2]) { |
| 58 fSegments.push_back().addLine(pts, fOperand, fXor); | 58 fSegments.push_back().addLine(pts, fOperand, fXor); |
| 59 return fSegments.count(); | 59 return fSegments.count(); |
| 60 } | 60 } |
| 61 | 61 |
| 62 void addOtherT(int segIndex, int tIndex, double otherT, int otherIndex) { | 62 void addOtherT(int segIndex, int tIndex, double otherT, int otherIndex) { |
| 63 fSegments[segIndex].addOtherT(tIndex, otherT, otherIndex); | 63 fSegments[segIndex].addOtherT(tIndex, otherT, otherIndex); |
| 64 } | 64 } |
| 65 | 65 |
| 66 void addPartialCoincident(int index, SkOpContour* other, int otherIndex, | 66 bool addPartialCoincident(int index, SkOpContour* other, int otherIndex, |
| 67 const SkIntersections& ts, int ptIndex, bool swap); | 67 const SkIntersections& ts, int ptIndex, bool swap); |
| 68 | 68 |
| 69 int addQuad(const SkPoint pts[3]) { | 69 int addQuad(const SkPoint pts[3]) { |
| 70 fSegments.push_back().addQuad(pts, fOperand, fXor); | 70 fSegments.push_back().addQuad(pts, fOperand, fXor); |
| 71 fContainsCurves = true; | 71 fContainsCurves = true; |
| 72 return fSegments.count(); | 72 return fSegments.count(); |
| 73 } | 73 } |
| 74 | 74 |
| 75 int addT(int segIndex, SkOpContour* other, int otherIndex, const SkPoint& pt
, double newT, | 75 int addT(int segIndex, SkOpContour* other, int otherIndex, const SkPoint& pt
, double newT, |
| 76 bool isNear) { | 76 bool isNear) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 93 void checkEnds() { | 93 void checkEnds() { |
| 94 if (!fContainsCurves) { | 94 if (!fContainsCurves) { |
| 95 return; | 95 return; |
| 96 } | 96 } |
| 97 int segmentCount = fSegments.count(); | 97 int segmentCount = fSegments.count(); |
| 98 for (int sIndex = 0; sIndex < segmentCount; ++sIndex) { | 98 for (int sIndex = 0; sIndex < segmentCount; ++sIndex) { |
| 99 SkOpSegment* segment = &fSegments[sIndex]; | 99 SkOpSegment* segment = &fSegments[sIndex]; |
| 100 if (segment->verb() == SkPath::kLine_Verb) { | 100 if (segment->verb() == SkPath::kLine_Verb) { |
| 101 continue; | 101 continue; |
| 102 } | 102 } |
| 103 if (segment->done()) { |
| 104 continue; // likely coincident, nothing to do |
| 105 } |
| 103 segment->checkEnds(); | 106 segment->checkEnds(); |
| 104 } | 107 } |
| 105 } | 108 } |
| 106 | 109 |
| 107 // if same point has different T values, choose a common T | 110 // if same point has different T values, choose a common T |
| 108 void checkTiny() { | 111 void checkTiny() { |
| 109 int segmentCount = fSegments.count(); | 112 int segmentCount = fSegments.count(); |
| 110 if (segmentCount <= 2) { | 113 if (segmentCount <= 2) { |
| 111 return; | 114 return; |
| 112 } | 115 } |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 bool fDone; | 255 bool fDone; |
| 253 bool fOperand; // true for the second argument to a binary operator | 256 bool fOperand; // true for the second argument to a binary operator |
| 254 bool fXor; | 257 bool fXor; |
| 255 bool fOppXor; | 258 bool fOppXor; |
| 256 #ifdef SK_DEBUG | 259 #ifdef SK_DEBUG |
| 257 int fID; | 260 int fID; |
| 258 #endif | 261 #endif |
| 259 }; | 262 }; |
| 260 | 263 |
| 261 #endif | 264 #endif |
| OLD | NEW |