caryclark | 45fa447 | 2015-01-16 07:04:10 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
deanm | 12670eb | 2016-04-26 14:09:01 -0700 | [diff] [blame] | 7 | #ifndef SkPathOpsTSect_DEFINED |
| 8 | #define SkPathOpsTSect_DEFINED |
caryclark | 45fa447 | 2015-01-16 07:04:10 -0800 | [diff] [blame] | 9 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 10 | #include "include/private/SkMacros.h" |
Ben Wagner | 729a23f | 2019-05-17 16:29:34 -0400 | [diff] [blame] | 11 | #include "src/core/SkArenaAlloc.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 12 | #include "src/pathops/SkIntersections.h" |
| 13 | #include "src/pathops/SkPathOpsBounds.h" |
| 14 | #include "src/pathops/SkPathOpsRect.h" |
| 15 | #include "src/pathops/SkPathOpsTCurve.h" |
caryclark | 45fa447 | 2015-01-16 07:04:10 -0800 | [diff] [blame] | 16 | |
Ben Wagner | f08d1d0 | 2018-06-18 15:11:00 -0400 | [diff] [blame] | 17 | #include <utility> |
| 18 | |
caryclark | ed0935a | 2015-10-22 07:23:52 -0700 | [diff] [blame] | 19 | #ifdef SK_DEBUG |
| 20 | typedef uint8_t SkOpDebugBool; |
| 21 | #else |
| 22 | typedef bool SkOpDebugBool; |
| 23 | #endif |
| 24 | |
Cary Clark | 0949bee | 2018-03-19 09:42:00 -0400 | [diff] [blame] | 25 | static inline bool SkDoubleIsNaN(double x) { |
| 26 | return x != x; |
| 27 | } |
| 28 | |
caryclark | 45fa447 | 2015-01-16 07:04:10 -0800 | [diff] [blame] | 29 | class SkTCoincident { |
| 30 | public: |
caryclark | 697ac1c | 2015-04-13 09:36:01 -0700 | [diff] [blame] | 31 | SkTCoincident() { |
caryclark | df386c5 | 2015-04-21 05:27:02 -0700 | [diff] [blame] | 32 | this->init(); |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 33 | } |
| 34 | |
caryclark | ed0935a | 2015-10-22 07:23:52 -0700 | [diff] [blame] | 35 | void debugInit() { |
| 36 | #ifdef SK_DEBUG |
| 37 | this->fPerpPt.fX = this->fPerpPt.fY = SK_ScalarNaN; |
| 38 | this->fPerpT = SK_ScalarNaN; |
caryclark | 6c3b9cd | 2016-09-26 05:36:58 -0700 | [diff] [blame] | 39 | this->fMatch = 0xFF; |
caryclark | ed0935a | 2015-10-22 07:23:52 -0700 | [diff] [blame] | 40 | #endif |
| 41 | } |
| 42 | |
| 43 | char dumpIsCoincidentStr() const; |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 44 | void dump() const; |
| 45 | |
caryclark | 6c3b9cd | 2016-09-26 05:36:58 -0700 | [diff] [blame] | 46 | bool isMatch() const { |
| 47 | SkASSERT(!!fMatch == fMatch); |
| 48 | return SkToBool(fMatch); |
caryclark | 45fa447 | 2015-01-16 07:04:10 -0800 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | void init() { |
caryclark | df386c5 | 2015-04-21 05:27:02 -0700 | [diff] [blame] | 52 | fPerpT = -1; |
caryclark | 6c3b9cd | 2016-09-26 05:36:58 -0700 | [diff] [blame] | 53 | fMatch = false; |
caryclark | df386c5 | 2015-04-21 05:27:02 -0700 | [diff] [blame] | 54 | fPerpPt.fX = fPerpPt.fY = SK_ScalarNaN; |
caryclark | 45fa447 | 2015-01-16 07:04:10 -0800 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | void markCoincident() { |
caryclark | 6c3b9cd | 2016-09-26 05:36:58 -0700 | [diff] [blame] | 58 | if (!fMatch) { |
caryclark | 45fa447 | 2015-01-16 07:04:10 -0800 | [diff] [blame] | 59 | fPerpT = -1; |
| 60 | } |
caryclark | 6c3b9cd | 2016-09-26 05:36:58 -0700 | [diff] [blame] | 61 | fMatch = true; |
caryclark | 45fa447 | 2015-01-16 07:04:10 -0800 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | const SkDPoint& perpPt() const { |
| 65 | return fPerpPt; |
| 66 | } |
| 67 | |
| 68 | double perpT() const { |
| 69 | return fPerpT; |
| 70 | } |
| 71 | |
Cary Clark | 8762fb6 | 2018-10-16 16:06:24 -0400 | [diff] [blame] | 72 | void setPerp(const SkTCurve& c1, double t, const SkDPoint& cPt, const SkTCurve& ); |
caryclark | 45fa447 | 2015-01-16 07:04:10 -0800 | [diff] [blame] | 73 | |
| 74 | private: |
| 75 | SkDPoint fPerpPt; |
| 76 | double fPerpT; // perpendicular intersection on opposite curve |
caryclark | 6c3b9cd | 2016-09-26 05:36:58 -0700 | [diff] [blame] | 77 | SkOpDebugBool fMatch; |
caryclark | 45fa447 | 2015-01-16 07:04:10 -0800 | [diff] [blame] | 78 | }; |
| 79 | |
Cary Clark | 8762fb6 | 2018-10-16 16:06:24 -0400 | [diff] [blame] | 80 | class SkTSect; |
| 81 | class SkTSpan; |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 82 | |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 83 | struct SkTSpanBounded { |
Cary Clark | 8762fb6 | 2018-10-16 16:06:24 -0400 | [diff] [blame] | 84 | SkTSpan* fBounded; |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 85 | SkTSpanBounded* fNext; |
| 86 | }; |
caryclark | 45fa447 | 2015-01-16 07:04:10 -0800 | [diff] [blame] | 87 | |
caryclark | 45fa447 | 2015-01-16 07:04:10 -0800 | [diff] [blame] | 88 | class SkTSpan { |
| 89 | public: |
Cary Clark | 8762fb6 | 2018-10-16 16:06:24 -0400 | [diff] [blame] | 90 | SkTSpan(const SkTCurve& curve, SkArenaAlloc& heap) { |
Cary Clark | 0a67198 | 2018-10-11 12:16:49 -0400 | [diff] [blame] | 91 | fPart = curve.make(heap); |
Cary Clark | 0a67198 | 2018-10-11 12:16:49 -0400 | [diff] [blame] | 92 | } |
| 93 | |
Cary Clark | 8762fb6 | 2018-10-16 16:06:24 -0400 | [diff] [blame] | 94 | void addBounded(SkTSpan* , SkArenaAlloc* ); |
reed | 0dc4dd6 | 2015-03-24 13:55:33 -0700 | [diff] [blame] | 95 | double closestBoundedT(const SkDPoint& pt) const; |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 96 | bool contains(double t) const; |
reed | 0dc4dd6 | 2015-03-24 13:55:33 -0700 | [diff] [blame] | 97 | |
Cary Clark | 8762fb6 | 2018-10-16 16:06:24 -0400 | [diff] [blame] | 98 | void debugInit(const SkTCurve& curve, SkArenaAlloc& heap) { |
| 99 | #ifdef SK_DEBUG |
Leon Scroggins III | 577536a | 2020-07-31 13:47:50 -0400 | [diff] [blame] | 100 | SkTCurve* fake = curve.make(heap); |
| 101 | fake->debugInit(); |
| 102 | init(*fake); |
| 103 | initBounds(*fake); |
caryclark | df386c5 | 2015-04-21 05:27:02 -0700 | [diff] [blame] | 104 | fCoinStart.init(); |
| 105 | fCoinEnd.init(); |
Cary Clark | 0a67198 | 2018-10-11 12:16:49 -0400 | [diff] [blame] | 106 | #endif |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 107 | } |
| 108 | |
Cary Clark | 8762fb6 | 2018-10-16 16:06:24 -0400 | [diff] [blame] | 109 | const SkTSect* debugOpp() const; |
caryclark | 643ede6 | 2016-08-08 14:27:45 -0700 | [diff] [blame] | 110 | |
| 111 | #ifdef SK_DEBUG |
| 112 | void debugSetGlobalState(SkOpGlobalState* state) { |
| 113 | fDebugGlobalState = state; |
| 114 | } |
caryclark | 643ede6 | 2016-08-08 14:27:45 -0700 | [diff] [blame] | 115 | |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 116 | const SkTSpan* debugSpan(int ) const; |
| 117 | const SkTSpan* debugT(double t) const; |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 118 | bool debugIsBefore(const SkTSpan* span) const; |
| 119 | #endif |
| 120 | void dump() const; |
caryclark | 26ad22a | 2015-10-16 09:03:38 -0700 | [diff] [blame] | 121 | void dumpAll() const; |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 122 | void dumpBounded(int id) const; |
| 123 | void dumpBounds() const; |
| 124 | void dumpCoin() const; |
caryclark | 45fa447 | 2015-01-16 07:04:10 -0800 | [diff] [blame] | 125 | |
| 126 | double endT() const { |
| 127 | return fEndT; |
| 128 | } |
| 129 | |
Cary Clark | 8762fb6 | 2018-10-16 16:06:24 -0400 | [diff] [blame] | 130 | SkTSpan* findOppSpan(const SkTSpan* opp) const; |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 131 | |
Cary Clark | 8762fb6 | 2018-10-16 16:06:24 -0400 | [diff] [blame] | 132 | SkTSpan* findOppT(double t) const { |
| 133 | SkTSpan* result = oppT(t); |
caryclark | 643ede6 | 2016-08-08 14:27:45 -0700 | [diff] [blame] | 134 | SkOPASSERT(result); |
caryclark | 45fa447 | 2015-01-16 07:04:10 -0800 | [diff] [blame] | 135 | return result; |
| 136 | } |
| 137 | |
caryclark | 643ede6 | 2016-08-08 14:27:45 -0700 | [diff] [blame] | 138 | SkDEBUGCODE(SkOpGlobalState* globalState() const { return fDebugGlobalState; }) |
| 139 | |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 140 | bool hasOppT(double t) const { |
| 141 | return SkToBool(oppT(t)); |
| 142 | } |
| 143 | |
Cary Clark | 8762fb6 | 2018-10-16 16:06:24 -0400 | [diff] [blame] | 144 | int hullsIntersect(SkTSpan* span, bool* start, bool* oppStart); |
| 145 | void init(const SkTCurve& ); |
| 146 | bool initBounds(const SkTCurve& ); |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 147 | |
| 148 | bool isBounded() const { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 149 | return fBounded != nullptr; |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 150 | } |
| 151 | |
Cary Clark | 8762fb6 | 2018-10-16 16:06:24 -0400 | [diff] [blame] | 152 | bool linearsIntersect(SkTSpan* span); |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 153 | double linearT(const SkDPoint& ) const; |
| 154 | |
| 155 | void markCoincident() { |
| 156 | fCoinStart.markCoincident(); |
| 157 | fCoinEnd.markCoincident(); |
| 158 | } |
caryclark | 45fa447 | 2015-01-16 07:04:10 -0800 | [diff] [blame] | 159 | |
| 160 | const SkTSpan* next() const { |
| 161 | return fNext; |
| 162 | } |
| 163 | |
Cary Clark | 8762fb6 | 2018-10-16 16:06:24 -0400 | [diff] [blame] | 164 | bool onlyEndPointsInCommon(const SkTSpan* opp, bool* start, |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 165 | bool* oppStart, bool* ptsInCommon); |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 166 | |
Cary Clark | 8762fb6 | 2018-10-16 16:06:24 -0400 | [diff] [blame] | 167 | const SkTCurve& part() const { |
Cary Clark | 0a67198 | 2018-10-11 12:16:49 -0400 | [diff] [blame] | 168 | return *fPart; |
Cary Clark | 0a67198 | 2018-10-11 12:16:49 -0400 | [diff] [blame] | 169 | } |
| 170 | |
Cary Clark | 8762fb6 | 2018-10-16 16:06:24 -0400 | [diff] [blame] | 171 | int pointCount() const { |
| 172 | return fPart->pointCount(); |
| 173 | } |
| 174 | |
| 175 | const SkDPoint& pointFirst() const { |
| 176 | return (*fPart)[0]; |
| 177 | } |
| 178 | |
| 179 | const SkDPoint& pointLast() const { |
| 180 | return (*fPart)[fPart->pointLast()]; |
caryclark | 45fa447 | 2015-01-16 07:04:10 -0800 | [diff] [blame] | 181 | } |
| 182 | |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 183 | bool removeAllBounded(); |
Cary Clark | 8762fb6 | 2018-10-16 16:06:24 -0400 | [diff] [blame] | 184 | bool removeBounded(const SkTSpan* opp); |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 185 | |
caryclark | 45fa447 | 2015-01-16 07:04:10 -0800 | [diff] [blame] | 186 | void reset() { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 187 | fBounded = nullptr; |
caryclark | 45fa447 | 2015-01-16 07:04:10 -0800 | [diff] [blame] | 188 | } |
| 189 | |
Cary Clark | 8762fb6 | 2018-10-16 16:06:24 -0400 | [diff] [blame] | 190 | void resetBounds(const SkTCurve& curve) { |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 191 | fIsLinear = fIsLine = false; |
| 192 | initBounds(curve); |
caryclark | 45fa447 | 2015-01-16 07:04:10 -0800 | [diff] [blame] | 193 | } |
| 194 | |
Herb Derby | c3cc5fa | 2017-03-07 11:11:47 -0500 | [diff] [blame] | 195 | bool split(SkTSpan* work, SkArenaAlloc* heap) { |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 196 | return splitAt(work, (work->fStartT + work->fEndT) * 0.5, heap); |
| 197 | } |
| 198 | |
Herb Derby | c3cc5fa | 2017-03-07 11:11:47 -0500 | [diff] [blame] | 199 | bool splitAt(SkTSpan* work, double t, SkArenaAlloc* heap); |
caryclark | 45fa447 | 2015-01-16 07:04:10 -0800 | [diff] [blame] | 200 | |
| 201 | double startT() const { |
| 202 | return fStartT; |
| 203 | } |
| 204 | |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 205 | private: |
caryclark | 45fa447 | 2015-01-16 07:04:10 -0800 | [diff] [blame] | 206 | |
| 207 | // implementation is for testing only |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 208 | int debugID() const { |
| 209 | return PATH_OPS_DEBUG_T_SECT_RELEASE(fID, -1); |
caryclark | 45fa447 | 2015-01-16 07:04:10 -0800 | [diff] [blame] | 210 | } |
| 211 | |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 212 | void dumpID() const; |
caryclark | 45fa447 | 2015-01-16 07:04:10 -0800 | [diff] [blame] | 213 | |
Cary Clark | 8762fb6 | 2018-10-16 16:06:24 -0400 | [diff] [blame] | 214 | int hullCheck(const SkTSpan* opp, bool* start, bool* oppStart); |
| 215 | int linearIntersects(const SkTCurve& ) const; |
| 216 | SkTSpan* oppT(double t) const; |
caryclark | 45fa447 | 2015-01-16 07:04:10 -0800 | [diff] [blame] | 217 | |
caryclark | 45fa447 | 2015-01-16 07:04:10 -0800 | [diff] [blame] | 218 | void validate() const; |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 219 | void validateBounded() const; |
| 220 | void validatePerpT(double oppT) const; |
| 221 | void validatePerpPt(double t, const SkDPoint& ) const; |
caryclark | 45fa447 | 2015-01-16 07:04:10 -0800 | [diff] [blame] | 222 | |
Cary Clark | 8762fb6 | 2018-10-16 16:06:24 -0400 | [diff] [blame] | 223 | SkTCurve* fPart; |
| 224 | SkTCoincident fCoinStart; |
| 225 | SkTCoincident fCoinEnd; |
| 226 | SkTSpanBounded* fBounded; |
caryclark | 45fa447 | 2015-01-16 07:04:10 -0800 | [diff] [blame] | 227 | SkTSpan* fPrev; |
| 228 | SkTSpan* fNext; |
| 229 | SkDRect fBounds; |
| 230 | double fStartT; |
| 231 | double fEndT; |
| 232 | double fBoundsMax; |
caryclark | ed0935a | 2015-10-22 07:23:52 -0700 | [diff] [blame] | 233 | SkOpDebugBool fCollapsed; |
| 234 | SkOpDebugBool fHasPerp; |
| 235 | SkOpDebugBool fIsLinear; |
| 236 | SkOpDebugBool fIsLine; |
| 237 | SkOpDebugBool fDeleted; |
caryclark | 643ede6 | 2016-08-08 14:27:45 -0700 | [diff] [blame] | 238 | SkDEBUGCODE(SkOpGlobalState* fDebugGlobalState); |
Cary Clark | 8762fb6 | 2018-10-16 16:06:24 -0400 | [diff] [blame] | 239 | SkDEBUGCODE(SkTSect* fDebugSect); |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 240 | PATH_OPS_DEBUG_T_SECT_CODE(int fID); |
Cary Clark | 8762fb6 | 2018-10-16 16:06:24 -0400 | [diff] [blame] | 241 | friend class SkTSect; |
caryclark | 45fa447 | 2015-01-16 07:04:10 -0800 | [diff] [blame] | 242 | }; |
| 243 | |
caryclark | 45fa447 | 2015-01-16 07:04:10 -0800 | [diff] [blame] | 244 | class SkTSect { |
| 245 | public: |
Cary Clark | 8762fb6 | 2018-10-16 16:06:24 -0400 | [diff] [blame] | 246 | SkTSect(const SkTCurve& c |
| 247 | SkDEBUGPARAMS(SkOpGlobalState* ) PATH_OPS_DEBUG_T_SECT_PARAMS(int id)); |
| 248 | static void BinarySearch(SkTSect* sect1, SkTSect* sect2, |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 249 | SkIntersections* intersections); |
caryclark | 45fa447 | 2015-01-16 07:04:10 -0800 | [diff] [blame] | 250 | |
caryclark | e25a4f6 | 2016-07-26 09:26:29 -0700 | [diff] [blame] | 251 | SkDEBUGCODE(SkOpGlobalState* globalState() { return fDebugGlobalState; }) |
Cary Clark | 8762fb6 | 2018-10-16 16:06:24 -0400 | [diff] [blame] | 252 | bool hasBounded(const SkTSpan* ) const; |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 253 | |
Cary Clark | 8762fb6 | 2018-10-16 16:06:24 -0400 | [diff] [blame] | 254 | const SkTSect* debugOpp() const { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 255 | return SkDEBUGRELEASE(fOppSect, nullptr); |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 256 | } |
| 257 | |
Cary Clark | 8762fb6 | 2018-10-16 16:06:24 -0400 | [diff] [blame] | 258 | #ifdef SK_DEBUG |
| 259 | const SkTSpan* debugSpan(int id) const; |
| 260 | const SkTSpan* debugT(double t) const; |
| 261 | #endif |
caryclark | 45fa447 | 2015-01-16 07:04:10 -0800 | [diff] [blame] | 262 | void dump() const; |
Cary Clark | 8762fb6 | 2018-10-16 16:06:24 -0400 | [diff] [blame] | 263 | void dumpBoth(SkTSect* ) const; |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 264 | void dumpBounded(int id) const; |
| 265 | void dumpBounds() const; |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 266 | void dumpCoin() const; |
| 267 | void dumpCoinCurves() const; |
caryclark | 45fa447 | 2015-01-16 07:04:10 -0800 | [diff] [blame] | 268 | void dumpCurves() const; |
| 269 | |
| 270 | private: |
| 271 | enum { |
| 272 | kZeroS1Set = 1, |
| 273 | kOneS1Set = 2, |
| 274 | kZeroS2Set = 4, |
| 275 | kOneS2Set = 8 |
| 276 | }; |
| 277 | |
Cary Clark | 8762fb6 | 2018-10-16 16:06:24 -0400 | [diff] [blame] | 278 | SkTSpan* addFollowing(SkTSpan* prior); |
| 279 | void addForPerp(SkTSpan* span, double t); |
| 280 | SkTSpan* addOne(); |
caryclark | 55888e4 | 2016-07-18 10:01:36 -0700 | [diff] [blame] | 281 | |
Cary Clark | 8762fb6 | 2018-10-16 16:06:24 -0400 | [diff] [blame] | 282 | SkTSpan* addSplitAt(SkTSpan* span, double t) { |
| 283 | SkTSpan* result = this->addOne(); |
caryclark | 643ede6 | 2016-08-08 14:27:45 -0700 | [diff] [blame] | 284 | SkDEBUGCODE(result->debugSetGlobalState(this->globalState())); |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 285 | result->splitAt(span, t, &fHeap); |
| 286 | result->initBounds(fCurve); |
| 287 | span->initBounds(fCurve); |
| 288 | return result; |
| 289 | } |
| 290 | |
Cary Clark | 8762fb6 | 2018-10-16 16:06:24 -0400 | [diff] [blame] | 291 | bool binarySearchCoin(SkTSect* , double tStart, double tStep, double* t, |
| 292 | double* oppT, SkTSpan** oppFirst); |
| 293 | SkTSpan* boundsMax(); |
| 294 | bool coincidentCheck(SkTSect* sect2); |
| 295 | void coincidentForce(SkTSect* sect2, double start1s, double start1e); |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 296 | bool coincidentHasT(double t); |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 297 | int collapsed() const; |
Cary Clark | 8762fb6 | 2018-10-16 16:06:24 -0400 | [diff] [blame] | 298 | void computePerpendiculars(SkTSect* sect2, SkTSpan* first, |
| 299 | SkTSpan* last); |
| 300 | int countConsecutiveSpans(SkTSpan* first, |
| 301 | SkTSpan** last) const; |
caryclark | ccec0f9 | 2015-03-24 07:28:17 -0700 | [diff] [blame] | 302 | |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 303 | int debugID() const { |
| 304 | return PATH_OPS_DEBUG_T_SECT_RELEASE(fID, -1); |
| 305 | } |
| 306 | |
caryclark | ef7cee4 | 2016-09-06 09:05:54 -0700 | [diff] [blame] | 307 | bool deleteEmptySpans(); |
Cary Clark | 8762fb6 | 2018-10-16 16:06:24 -0400 | [diff] [blame] | 308 | void dumpCommon(const SkTSpan* ) const; |
| 309 | void dumpCommonCurves(const SkTSpan* ) const; |
| 310 | static int EndsEqual(const SkTSect* sect1, const SkTSect* sect2, |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 311 | SkIntersections* ); |
Cary Clark | 8762fb6 | 2018-10-16 16:06:24 -0400 | [diff] [blame] | 312 | bool extractCoincident(SkTSect* sect2, SkTSpan* first, |
| 313 | SkTSpan* last, SkTSpan** result); |
| 314 | SkTSpan* findCoincidentRun(SkTSpan* first, SkTSpan** lastPtr); |
| 315 | int intersects(SkTSpan* span, SkTSect* opp, |
| 316 | SkTSpan* oppSpan, int* oppResult); |
| 317 | bool isParallel(const SkDLine& thisLine, const SkTSect* opp) const; |
| 318 | int linesIntersect(SkTSpan* span, SkTSect* opp, |
| 319 | SkTSpan* oppSpan, SkIntersections* ); |
| 320 | bool markSpanGone(SkTSpan* span); |
| 321 | bool matchedDirection(double t, const SkTSect* sect2, double t2) const; |
| 322 | void matchedDirCheck(double t, const SkTSect* sect2, double t2, |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 323 | bool* calcMatched, bool* oppMatched) const; |
Cary Clark | 8762fb6 | 2018-10-16 16:06:24 -0400 | [diff] [blame] | 324 | void mergeCoincidence(SkTSect* sect2); |
| 325 | |
| 326 | const SkDPoint& pointLast() const { |
| 327 | return fCurve[fCurve.pointLast()]; |
| 328 | } |
| 329 | |
| 330 | SkTSpan* prev(SkTSpan* ) const; |
| 331 | bool removeByPerpendicular(SkTSect* opp); |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 332 | void recoverCollapsed(); |
Cary Clark | 8762fb6 | 2018-10-16 16:06:24 -0400 | [diff] [blame] | 333 | bool removeCoincident(SkTSpan* span, bool isBetween); |
| 334 | void removeAllBut(const SkTSpan* keep, SkTSpan* span, |
| 335 | SkTSect* opp); |
| 336 | bool removeSpan(SkTSpan* span); |
| 337 | void removeSpanRange(SkTSpan* first, SkTSpan* last); |
| 338 | bool removeSpans(SkTSpan* span, SkTSect* opp); |
| 339 | void removedEndCheck(SkTSpan* span); |
caryclark | 34efb70 | 2016-10-24 08:19:06 -0700 | [diff] [blame] | 340 | |
Herb Derby | c3cc5fa | 2017-03-07 11:11:47 -0500 | [diff] [blame] | 341 | void resetRemovedEnds() { |
caryclark | 34efb70 | 2016-10-24 08:19:06 -0700 | [diff] [blame] | 342 | fRemovedStartT = fRemovedEndT = false; |
| 343 | } |
| 344 | |
Cary Clark | 8762fb6 | 2018-10-16 16:06:24 -0400 | [diff] [blame] | 345 | SkTSpan* spanAtT(double t, SkTSpan** priorSpan); |
| 346 | SkTSpan* tail(); |
| 347 | bool trim(SkTSpan* span, SkTSect* opp); |
| 348 | bool unlinkSpan(SkTSpan* span); |
| 349 | bool updateBounded(SkTSpan* first, SkTSpan* last, |
| 350 | SkTSpan* oppFirst); |
reed | 0dc4dd6 | 2015-03-24 13:55:33 -0700 | [diff] [blame] | 351 | void validate() const; |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 352 | void validateBounded() const; |
| 353 | |
Cary Clark | 8762fb6 | 2018-10-16 16:06:24 -0400 | [diff] [blame] | 354 | const SkTCurve& fCurve; |
Mike Reed | 534e776 | 2018-11-05 07:46:38 -0500 | [diff] [blame] | 355 | SkSTArenaAlloc<1024> fHeap; |
Cary Clark | 8762fb6 | 2018-10-16 16:06:24 -0400 | [diff] [blame] | 356 | SkTSpan* fHead; |
| 357 | SkTSpan* fCoincident; |
| 358 | SkTSpan* fDeleted; |
caryclark | 45fa447 | 2015-01-16 07:04:10 -0800 | [diff] [blame] | 359 | int fActiveCount; |
caryclark | 6c3b9cd | 2016-09-26 05:36:58 -0700 | [diff] [blame] | 360 | bool fRemovedStartT; |
| 361 | bool fRemovedEndT; |
Cary Clark | 5de5233 | 2018-08-30 12:58:23 -0400 | [diff] [blame] | 362 | bool fHung; |
caryclark | e25a4f6 | 2016-07-26 09:26:29 -0700 | [diff] [blame] | 363 | SkDEBUGCODE(SkOpGlobalState* fDebugGlobalState); |
Cary Clark | 8762fb6 | 2018-10-16 16:06:24 -0400 | [diff] [blame] | 364 | SkDEBUGCODE(SkTSect* fOppSect); |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 365 | PATH_OPS_DEBUG_T_SECT_CODE(int fID); |
| 366 | PATH_OPS_DEBUG_T_SECT_CODE(int fDebugCount); |
caryclark | 45fa447 | 2015-01-16 07:04:10 -0800 | [diff] [blame] | 367 | #if DEBUG_T_SECT |
caryclark | 45fa447 | 2015-01-16 07:04:10 -0800 | [diff] [blame] | 368 | int fDebugAllocatedCount; |
| 369 | #endif |
Cary Clark | 8762fb6 | 2018-10-16 16:06:24 -0400 | [diff] [blame] | 370 | friend class SkTSpan; |
caryclark | 45fa447 | 2015-01-16 07:04:10 -0800 | [diff] [blame] | 371 | }; |
| 372 | |
deanm | 12670eb | 2016-04-26 14:09:01 -0700 | [diff] [blame] | 373 | #endif |