Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: src/pathops/SkOpSegment.cpp

Issue 607913007: fail on extremely large coincident curves (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/pathops/SkOpSegment.h ('k') | tests/PathOpsOpTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "SkIntersections.h" 7 #include "SkIntersections.h"
8 #include "SkOpContour.h" 8 #include "SkOpContour.h"
9 #include "SkOpSegment.h" 9 #include "SkOpSegment.h"
10 #include "SkPathWriter.h" 10 #include "SkPathWriter.h"
(...skipping 1193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1204 int oWindValue = oTest.fWindValue; 1204 int oWindValue = oTest.fWindValue;
1205 int oOppValue = oTest.fOppValue; 1205 int oOppValue = oTest.fOppValue;
1206 if (binary) { 1206 if (binary) {
1207 SkTSwap<int>(oWindValue, oOppValue); 1207 SkTSwap<int>(oWindValue, oOppValue);
1208 } 1208 }
1209 do { 1209 do {
1210 (void) bumpSpan(&fTs[index], oWindValue, oOppValue); 1210 (void) bumpSpan(&fTs[index], oWindValue, oOppValue);
1211 } while (++index < endIndex); 1211 } while (++index < endIndex);
1212 } 1212 }
1213 1213
1214 void SkOpSegment::bumpCoincidentThis(const SkOpSpan& oTest, bool binary, int* in dexPtr, 1214 bool SkOpSegment::bumpCoincidentThis(const SkOpSpan& oTest, bool binary, int* in dexPtr,
1215 SkTArray<SkPoint, true>* outsideTs) { 1215 SkTArray<SkPoint, true>* outsideTs) {
1216 int index = *indexPtr; 1216 int index = *indexPtr;
1217 int oWindValue = oTest.fWindValue; 1217 int oWindValue = oTest.fWindValue;
1218 int oOppValue = oTest.fOppValue; 1218 int oOppValue = oTest.fOppValue;
1219 if (binary) { 1219 if (binary) {
1220 SkTSwap<int>(oWindValue, oOppValue); 1220 SkTSwap<int>(oWindValue, oOppValue);
1221 } 1221 }
1222 SkOpSpan* const test = &fTs[index]; 1222 SkOpSpan* const test = &fTs[index];
1223 SkOpSpan* end = test; 1223 SkOpSpan* end = test;
1224 const SkPoint& oStartPt = oTest.fPt; 1224 const SkPoint& oStartPt = oTest.fPt;
1225 do { 1225 do {
1226 if (end->fDone && !end->fTiny && !end->fSmall) { // extremely large pat hs trigger this
1227 return false;
1228 }
1226 if (bumpSpan(end, oWindValue, oOppValue)) { 1229 if (bumpSpan(end, oWindValue, oOppValue)) {
1227 TrackOutside(outsideTs, oStartPt); 1230 TrackOutside(outsideTs, oStartPt);
1228 } 1231 }
1229 end = &fTs[++index]; 1232 end = &fTs[++index];
1230 } while ((end->fPt == test->fPt || precisely_equal(end->fT, test->fT)) && en d->fT < 1); 1233 } while ((end->fPt == test->fPt || precisely_equal(end->fT, test->fT)) && en d->fT < 1);
1231 *indexPtr = index; 1234 *indexPtr = index;
1235 return true;
1232 } 1236 }
1233 1237
1234 void SkOpSegment::bumpCoincidentOBlind(int index, int endIndex) { 1238 void SkOpSegment::bumpCoincidentOBlind(int index, int endIndex) {
1235 do { 1239 do {
1236 zeroSpan(&fTs[index]); 1240 zeroSpan(&fTs[index]);
1237 } while (++index < endIndex); 1241 } while (++index < endIndex);
1238 } 1242 }
1239 1243
1240 // because of the order in which coincidences are resolved, this and other 1244 // because of the order in which coincidences are resolved, this and other
1241 // may not have the same intermediate points. Compute the corresponding 1245 // may not have the same intermediate points. Compute the corresponding
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1322 SkDEBUGCODE(firstWind = oTest->fWindValue); 1326 SkDEBUGCODE(firstWind = oTest->fWindValue);
1323 SkDEBUGCODE(firstOpp = oTest->fOppValue); 1327 SkDEBUGCODE(firstOpp = oTest->fOppValue);
1324 do { 1328 do {
1325 SkASSERT(firstWind == other->fTs[oIndex].fWindValue); 1329 SkASSERT(firstWind == other->fTs[oIndex].fWindValue);
1326 SkASSERT(firstOpp == other->fTs[oIndex].fOppValue); 1330 SkASSERT(firstOpp == other->fTs[oIndex].fOppValue);
1327 ++oIndex; 1331 ++oIndex;
1328 SkASSERT(oIndex < other->fTs.count()); 1332 SkASSERT(oIndex < other->fTs.count());
1329 } while (*oTestPt == other->fTs[oIndex].fPt); 1333 } while (*oTestPt == other->fTs[oIndex].fPt);
1330 } else { 1334 } else {
1331 if (!binary || test->fWindValue + oTest->fOppValue >= 0) { 1335 if (!binary || test->fWindValue + oTest->fOppValue >= 0) {
1332 bumpCoincidentThis(*oTest, binary, &index, &outsidePts); 1336 if (!bumpCoincidentThis(*oTest, binary, &index, &outsidePts)) {
1337 return false;
1338 }
1333 other->bumpCoincidentOther(*test, &oIndex, &oOutsidePts); 1339 other->bumpCoincidentOther(*test, &oIndex, &oOutsidePts);
1334 } else { 1340 } else {
1335 other->bumpCoincidentThis(*test, binary, &oIndex, &oOutsidePts); 1341 if (!other->bumpCoincidentThis(*test, binary, &oIndex, &oOutside Pts)) {
1342 return false;
1343 }
1336 bumpCoincidentOther(*oTest, &index, &outsidePts); 1344 bumpCoincidentOther(*oTest, &index, &outsidePts);
1337 } 1345 }
1338 } 1346 }
1339 test = &fTs[index]; 1347 test = &fTs[index];
1340 testPt = &test->fPt; 1348 testPt = &test->fPt;
1341 testT = test->fT; 1349 testT = test->fT;
1342 oTest = &other->fTs[oIndex]; 1350 oTest = &other->fTs[oIndex];
1343 oTestPt = &oTest->fPt; 1351 oTestPt = &oTest->fPt;
1344 if (endPt == *testPt || precisely_equal(endT, testT)) { 1352 if (endPt == *testPt || precisely_equal(endT, testT)) {
1345 break; 1353 break;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1389 break; 1397 break;
1390 } 1398 }
1391 oPeek = &other->fTs[oPeekIndex]; 1399 oPeek = &other->fTs[oPeekIndex];
1392 } while (endPt == oPeek->fPt); 1400 } while (endPt == oPeek->fPt);
1393 } 1401 }
1394 if (success) { 1402 if (success) {
1395 do { 1403 do {
1396 if (!binary || test->fWindValue + oTest->fOppValue >= 0) { 1404 if (!binary || test->fWindValue + oTest->fOppValue >= 0) {
1397 other->bumpCoincidentOther(*test, &oIndex, &oOutsidePts); 1405 other->bumpCoincidentOther(*test, &oIndex, &oOutsidePts);
1398 } else { 1406 } else {
1399 other->bumpCoincidentThis(*test, binary, &oIndex, &oOutsideP ts); 1407 if (!other->bumpCoincidentThis(*test, binary, &oIndex, &oOut sidePts)) {
1408 return false;
1409 }
1400 } 1410 }
1401 oTest = &other->fTs[oIndex]; 1411 oTest = &other->fTs[oIndex];
1402 oTestPt = &oTest->fPt; 1412 oTestPt = &oTest->fPt;
1403 } while (endPt != *oTestPt); 1413 } while (endPt != *oTestPt);
1404 } 1414 }
1405 } 1415 }
1406 int outCount = outsidePts.count(); 1416 int outCount = outsidePts.count();
1407 if (!done() && outCount) { 1417 if (!done() && outCount) {
1408 addCoinOutsides(outsidePts[0], endPt, other); 1418 addCoinOutsides(outsidePts[0], endPt, other);
1409 } 1419 }
(...skipping 3035 matching lines...) Expand 10 before | Expand all | Expand 10 after
4445 SkASSERT(span->fWindValue > 0 || span->fOppValue != 0); 4455 SkASSERT(span->fWindValue > 0 || span->fOppValue != 0);
4446 span->fWindValue = 0; 4456 span->fWindValue = 0;
4447 span->fOppValue = 0; 4457 span->fOppValue = 0;
4448 if (span->fTiny || span->fSmall) { 4458 if (span->fTiny || span->fSmall) {
4449 return; 4459 return;
4450 } 4460 }
4451 SkASSERT(!span->fDone); 4461 SkASSERT(!span->fDone);
4452 span->fDone = true; 4462 span->fDone = true;
4453 ++fDoneSpans; 4463 ++fDoneSpans;
4454 } 4464 }
OLDNEW
« no previous file with comments | « src/pathops/SkOpSegment.h ('k') | tests/PathOpsOpTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698