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

Side by Side Diff: src/pathops/SkPathOpsDebug.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/SkPathOpsCommon.cpp ('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 2013 Google Inc. 2 * Copyright 2013 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 7
8 #include "SkMutex.h" 8 #include "SkMutex.h"
9 #include "SkOpCoincidence.h" 9 #include "SkOpCoincidence.h"
10 #include "SkOpContour.h" 10 #include "SkOpContour.h"
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 } while ((contour = contour->next())); 270 } while ((contour = contour->next()));
271 } 271 }
272 272
273 273
274 #endif 274 #endif
275 275
276 #if DEBUG_COIN 276 #if DEBUG_COIN
277 void SkOpGlobalState::debugAddToCoinChangedDict() { 277 void SkOpGlobalState::debugAddToCoinChangedDict() {
278 278
279 #if DEBUG_COINCIDENCE 279 #if DEBUG_COINCIDENCE
280 CheckHealth(contourList); 280 SkPathOpsDebug::CheckHealth(fContourHead);
281 #endif 281 #endif
282 // see if next coincident operation makes a change; if so, record it 282 // see if next coincident operation makes a change; if so, record it
283 SkPathOpsDebug::GlitchLog glitches; 283 SkPathOpsDebug::GlitchLog glitches;
284 const char* funcName = fCoinDictEntry.fFunctionName; 284 const char* funcName = fCoinDictEntry.fFunctionName;
285 if (!strcmp("calc_angles", funcName)) { 285 if (!strcmp("calc_angles", funcName)) {
286 ; 286 ;
287 } else if (!strcmp("missing_coincidence", funcName)) { 287 } else if (!strcmp("missing_coincidence", funcName)) {
288 missing_coincidence(&glitches, fContourHead); 288 missing_coincidence(&glitches, fContourHead);
289 } else if (!strcmp("move_multiples", funcName)) { 289 } else if (!strcmp("move_multiples", funcName)) {
290 move_multiples(&glitches, fContourHead); 290 move_multiples(&glitches, fContourHead);
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 } 470 }
471 memmove(&str[idx + 2], &str[idx + 1], len - idx); 471 memmove(&str[idx + 2], &str[idx + 1], len - idx);
472 str[idx] = '*'; 472 str[idx] = '*';
473 str[idx + 1] = '^'; 473 str[idx + 1] = '^';
474 ++len; 474 ++len;
475 } 475 }
476 num = str[idx] >= '0' && str[idx] <= '9'; 476 num = str[idx] >= '0' && str[idx] <= '9';
477 } 477 }
478 } 478 }
479 479
480 #if DEBUG_VALIDATE
481 void SkPathOpsDebug::SetPhase(SkOpContourHead* contourList, CoinID next,
482 int lineNumber, SkOpPhase phase) {
483 AddedCoin(contourList, next, 0, lineNumber);
484 contourList->globalState()->setPhase(phase);
485 }
486 #endif
487
488 bool SkPathOpsDebug::ValidWind(int wind) { 480 bool SkPathOpsDebug::ValidWind(int wind) {
489 return wind > SK_MinS32 + 0xFFFF && wind < SK_MaxS32 - 0xFFFF; 481 return wind > SK_MinS32 + 0xFFFF && wind < SK_MaxS32 - 0xFFFF;
490 } 482 }
491 483
492 void SkPathOpsDebug::WindingPrintf(int wind) { 484 void SkPathOpsDebug::WindingPrintf(int wind) {
493 if (wind == SK_MinS32) { 485 if (wind == SK_MinS32) {
494 SkDebugf("?"); 486 SkDebugf("?");
495 } else { 487 } else {
496 SkDebugf("%d", wind); 488 SkDebugf("%d", wind);
497 } 489 }
(...skipping 1183 matching lines...) Expand 10 before | Expand all | Expand 10 after
1681 if (oTest != oEnd) { 1673 if (oTest != oEnd) {
1682 oPriorT = oTest->t(); 1674 oPriorT = oTest->t();
1683 oTest = coin->flipped() ? oTest->prev() : oTest->upCast()->next( ); 1675 oTest = coin->flipped() ? oTest->prev() : oTest->upCast()->next( );
1684 FAIL_IF(!oTest, coin); 1676 FAIL_IF(!oTest, coin);
1685 } 1677 }
1686 } 1678 }
1687 } while ((coin = coin->next())); 1679 } while ((coin = coin->next()));
1688 return; 1680 return;
1689 } 1681 }
1690 1682
1691 /* Commented-out lines keep this in sync with addIfMissing() */
1692 void SkOpCoincidence::debugAddIfMissing(SkPathOpsDebug::GlitchLog* log, const Sk CoincidentSpans* outer, const SkOpPtT* over1s,
1693 const SkOpPtT* over1e) const {
1694 // SkASSERT(fTop);
1695 if (fTop && alreadyAdded(fTop, outer, over1s, over1e)) { // in debug, fTop may be null
1696 return;
1697 }
1698 if (fHead && alreadyAdded(fHead, outer, over1s, over1e)) {
1699 return;
1700 }
1701 log->record(SkPathOpsDebug::kAddIfMissingCoin_Glitch, outer->coinPtTStart(), outer->coinPtTEnd(), over1s, over1e);
1702 this->debugValidate();
1703 return;
1704 }
1705
1706 /* Commented-out lines keep this in sync addIfMissing() */ 1683 /* Commented-out lines keep this in sync addIfMissing() */
1707 // note that over1s, over1e, over2s, over2e are ordered 1684 // note that over1s, over1e, over2s, over2e are ordered
1708 void SkOpCoincidence::debugAddIfMissing(SkPathOpsDebug::GlitchLog* log, const Sk OpPtT* over1s, const SkOpPtT* over2s, 1685 void SkOpCoincidence::debugAddIfMissing(SkPathOpsDebug::GlitchLog* log, const Sk OpPtT* over1s, const SkOpPtT* over2s,
1709 double tStart, double tEnd, const SkOpSegment* coinSeg, const SkOpSegmen t* oppSeg, bool* added, 1686 double tStart, double tEnd, const SkOpSegment* coinSeg, const SkOpSegmen t* oppSeg, bool* added,
1710 const SkOpPtT* over1e, const SkOpPtT* over2e) const { 1687 const SkOpPtT* over1e, const SkOpPtT* over2e) const {
1711 SkASSERT(tStart < tEnd); 1688 SkASSERT(tStart < tEnd);
1712 SkASSERT(over1s->fT < over1e->fT); 1689 SkASSERT(over1s->fT < over1e->fT);
1713 SkASSERT(between(over1s->fT, tStart, over1e->fT)); 1690 SkASSERT(between(over1s->fT, tStart, over1e->fT));
1714 SkASSERT(between(over1s->fT, tEnd, over1e->fT)); 1691 SkASSERT(between(over1s->fT, tEnd, over1e->fT));
1715 SkASSERT(over2s->fT < over2e->fT); 1692 SkASSERT(over2s->fT < over2e->fT);
(...skipping 1188 matching lines...) Expand 10 before | Expand all | Expand 10 after
2904 #endif 2881 #endif
2905 SkPath::FillType fillType = path.getFillType(); 2882 SkPath::FillType fillType = path.getFillType();
2906 SkASSERT(fillType >= SkPath::kWinding_FillType && fillType <= SkPath::kInver seEvenOdd_FillType); 2883 SkASSERT(fillType >= SkPath::kWinding_FillType && fillType <= SkPath::kInver seEvenOdd_FillType);
2907 if (includeDeclaration) { 2884 if (includeDeclaration) {
2908 SkDebugf(" SkPath %s;\n", name); 2885 SkDebugf(" SkPath %s;\n", name);
2909 } 2886 }
2910 SkDebugf(" %s.setFillType(SkPath::%s);\n", name, gFillTypeStr[fillType]); 2887 SkDebugf(" %s.setFillType(SkPath::%s);\n", name, gFillTypeStr[fillType]);
2911 iter.setPath(path); 2888 iter.setPath(path);
2912 showPathContours(iter, name); 2889 showPathContours(iter, name);
2913 } 2890 }
OLDNEW
« no previous file with comments | « src/pathops/SkPathOpsCommon.cpp ('k') | tests/PathOpsOpTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698