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 #ifndef SkOpSegment_DEFINE | 7 #ifndef SkOpSegment_DEFINE |
8 #define SkOpSegment_DEFINE | 8 #define SkOpSegment_DEFINE |
9 | 9 |
10 #include "SkOpAngle.h" | 10 #include "SkOpAngle.h" |
| 11 #include "SkOpSpan.h" |
11 #include "SkPathOpsBounds.h" | 12 #include "SkPathOpsBounds.h" |
12 #include "SkPathOpsCurve.h" | 13 #include "SkPathOpsCurve.h" |
13 #include "SkTDArray.h" | 14 #include "SkTDArray.h" |
14 | 15 |
15 class SkPathWriter; | 16 class SkPathWriter; |
16 | 17 |
17 class SkOpSegment { | 18 class SkOpSegment { |
18 public: | 19 public: |
19 SkOpSegment() { | 20 SkOpSegment() { |
20 #if DEBUG_DUMP | 21 #if DEBUG_DUMP |
(...skipping 12 matching lines...) Expand all Loading... |
33 // OPTIMIZE | 34 // OPTIMIZE |
34 // when the edges are initially walked, they don't automatically get the pri
or and next | 35 // when the edges are initially walked, they don't automatically get the pri
or and next |
35 // edges assigned to positions t=0 and t=1. Doing that would remove the need
for this check, | 36 // edges assigned to positions t=0 and t=1. Doing that would remove the need
for this check, |
36 // and would additionally remove the need for similar checks in condition ed
ges. It would | 37 // and would additionally remove the need for similar checks in condition ed
ges. It would |
37 // also allow intersection code to assume end of segment intersections (mayb
e?) | 38 // also allow intersection code to assume end of segment intersections (mayb
e?) |
38 bool complete() const { | 39 bool complete() const { |
39 int count = fTs.count(); | 40 int count = fTs.count(); |
40 return count > 1 && fTs[0].fT == 0 && fTs[--count].fT == 1; | 41 return count > 1 && fTs[0].fT == 0 && fTs[--count].fT == 1; |
41 } | 42 } |
42 | 43 |
| 44 int count() const { |
| 45 return fTs.count(); |
| 46 } |
| 47 |
43 bool done() const { | 48 bool done() const { |
44 SkASSERT(fDoneSpans <= fTs.count()); | 49 SkASSERT(fDoneSpans <= fTs.count()); |
45 return fDoneSpans == fTs.count(); | 50 return fDoneSpans == fTs.count(); |
46 } | 51 } |
47 | 52 |
48 bool done(int min) const { | 53 bool done(int min) const { |
49 return fTs[min].fDone; | 54 return fTs[min].fDone; |
50 } | 55 } |
51 | 56 |
52 bool done(const SkOpAngle* angle) const { | 57 bool done(const SkOpAngle* angle) const { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 | 118 |
114 int oppValue(int tIndex) const { | 119 int oppValue(int tIndex) const { |
115 return fTs[tIndex].fOppValue; | 120 return fTs[tIndex].fOppValue; |
116 } | 121 } |
117 | 122 |
118 int oppValue(const SkOpAngle* angle) const { | 123 int oppValue(const SkOpAngle* angle) const { |
119 int lesser = SkMin32(angle->start(), angle->end()); | 124 int lesser = SkMin32(angle->start(), angle->end()); |
120 return fTs[lesser].fOppValue; | 125 return fTs[lesser].fOppValue; |
121 } | 126 } |
122 | 127 |
| 128 const SkOpSegment* other(int index) const { |
| 129 return fTs[index].fOther; |
| 130 } |
| 131 |
123 const SkPoint* pts() const { | 132 const SkPoint* pts() const { |
124 return fPts; | 133 return fPts; |
125 } | 134 } |
126 | 135 |
127 void reset() { | 136 void reset() { |
128 init(NULL, (SkPath::Verb) -1, false, false); | 137 init(NULL, (SkPath::Verb) -1, false, false); |
129 fBounds.set(SK_ScalarMax, SK_ScalarMax, SK_ScalarMax, SK_ScalarMax); | 138 fBounds.set(SK_ScalarMax, SK_ScalarMax, SK_ScalarMax, SK_ScalarMax); |
130 fTs.reset(); | 139 fTs.reset(); |
131 } | 140 } |
132 | 141 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 SkOpSegment* findNextXor(int* nextStart, int* nextEnd, bool* unsortable); | 264 SkOpSegment* findNextXor(int* nextStart, int* nextEnd, bool* unsortable); |
256 void findTooCloseToCall(); | 265 void findTooCloseToCall(); |
257 SkOpSegment* findTop(int* tIndex, int* endIndex, bool* unsortable, bool only
Sortable); | 266 SkOpSegment* findTop(int* tIndex, int* endIndex, bool* unsortable, bool only
Sortable); |
258 void fixOtherTIndex(); | 267 void fixOtherTIndex(); |
259 void initWinding(int start, int end); | 268 void initWinding(int start, int end); |
260 void initWinding(int start, int end, double tHit, int winding, SkScalar hitD
x, int oppWind, | 269 void initWinding(int start, int end, double tHit, int winding, SkScalar hitD
x, int oppWind, |
261 SkScalar hitOppDx); | 270 SkScalar hitOppDx); |
262 bool isLinear(int start, int end) const; | 271 bool isLinear(int start, int end) const; |
263 bool isMissing(double startT) const; | 272 bool isMissing(double startT) const; |
264 bool isSimple(int end) const; | 273 bool isSimple(int end) const; |
| 274 bool isTiny(const SkOpAngle* angle) const; |
| 275 bool isTiny(int index) const; |
265 SkOpSpan* markAndChaseDoneBinary(int index, int endIndex); | 276 SkOpSpan* markAndChaseDoneBinary(int index, int endIndex); |
266 SkOpSpan* markAndChaseDoneUnary(int index, int endIndex); | 277 SkOpSpan* markAndChaseDoneUnary(int index, int endIndex); |
267 SkOpSpan* markAndChaseWinding(const SkOpAngle* angle, int winding, int oppWi
nding); | 278 SkOpSpan* markAndChaseWinding(const SkOpAngle* angle, int winding, int oppWi
nding); |
268 SkOpSpan* markAngle(int maxWinding, int sumWinding, int oppMaxWinding, int o
ppSumWinding, | 279 SkOpSpan* markAngle(int maxWinding, int sumWinding, int oppMaxWinding, int o
ppSumWinding, |
269 bool activeAngle, const SkOpAngle* angle); | 280 bool activeAngle, const SkOpAngle* angle); |
270 void markDone(int index, int winding); | 281 void markDone(int index, int winding); |
271 void markDoneBinary(int index); | 282 void markDoneBinary(int index); |
272 void markDoneUnary(int index); | 283 void markDoneUnary(int index); |
273 SkOpSpan* markOneWinding(const char* funName, int tIndex, int winding); | 284 SkOpSpan* markOneWinding(const char* funName, int tIndex, int winding); |
274 SkOpSpan* markOneWinding(const char* funName, int tIndex, int winding, int o
ppWinding); | 285 SkOpSpan* markOneWinding(const char* funName, int tIndex, int winding, int o
ppWinding); |
275 void markWinding(int index, int winding); | 286 void markWinding(int index, int winding); |
276 void markWinding(int index, int winding, int oppWinding); | 287 void markWinding(int index, int winding, int oppWinding); |
277 bool nextCandidate(int* start, int* end) const; | 288 bool nextCandidate(int* start, int* end) const; |
278 int nextExactSpan(int from, int step) const; | 289 int nextExactSpan(int from, int step) const; |
279 int nextSpan(int from, int step) const; | 290 int nextSpan(int from, int step) const; |
280 void setUpWindings(int index, int endIndex, int* sumMiWinding, int* sumSuWin
ding, | 291 void setUpWindings(int index, int endIndex, int* sumMiWinding, int* sumSuWin
ding, |
281 int* maxWinding, int* sumWinding, int* oppMaxWinding, int* oppSumWin
ding); | 292 int* maxWinding, int* sumWinding, int* oppMaxWinding, int* oppSumWin
ding); |
282 static bool SortAngles(const SkTDArray<SkOpAngle>& angles, SkTDArray<SkOpAng
le*>* angleList); | 293 enum SortAngleKind { |
283 void subDivide(int start, int end, SkPoint edge[4]) const; | 294 kMustBeOrdered_SortAngleKind, // required for winding calc |
| 295 kMayBeUnordered_SortAngleKind // ok for find top |
| 296 }; |
| 297 static bool SortAngles(const SkTDArray<SkOpAngle>& angles, SkTDArray<SkOpAng
le*>* angleList, |
| 298 SortAngleKind ); |
| 299 bool subDivide(int start, int end, SkPoint edge[4]) const; |
| 300 bool subDivide(int start, int end, SkDCubic* result) const; |
284 void undoneSpan(int* start, int* end); | 301 void undoneSpan(int* start, int* end); |
285 int updateOppWindingReverse(const SkOpAngle* angle) const; | 302 int updateOppWindingReverse(const SkOpAngle* angle) const; |
286 int updateWindingReverse(const SkOpAngle* angle) const; | 303 int updateWindingReverse(const SkOpAngle* angle) const; |
287 static bool UseInnerWinding(int outerWinding, int innerWinding); | 304 static bool UseInnerWinding(int outerWinding, int innerWinding); |
288 int windingAtT(double tHit, int tIndex, bool crossOpp, SkScalar* dx) const; | 305 int windingAtT(double tHit, int tIndex, bool crossOpp, SkScalar* dx) const; |
289 int windSum(const SkOpAngle* angle) const; | 306 int windSum(const SkOpAngle* angle) const; |
290 int windValue(const SkOpAngle* angle) const; | 307 int windValue(const SkOpAngle* angle) const; |
291 | 308 |
292 #if DEBUG_DUMP | 309 #if DEBUG_DUMP |
293 int debugID() const { | 310 int debugID() const { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 void markOneDone(const char* funName, int tIndex, int winding); | 358 void markOneDone(const char* funName, int tIndex, int winding); |
342 void markOneDoneBinary(const char* funName, int tIndex); | 359 void markOneDoneBinary(const char* funName, int tIndex); |
343 void markOneDoneBinary(const char* funName, int tIndex, int winding, int opp
Winding); | 360 void markOneDoneBinary(const char* funName, int tIndex, int winding, int opp
Winding); |
344 void markOneDoneUnary(const char* funName, int tIndex); | 361 void markOneDoneUnary(const char* funName, int tIndex); |
345 void markUnsortable(int start, int end); | 362 void markUnsortable(int start, int end); |
346 bool monotonicInY(int tStart, int tEnd) const; | 363 bool monotonicInY(int tStart, int tEnd) const; |
347 bool multipleSpans(int end) const; | 364 bool multipleSpans(int end) const; |
348 SkOpSegment* nextChase(int* index, const int step, int* min, SkOpSpan** last
); | 365 SkOpSegment* nextChase(int* index, const int step, int* min, SkOpSpan** last
); |
349 bool serpentine(int tStart, int tEnd) const; | 366 bool serpentine(int tStart, int tEnd) const; |
350 void subDivideBounds(int start, int end, SkPathOpsBounds* bounds) const; | 367 void subDivideBounds(int start, int end, SkPathOpsBounds* bounds) const; |
351 bool tiny(const SkOpAngle* angle) const; | |
352 static void TrackOutside(SkTDArray<double>* outsideTs, double end, double st
art); | 368 static void TrackOutside(SkTDArray<double>* outsideTs, double end, double st
art); |
353 int updateOppWinding(int index, int endIndex) const; | 369 int updateOppWinding(int index, int endIndex) const; |
354 int updateOppWinding(const SkOpAngle* angle) const; | 370 int updateOppWinding(const SkOpAngle* angle) const; |
355 int updateWinding(int index, int endIndex) const; | 371 int updateWinding(int index, int endIndex) const; |
356 int updateWinding(const SkOpAngle* angle) const; | 372 int updateWinding(const SkOpAngle* angle) const; |
357 SkOpSpan* verifyOneWinding(const char* funName, int tIndex); | 373 SkOpSpan* verifyOneWinding(const char* funName, int tIndex); |
358 SkOpSpan* verifyOneWindingU(const char* funName, int tIndex); | 374 SkOpSpan* verifyOneWindingU(const char* funName, int tIndex); |
359 int windValueAt(double t) const; | 375 int windValueAt(double t) const; |
360 void zeroSpan(SkOpSpan* span); | 376 void zeroSpan(SkOpSpan* span); |
361 | 377 |
(...skipping 22 matching lines...) Expand all Loading... |
384 SkPath::Verb fVerb; | 400 SkPath::Verb fVerb; |
385 bool fOperand; | 401 bool fOperand; |
386 bool fXor; // set if original contour had even-odd fill | 402 bool fXor; // set if original contour had even-odd fill |
387 bool fOppXor; // set if opposite operand had even-odd fill | 403 bool fOppXor; // set if opposite operand had even-odd fill |
388 #if DEBUG_DUMP | 404 #if DEBUG_DUMP |
389 int fID; | 405 int fID; |
390 #endif | 406 #endif |
391 }; | 407 }; |
392 | 408 |
393 #endif | 409 #endif |
OLD | NEW |