caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2012 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 | */ |
| 7 | #include "SkAddIntersections.h" |
| 8 | #include "SkOpEdgeBuilder.h" |
| 9 | #include "SkPathOpsCommon.h" |
| 10 | #include "SkPathWriter.h" |
| 11 | |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 12 | static SkOpSegment* findChaseOp(SkTDArray<SkOpSpan*>& chase, int* tIndex, int* endIndex) { |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 13 | while (chase.count()) { |
| 14 | SkOpSpan* span; |
| 15 | chase.pop(&span); |
| 16 | const SkOpSpan& backPtr = span->fOther->span(span->fOtherIndex); |
| 17 | SkOpSegment* segment = backPtr.fOther; |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 18 | *tIndex = backPtr.fOtherIndex; |
| 19 | bool sortable = true; |
| 20 | bool done = true; |
| 21 | *endIndex = -1; |
| 22 | if (const SkOpAngle* last = segment->activeAngle(*tIndex, tIndex, endIndex, &done, |
| 23 | &sortable)) { |
commit-bot@chromium.org | 8cb1daa | 2014-04-25 12:59:11 +0000 | [diff] [blame] | 24 | if (last->unorderable()) { |
| 25 | continue; |
| 26 | } |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 27 | *tIndex = last->start(); |
| 28 | *endIndex = last->end(); |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 29 | #if TRY_ROTATE |
| 30 | *chase.insert(0) = span; |
| 31 | #else |
| 32 | *chase.append() = span; |
| 33 | #endif |
| 34 | return last->segment(); |
| 35 | } |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 36 | if (done) { |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 37 | continue; |
| 38 | } |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 39 | if (!sortable) { |
| 40 | continue; |
| 41 | } |
| 42 | // find first angle, initialize winding to computed fWindSum |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 43 | const SkOpAngle* angle = segment->spanToAngle(*tIndex, *endIndex); |
caryclark | dac1d17 | 2014-06-17 05:15:38 -0700 | [diff] [blame] | 44 | if (!angle) { |
| 45 | continue; |
| 46 | } |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 47 | const SkOpAngle* firstAngle = angle; |
hcm | 27c46a0 | 2014-10-28 10:55:54 -0700 | [diff] [blame] | 48 | SkDEBUGCODE(bool loop = false); |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 49 | int winding; |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 50 | do { |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 51 | angle = angle->next(); |
hcm | 27c46a0 | 2014-10-28 10:55:54 -0700 | [diff] [blame] | 52 | SkASSERT(angle != firstAngle || !loop); |
| 53 | SkDEBUGCODE(loop |= angle == firstAngle); |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 54 | segment = angle->segment(); |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 55 | winding = segment->windSum(angle); |
| 56 | } while (winding == SK_MinS32); |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 57 | int sumMiWinding = segment->updateWindingReverse(angle); |
| 58 | int sumSuWinding = segment->updateOppWindingReverse(angle); |
| 59 | if (segment->operand()) { |
| 60 | SkTSwap<int>(sumMiWinding, sumSuWinding); |
| 61 | } |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 62 | SkOpSegment* first = NULL; |
hcm | 27c46a0 | 2014-10-28 10:55:54 -0700 | [diff] [blame] | 63 | while ((angle = angle->next()) != firstAngle) { |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 64 | segment = angle->segment(); |
| 65 | int start = angle->start(); |
| 66 | int end = angle->end(); |
| 67 | int maxWinding, sumWinding, oppMaxWinding, oppSumWinding; |
| 68 | segment->setUpWindings(start, end, &sumMiWinding, &sumSuWinding, |
| 69 | &maxWinding, &sumWinding, &oppMaxWinding, &oppSumWinding); |
| 70 | if (!segment->done(angle)) { |
| 71 | if (!first) { |
| 72 | first = segment; |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 73 | *tIndex = start; |
| 74 | *endIndex = end; |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 75 | } |
caryclark | dac1d17 | 2014-06-17 05:15:38 -0700 | [diff] [blame] | 76 | // OPTIMIZATION: should this also add to the chase? |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 77 | (void) segment->markAngle(maxWinding, sumWinding, oppMaxWinding, |
commit-bot@chromium.org | 866f4e3 | 2013-11-21 17:04:29 +0000 | [diff] [blame] | 78 | oppSumWinding, angle); |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 79 | } |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 80 | } |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 81 | if (first) { |
| 82 | #if TRY_ROTATE |
| 83 | *chase.insert(0) = span; |
| 84 | #else |
| 85 | *chase.append() = span; |
| 86 | #endif |
| 87 | return first; |
| 88 | } |
| 89 | } |
| 90 | return NULL; |
| 91 | } |
| 92 | |
| 93 | /* |
| 94 | static bool windingIsActive(int winding, int oppWinding, int spanWinding, int oppSpanWinding, |
| 95 | bool windingIsOp, PathOp op) { |
| 96 | bool active = windingIsActive(winding, spanWinding); |
| 97 | if (!active) { |
| 98 | return false; |
| 99 | } |
| 100 | if (oppSpanWinding && windingIsActive(oppWinding, oppSpanWinding)) { |
| 101 | switch (op) { |
| 102 | case kIntersect_Op: |
| 103 | case kUnion_Op: |
| 104 | return true; |
| 105 | case kDifference_Op: { |
| 106 | int absSpan = abs(spanWinding); |
| 107 | int absOpp = abs(oppSpanWinding); |
| 108 | return windingIsOp ? absSpan < absOpp : absSpan > absOpp; |
| 109 | } |
| 110 | case kXor_Op: |
| 111 | return spanWinding != oppSpanWinding; |
| 112 | default: |
| 113 | SkASSERT(0); |
| 114 | } |
| 115 | } |
| 116 | bool opActive = oppWinding != 0; |
| 117 | return gOpLookup[op][opActive][windingIsOp]; |
| 118 | } |
| 119 | */ |
| 120 | |
caryclark@google.com | d892bd8 | 2013-06-17 14:10:36 +0000 | [diff] [blame] | 121 | static bool bridgeOp(SkTArray<SkOpContour*, true>& contourList, const SkPathOp op, |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 122 | const int xorMask, const int xorOpMask, SkPathWriter* simple) { |
| 123 | bool firstContour = true; |
| 124 | bool unsortable = false; |
| 125 | bool topUnsortable = false; |
commit-bot@chromium.org | 8cb1daa | 2014-04-25 12:59:11 +0000 | [diff] [blame] | 126 | bool firstPass = true; |
| 127 | SkPoint lastTopLeft; |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 128 | SkPoint topLeft = {SK_ScalarMin, SK_ScalarMin}; |
| 129 | do { |
| 130 | int index, endIndex; |
commit-bot@chromium.org | 8cb1daa | 2014-04-25 12:59:11 +0000 | [diff] [blame] | 131 | bool topDone; |
caryclark | dac1d17 | 2014-06-17 05:15:38 -0700 | [diff] [blame] | 132 | bool onlyVertical = false; |
commit-bot@chromium.org | 8cb1daa | 2014-04-25 12:59:11 +0000 | [diff] [blame] | 133 | lastTopLeft = topLeft; |
caryclark@google.com | 570863f | 2013-09-16 15:55:01 +0000 | [diff] [blame] | 134 | SkOpSegment* current = FindSortableTop(contourList, SkOpAngle::kBinarySingle, &firstContour, |
caryclark | dac1d17 | 2014-06-17 05:15:38 -0700 | [diff] [blame] | 135 | &index, &endIndex, &topLeft, &topUnsortable, &topDone, &onlyVertical, firstPass); |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 136 | if (!current) { |
commit-bot@chromium.org | 8cb1daa | 2014-04-25 12:59:11 +0000 | [diff] [blame] | 137 | if ((!topUnsortable || firstPass) && !topDone) { |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 138 | SkASSERT(topLeft.fX != SK_ScalarMin && topLeft.fY != SK_ScalarMin); |
commit-bot@chromium.org | 8cb1daa | 2014-04-25 12:59:11 +0000 | [diff] [blame] | 139 | if (lastTopLeft.fX == SK_ScalarMin && lastTopLeft.fY == SK_ScalarMin) { |
| 140 | if (firstPass) { |
| 141 | firstPass = false; |
| 142 | } else { |
| 143 | break; |
| 144 | } |
| 145 | } |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 146 | topLeft.fX = topLeft.fY = SK_ScalarMin; |
| 147 | continue; |
| 148 | } |
| 149 | break; |
caryclark | dac1d17 | 2014-06-17 05:15:38 -0700 | [diff] [blame] | 150 | } else if (onlyVertical) { |
| 151 | break; |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 152 | } |
commit-bot@chromium.org | 8cb1daa | 2014-04-25 12:59:11 +0000 | [diff] [blame] | 153 | firstPass = !topUnsortable || lastTopLeft != topLeft; |
caryclark | dac1d17 | 2014-06-17 05:15:38 -0700 | [diff] [blame] | 154 | SkTDArray<SkOpSpan*> chase; |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 155 | do { |
| 156 | if (current->activeOp(index, endIndex, xorMask, xorOpMask, op)) { |
| 157 | do { |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 158 | if (!unsortable && current->done()) { |
caryclark@google.com | 7eaa53d | 2013-10-02 14:49:34 +0000 | [diff] [blame] | 159 | break; |
caryclark@google.com | a5e5592 | 2013-05-07 18:51:31 +0000 | [diff] [blame] | 160 | } |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 161 | SkASSERT(unsortable || !current->done()); |
| 162 | int nextStart = index; |
| 163 | int nextEnd = endIndex; |
caryclark | dac1d17 | 2014-06-17 05:15:38 -0700 | [diff] [blame] | 164 | SkOpSegment* next = current->findNextOp(&chase, &nextStart, &nextEnd, |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 165 | &unsortable, op, xorMask, xorOpMask); |
| 166 | if (!next) { |
| 167 | if (!unsortable && simple->hasMove() |
| 168 | && current->verb() != SkPath::kLine_Verb |
| 169 | && !simple->isClosed()) { |
| 170 | current->addCurveTo(index, endIndex, simple, true); |
caryclark | dac1d17 | 2014-06-17 05:15:38 -0700 | [diff] [blame] | 171 | #if DEBUG_ACTIVE_SPANS |
| 172 | if (!simple->isClosed()) { |
| 173 | DebugShowActiveSpans(contourList); |
| 174 | } |
| 175 | #endif |
| 176 | // SkASSERT(simple->isClosed()); |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 177 | } |
| 178 | break; |
| 179 | } |
| 180 | #if DEBUG_FLOW |
| 181 | SkDebugf("%s current id=%d from=(%1.9g,%1.9g) to=(%1.9g,%1.9g)\n", __FUNCTION__, |
| 182 | current->debugID(), current->xyAtT(index).fX, current->xyAtT(index).fY, |
| 183 | current->xyAtT(endIndex).fX, current->xyAtT(endIndex).fY); |
| 184 | #endif |
| 185 | current->addCurveTo(index, endIndex, simple, true); |
| 186 | current = next; |
| 187 | index = nextStart; |
| 188 | endIndex = nextEnd; |
caryclark@google.com | a5e5592 | 2013-05-07 18:51:31 +0000 | [diff] [blame] | 189 | } while (!simple->isClosed() && (!unsortable |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 190 | || !current->done(SkMin32(index, endIndex)))); |
| 191 | if (current->activeWinding(index, endIndex) && !simple->isClosed()) { |
caryclark@google.com | 570863f | 2013-09-16 15:55:01 +0000 | [diff] [blame] | 192 | // FIXME : add to simplify, xor cpaths |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 193 | int min = SkMin32(index, endIndex); |
caryclark@google.com | 570863f | 2013-09-16 15:55:01 +0000 | [diff] [blame] | 194 | if (!unsortable && !simple->isEmpty()) { |
| 195 | unsortable = current->checkSmall(min); |
| 196 | } |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 197 | if (!current->done(min)) { |
| 198 | current->addCurveTo(index, endIndex, simple, true); |
| 199 | current->markDoneBinary(min); |
| 200 | } |
| 201 | } |
| 202 | simple->close(); |
| 203 | } else { |
| 204 | SkOpSpan* last = current->markAndChaseDoneBinary(index, endIndex); |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 205 | if (last && !last->fChased && !last->fLoop) { |
| 206 | last->fChased = true; |
caryclark | dac1d17 | 2014-06-17 05:15:38 -0700 | [diff] [blame] | 207 | SkASSERT(!SkPathOpsDebug::ChaseContains(chase, last)); |
| 208 | *chase.append() = last; |
| 209 | #if DEBUG_WINDING |
| 210 | SkDebugf("%s chase.append id=%d windSum=%d small=%d\n", __FUNCTION__, |
| 211 | last->fOther->span(last->fOtherIndex).fOther->debugID(), last->fWindSum, |
| 212 | last->fSmall); |
| 213 | #endif |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 214 | } |
| 215 | } |
caryclark | dac1d17 | 2014-06-17 05:15:38 -0700 | [diff] [blame] | 216 | current = findChaseOp(chase, &index, &endIndex); |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 217 | #if DEBUG_ACTIVE_SPANS |
| 218 | DebugShowActiveSpans(contourList); |
| 219 | #endif |
| 220 | if (!current) { |
| 221 | break; |
| 222 | } |
| 223 | } while (true); |
| 224 | } while (true); |
| 225 | return simple->someAssemblyRequired(); |
| 226 | } |
| 227 | |
caryclark@google.com | 7dfbb07 | 2013-04-22 14:37:05 +0000 | [diff] [blame] | 228 | // pretty picture: |
| 229 | // https://docs.google.com/a/google.com/drawings/d/1sPV8rPfpEFXymBp3iSbDRWAycp1b-7vD9JP2V-kn9Ss/edit?usp=sharing |
| 230 | static const SkPathOp gOpInverse[kReverseDifference_PathOp + 1][2][2] = { |
| 231 | // inside minuend outside minuend |
| 232 | // inside subtrahend outside subtrahend inside subtrahend outside subtrahend |
| 233 | {{ kDifference_PathOp, kIntersect_PathOp }, { kUnion_PathOp, kReverseDifference_PathOp }}, |
| 234 | {{ kIntersect_PathOp, kDifference_PathOp }, { kReverseDifference_PathOp, kUnion_PathOp }}, |
| 235 | {{ kUnion_PathOp, kReverseDifference_PathOp }, { kDifference_PathOp, kIntersect_PathOp }}, |
| 236 | {{ kXOR_PathOp, kXOR_PathOp }, { kXOR_PathOp, kXOR_PathOp }}, |
| 237 | {{ kReverseDifference_PathOp, kUnion_PathOp }, { kIntersect_PathOp, kDifference_PathOp }}, |
| 238 | }; |
| 239 | |
| 240 | static const bool gOutInverse[kReverseDifference_PathOp + 1][2][2] = { |
| 241 | {{ false, false }, { true, false }}, // diff |
| 242 | {{ false, false }, { false, true }}, // sect |
| 243 | {{ false, true }, { true, true }}, // union |
| 244 | {{ false, true }, { true, false }}, // xor |
| 245 | {{ false, true }, { false, false }}, // rev diff |
| 246 | }; |
| 247 | |
caryclark@google.com | 66560ca | 2013-04-26 19:51:16 +0000 | [diff] [blame] | 248 | bool Op(const SkPath& one, const SkPath& two, SkPathOp op, SkPath* result) { |
caryclark@google.com | 07e97fc | 2013-07-08 17:17:02 +0000 | [diff] [blame] | 249 | #if DEBUG_SHOW_TEST_NAME |
| 250 | char* debugName = DEBUG_FILENAME_STRING; |
| 251 | if (debugName && debugName[0]) { |
caryclark@google.com | 570863f | 2013-09-16 15:55:01 +0000 | [diff] [blame] | 252 | SkPathOpsDebug::BumpTestName(debugName); |
| 253 | SkPathOpsDebug::ShowPath(one, two, op, debugName); |
caryclark@google.com | 07e97fc | 2013-07-08 17:17:02 +0000 | [diff] [blame] | 254 | } |
caryclark@google.com | a5e5592 | 2013-05-07 18:51:31 +0000 | [diff] [blame] | 255 | #endif |
caryclark@google.com | 7dfbb07 | 2013-04-22 14:37:05 +0000 | [diff] [blame] | 256 | op = gOpInverse[op][one.isInverseFillType()][two.isInverseFillType()]; |
caryclark@google.com | 7dfbb07 | 2013-04-22 14:37:05 +0000 | [diff] [blame] | 257 | SkPath::FillType fillType = gOutInverse[op][one.isInverseFillType()][two.isInverseFillType()] |
| 258 | ? SkPath::kInverseEvenOdd_FillType : SkPath::kEvenOdd_FillType; |
caryclark@google.com | 7dfbb07 | 2013-04-22 14:37:05 +0000 | [diff] [blame] | 259 | const SkPath* minuend = &one; |
| 260 | const SkPath* subtrahend = &two; |
| 261 | if (op == kReverseDifference_PathOp) { |
| 262 | minuend = &two; |
| 263 | subtrahend = &one; |
| 264 | op = kDifference_PathOp; |
| 265 | } |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 266 | #if DEBUG_SORT || DEBUG_SWAP_TOP |
caryclark@google.com | 570863f | 2013-09-16 15:55:01 +0000 | [diff] [blame] | 267 | SkPathOpsDebug::gSortCount = SkPathOpsDebug::gSortCountDefault; |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 268 | #endif |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 269 | // turn path into list of segments |
| 270 | SkTArray<SkOpContour> contours; |
| 271 | // FIXME: add self-intersecting cubics' T values to segment |
caryclark@google.com | 7dfbb07 | 2013-04-22 14:37:05 +0000 | [diff] [blame] | 272 | SkOpEdgeBuilder builder(*minuend, contours); |
caryclark | d751ac0 | 2014-10-03 05:36:27 -0700 | [diff] [blame] | 273 | if (builder.unparseable()) { |
| 274 | return false; |
| 275 | } |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 276 | const int xorMask = builder.xorMask(); |
caryclark@google.com | 7dfbb07 | 2013-04-22 14:37:05 +0000 | [diff] [blame] | 277 | builder.addOperand(*subtrahend); |
caryclark@google.com | 66560ca | 2013-04-26 19:51:16 +0000 | [diff] [blame] | 278 | if (!builder.finish()) { |
| 279 | return false; |
| 280 | } |
caryclark@google.com | 6dc7df6 | 2013-04-25 11:51:54 +0000 | [diff] [blame] | 281 | result->reset(); |
| 282 | result->setFillType(fillType); |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 283 | const int xorOpMask = builder.xorMask(); |
caryclark@google.com | d892bd8 | 2013-06-17 14:10:36 +0000 | [diff] [blame] | 284 | SkTArray<SkOpContour*, true> contourList; |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 285 | MakeContourList(contours, contourList, xorMask == kEvenOdd_PathOpsMask, |
| 286 | xorOpMask == kEvenOdd_PathOpsMask); |
| 287 | SkOpContour** currentPtr = contourList.begin(); |
| 288 | if (!currentPtr) { |
caryclark@google.com | 66560ca | 2013-04-26 19:51:16 +0000 | [diff] [blame] | 289 | return true; |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 290 | } |
| 291 | SkOpContour** listEnd = contourList.end(); |
| 292 | // find all intersections between segments |
| 293 | do { |
| 294 | SkOpContour** nextPtr = currentPtr; |
| 295 | SkOpContour* current = *currentPtr++; |
| 296 | if (current->containsCubics()) { |
| 297 | AddSelfIntersectTs(current); |
| 298 | } |
| 299 | SkOpContour* next; |
| 300 | do { |
| 301 | next = *nextPtr++; |
| 302 | } while (AddIntersectTs(current, next) && nextPtr != listEnd); |
| 303 | } while (currentPtr != listEnd); |
| 304 | // eat through coincident edges |
| 305 | |
| 306 | int total = 0; |
| 307 | int index; |
| 308 | for (index = 0; index < contourList.count(); ++index) { |
| 309 | total += contourList[index]->segments().count(); |
| 310 | } |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 311 | if (!HandleCoincidence(&contourList, total)) { |
| 312 | return false; |
| 313 | } |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 314 | // construct closed contours |
| 315 | SkPathWriter wrapper(*result); |
| 316 | bridgeOp(contourList, op, xorMask, xorOpMask, &wrapper); |
| 317 | { // if some edges could not be resolved, assemble remaining fragments |
| 318 | SkPath temp; |
caryclark@google.com | 7dfbb07 | 2013-04-22 14:37:05 +0000 | [diff] [blame] | 319 | temp.setFillType(fillType); |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 320 | SkPathWriter assembled(temp); |
| 321 | Assemble(wrapper, &assembled); |
| 322 | *result = *assembled.nativePath(); |
caryclark@google.com | 66560ca | 2013-04-26 19:51:16 +0000 | [diff] [blame] | 323 | result->setFillType(fillType); |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 324 | } |
caryclark@google.com | 66560ca | 2013-04-26 19:51:16 +0000 | [diff] [blame] | 325 | return true; |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 326 | } |