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

Side by Side Diff: tests/PathOpsDebug.cpp

Issue 2128633003: pathops coincidence and security rewrite (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: require resulting t to be between 0 and 1 Created 4 years, 5 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
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 void SkPathOpsDebug::WindingPrintf(int wind) { 44 void SkPathOpsDebug::WindingPrintf(int wind) {
45 if (wind == SK_MinS32) { 45 if (wind == SK_MinS32) {
46 SkDebugf("?"); 46 SkDebugf("?");
47 } else { 47 } else {
48 SkDebugf("%d", wind); 48 SkDebugf("%d", wind);
49 } 49 }
50 } 50 }
51 #endif 51 #endif
52 52
53 static void DumpID(int id) {
54 SkDebugf("} ");
55 if (id >= 0) {
56 SkDebugf("id=%d", id);
57 }
58 SkDebugf("\n");
59 }
60
53 void SkDConic::dump() const { 61 void SkDConic::dump() const {
54 dumpInner(); 62 dumpInner();
55 SkDebugf("},\n"); 63 SkDebugf("},\n");
56 } 64 }
57 65
58 void SkDConic::dumpID(int id) const { 66 void SkDConic::dumpID(int id) const {
59 dumpInner(); 67 dumpInner();
60 SkDebugf("} id=%d\n", id); 68 DumpID(id);
61 } 69 }
62 70
63 void SkDConic::dumpInner() const { 71 void SkDConic::dumpInner() const {
64 SkDebugf("{"); 72 SkDebugf("{");
65 fPts.dumpInner(); 73 fPts.dumpInner();
66 SkDebugf("}}, %1.9gf", fWeight); 74 SkDebugf("}}, %1.9gf", fWeight);
67 } 75 }
68 76
69 void SkDCubic::dump() const { 77 void SkDCubic::dump() const {
70 this->dumpInner(); 78 this->dumpInner();
71 SkDebugf("}},\n"); 79 SkDebugf("}},\n");
72 } 80 }
73 81
74 void SkDCubic::dumpID(int id) const { 82 void SkDCubic::dumpID(int id) const {
75 this->dumpInner(); 83 this->dumpInner();
76 SkDebugf("}} id=%d\n", id); 84 SkDebugf("}");
85 DumpID(id);
77 } 86 }
78 87
79 static inline bool double_is_NaN(double x) { return x != x; } 88 static inline bool double_is_NaN(double x) { return x != x; }
80 89
81 void SkDCubic::dumpInner() const { 90 void SkDCubic::dumpInner() const {
82 SkDebugf("{{"); 91 SkDebugf("{{");
83 int index = 0; 92 int index = 0;
84 do { 93 do {
85 if (index != 0) { 94 if (index != 0) {
86 if (double_is_NaN(fPts[index].fX) && double_is_NaN(fPts[index].fY)) { 95 if (double_is_NaN(fPts[index].fX) && double_is_NaN(fPts[index].fY)) {
87 return; 96 return;
88 } 97 }
89 SkDebugf(", "); 98 SkDebugf(", ");
90 } 99 }
91 fPts[index].dump(); 100 fPts[index].dump();
92 } while (++index < 3); 101 } while (++index < 3);
93 if (double_is_NaN(fPts[index].fX) && double_is_NaN(fPts[index].fY)) { 102 if (double_is_NaN(fPts[index].fX) && double_is_NaN(fPts[index].fY)) {
94 return; 103 return;
95 } 104 }
96 SkDebugf(", "); 105 SkDebugf(", ");
97 fPts[index].dump(); 106 fPts[index].dump();
98 } 107 }
99 108
109 void SkDCurve::dump() const {
110 dumpID(-1);
111 }
112
100 void SkDCurve::dumpID(int id) const { 113 void SkDCurve::dumpID(int id) const {
101 #ifndef SK_RELEASE 114 #ifndef SK_RELEASE
102 switch(fVerb) { 115 switch(fVerb) {
103 case SkPath::kLine_Verb: 116 case SkPath::kLine_Verb:
104 fLine.dumpID(id); 117 fLine.dumpID(id);
105 break; 118 break;
106 case SkPath::kQuad_Verb: 119 case SkPath::kQuad_Verb:
107 fQuad.dumpID(id); 120 fQuad.dumpID(id);
108 break; 121 break;
109 case SkPath::kConic_Verb: 122 case SkPath::kConic_Verb:
(...skipping 10 matching lines...) Expand all
120 #endif 133 #endif
121 } 134 }
122 135
123 void SkDLine::dump() const { 136 void SkDLine::dump() const {
124 this->dumpInner(); 137 this->dumpInner();
125 SkDebugf("}},\n"); 138 SkDebugf("}},\n");
126 } 139 }
127 140
128 void SkDLine::dumpID(int id) const { 141 void SkDLine::dumpID(int id) const {
129 this->dumpInner(); 142 this->dumpInner();
130 SkDebugf("}} id=%d\n", id); 143 SkDebugf("}");
144 DumpID(id);
131 } 145 }
132 146
133 void SkDLine::dumpInner() const { 147 void SkDLine::dumpInner() const {
134 SkDebugf("{{"); 148 SkDebugf("{{");
135 fPts[0].dump(); 149 fPts[0].dump();
136 SkDebugf(", "); 150 SkDebugf(", ");
137 fPts[1].dump(); 151 fPts[1].dump();
138 } 152 }
139 153
140 void SkDPoint::dump() const { 154 void SkDPoint::dump() const {
(...skipping 20 matching lines...) Expand all
161 SkDebugf("}"); 175 SkDebugf("}");
162 } 176 }
163 177
164 void SkDQuad::dump() const { 178 void SkDQuad::dump() const {
165 dumpInner(); 179 dumpInner();
166 SkDebugf("}},\n"); 180 SkDebugf("}},\n");
167 } 181 }
168 182
169 void SkDQuad::dumpID(int id) const { 183 void SkDQuad::dumpID(int id) const {
170 dumpInner(); 184 dumpInner();
171 SkDebugf("}} id=%d\n", id); 185 SkDebugf("}");
186 DumpID(id);
172 } 187 }
173 188
174 void SkDQuad::dumpInner() const { 189 void SkDQuad::dumpInner() const {
175 SkDebugf("{{"); 190 SkDebugf("{{");
176 int index = 0; 191 int index = 0;
177 do { 192 do {
178 fPts[index].dump(); 193 fPts[index].dump();
179 SkDebugf(", "); 194 SkDebugf(", ");
180 } while (++index < 2); 195 } while (++index < 2);
181 fPts[index].dump(); 196 fPts[index].dump();
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 795
781 void DumpT(const SkDQuad& quad, double t) { 796 void DumpT(const SkDQuad& quad, double t) {
782 SkDLine line = {{quad.ptAtT(t), quad[0]}}; 797 SkDLine line = {{quad.ptAtT(t), quad[0]}};
783 line.dump(); 798 line.dump();
784 } 799 }
785 800
786 const SkOpAngle* SkOpAngle::debugAngle(int id) const { 801 const SkOpAngle* SkOpAngle::debugAngle(int id) const {
787 return this->segment()->debugAngle(id); 802 return this->segment()->debugAngle(id);
788 } 803 }
789 804
805 const SkOpCoincidence* SkOpAngle::debugCoincidence() const {
806 return this->segment()->debugCoincidence();
807 }
808
790 SkOpContour* SkOpAngle::debugContour(int id) { 809 SkOpContour* SkOpAngle::debugContour(int id) {
791 return this->segment()->debugContour(id); 810 return this->segment()->debugContour(id);
792 } 811 }
793 812
794 const SkOpPtT* SkOpAngle::debugPtT(int id) const { 813 const SkOpPtT* SkOpAngle::debugPtT(int id) const {
795 return this->segment()->debugPtT(id); 814 return this->segment()->debugPtT(id);
796 } 815 }
797 816
798 const SkOpSegment* SkOpAngle::debugSegment(int id) const { 817 const SkOpSegment* SkOpAngle::debugSegment(int id) const {
799 return this->segment()->debugSegment(id); 818 return this->segment()->debugSegment(id);
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 } 937 }
919 938
920 const SkOpAngle* SkOpPtT::debugAngle(int id) const { 939 const SkOpAngle* SkOpPtT::debugAngle(int id) const {
921 return this->span()->debugAngle(id); 940 return this->span()->debugAngle(id);
922 } 941 }
923 942
924 SkOpContour* SkOpPtT::debugContour(int id) { 943 SkOpContour* SkOpPtT::debugContour(int id) {
925 return this->span()->debugContour(id); 944 return this->span()->debugContour(id);
926 } 945 }
927 946
947 const SkOpCoincidence* SkOpPtT::debugCoincidence() const {
948 return this->span()->debugCoincidence();
949 }
950
928 const SkOpPtT* SkOpPtT::debugPtT(int id) const { 951 const SkOpPtT* SkOpPtT::debugPtT(int id) const {
929 return this->span()->debugPtT(id); 952 return this->span()->debugPtT(id);
930 } 953 }
931 954
932 const SkOpSegment* SkOpPtT::debugSegment(int id) const { 955 const SkOpSegment* SkOpPtT::debugSegment(int id) const {
933 return this->span()->debugSegment(id); 956 return this->span()->debugSegment(id);
934 } 957 }
935 958
936 const SkOpSpanBase* SkOpPtT::debugSpan(int id) const { 959 const SkOpSpanBase* SkOpPtT::debugSpan(int id) const {
937 return this->span()->debugSpan(id); 960 return this->span()->debugSpan(id);
(...skipping 19 matching lines...) Expand all
957 SkDebugf("\n"); 980 SkDebugf("\n");
958 if (limit && ++loop >= limit) { 981 if (limit && ++loop >= limit) {
959 SkDebugf("*** abort loop ***\n"); 982 SkDebugf("*** abort loop ***\n");
960 break; 983 break;
961 } 984 }
962 } while ((next = next->fNext) && next != this); 985 } while ((next = next->fNext) && next != this);
963 contour()->outdentDump(); 986 contour()->outdentDump();
964 } 987 }
965 988
966 void SkOpPtT::dumpBase() const { 989 void SkOpPtT::dumpBase() const {
967 SkDebugf(" t=%1.9g pt=(%1.9g,%1.9g)%s%s", this->fT, this->fPt.fX, this->fPt. fY, 990 SkDebugf(" t=%1.9g pt=(%1.9g,%1.9g)%s%s%s", this->fT, this->fPt.fX, this->fP t.fY,
991 this->fCoincident ? " coin" : "",
968 this->fDuplicatePt ? " dup" : "", this->fDeleted ? " deleted" : ""); 992 this->fDuplicatePt ? " dup" : "", this->fDeleted ? " deleted" : "");
969 } 993 }
970 994
971 const SkOpAngle* SkOpSpanBase::debugAngle(int id) const { 995 const SkOpAngle* SkOpSpanBase::debugAngle(int id) const {
972 return this->segment()->debugAngle(id); 996 return this->segment()->debugAngle(id);
973 } 997 }
974 998
999 const SkOpCoincidence* SkOpSpanBase::debugCoincidence() const {
1000 return this->segment()->debugCoincidence();
1001 }
1002
975 SkOpContour* SkOpSpanBase::debugContour(int id) { 1003 SkOpContour* SkOpSpanBase::debugContour(int id) {
976 return this->segment()->debugContour(id); 1004 return this->segment()->debugContour(id);
977 } 1005 }
978 1006
979 const SkOpPtT* SkOpSpanBase::debugPtT(int id) const { 1007 const SkOpPtT* SkOpSpanBase::debugPtT(int id) const {
980 return this->segment()->debugPtT(id); 1008 return this->segment()->debugPtT(id);
981 } 1009 }
982 1010
983 const SkOpSegment* SkOpSpanBase::debugSegment(int id) const { 1011 const SkOpSegment* SkOpSpanBase::debugSegment(int id) const {
984 return this->segment()->debugSegment(id); 1012 return this->segment()->debugSegment(id);
985 } 1013 }
986 1014
987 const SkOpSpanBase* SkOpSpanBase::debugSpan(int id) const { 1015 const SkOpSpanBase* SkOpSpanBase::debugSpan(int id) const {
988 return this->segment()->debugSpan(id); 1016 return this->segment()->debugSpan(id);
989 } 1017 }
990 1018
991 void SkOpSpanBase::dump() const { 1019 void SkOpSpanBase::dump() const {
992 this->dumpAll(); 1020 this->dumpHead();
1021 this->fPtT.dump();
1022 }
1023
1024 void SkOpSpanBase::dumpHead() const {
1025 SkDebugf("%.*s", contour()->debugIndent(), " ");
1026 SkDebugf("seg=%d span=%d", this->segment()->debugID(), this->debugID());
1027 this->dumpBase();
993 SkDebugf("\n"); 1028 SkDebugf("\n");
994 } 1029 }
995 1030
996 void SkOpSpanBase::dumpAll() const { 1031 void SkOpSpanBase::dumpAll() const {
997 SkDebugf("%.*s", contour()->debugIndent(), " "); 1032 this->dumpHead();
998 SkDebugf("seg=%d span=%d", this->segment()->debugID(), this->debugID());
999 this->dumpBase();
1000 SkDebugf("\n");
1001 this->fPtT.dumpAll(); 1033 this->fPtT.dumpAll();
1002 } 1034 }
1003 1035
1004 void SkOpSpanBase::dumpBase() const { 1036 void SkOpSpanBase::dumpBase() const {
1005 if (this->fAligned) { 1037 if (this->fAligned) {
1006 SkDebugf(" aligned"); 1038 SkDebugf(" aligned");
1007 } 1039 }
1008 if (this->fChased) { 1040 if (this->fChased) {
1009 SkDebugf(" chased"); 1041 SkDebugf(" chased");
1010 } 1042 }
1043 #ifdef SK_DEBUG
1044 if (this->fDeleted) {
1045 SkDebugf(" deleted");
1046 }
1047 #endif
1011 if (!this->final()) { 1048 if (!this->final()) {
1012 this->upCast()->dumpSpan(); 1049 this->upCast()->dumpSpan();
1013 } 1050 }
1014 const SkOpSpanBase* coin = this->coinEnd(); 1051 const SkOpSpanBase* coin = this->coinEnd();
1015 if (this != coin) { 1052 if (this != coin) {
1016 SkDebugf(" coinEnd seg/span=%d/%d", coin->segment()->debugID(), coin->de bugID()); 1053 SkDebugf(" coinEnd seg/span=%d/%d", coin->segment()->debugID(), coin->de bugID());
1017 } else if (this->final() || !this->upCast()->isCoincident()) { 1054 } else if (this->final() || !this->upCast()->isCoincident()) {
1018 const SkOpPtT* oPt = this->ptT()->next(); 1055 const SkOpPtT* oPt = this->ptT()->next();
1019 SkDebugf(" seg/span=%d/%d", oPt->segment()->debugID(), oPt->span()->debu gID()); 1056 SkDebugf(" seg/span=%d/%d", oPt->segment()->debugID(), oPt->span()->debu gID());
1020 } 1057 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1062 if (this->done()) { 1099 if (this->done()) {
1063 SkDebugf(" done"); 1100 SkDebugf(" done");
1064 } 1101 }
1065 return this != coin; 1102 return this != coin;
1066 } 1103 }
1067 1104
1068 const SkOpAngle* SkOpSegment::debugAngle(int id) const { 1105 const SkOpAngle* SkOpSegment::debugAngle(int id) const {
1069 return this->contour()->debugAngle(id); 1106 return this->contour()->debugAngle(id);
1070 } 1107 }
1071 1108
1109
1110 const SkOpCoincidence* SkOpSegment::debugCoincidence() const {
1111 return this->contour()->debugCoincidence();
1112 }
1113
1072 SkOpContour* SkOpSegment::debugContour(int id) { 1114 SkOpContour* SkOpSegment::debugContour(int id) {
1073 return this->contour()->debugContour(id); 1115 return this->contour()->debugContour(id);
1074 } 1116 }
1075 1117
1076 const SkOpPtT* SkOpSegment::debugPtT(int id) const { 1118 const SkOpPtT* SkOpSegment::debugPtT(int id) const {
1077 return this->contour()->debugPtT(id); 1119 return this->contour()->debugPtT(id);
1078 } 1120 }
1079 1121
1080 const SkOpSegment* SkOpSegment::debugSegment(int id) const { 1122 const SkOpSegment* SkOpSegment::debugSegment(int id) const {
1081 return this->contour()->debugSegment(id); 1123 return this->contour()->debugSegment(id);
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1181 if (fOppPtTStart->segment()->isXor()) { 1223 if (fOppPtTStart->segment()->isXor()) {
1182 SkDebugf(" xor"); 1224 SkDebugf(" xor");
1183 } 1225 }
1184 SkDebugf("\n"); 1226 SkDebugf("\n");
1185 } 1227 }
1186 1228
1187 void SkOpCoincidence::dump() const { 1229 void SkOpCoincidence::dump() const {
1188 SkCoincidentSpans* span = fHead; 1230 SkCoincidentSpans* span = fHead;
1189 while (span) { 1231 while (span) {
1190 span->dump(); 1232 span->dump();
1191 span = span->fNext; 1233 span = span->next();
1192 } 1234 }
1193 if (!fTop || fHead == fTop) { 1235 if (!fTop || fHead == fTop) {
1194 return; 1236 return;
1195 } 1237 }
1196 SkDebugf("top:\n"); 1238 SkDebugf("top:\n");
1197 span = fTop; 1239 span = fTop;
1198 if (fHead) { 1240 int count = 0;
1199 span->dump();
1200 return;
1201 }
1202 while (span) { 1241 while (span) {
1203 span->dump(); 1242 span->dump();
1204 span = span->fNext; 1243 span = span->next();
1244 SkCoincidentSpans* check = fTop;
1245 ++count;
1246 for (int index = 0; index < count; ++index) {
1247 if (span == check) {
1248 SkDebugf("(loops to #%d)\n", index);
1249 return;
1250 }
1251 check = check->next();
1252 }
1205 } 1253 }
1206 } 1254 }
1207 1255
1208 void SkOpContour::dump() const { 1256 void SkOpContour::dump() const {
1209 SkDebugf("contour=%d count=%d op=%d xor=%d\n", this->debugID(), fCount, fOpe rand, fXor); 1257 SkDebugf("contour=%d count=%d op=%d xor=%d\n", this->debugID(), fCount, fOpe rand, fXor);
1210 if (!fCount) { 1258 if (!fCount) {
1211 return; 1259 return;
1212 } 1260 }
1213 const SkOpSegment* segment = &fHead; 1261 const SkOpSegment* segment = &fHead;
1214 SkDEBUGCODE(fDebugIndent = 0); 1262 SkDEBUGCODE(fDebugIndent = 0);
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
1406 segment = segment->next(); 1454 segment = segment->next();
1407 } 1455 }
1408 } while ((contour = contour->next())); 1456 } while ((contour = contour->next()));
1409 return nullptr; 1457 return nullptr;
1410 } 1458 }
1411 #endif 1459 #endif
1412 1460
1413 #if DEBUG_T_SECT_DUMP > 1 1461 #if DEBUG_T_SECT_DUMP > 1
1414 int gDumpTSectNum; 1462 int gDumpTSectNum;
1415 #endif 1463 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698