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

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

Issue 2425733002: fix some fuzz (Closed)
Patch Set: Created 4 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/SkOpCoincidence.h ('k') | src/pathops/SkOpSpan.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 2015 Google Inc. 2 * Copyright 2015 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 "SkOpCoincidence.h" 7 #include "SkOpCoincidence.h"
8 #include "SkOpSegment.h" 8 #include "SkOpSegment.h"
9 #include "SkPathOpsTSect.h" 9 #include "SkPathOpsTSect.h"
10 10
(...skipping 1244 matching lines...) Expand 10 before | Expand all | Expand 10 after
1255 this->release(head, coin); 1255 this->release(head, coin);
1256 continue; 1256 continue;
1257 } 1257 }
1258 coin->setOppPtTEnd(kept); 1258 coin->setOppPtTEnd(kept);
1259 } 1259 }
1260 } while ((coin = coin->next())); 1260 } while ((coin = coin->next()));
1261 } 1261 }
1262 1262
1263 // Please keep this in sync with debugMark() 1263 // Please keep this in sync with debugMark()
1264 /* this sets up the coincidence links in the segments when the coincidence cross es multiple spans */ 1264 /* this sets up the coincidence links in the segments when the coincidence cross es multiple spans */
1265 void SkOpCoincidence::mark(DEBUG_COIN_DECLARE_ONLY_PARAMS()) { 1265 bool SkOpCoincidence::mark(DEBUG_COIN_DECLARE_ONLY_PARAMS()) {
1266 DEBUG_SET_PHASE(); 1266 DEBUG_SET_PHASE();
1267 SkCoincidentSpans* coin = fHead; 1267 SkCoincidentSpans* coin = fHead;
1268 if (!coin) { 1268 if (!coin) {
1269 return; 1269 return true;
1270 } 1270 }
1271 do { 1271 do {
1272 SkOpSpan* start = coin->coinPtTStartWritable()->span()->upCast(); 1272 SkOpSpanBase* startBase = coin->coinPtTStartWritable()->span();
1273 FAIL_IF(!startBase->upCastable());
1274 SkOpSpan* start = startBase->upCast();
1273 SkASSERT(!start->deleted()); 1275 SkASSERT(!start->deleted());
1274 SkOpSpanBase* end = coin->coinPtTEndWritable()->span(); 1276 SkOpSpanBase* end = coin->coinPtTEndWritable()->span();
1275 SkOPASSERT(!end->deleted()); 1277 SkOPASSERT(!end->deleted());
1276 SkOpSpanBase* oStart = coin->oppPtTStartWritable()->span(); 1278 SkOpSpanBase* oStart = coin->oppPtTStartWritable()->span();
1277 SkOPASSERT(!oStart->deleted()); 1279 SkOPASSERT(!oStart->deleted());
1278 SkOpSpanBase* oEnd = coin->oppPtTEndWritable()->span(); 1280 SkOpSpanBase* oEnd = coin->oppPtTEndWritable()->span();
1279 SkASSERT(!oEnd->deleted()); 1281 SkASSERT(!oEnd->deleted());
1280 bool flipped = coin->flipped(); 1282 bool flipped = coin->flipped();
1281 if (flipped) { 1283 if (flipped) {
1282 SkTSwap(oStart, oEnd); 1284 SkTSwap(oStart, oEnd);
1283 } 1285 }
1284 /* coin and opp spans may not match up. Mark the ends, and then let the interior 1286 /* coin and opp spans may not match up. Mark the ends, and then let the interior
1285 get marked as many times as the spans allow */ 1287 get marked as many times as the spans allow */
1286 start->insertCoincidence(oStart->upCast()); 1288 start->insertCoincidence(oStart->upCast());
1287 end->insertCoinEnd(oEnd); 1289 end->insertCoinEnd(oEnd);
1288 const SkOpSegment* segment = start->segment(); 1290 const SkOpSegment* segment = start->segment();
1289 const SkOpSegment* oSegment = oStart->segment(); 1291 const SkOpSegment* oSegment = oStart->segment();
1290 SkOpSpanBase* next = start; 1292 SkOpSpanBase* next = start;
1291 SkOpSpanBase* oNext = oStart; 1293 SkOpSpanBase* oNext = oStart;
1292 bool ordered = coin->ordered(); 1294 bool ordered = coin->ordered();
1293 while ((next = next->upCast()->next()) != end) { 1295 while ((next = next->upCast()->next()) != end) {
1296 FAIL_IF(!next->upCastable());
1294 SkAssertResult(next->upCast()->insertCoincidence(oSegment, flipped, ordered)); 1297 SkAssertResult(next->upCast()->insertCoincidence(oSegment, flipped, ordered));
1295 } 1298 }
1296 while ((oNext = oNext->upCast()->next()) != oEnd) { 1299 while ((oNext = oNext->upCast()->next()) != oEnd) {
1297 SkAssertResult(oNext->upCast()->insertCoincidence(segment, flipped, ordered)); 1300 FAIL_IF(!oNext->upCast()->insertCoincidence(segment, flipped, ordere d));
1298 } 1301 }
1299 } while ((coin = coin->next())); 1302 } while ((coin = coin->next()));
1303 return true;
1300 } 1304 }
1301 1305
1302 // Please keep in sync with debugMarkCollapsed() 1306 // Please keep in sync with debugMarkCollapsed()
1303 void SkOpCoincidence::markCollapsed(SkCoincidentSpans* coin, SkOpPtT* test) { 1307 void SkOpCoincidence::markCollapsed(SkCoincidentSpans* coin, SkOpPtT* test) {
1304 SkCoincidentSpans* head = coin; 1308 SkCoincidentSpans* head = coin;
1305 while (coin) { 1309 while (coin) {
1306 if (coin->collapsed(test)) { 1310 if (coin->collapsed(test)) {
1307 if (zero_or_one(coin->coinPtTStart()->fT) && zero_or_one(coin->coinP tTEnd()->fT)) { 1311 if (zero_or_one(coin->coinPtTStart()->fT) && zero_or_one(coin->coinP tTEnd()->fT)) {
1308 coin->coinPtTStartWritable()->segment()->markAllDone(); 1312 coin->coinPtTStartWritable()->segment()->markAllDone();
1309 } 1313 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1361 } 1365 }
1362 do { 1366 do {
1363 if (coin->coinPtTStart()->segment() == deleted 1367 if (coin->coinPtTStart()->segment() == deleted
1364 || coin->coinPtTEnd()->segment() == deleted 1368 || coin->coinPtTEnd()->segment() == deleted
1365 || coin->oppPtTStart()->segment() == deleted 1369 || coin->oppPtTStart()->segment() == deleted
1366 || coin->oppPtTEnd()->segment() == deleted) { 1370 || coin->oppPtTEnd()->segment() == deleted) {
1367 this->release(fHead, coin); 1371 this->release(fHead, coin);
1368 } 1372 }
1369 } while ((coin = coin->next())); 1373 } while ((coin = coin->next()));
1370 } 1374 }
OLDNEW
« no previous file with comments | « src/pathops/SkOpCoincidence.h ('k') | src/pathops/SkOpSpan.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698