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 "SkAddIntersections.h" | 7 #include "SkAddIntersections.h" |
8 #include "SkOpCoincidence.h" | 8 #include "SkOpCoincidence.h" |
9 #include "SkOpEdgeBuilder.h" | 9 #include "SkOpEdgeBuilder.h" |
10 #include "SkPathOpsCommon.h" | 10 #include "SkPathOpsCommon.h" |
11 #include "SkPathWriter.h" | 11 #include "SkPathWriter.h" |
12 | 12 |
13 static SkOpSegment* findChaseOp(SkTDArray<SkOpSpanBase*>& chase, SkOpSpanBase**
startPtr, | 13 static SkOpSegment* findChaseOp(SkTDArray<SkOpSpanBase*>& chase, SkOpSpanBase**
startPtr, |
14 SkOpSpanBase** endPtr) { | 14 SkOpSpanBase** endPtr) { |
15 while (chase.count()) { | 15 while (chase.count()) { |
16 SkOpSpanBase* span; | 16 SkOpSpanBase* span; |
17 chase.pop(&span); | 17 chase.pop(&span); |
18 // OPTIMIZE: prev makes this compatible with old code -- but is it neces
sary? | 18 // OPTIMIZE: prev makes this compatible with old code -- but is it neces
sary? |
19 *startPtr = span->ptT()->prev()->span(); | 19 *startPtr = span->ptT()->prev()->span(); |
20 SkOpSegment* segment = (*startPtr)->segment(); | 20 SkOpSegment* segment = (*startPtr)->segment(); |
21 bool done = true; | 21 bool done = true; |
22 *endPtr = NULL; | 22 *endPtr = nullptr; |
23 if (SkOpAngle* last = segment->activeAngle(*startPtr, startPtr, endPtr,
&done)) { | 23 if (SkOpAngle* last = segment->activeAngle(*startPtr, startPtr, endPtr,
&done)) { |
24 *startPtr = last->start(); | 24 *startPtr = last->start(); |
25 *endPtr = last->end(); | 25 *endPtr = last->end(); |
26 #if TRY_ROTATE | 26 #if TRY_ROTATE |
27 *chase.insert(0) = span; | 27 *chase.insert(0) = span; |
28 #else | 28 #else |
29 *chase.append() = span; | 29 *chase.append() = span; |
30 #endif | 30 #endif |
31 return last->segment(); | 31 return last->segment(); |
32 } | 32 } |
33 if (done) { | 33 if (done) { |
34 continue; | 34 continue; |
35 } | 35 } |
36 int winding; | 36 int winding; |
37 bool sortable; | 37 bool sortable; |
38 const SkOpAngle* angle = AngleWinding(*startPtr, *endPtr, &winding, &sor
table); | 38 const SkOpAngle* angle = AngleWinding(*startPtr, *endPtr, &winding, &sor
table); |
39 if (winding == SK_MinS32) { | 39 if (winding == SK_MinS32) { |
40 continue; | 40 continue; |
41 } | 41 } |
42 int sumMiWinding, sumSuWinding; | 42 int sumMiWinding, sumSuWinding; |
43 if (sortable) { | 43 if (sortable) { |
44 segment = angle->segment(); | 44 segment = angle->segment(); |
45 sumMiWinding = segment->updateWindingReverse(angle); | 45 sumMiWinding = segment->updateWindingReverse(angle); |
46 sumSuWinding = segment->updateOppWindingReverse(angle); | 46 sumSuWinding = segment->updateOppWindingReverse(angle); |
47 if (segment->operand()) { | 47 if (segment->operand()) { |
48 SkTSwap<int>(sumMiWinding, sumSuWinding); | 48 SkTSwap<int>(sumMiWinding, sumSuWinding); |
49 } | 49 } |
50 } | 50 } |
51 SkOpSegment* first = NULL; | 51 SkOpSegment* first = nullptr; |
52 const SkOpAngle* firstAngle = angle; | 52 const SkOpAngle* firstAngle = angle; |
53 while ((angle = angle->next()) != firstAngle) { | 53 while ((angle = angle->next()) != firstAngle) { |
54 segment = angle->segment(); | 54 segment = angle->segment(); |
55 SkOpSpanBase* start = angle->start(); | 55 SkOpSpanBase* start = angle->start(); |
56 SkOpSpanBase* end = angle->end(); | 56 SkOpSpanBase* end = angle->end(); |
57 int maxWinding, sumWinding, oppMaxWinding, oppSumWinding; | 57 int maxWinding, sumWinding, oppMaxWinding, oppSumWinding; |
58 if (sortable) { | 58 if (sortable) { |
59 segment->setUpWindings(start, end, &sumMiWinding, &sumSuWinding, | 59 segment->setUpWindings(start, end, &sumMiWinding, &sumSuWinding, |
60 &maxWinding, &sumWinding, &oppMaxWinding, &oppSumWinding
); | 60 &maxWinding, &sumWinding, &oppMaxWinding, &oppSumWinding
); |
61 } | 61 } |
(...skipping 12 matching lines...) Expand all Loading... |
74 } | 74 } |
75 if (first) { | 75 if (first) { |
76 #if TRY_ROTATE | 76 #if TRY_ROTATE |
77 *chase.insert(0) = span; | 77 *chase.insert(0) = span; |
78 #else | 78 #else |
79 *chase.append() = span; | 79 *chase.append() = span; |
80 #endif | 80 #endif |
81 return first; | 81 return first; |
82 } | 82 } |
83 } | 83 } |
84 return NULL; | 84 return nullptr; |
85 } | 85 } |
86 | 86 |
87 static bool bridgeOp(SkOpContourHead* contourList, const SkPathOp op, | 87 static bool bridgeOp(SkOpContourHead* contourList, const SkPathOp op, |
88 const int xorMask, const int xorOpMask, SkPathWriter* simple, SkChunkAll
oc* allocator) { | 88 const int xorMask, const int xorOpMask, SkPathWriter* simple, SkChunkAll
oc* allocator) { |
89 bool unsortable = false; | 89 bool unsortable = false; |
90 do { | 90 do { |
91 SkOpSpan* span = FindSortableTop(contourList); | 91 SkOpSpan* span = FindSortableTop(contourList); |
92 if (!span) { | 92 if (!span) { |
93 break; | 93 break; |
94 } | 94 } |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 temp.setFillType(fillType); | 297 temp.setFillType(fillType); |
298 SkPathWriter assembled(temp); | 298 SkPathWriter assembled(temp); |
299 Assemble(wrapper, &assembled); | 299 Assemble(wrapper, &assembled); |
300 *result = *assembled.nativePath(); | 300 *result = *assembled.nativePath(); |
301 result->setFillType(fillType); | 301 result->setFillType(fillType); |
302 } | 302 } |
303 return true; | 303 return true; |
304 } | 304 } |
305 | 305 |
306 bool Op(const SkPath& one, const SkPath& two, SkPathOp op, SkPath* result) { | 306 bool Op(const SkPath& one, const SkPath& two, SkPathOp op, SkPath* result) { |
307 return OpDebug(one, two, op, result, true SkDEBUGPARAMS(NULL)); | 307 return OpDebug(one, two, op, result, true SkDEBUGPARAMS(nullptr)); |
308 } | 308 } |
OLD | NEW |