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

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

Issue 2274803003: add pathops debugging (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 4 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/SkPathOpsDebug.h ('k') | no next file » | 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 957 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 spanBase = test; 968 spanBase = test;
969 } while (!spanBase->final()); 969 } while (!spanBase->final());
970 debugValidate(); 970 debugValidate();
971 } 971 }
972 #endif 972 #endif
973 973
974 void SkOpSegment::debugReset() { 974 void SkOpSegment::debugReset() {
975 this->init(this->fPts, this->fWeight, this->contour(), this->verb()); 975 this->init(this->fPts, this->fWeight, this->contour(), this->verb());
976 } 976 }
977 977
978 #if DEBUG_COINCIDENCE_ORDER
979 void SkOpSegment::debugSetCoinT(int index, SkScalar t) const {
980 if (fDebugBaseMax < 0 || fDebugBaseIndex == index) {
981 fDebugBaseIndex = index;
982 fDebugBaseMin = SkTMin(t, fDebugBaseMin);
983 fDebugBaseMax = SkTMax(t, fDebugBaseMax);
984 return;
985 }
986 SkASSERT(fDebugBaseMin >= t || t >= fDebugBaseMax);
987 if (fDebugLastMax < 0 || fDebugLastIndex == index) {
988 fDebugLastIndex = index;
989 fDebugLastMin = SkTMin(t, fDebugLastMin);
990 fDebugLastMax = SkTMax(t, fDebugLastMax);
991 return;
992 }
993 SkASSERT(fDebugLastMin >= t || t >= fDebugLastMax);
994 SkASSERT((t - fDebugBaseMin > 0) == (fDebugLastMin - fDebugBaseMin > 0));
995 }
996 #endif
997
978 #if DEBUG_ACTIVE_SPANS 998 #if DEBUG_ACTIVE_SPANS
979 void SkOpSegment::debugShowActiveSpans() const { 999 void SkOpSegment::debugShowActiveSpans() const {
980 debugValidate(); 1000 debugValidate();
981 if (done()) { 1001 if (done()) {
982 return; 1002 return;
983 } 1003 }
984 int lastId = -1; 1004 int lastId = -1;
985 double lastT = -1; 1005 double lastT = -1;
986 const SkOpSpan* span = &fHead; 1006 const SkOpSpan* span = &fHead;
987 do { 1007 do {
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
1283 double midT = (end->t() + next->t()) / 2; 1303 double midT = (end->t() + next->t()) / 2;
1284 if (!segment->isClose(midT, oppSegment)) { 1304 if (!segment->isClose(midT, oppSegment)) {
1285 break; 1305 break;
1286 } 1306 }
1287 if (log) log->record(kExpandCoin_Glitch, id, this, next->ptT(), oppPtT); 1307 if (log) log->record(kExpandCoin_Glitch, id, this, next->ptT(), oppPtT);
1288 expanded = true; 1308 expanded = true;
1289 } while (false); // actual continues while expansion is possible 1309 } while (false); // actual continues while expansion is possible
1290 return expanded; 1310 return expanded;
1291 } 1311 }
1292 1312
1313 #undef FAIL_IF
1293 #define FAIL_IF(cond) do { if (cond) log->record(kAddExpandedFail_Glitch, id, c oin); } while (false) 1314 #define FAIL_IF(cond) do { if (cond) log->record(kAddExpandedFail_Glitch, id, c oin); } while (false)
1294 1315
1295 /* Commented-out lines keep this in sync with addExpanded */ 1316 /* Commented-out lines keep this in sync with addExpanded */
1296 // for each coincident pair, match the spans 1317 // for each coincident pair, match the spans
1297 // if the spans don't match, add the mssing pt to the segment and loop it in the opposite span 1318 // if the spans don't match, add the mssing pt to the segment and loop it in the opposite span
1298 void SkOpCoincidence::debugAddExpanded(const char* id, SkPathOpsDebug::GlitchLog * log) const { 1319 void SkOpCoincidence::debugAddExpanded(const char* id, SkPathOpsDebug::GlitchLog * log) const {
1299 const SkCoincidentSpans* coin = this->fHead; 1320 const SkCoincidentSpans* coin = this->fHead;
1300 if (!coin) { 1321 if (!coin) {
1301 return; 1322 return;
1302 } 1323 }
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after
1969 // 1990 //
1970 // 1991 //
1971 // continue; 1992 // continue;
1972 } 1993 }
1973 segment = segment->next(); 1994 segment = segment->next();
1974 } while (segment); 1995 } while (segment);
1975 return; 1996 return;
1976 } 1997 }
1977 #endif 1998 #endif
1978 1999
2000 #if DEBUG_COINCIDENCE_ORDER
2001 void SkOpSegment::debugResetCoinT() const {
2002 fDebugBaseIndex = -1;
2003 fDebugBaseMin = 1;
2004 fDebugBaseMax = -1;
2005 fDebugLastIndex = -1;
2006 fDebugLastMin = 1;
2007 fDebugLastMax = -1;
2008 }
2009 #endif
2010
1979 void SkOpSegment::debugValidate() const { 2011 void SkOpSegment::debugValidate() const {
2012 #if DEBUG_COINCIDENCE_ORDER
2013 {
2014 const SkOpSpanBase* span = &fHead;
2015 do {
2016 span->debugResetCoinT();
2017 } while (!span->final() && (span = span->upCast()->next()));
2018 span = &fHead;
2019 int index = 0;
2020 do {
2021 span->debugSetCoinT(index++);
2022 } while (!span->final() && (span = span->upCast()->next()));
2023 }
2024 #endif
1980 #if DEBUG_COINCIDENCE 2025 #if DEBUG_COINCIDENCE
1981 if (this->globalState()->debugCheckHealth()) { 2026 if (this->globalState()->debugCheckHealth()) {
1982 return; 2027 return;
1983 } 2028 }
1984 #endif 2029 #endif
1985 #if DEBUG_VALIDATE 2030 #if DEBUG_VALIDATE
1986 const SkOpSpanBase* span = &fHead; 2031 const SkOpSpanBase* span = &fHead;
1987 double lastT = -1; 2032 double lastT = -1;
1988 const SkOpSpanBase* prev = nullptr; 2033 const SkOpSpanBase* prev = nullptr;
1989 int count = 0; 2034 int count = 0;
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
2120 log->record(kMergeContained_Glitch, id, next, current); 2165 log->record(kMergeContained_Glitch, id, next, current);
2121 current = next; 2166 current = next;
2122 } 2167 }
2123 } 2168 }
2124 #if DEBUG_COINCIDENCE 2169 #if DEBUG_COINCIDENCE
2125 // this->globalState()->coincidence()->debugValidate(); 2170 // this->globalState()->coincidence()->debugValidate();
2126 #endif 2171 #endif
2127 } 2172 }
2128 #endif 2173 #endif
2129 2174
2175 void SkOpSpanBase::debugResetCoinT() const {
2176 #if DEBUG_COINCIDENCE_ORDER
2177 const SkOpPtT* ptT = &fPtT;
2178 do {
2179 ptT->debugResetCoinT();
2180 ptT = ptT->next();
2181 } while (ptT != &fPtT);
2182 #endif
2183 }
2184
2185 void SkOpSpanBase::debugSetCoinT(int index) const {
2186 #if DEBUG_COINCIDENCE_ORDER
2187 const SkOpPtT* ptT = &fPtT;
2188 do {
2189 if (!ptT->deleted()) {
2190 ptT->debugSetCoinT(index);
2191 }
2192 ptT = ptT->next();
2193 } while (ptT != &fPtT);
2194 #endif
2195 }
2196
2130 const SkOpSpan* SkOpSpanBase::debugStarter(SkOpSpanBase const** endPtr) const { 2197 const SkOpSpan* SkOpSpanBase::debugStarter(SkOpSpanBase const** endPtr) const {
2131 const SkOpSpanBase* end = *endPtr; 2198 const SkOpSpanBase* end = *endPtr;
2132 SkASSERT(this->segment() == end->segment()); 2199 SkASSERT(this->segment() == end->segment());
2133 const SkOpSpanBase* result; 2200 const SkOpSpanBase* result;
2134 if (t() < end->t()) { 2201 if (t() < end->t()) {
2135 result = this; 2202 result = this;
2136 } else { 2203 } else {
2137 result = end; 2204 result = end;
2138 *endPtr = this; 2205 *endPtr = this;
2139 } 2206 }
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
2329 // by taking a very long time to figure out that no loop entry is a dupl icate 2396 // by taking a very long time to figure out that no loop entry is a dupl icate
2330 // -- and it's likely that a large loop count is indicative of a bug som ewhere 2397 // -- and it's likely that a large loop count is indicative of a bug som ewhere
2331 if (++loop > 1000) { 2398 if (++loop > 1000) {
2332 SkDebugf("*** loop count exceeds 1000 ***\n"); 2399 SkDebugf("*** loop count exceeds 1000 ***\n");
2333 return 1000; 2400 return 1000;
2334 } 2401 }
2335 } while ((next = next->fNext) && next != this); 2402 } while ((next = next->fNext) && next != this);
2336 return 0; 2403 return 0;
2337 } 2404 }
2338 2405
2406 void SkOpPtT::debugResetCoinT() const {
2407 #if DEBUG_COINCIDENCE_ORDER
2408 this->segment()->debugResetCoinT();
2409 #endif
2410 }
2411
2412 void SkOpPtT::debugSetCoinT(int index) const {
2413 #if DEBUG_COINCIDENCE_ORDER
2414 this->segment()->debugSetCoinT(index, fT);
2415 #endif
2416 }
2417
2339 void SkOpPtT::debugValidate() const { 2418 void SkOpPtT::debugValidate() const {
2340 #if DEBUG_COINCIDENCE 2419 #if DEBUG_COINCIDENCE
2341 if (this->globalState()->debugCheckHealth()) { 2420 if (this->globalState()->debugCheckHealth()) {
2342 return; 2421 return;
2343 } 2422 }
2344 #endif 2423 #endif
2345 #if DEBUG_VALIDATE 2424 #if DEBUG_VALIDATE
2346 SkOpGlobalState::Phase phase = contour()->globalState()->phase(); 2425 SkOpGlobalState::Phase phase = contour()->globalState()->phase();
2347 if (phase == SkOpGlobalState::kIntersecting 2426 if (phase == SkOpGlobalState::kIntersecting
2348 || phase == SkOpGlobalState::kFixWinding) { 2427 || phase == SkOpGlobalState::kFixWinding) {
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
2451 #endif 2530 #endif
2452 SkPath::FillType fillType = path.getFillType(); 2531 SkPath::FillType fillType = path.getFillType();
2453 SkASSERT(fillType >= SkPath::kWinding_FillType && fillType <= SkPath::kInver seEvenOdd_FillType); 2532 SkASSERT(fillType >= SkPath::kWinding_FillType && fillType <= SkPath::kInver seEvenOdd_FillType);
2454 if (includeDeclaration) { 2533 if (includeDeclaration) {
2455 SkDebugf(" SkPath %s;\n", name); 2534 SkDebugf(" SkPath %s;\n", name);
2456 } 2535 }
2457 SkDebugf(" %s.setFillType(SkPath::%s);\n", name, gFillTypeStr[fillType]); 2536 SkDebugf(" %s.setFillType(SkPath::%s);\n", name, gFillTypeStr[fillType]);
2458 iter.setPath(path); 2537 iter.setPath(path);
2459 showPathContours(iter, name); 2538 showPathContours(iter, name);
2460 } 2539 }
OLDNEW
« no previous file with comments | « src/pathops/SkPathOpsDebug.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698