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: tests/PathOpsDebug.cpp

Issue 1394503003: fix some pathops bugs found in 1M skps (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: init to avoid warning Created 5 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 | « tests/PathOpsCubicIntersectionTest.cpp ('k') | tests/PathOpsExtendedTest.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 2014 Google Inc. 2 * Copyright 2014 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 "PathOpsTSectDebug.h" 8 #include "PathOpsTSectDebug.h"
9 #include "SkOpCoincidence.h" 9 #include "SkOpCoincidence.h"
10 #include "SkOpContour.h" 10 #include "SkOpContour.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 dumpInner(); 54 dumpInner();
55 SkDebugf("},\n"); 55 SkDebugf("},\n");
56 } 56 }
57 57
58 void SkDConic::dumpID(int id) const { 58 void SkDConic::dumpID(int id) const {
59 dumpInner(); 59 dumpInner();
60 SkDebugf("} id=%d\n", id); 60 SkDebugf("} id=%d\n", id);
61 } 61 }
62 62
63 void SkDConic::dumpInner() const { 63 void SkDConic::dumpInner() const {
64 SkDebugf("{{"); 64 SkDebugf("{");
65 int index = 0; 65 fPts.dumpInner();
66 do { 66 SkDebugf("}}, %1.9gf", fWeight);
67 fPts[index].dump();
68 SkDebugf(", ");
69 } while (++index < 2);
70 fPts[index].dump();
71 SkDebugf("}, %1.9g", fWeight);
72 } 67 }
73 68
74 void SkDCubic::dump() const { 69 void SkDCubic::dump() const {
75 this->dumpInner(); 70 this->dumpInner();
76 SkDebugf("}},\n"); 71 SkDebugf("}},\n");
77 } 72 }
78 73
79 void SkDCubic::dumpID(int id) const { 74 void SkDCubic::dumpID(int id) const {
80 this->dumpInner(); 75 this->dumpInner();
81 SkDebugf("}} id=%d\n", id); 76 SkDebugf("}} id=%d\n", id);
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 Dump(&q1c2); 662 Dump(&q1c2);
668 Dump(&k1q2); 663 Dump(&k1q2);
669 Dump(&k1k2); 664 Dump(&k1k2);
670 Dump(&k1c2); 665 Dump(&k1c2);
671 Dump(&c1q2); 666 Dump(&c1q2);
672 Dump(&c1k2); 667 Dump(&c1k2);
673 Dump(&c1c2); 668 Dump(&c1c2);
674 } 669 }
675 670
676 template <typename TCurve, typename OppCurve> 671 template <typename TCurve, typename OppCurve>
672 void DumpAll(const SkTSpan<TCurve, OppCurve>* span) {
673 span->dumpAll();
674 }
675
676 void DontCallDumpSpanAll();
677 void DontCallDumpSpanAll() { // exists to instantiate the templates
678 SkTSpan<SkDQuad, SkDQuad> q1q2; q1q2.debugInit();
679 SkTSpan<SkDQuad, SkDConic> q1k2; q1k2.debugInit();
680 SkTSpan<SkDQuad, SkDCubic> q1c2; q1c2.debugInit();
681 SkTSpan<SkDConic, SkDQuad> k1q2; k1q2.debugInit();
682 SkTSpan<SkDConic, SkDConic> k1k2; k1k2.debugInit();
683 SkTSpan<SkDConic, SkDCubic> k1c2; k1c2.debugInit();
684 SkTSpan<SkDCubic, SkDQuad> c1q2; c1q2.debugInit();
685 SkTSpan<SkDCubic, SkDConic> c1k2; c1k2.debugInit();
686 SkTSpan<SkDCubic, SkDCubic> c1c2; c1c2.debugInit();
687 DumpAll(&q1q2);
688 DumpAll(&q1k2);
689 DumpAll(&q1c2);
690 DumpAll(&k1q2);
691 DumpAll(&k1k2);
692 DumpAll(&k1c2);
693 DumpAll(&c1q2);
694 DumpAll(&c1k2);
695 DumpAll(&c1c2);
696 }
697
698 template <typename TCurve, typename OppCurve>
699 void DumpBounded(const SkTSpan<TCurve, OppCurve>* span) {
700 span->dumpBounded(0);
701 }
702
703 void DontCallDumpSpanBounded();
704 void DontCallDumpSpanBounded() { // exists to instantiate the templates
705 SkTSpan<SkDQuad, SkDQuad> q1q2; q1q2.debugInit();
706 SkTSpan<SkDQuad, SkDConic> q1k2; q1k2.debugInit();
707 SkTSpan<SkDQuad, SkDCubic> q1c2; q1c2.debugInit();
708 SkTSpan<SkDConic, SkDQuad> k1q2; k1q2.debugInit();
709 SkTSpan<SkDConic, SkDConic> k1k2; k1k2.debugInit();
710 SkTSpan<SkDConic, SkDCubic> k1c2; k1c2.debugInit();
711 SkTSpan<SkDCubic, SkDQuad> c1q2; c1q2.debugInit();
712 SkTSpan<SkDCubic, SkDConic> c1k2; c1k2.debugInit();
713 SkTSpan<SkDCubic, SkDCubic> c1c2; c1c2.debugInit();
714 DumpBounded(&q1q2);
715 DumpBounded(&q1k2);
716 DumpBounded(&q1c2);
717 DumpBounded(&k1q2);
718 DumpBounded(&k1k2);
719 DumpBounded(&k1c2);
720 DumpBounded(&c1q2);
721 DumpBounded(&c1k2);
722 DumpBounded(&c1c2);
723 }
724
725 template <typename TCurve, typename OppCurve>
677 void DumpCoin(const SkTSpan<TCurve, OppCurve>* span) { 726 void DumpCoin(const SkTSpan<TCurve, OppCurve>* span) {
678 span->dumpCoin(); 727 span->dumpCoin();
679 } 728 }
680 729
681 void DontCallDumpSpanCoin(); 730 void DontCallDumpSpanCoin();
682 void DontCallDumpSpanCoin() { // exists to instantiate the templates 731 void DontCallDumpSpanCoin() { // exists to instantiate the templates
683 SkTSpan<SkDQuad, SkDQuad> q1q2; q1q2.debugInit(); 732 SkTSpan<SkDQuad, SkDQuad> q1q2; q1q2.debugInit();
684 SkTSpan<SkDQuad, SkDConic> q1k2; q1k2.debugInit(); 733 SkTSpan<SkDQuad, SkDConic> q1k2; q1k2.debugInit();
685 SkTSpan<SkDQuad, SkDCubic> q1c2; q1c2.debugInit(); 734 SkTSpan<SkDQuad, SkDCubic> q1c2; q1c2.debugInit();
686 SkTSpan<SkDConic, SkDQuad> k1q2; k1q2.debugInit(); 735 SkTSpan<SkDConic, SkDQuad> k1q2; k1q2.debugInit();
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
1078 } while (!span->final() && (span = span->upCast()->next())); 1127 } while (!span->final() && (span = span->upCast()->next()));
1079 } 1128 }
1080 1129
1081 void SkOpSegment::dumpCoin() const { 1130 void SkOpSegment::dumpCoin() const {
1082 const SkOpSpan* span = &fHead; 1131 const SkOpSpan* span = &fHead;
1083 do { 1132 do {
1084 span->dumpCoin(); 1133 span->dumpCoin();
1085 } while ((span = span->next()->upCastable())); 1134 } while ((span = span->next()->upCastable()));
1086 } 1135 }
1087 1136
1088 void SkOpSegment::dumpPtsInner() const { 1137 void SkOpSegment::dumpPtsInner(const char* prefix) const {
1089 int last = SkPathOpsVerbToPoints(fVerb); 1138 int last = SkPathOpsVerbToPoints(fVerb);
1090 SkDebugf("seg=%d {{", this->debugID()); 1139 SkDebugf("%s=%d {{", prefix, this->debugID());
1091 if (fVerb == SkPath::kConic_Verb) { 1140 if (fVerb == SkPath::kConic_Verb) {
1092 SkDebugf("{"); 1141 SkDebugf("{");
1093 } 1142 }
1094 int index = 0; 1143 int index = 0;
1095 do { 1144 do {
1096 SkDPoint::Dump(fPts[index]); 1145 SkDPoint::Dump(fPts[index]);
1097 SkDebugf(", "); 1146 SkDebugf(", ");
1098 } while (++index < last); 1147 } while (++index < last);
1099 SkDPoint::Dump(fPts[index]); 1148 SkDPoint::Dump(fPts[index]);
1100 SkDebugf("}}"); 1149 SkDebugf("}}");
1101 if (fVerb == SkPath::kConic_Verb) { 1150 if (fVerb == SkPath::kConic_Verb) {
1102 SkDebugf(", %1.9gf}", fWeight); 1151 SkDebugf(", %1.9gf}", fWeight);
1103 } 1152 }
1104 } 1153 }
1105 1154
1106 void SkOpSegment::dumpPts() const { 1155 void SkOpSegment::dumpPts(const char* prefix) const {
1107 dumpPtsInner(); 1156 dumpPtsInner(prefix);
1108 SkDebugf("\n"); 1157 SkDebugf("\n");
1109 } 1158 }
1110 1159
1111 void SkCoincidentSpans::dump() const { 1160 void SkCoincidentSpans::dump() const {
1112 SkDebugf("- seg=%d span=%d ptT=%d ", fCoinPtTStart->segment()->debugID(), 1161 SkDebugf("- seg=%d span=%d ptT=%d ", fCoinPtTStart->segment()->debugID(),
1113 fCoinPtTStart->span()->debugID(), fCoinPtTStart->debugID()); 1162 fCoinPtTStart->span()->debugID(), fCoinPtTStart->debugID());
1114 fCoinPtTStart->dumpBase(); 1163 fCoinPtTStart->dumpBase();
1115 SkDebugf(" span=%d ptT=%d ", fCoinPtTEnd->span()->debugID(), fCoinPtTEnd->de bugID()); 1164 SkDebugf(" span=%d ptT=%d ", fCoinPtTEnd->span()->debugID(), fCoinPtTEnd->de bugID());
1116 fCoinPtTEnd->dumpBase(); 1165 fCoinPtTEnd->dumpBase();
1117 if (fCoinPtTStart->segment()->operand()) { 1166 if (fCoinPtTStart->segment()->operand()) {
(...skipping 16 matching lines...) Expand all
1134 } 1183 }
1135 SkDebugf("\n"); 1184 SkDebugf("\n");
1136 } 1185 }
1137 1186
1138 void SkOpCoincidence::dump() const { 1187 void SkOpCoincidence::dump() const {
1139 SkCoincidentSpans* span = fHead; 1188 SkCoincidentSpans* span = fHead;
1140 while (span) { 1189 while (span) {
1141 span->dump(); 1190 span->dump();
1142 span = span->fNext; 1191 span = span->fNext;
1143 } 1192 }
1144 if (!fTop) { 1193 if (!fTop || fHead == fTop) {
1145 return; 1194 return;
1146 } 1195 }
1147 SkDebugf("top:\n"); 1196 SkDebugf("top:\n");
1148 span = fTop; 1197 span = fTop;
1198 if (fHead) {
1199 span->dump();
1200 return;
1201 }
1149 while (span) { 1202 while (span) {
1150 span->dump(); 1203 span->dump();
1151 span = span->fNext; 1204 span = span->fNext;
1152 } 1205 }
1153 } 1206 }
1154 1207
1155 void SkOpContour::dump() const { 1208 void SkOpContour::dump() const {
1156 SkDebugf("contour=%d count=%d op=%d xor=%d\n", this->debugID(), fCount, fOpe rand, fXor); 1209 SkDebugf("contour=%d count=%d op=%d xor=%d\n", this->debugID(), fCount, fOpe rand, fXor);
1157 if (!fCount) { 1210 if (!fCount) {
1158 return; 1211 return;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1192 1245
1193 void SkOpContour::dumpPt(int index) const { 1246 void SkOpContour::dumpPt(int index) const {
1194 const SkOpSegment* segment = &fHead; 1247 const SkOpSegment* segment = &fHead;
1195 do { 1248 do {
1196 if (segment->debugID() == index) { 1249 if (segment->debugID() == index) {
1197 segment->dumpPts(); 1250 segment->dumpPts();
1198 } 1251 }
1199 } while ((segment = segment->next())); 1252 } while ((segment = segment->next()));
1200 } 1253 }
1201 1254
1202 void SkOpContour::dumpPts() const { 1255 void SkOpContour::dumpPts(const char* prefix) const {
1203 SkDebugf("contour=%d\n", this->debugID()); 1256 SkDebugf("contour=%d\n", this->debugID());
1204 const SkOpSegment* segment = &fHead; 1257 const SkOpSegment* segment = &fHead;
1205 do { 1258 do {
1206 SkDebugf(" seg=%d ", segment->debugID()); 1259 SkDebugf(" %s=%d ", prefix, segment->debugID());
1207 segment->dumpPts(); 1260 segment->dumpPts(prefix);
1208 } while ((segment = segment->next())); 1261 } while ((segment = segment->next()));
1209 } 1262 }
1210 1263
1211 void SkOpContour::dumpPtsX() const { 1264 void SkOpContour::dumpPtsX(const char* prefix) const {
1212 if (!this->fCount) { 1265 if (!this->fCount) {
1213 SkDebugf("<empty>\n"); 1266 SkDebugf("<empty>\n");
1214 return; 1267 return;
1215 } 1268 }
1216 const SkOpSegment* segment = &fHead; 1269 const SkOpSegment* segment = &fHead;
1217 do { 1270 do {
1218 segment->dumpPts(); 1271 segment->dumpPts(prefix);
1219 } while ((segment = segment->next())); 1272 } while ((segment = segment->next()));
1220 } 1273 }
1221 1274
1222 void SkOpContour::dumpSegment(int index) const { 1275 void SkOpContour::dumpSegment(int index) const {
1223 debugSegment(index)->dump(); 1276 debugSegment(index)->dump();
1224 } 1277 }
1225 1278
1226 void SkOpContour::dumpSegments(SkPathOp op) const { 1279 void SkOpContour::dumpSegments(const char* prefix, SkPathOp op) const {
1227 bool firstOp = false; 1280 bool firstOp = false;
1228 const SkOpContour* c = this; 1281 const SkOpContour* c = this;
1229 do { 1282 do {
1230 if (!firstOp && c->operand()) { 1283 if (!firstOp && c->operand() && op >= 0) {
1231 #if DEBUG_ACTIVE_OP 1284 #if DEBUG_ACTIVE_OP
1232 SkDebugf("op %s\n", SkPathOpsDebug::kPathOpStr[op]); 1285 SkDebugf("op %s\n", SkPathOpsDebug::kPathOpStr[op]);
1233 #endif 1286 #endif
1234 firstOp = true; 1287 firstOp = true;
1235 } 1288 }
1236 c->dumpPtsX(); 1289 c->dumpPtsX(prefix);
1237 } while ((c = c->next())); 1290 } while ((c = c->next()));
1238 } 1291 }
1239 1292
1240 void SkOpContour::dumpSpan(int index) const { 1293 void SkOpContour::dumpSpan(int index) const {
1241 debugSpan(index)->dump(); 1294 debugSpan(index)->dump();
1242 } 1295 }
1243 1296
1244 void SkOpContour::dumpSpans() const { 1297 void SkOpContour::dumpSpans() const {
1245 SkDebugf("contour=%d\n", this->debugID()); 1298 SkDebugf("contour=%d\n", this->debugID());
1246 const SkOpSegment* segment = &fHead; 1299 const SkOpSegment* segment = &fHead;
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1353 segment = segment->next(); 1406 segment = segment->next();
1354 } 1407 }
1355 } while ((contour = contour->next())); 1408 } while ((contour = contour->next()));
1356 return nullptr; 1409 return nullptr;
1357 } 1410 }
1358 #endif 1411 #endif
1359 1412
1360 #if DEBUG_T_SECT_DUMP > 1 1413 #if DEBUG_T_SECT_DUMP > 1
1361 int gDumpTSectNum; 1414 int gDumpTSectNum;
1362 #endif 1415 #endif
OLDNEW
« no previous file with comments | « tests/PathOpsCubicIntersectionTest.cpp ('k') | tests/PathOpsExtendedTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698