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

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

Issue 633393002: harden pathops for pathological test (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: exclude new test that asserts in debug Created 6 years, 1 month 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 | « gyp/pathops_unittest.gypi ('k') | src/pathops/SkDCubicIntersection.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 "SkAddIntersections.h" 7 #include "SkAddIntersections.h"
8 #include "SkPathOpsBounds.h" 8 #include "SkPathOpsBounds.h"
9 9
10 #if DEBUG_ADD_INTERSECTING_TS 10 #if DEBUG_ADD_INTERSECTING_TS
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 wn.bottom(), wn.x(), wn.yFlipped()); 300 wn.bottom(), wn.x(), wn.yFlipped());
301 debugShowQuadLineIntersection(pts, wt, wn, ts); 301 debugShowQuadLineIntersection(pts, wt, wn, ts);
302 break; 302 break;
303 case SkIntersectionHelper::kLine_Segment: { 303 case SkIntersectionHelper::kLine_Segment: {
304 pts = ts.quadLine(wt.pts(), wn.pts()); 304 pts = ts.quadLine(wt.pts(), wn.pts());
305 debugShowQuadLineIntersection(pts, wt, wn, ts); 305 debugShowQuadLineIntersection(pts, wt, wn, ts);
306 break; 306 break;
307 } 307 }
308 case SkIntersectionHelper::kQuad_Segment: { 308 case SkIntersectionHelper::kQuad_Segment: {
309 pts = ts.quadQuad(wt.pts(), wn.pts()); 309 pts = ts.quadQuad(wt.pts(), wn.pts());
310 ts.alignQuadPts(wt.pts(), wn.pts());
310 debugShowQuadIntersection(pts, wt, wn, ts); 311 debugShowQuadIntersection(pts, wt, wn, ts);
311 break; 312 break;
312 } 313 }
313 case SkIntersectionHelper::kCubic_Segment: { 314 case SkIntersectionHelper::kCubic_Segment: {
314 swap = true; 315 swap = true;
315 pts = ts.cubicQuad(wn.pts(), wt.pts()); 316 pts = ts.cubicQuad(wn.pts(), wt.pts());
316 debugShowCubicQuadIntersection(pts, wn, wt, ts); 317 debugShowCubicQuadIntersection(pts, wn, wt, ts);
317 break; 318 break;
318 } 319 }
319 default: 320 default:
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 next->addCross(test); 360 next->addCross(test);
360 foundCommonContour = true; 361 foundCommonContour = true;
361 } 362 }
362 // in addition to recording T values, record matching segment 363 // in addition to recording T values, record matching segment
363 if (pts == 2) { 364 if (pts == 2) {
364 if (wn.segmentType() <= SkIntersectionHelper::kLine_Segment 365 if (wn.segmentType() <= SkIntersectionHelper::kLine_Segment
365 && wt.segmentType() <= SkIntersectionHelper::kLine_Segme nt) { 366 && wt.segmentType() <= SkIntersectionHelper::kLine_Segme nt) {
366 if (wt.addCoincident(wn, ts, swap)) { 367 if (wt.addCoincident(wn, ts, swap)) {
367 continue; 368 continue;
368 } 369 }
369 ts.cleanUpCoincidence(); // prefer (t == 0 or t == 1) 370 pts = ts.cleanUpCoincidence(); // prefer (t == 0 or t == 1)
370 pts = 1;
371 } else if (wn.segmentType() >= SkIntersectionHelper::kQuad_Segme nt 371 } else if (wn.segmentType() >= SkIntersectionHelper::kQuad_Segme nt
372 && wt.segmentType() >= SkIntersectionHelper::kQuad_Segme nt 372 && wt.segmentType() >= SkIntersectionHelper::kQuad_Segme nt
373 && ts.isCoincident(0)) { 373 && ts.isCoincident(0)) {
374 SkASSERT(ts.coincidentUsed() == 2); 374 SkASSERT(ts.coincidentUsed() == 2);
375 if (wt.addCoincident(wn, ts, swap)) { 375 if (wt.addCoincident(wn, ts, swap)) {
376 continue; 376 continue;
377 } 377 }
378 ts.cleanUpCoincidence(); // prefer (t == 0 or t == 1) 378 pts = ts.cleanUpCoincidence(); // prefer (t == 0 or t == 1)
379 pts = 1;
380 } 379 }
381 } 380 }
382 if (pts >= 2) { 381 if (pts >= 2) {
383 for (int pt = 0; pt < pts - 1; ++pt) { 382 for (int pt = 0; pt < pts - 1; ++pt) {
384 const SkDPoint& point = ts.pt(pt); 383 const SkDPoint& point = ts.pt(pt);
385 const SkDPoint& next = ts.pt(pt + 1); 384 const SkDPoint& next = ts.pt(pt + 1);
386 if (wt.isPartial(ts[swap][pt], ts[swap][pt + 1], point, next ) 385 if (wt.isPartial(ts[swap][pt], ts[swap][pt + 1], point, next )
387 && wn.isPartial(ts[!swap][pt], ts[!swap][pt + 1], po int, next)) { 386 && wn.isPartial(ts[!swap][pt], ts[!swap][pt + 1], po int, next)) {
388 if (!wt.addPartialCoincident(wn, ts, pt, swap)) { 387 if (!wt.addPartialCoincident(wn, ts, pt, swap)) {
389 // remove extra point if two map to same float value s 388 // remove extra point if two map to same float value s
390 ts.cleanUpCoincidence(); // prefer (t == 0 or t == 1) 389 pts = ts.cleanUpCoincidence(); // prefer (t == 0 or t == 1)
391 pts = 1;
392 } 390 }
393 } 391 }
394 } 392 }
395 } 393 }
396 for (int pt = 0; pt < pts; ++pt) { 394 for (int pt = 0; pt < pts; ++pt) {
397 SkASSERT(ts[0][pt] >= 0 && ts[0][pt] <= 1); 395 SkASSERT(ts[0][pt] >= 0 && ts[0][pt] <= 1);
398 SkASSERT(ts[1][pt] >= 0 && ts[1][pt] <= 1); 396 SkASSERT(ts[1][pt] >= 0 && ts[1][pt] <= 1);
399 SkPoint point = ts.pt(pt).asSkPoint(); 397 SkPoint point = ts.pt(pt).asSkPoint();
400 wt.alignTPt(wn, swap, pt, &ts, &point); 398 wt.alignTPt(wn, swap, pt, &ts, &point);
401 int testTAt = wt.addT(wn, point, ts[swap][pt]); 399 int testTAt = wt.addT(wn, point, ts[swap][pt]);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 if (!contour->calcCoincidentWinding()) { 447 if (!contour->calcCoincidentWinding()) {
450 return false; 448 return false;
451 } 449 }
452 } 450 }
453 for (int cIndex = 0; cIndex < contourCount; ++cIndex) { 451 for (int cIndex = 0; cIndex < contourCount; ++cIndex) {
454 SkOpContour* contour = (*contourList)[cIndex]; 452 SkOpContour* contour = (*contourList)[cIndex];
455 contour->calcPartialCoincidentWinding(); 453 contour->calcPartialCoincidentWinding();
456 } 454 }
457 return true; 455 return true;
458 } 456 }
OLDNEW
« no previous file with comments | « gyp/pathops_unittest.gypi ('k') | src/pathops/SkDCubicIntersection.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698