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

Side by Side Diff: tests/PathOpsDebug.cpp

Issue 1037953004: add conics to path ops (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: turn off pathops specific debuggging Created 5 years, 8 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/PathOpsDCubicTest.cpp ('k') | tests/PathOpsExtendedTest.h » ('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"
11 #include "SkIntersectionHelper.h" 11 #include "SkIntersectionHelper.h"
12 #include "SkMutex.h"
12 #include "SkOpSegment.h" 13 #include "SkOpSegment.h"
13 #include "SkString.h" 14 #include "SkString.h"
14 15
15 inline void DebugDumpDouble(double x) { 16 inline void DebugDumpDouble(double x) {
16 if (x == floor(x)) { 17 if (x == floor(x)) {
17 SkDebugf("%.0f", x); 18 SkDebugf("%.0f", x);
18 } else { 19 } else {
19 SkDebugf("%1.19g", x); 20 SkDebugf("%1.19g", x);
20 } 21 }
21 } 22 }
22 23
23 inline void DebugDumpFloat(float x) { 24 inline void DebugDumpFloat(float x) {
24 if (x == floorf(x)) { 25 if (x == floorf(x)) {
25 SkDebugf("%.0f", x); 26 SkDebugf("%.0f", x);
26 } else { 27 } else {
27 SkDebugf("%1.9gf", x); 28 SkDebugf("%1.9gf", x);
28 } 29 }
29 } 30 }
30 31
31 inline void DebugDumpHexFloat(float x) { 32 inline void DebugDumpHexFloat(float x) {
32 SkDebugf("SkBits2Float(0x%08x)", SkFloat2Bits(x)); 33 SkDebugf("SkBits2Float(0x%08x)", SkFloat2Bits(x));
33 } 34 }
34 35
35 #if DEBUG_SHOW_TEST_NAME
36
37 static void output_scalar(SkScalar num) {
38 if (num == (int) num) {
39 SkDebugf("%d", (int) num);
40 } else {
41 SkString str;
42 str.printf("%1.9g", num);
43 int width = (int) str.size();
44 const char* cStr = str.c_str();
45 while (cStr[width - 1] == '0') {
46 --width;
47 }
48 str.resize(width);
49 SkDebugf("%sf", str.c_str());
50 }
51 }
52
53 static void output_points(const SkPoint* pts, int count) {
54 for (int index = 0; index < count; ++index) {
55 output_scalar(pts[index].fX);
56 SkDebugf(", ");
57 output_scalar(pts[index].fY);
58 if (index + 1 < count) {
59 SkDebugf(", ");
60 }
61 }
62 }
63
64 static void showPathContours(SkPath::RawIter& iter, const char* pathName) {
65 uint8_t verb;
66 SkPoint pts[4];
67 while ((verb = iter.next(pts)) != SkPath::kDone_Verb) {
68 switch (verb) {
69 case SkPath::kMove_Verb:
70 SkDebugf(" %s.moveTo(", pathName);
71 output_points(&pts[0], 1);
72 SkDebugf(");\n");
73 continue;
74 case SkPath::kLine_Verb:
75 SkDebugf(" %s.lineTo(", pathName);
76 output_points(&pts[1], 1);
77 SkDebugf(");\n");
78 break;
79 case SkPath::kQuad_Verb:
80 SkDebugf(" %s.quadTo(", pathName);
81 output_points(&pts[1], 2);
82 SkDebugf(");\n");
83 break;
84 case SkPath::kConic_Verb:
85 SkDebugf(" %s.conicTo(", pathName);
86 output_points(&pts[1], 2);
87 SkDebugf(", %1.9gf);\n", iter.conicWeight());
88 break;
89 case SkPath::kCubic_Verb:
90 SkDebugf(" %s.cubicTo(", pathName);
91 output_points(&pts[1], 3);
92 SkDebugf(");\n");
93 break;
94 case SkPath::kClose_Verb:
95 SkDebugf(" %s.close();\n", pathName);
96 break;
97 default:
98 SkDEBUGFAIL("bad verb");
99 return;
100 }
101 }
102 }
103
104 static const char* gFillTypeStr[] = {
105 "kWinding_FillType",
106 "kEvenOdd_FillType",
107 "kInverseWinding_FillType",
108 "kInverseEvenOdd_FillType"
109 };
110
111 void SkPathOpsDebug::ShowOnePath(const SkPath& path, const char* name, bool incl udeDeclaration) {
112 SkPath::RawIter iter(path);
113 #define SUPPORT_RECT_CONTOUR_DETECTION 0
114 #if SUPPORT_RECT_CONTOUR_DETECTION
115 int rectCount = path.isRectContours() ? path.rectContours(NULL, NULL) : 0;
116 if (rectCount > 0) {
117 SkTDArray<SkRect> rects;
118 SkTDArray<SkPath::Direction> directions;
119 rects.setCount(rectCount);
120 directions.setCount(rectCount);
121 path.rectContours(rects.begin(), directions.begin());
122 for (int contour = 0; contour < rectCount; ++contour) {
123 const SkRect& rect = rects[contour];
124 SkDebugf("path.addRect(%1.9g, %1.9g, %1.9g, %1.9g, %s);\n", rect.fLe ft, rect.fTop,
125 rect.fRight, rect.fBottom, directions[contour] == SkPath::kC CW_Direction
126 ? "SkPath::kCCW_Direction" : "SkPath::kCW_Direction");
127 }
128 return;
129 }
130 #endif
131 SkPath::FillType fillType = path.getFillType();
132 SkASSERT(fillType >= SkPath::kWinding_FillType && fillType <= SkPath::kInver seEvenOdd_FillType);
133 if (includeDeclaration) {
134 SkDebugf(" SkPath %s;\n", name);
135 }
136 SkDebugf(" %s.setFillType(SkPath::%s);\n", name, gFillTypeStr[fillType]);
137 iter.setPath(path);
138 showPathContours(iter, name);
139 }
140
141 static void show_function_header(const char* functionName) {
142 SkDebugf("\nstatic void %s(skiatest::Reporter* reporter, const char* filenam e) {\n", functionName);
143 if (strcmp("skphealth_com76", functionName) == 0) {
144 SkDebugf("found it\n");
145 }
146 }
147
148 static const char* gOpStrs[] = {
149 "kDifference_SkPathOp",
150 "kIntersect_SkPathOp",
151 "kUnion_SkPathOp",
152 "kXor_PathOp",
153 "kReverseDifference_SkPathOp",
154 };
155
156 static void show_op(SkPathOp op, const char* pathOne, const char* pathTwo) {
157 SkDebugf(" testPathOp(reporter, %s, %s, %s, filename);\n", pathOne, pathT wo, gOpStrs[op]);
158 SkDebugf("}\n");
159 }
160
161 SK_DECLARE_STATIC_MUTEX(gTestMutex);
162
163 void SkPathOpsDebug::ShowPath(const SkPath& a, const SkPath& b, SkPathOp shapeOp ,
164 const char* testName) {
165 SkAutoMutexAcquire ac(gTestMutex);
166 show_function_header(testName);
167 ShowOnePath(a, "path", true);
168 ShowOnePath(b, "pathB", true);
169 show_op(shapeOp, "path", "pathB");
170 }
171 #endif
172
173 // if not defined by PathOpsDebug.cpp ... 36 // if not defined by PathOpsDebug.cpp ...
174 #if !defined SK_DEBUG && FORCE_RELEASE 37 #if !defined SK_DEBUG && FORCE_RELEASE
175 bool SkPathOpsDebug::ValidWind(int wind) { 38 bool SkPathOpsDebug::ValidWind(int wind) {
176 return wind > SK_MinS32 + 0xFFFF && wind < SK_MaxS32 - 0xFFFF; 39 return wind > SK_MinS32 + 0xFFFF && wind < SK_MaxS32 - 0xFFFF;
177 } 40 }
178 41
179 void SkPathOpsDebug::WindingPrintf(int wind) { 42 void SkPathOpsDebug::WindingPrintf(int wind) {
180 if (wind == SK_MinS32) { 43 if (wind == SK_MinS32) {
181 SkDebugf("?"); 44 SkDebugf("?");
182 } else { 45 } else {
183 SkDebugf("%d", wind); 46 SkDebugf("%d", wind);
184 } 47 }
185 } 48 }
186 #endif 49 #endif
187 50
51 void SkDConic::dump() const {
52 dumpInner();
53 SkDebugf("},\n");
54 }
55
56 void SkDConic::dumpID(int id) const {
57 dumpInner();
58 SkDebugf("} id=%d\n", id);
59 }
60
61 void SkDConic::dumpInner() const {
62 SkDebugf("{{");
63 int index = 0;
64 do {
65 fPts[index].dump();
66 SkDebugf(", ");
67 } while (++index < 2);
68 fPts[index].dump();
69 SkDebugf("}, %1.9g", fWeight);
70 }
71
188 void SkDCubic::dump() const { 72 void SkDCubic::dump() const {
189 dumpInner(); 73 this->dumpInner();
190 SkDebugf("}},\n"); 74 SkDebugf("}},\n");
191 } 75 }
192 76
193 void SkDCubic::dumpID(int id) const { 77 void SkDCubic::dumpID(int id) const {
194 dumpInner(); 78 this->dumpInner();
195 SkDebugf("}} id=%d\n", id); 79 SkDebugf("}} id=%d\n", id);
196 } 80 }
197 81
198 static inline bool double_is_NaN(double x) { return x != x; } 82 static inline bool double_is_NaN(double x) { return x != x; }
199 83
200 void SkDCubic::dumpInner() const { 84 void SkDCubic::dumpInner() const {
201 SkDebugf("{{"); 85 SkDebugf("{{");
202 int index = 0; 86 int index = 0;
203 do { 87 do {
204 if (index != 0) { 88 if (index != 0) {
205 if (double_is_NaN(fPts[index].fX) && double_is_NaN(fPts[index].fY)) { 89 if (double_is_NaN(fPts[index].fX) && double_is_NaN(fPts[index].fY)) {
206 return; 90 return;
207 } 91 }
208 SkDebugf(", "); 92 SkDebugf(", ");
209 } 93 }
210 fPts[index].dump(); 94 fPts[index].dump();
211 } while (++index < 3); 95 } while (++index < 3);
212 if (double_is_NaN(fPts[index].fX) && double_is_NaN(fPts[index].fY)) { 96 if (double_is_NaN(fPts[index].fX) && double_is_NaN(fPts[index].fY)) {
213 return; 97 return;
214 } 98 }
215 SkDebugf(", "); 99 SkDebugf(", ");
216 fPts[index].dump(); 100 fPts[index].dump();
217 } 101 }
218 102
103 void SkDCurve::dumpID(int id) const {
104 #ifndef SK_RELEASE
105 switch(fVerb) {
106 case SkPath::kLine_Verb:
107 fLine.dumpID(id);
108 break;
109 case SkPath::kQuad_Verb:
110 fQuad.dumpID(id);
111 break;
112 case SkPath::kConic_Verb:
113 fConic.dumpID(id);
114 break;
115 case SkPath::kCubic_Verb:
116 fCubic.dumpID(id);
117 break;
118 default:
119 SkASSERT(0);
120 }
121 #else
122 fCubic.dumpID(id);
123 #endif
124 }
125
219 void SkDLine::dump() const { 126 void SkDLine::dump() const {
127 this->dumpInner();
128 SkDebugf("}},\n");
129 }
130
131 void SkDLine::dumpID(int id) const {
132 this->dumpInner();
133 SkDebugf("}} id=%d\n", id);
134 }
135
136 void SkDLine::dumpInner() const {
220 SkDebugf("{{"); 137 SkDebugf("{{");
221 fPts[0].dump(); 138 fPts[0].dump();
222 SkDebugf(", "); 139 SkDebugf(", ");
223 fPts[1].dump(); 140 fPts[1].dump();
224 SkDebugf("}},\n");
225 } 141 }
226 142
227 void SkDPoint::dump() const { 143 void SkDPoint::dump() const {
228 SkDebugf("{"); 144 SkDebugf("{");
229 DebugDumpDouble(fX); 145 DebugDumpDouble(fX);
230 SkDebugf(", "); 146 SkDebugf(", ");
231 DebugDumpDouble(fY); 147 DebugDumpDouble(fY);
232 SkDebugf("}"); 148 SkDebugf("}");
233 } 149 }
234 150
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 } 347 }
432 } 348 }
433 349
434 void SkPathOpsDebug::DumpContoursSpans(const SkTDArray<SkOpContour* >* contours) { 350 void SkPathOpsDebug::DumpContoursSpans(const SkTDArray<SkOpContour* >* contours) {
435 int count = contours->count(); 351 int count = contours->count();
436 for (int index = 0; index < count; ++index) { 352 for (int index = 0; index < count; ++index) {
437 (*contours)[index]->dumpSpans(); 353 (*contours)[index]->dumpSpans();
438 } 354 }
439 } 355 }
440 356
441 const SkTSpan<SkDCubic>* DebugSpan(const SkTSect<SkDCubic>* sect, int id) { 357 template <typename TCurve, typename OppCurve>
358 const SkTSpan<TCurve, OppCurve>* DebugSpan(const SkTSect<TCurve, OppCurve>* sect , int id) {
442 return sect->debugSpan(id); 359 return sect->debugSpan(id);
443 } 360 }
444 361
445 const SkTSpan<SkDQuad>* DebugSpan(const SkTSect<SkDQuad>* sect, int id) { 362 void DontCallDebugSpan(int id);
446 return sect->debugSpan(id); 363 void DontCallDebugSpan(int id) { // exists to instantiate the templates
447 } 364 SkDQuad quad;
448 365 SkDConic conic;
449 const SkTSpan<SkDCubic>* DebugT(const SkTSect<SkDCubic>* sect, double t) { 366 SkDCubic cubic;
367 SkTSect<SkDQuad, SkDQuad> q1q2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
368 SkTSect<SkDQuad, SkDConic> q1k2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
369 SkTSect<SkDQuad, SkDCubic> q1c2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
370 SkTSect<SkDConic, SkDQuad> k1q2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
371 SkTSect<SkDConic, SkDConic> k1k2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
372 SkTSect<SkDConic, SkDCubic> k1c2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
373 SkTSect<SkDCubic, SkDQuad> c1q2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
374 SkTSect<SkDCubic, SkDConic> c1k2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
375 SkTSect<SkDCubic, SkDCubic> c1c2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
376 DebugSpan(&q1q2, id);
377 DebugSpan(&q1k2, id);
378 DebugSpan(&q1c2, id);
379 DebugSpan(&k1q2, id);
380 DebugSpan(&k1k2, id);
381 DebugSpan(&k1c2, id);
382 DebugSpan(&c1q2, id);
383 DebugSpan(&c1k2, id);
384 DebugSpan(&c1c2, id);
385 }
386
387 template <typename TCurve, typename OppCurve>
388 const SkTSpan<TCurve, OppCurve>* DebugT(const SkTSect<TCurve, OppCurve>* sect, d ouble t) {
450 return sect->debugT(t); 389 return sect->debugT(t);
451 } 390 }
452 391
453 const SkTSpan<SkDQuad>* DebugT(const SkTSect<SkDQuad>* sect, double t) { 392 void DontCallDebugT(double t);
454 return sect->debugT(t); 393 void DontCallDebugT(double t) { // exists to instantiate the templates
455 } 394 SkDQuad quad;
456 395 SkDConic conic;
457 const SkTSpan<SkDCubic>* DebugSpan(const SkTSpan<SkDCubic>* span, int id) { 396 SkDCubic cubic;
458 return span->debugSpan(id); 397 SkTSect<SkDQuad, SkDQuad> q1q2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
459 } 398 SkTSect<SkDQuad, SkDConic> q1k2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
460 399 SkTSect<SkDQuad, SkDCubic> q1c2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
461 const SkTSpan<SkDQuad>* DebugSpan(const SkTSpan<SkDQuad>* span, int id) { 400 SkTSect<SkDConic, SkDQuad> k1q2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
462 return span->debugSpan(id); 401 SkTSect<SkDConic, SkDConic> k1k2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
463 } 402 SkTSect<SkDConic, SkDCubic> k1c2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
464 403 SkTSect<SkDCubic, SkDQuad> c1q2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
465 const SkTSpan<SkDCubic>* DebugT(const SkTSpan<SkDCubic>* span, double t) { 404 SkTSect<SkDCubic, SkDConic> c1k2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
466 return span->debugT(t); 405 SkTSect<SkDCubic, SkDCubic> c1c2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
467 } 406 DebugT(&q1q2, t);
468 407 DebugT(&q1k2, t);
469 const SkTSpan<SkDQuad>* DebugT(const SkTSpan<SkDQuad>* span, double t) { 408 DebugT(&q1c2, t);
470 return span->debugT(t); 409 DebugT(&k1q2, t);
471 } 410 DebugT(&k1k2, t);
472 411 DebugT(&k1c2, t);
473 void Dump(const SkTSect<SkDCubic>* sect) { 412 DebugT(&c1q2, t);
413 DebugT(&c1k2, t);
414 DebugT(&c1c2, t);
415 }
416
417 template <typename TCurve, typename OppCurve>
418 void Dump(const SkTSect<TCurve, OppCurve>* sect) {
474 sect->dump(); 419 sect->dump();
475 } 420 }
476 421
477 void Dump(const SkTSect<SkDQuad>* sect) { 422 void DontCallDumpTSect();
478 sect->dump(); 423 void DontCallDumpTSect() { // exists to instantiate the templates
479 } 424 SkDQuad quad;
480 425 SkDConic conic;
481 void Dump(const SkTSpan<SkDCubic>* span) { 426 SkDCubic cubic;
427 SkTSect<SkDQuad, SkDQuad> q1q2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
428 SkTSect<SkDQuad, SkDConic> q1k2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
429 SkTSect<SkDQuad, SkDCubic> q1c2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
430 SkTSect<SkDConic, SkDQuad> k1q2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
431 SkTSect<SkDConic, SkDConic> k1k2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
432 SkTSect<SkDConic, SkDCubic> k1c2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
433 SkTSect<SkDCubic, SkDQuad> c1q2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
434 SkTSect<SkDCubic, SkDConic> c1k2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
435 SkTSect<SkDCubic, SkDCubic> c1c2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
436 Dump(&q1q2);
437 Dump(&q1k2);
438 Dump(&q1c2);
439 Dump(&k1q2);
440 Dump(&k1k2);
441 Dump(&k1c2);
442 Dump(&c1q2);
443 Dump(&c1k2);
444 Dump(&c1c2);
445 }
446
447 template <typename TCurve, typename OppCurve>
448 void DumpBoth(SkTSect<TCurve, OppCurve>* sect1, SkTSect<OppCurve, TCurve>* sect2 ) {
449 sect1->dumpBoth(sect2);
450 }
451
452 void DontCallDumpBoth();
453 void DontCallDumpBoth() { // exists to instantiate the templates
454 SkDQuad quad;
455 SkDConic conic;
456 SkDCubic cubic;
457 SkTSect<SkDQuad, SkDQuad> q1q2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
458 SkTSect<SkDQuad, SkDConic> q1k2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
459 SkTSect<SkDQuad, SkDCubic> q1c2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
460 SkTSect<SkDConic, SkDQuad> k1q2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
461 SkTSect<SkDConic, SkDConic> k1k2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
462 SkTSect<SkDConic, SkDCubic> k1c2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
463 SkTSect<SkDCubic, SkDQuad> c1q2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
464 SkTSect<SkDCubic, SkDConic> c1k2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
465 SkTSect<SkDCubic, SkDCubic> c1c2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
466 DumpBoth(&q1q2, &q1q2);
467 DumpBoth(&q1k2, &k1q2);
468 DumpBoth(&q1c2, &c1q2);
469 DumpBoth(&k1q2, &q1k2);
470 DumpBoth(&k1k2, &k1k2);
471 DumpBoth(&k1c2, &c1k2);
472 DumpBoth(&c1q2, &q1c2);
473 DumpBoth(&c1k2, &k1c2);
474 DumpBoth(&c1c2, &c1c2);
475 }
476
477 template <typename TCurve, typename OppCurve>
478 void DumpBounded(SkTSect<TCurve, OppCurve>* sect1, int id) {
479 sect1->dumpBounded(id);
480 }
481
482 void DontCallDumpBounded();
483 void DontCallDumpBounded() {
484 SkDQuad quad;
485 SkDConic conic;
486 SkDCubic cubic;
487 SkTSect<SkDQuad, SkDQuad> q1q2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
488 SkTSect<SkDQuad, SkDConic> q1k2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
489 SkTSect<SkDQuad, SkDCubic> q1c2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
490 SkTSect<SkDConic, SkDQuad> k1q2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
491 SkTSect<SkDConic, SkDConic> k1k2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
492 SkTSect<SkDConic, SkDCubic> k1c2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
493 SkTSect<SkDCubic, SkDQuad> c1q2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
494 SkTSect<SkDCubic, SkDConic> c1k2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
495 SkTSect<SkDCubic, SkDCubic> c1c2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
496 DumpBounded(&q1q2, 0);
497 DumpBounded(&q1k2, 0);
498 DumpBounded(&q1c2, 0);
499 DumpBounded(&k1q2, 0);
500 DumpBounded(&k1k2, 0);
501 DumpBounded(&k1c2, 0);
502 DumpBounded(&c1q2, 0);
503 DumpBounded(&c1k2, 0);
504 DumpBounded(&c1c2, 0);
505 }
506
507 template <typename TCurve, typename OppCurve>
508 void DumpBounds(SkTSect<TCurve, OppCurve>* sect1) {
509 sect1->dumpBounds();
510 }
511
512 void DontCallDumpBounds();
513 void DontCallDumpBounds() {
514 SkDQuad quad;
515 SkDConic conic;
516 SkDCubic cubic;
517 SkTSect<SkDQuad, SkDQuad> q1q2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
518 SkTSect<SkDQuad, SkDConic> q1k2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
519 SkTSect<SkDQuad, SkDCubic> q1c2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
520 SkTSect<SkDConic, SkDQuad> k1q2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
521 SkTSect<SkDConic, SkDConic> k1k2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
522 SkTSect<SkDConic, SkDCubic> k1c2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
523 SkTSect<SkDCubic, SkDQuad> c1q2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
524 SkTSect<SkDCubic, SkDConic> c1k2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
525 SkTSect<SkDCubic, SkDCubic> c1c2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
526 DumpBounds(&q1q2);
527 DumpBounds(&q1k2);
528 DumpBounds(&q1c2);
529 DumpBounds(&k1q2);
530 DumpBounds(&k1k2);
531 DumpBounds(&k1c2);
532 DumpBounds(&c1q2);
533 DumpBounds(&c1k2);
534 DumpBounds(&c1c2);
535 }
536
537 template <typename TCurve, typename OppCurve>
538 void DumpCoin(SkTSect<TCurve, OppCurve>* sect1) {
539 sect1->dumpCoin();
540 }
541
542 void DontCallDumpCoin();
543 void DontCallDumpCoin() { // exists to instantiate the templates
544 SkDQuad quad;
545 SkDConic conic;
546 SkDCubic cubic;
547 SkTSect<SkDQuad, SkDQuad> q1q2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
548 SkTSect<SkDQuad, SkDConic> q1k2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
549 SkTSect<SkDQuad, SkDCubic> q1c2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
550 SkTSect<SkDConic, SkDQuad> k1q2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
551 SkTSect<SkDConic, SkDConic> k1k2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
552 SkTSect<SkDConic, SkDCubic> k1c2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
553 SkTSect<SkDCubic, SkDQuad> c1q2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
554 SkTSect<SkDCubic, SkDConic> c1k2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
555 SkTSect<SkDCubic, SkDCubic> c1c2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
556 DumpCoin(&q1q2);
557 DumpCoin(&q1k2);
558 DumpCoin(&q1c2);
559 DumpCoin(&k1q2);
560 DumpCoin(&k1k2);
561 DumpCoin(&k1c2);
562 DumpCoin(&c1q2);
563 DumpCoin(&c1k2);
564 DumpCoin(&c1c2);
565 }
566
567 template <typename TCurve, typename OppCurve>
568 void DumpCoinCurves(SkTSect<TCurve, OppCurve>* sect1) {
569 sect1->dumpCoinCurves();
570 }
571
572 void DontCallDumpCoinCurves();
573 void DontCallDumpCoinCurves() { // exists to instantiate the templates
574 SkDQuad quad;
575 SkDConic conic;
576 SkDCubic cubic;
577 SkTSect<SkDQuad, SkDQuad> q1q2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
578 SkTSect<SkDQuad, SkDConic> q1k2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
579 SkTSect<SkDQuad, SkDCubic> q1c2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
580 SkTSect<SkDConic, SkDQuad> k1q2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
581 SkTSect<SkDConic, SkDConic> k1k2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
582 SkTSect<SkDConic, SkDCubic> k1c2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
583 SkTSect<SkDCubic, SkDQuad> c1q2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
584 SkTSect<SkDCubic, SkDConic> c1k2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
585 SkTSect<SkDCubic, SkDCubic> c1c2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
586 DumpCoinCurves(&q1q2);
587 DumpCoinCurves(&q1k2);
588 DumpCoinCurves(&q1c2);
589 DumpCoinCurves(&k1q2);
590 DumpCoinCurves(&k1k2);
591 DumpCoinCurves(&k1c2);
592 DumpCoinCurves(&c1q2);
593 DumpCoinCurves(&c1k2);
594 DumpCoinCurves(&c1c2);
595 }
596
597 template <typename TCurve, typename OppCurve>
598 void DumpCurves(const SkTSect<TCurve, OppCurve>* sect) {
599 sect->dumpCurves();
600 }
601
602 void DontCallDumpCurves();
603 void DontCallDumpCurves() { // exists to instantiate the templates
604 SkDQuad quad;
605 SkDConic conic;
606 SkDCubic cubic;
607 SkTSect<SkDQuad, SkDQuad> q1q2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
608 SkTSect<SkDQuad, SkDConic> q1k2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
609 SkTSect<SkDQuad, SkDCubic> q1c2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
610 SkTSect<SkDConic, SkDQuad> k1q2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
611 SkTSect<SkDConic, SkDConic> k1k2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
612 SkTSect<SkDConic, SkDCubic> k1c2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
613 SkTSect<SkDCubic, SkDQuad> c1q2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
614 SkTSect<SkDCubic, SkDConic> c1k2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
615 SkTSect<SkDCubic, SkDCubic> c1c2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
616 DumpCurves(&q1q2);
617 DumpCurves(&q1k2);
618 DumpCurves(&q1c2);
619 DumpCurves(&k1q2);
620 DumpCurves(&k1k2);
621 DumpCurves(&k1c2);
622 DumpCurves(&c1q2);
623 DumpCurves(&c1k2);
624 DumpCurves(&c1c2);
625 }
626
627 template <typename TCurve, typename OppCurve>
628 void Dump(const SkTSpan<TCurve, OppCurve>* span) {
482 span->dump(); 629 span->dump();
483 } 630 }
484 631
485 void Dump(const SkTSpan<SkDQuad>* span) { 632 void DontCallDumpTSpan();
486 span->dump(); 633 void DontCallDumpTSpan() { // exists to instantiate the templates
487 } 634 SkTSpan<SkDQuad, SkDQuad> q1q2; q1q2.debugInit();
488 635 SkTSpan<SkDQuad, SkDConic> q1k2; q1k2.debugInit();
489 void DumpBoth(SkTSect<SkDCubic>* sect1, SkTSect<SkDCubic>* sect2) { 636 SkTSpan<SkDQuad, SkDCubic> q1c2; q1c2.debugInit();
490 sect1->dumpBoth(sect2); 637 SkTSpan<SkDConic, SkDQuad> k1q2; k1q2.debugInit();
491 } 638 SkTSpan<SkDConic, SkDConic> k1k2; k1k2.debugInit();
492 639 SkTSpan<SkDConic, SkDCubic> k1c2; k1c2.debugInit();
493 void DumpBoth(SkTSect<SkDQuad>* sect1, SkTSect<SkDQuad>* sect2) { 640 SkTSpan<SkDCubic, SkDQuad> c1q2; c1q2.debugInit();
494 sect1->dumpBoth(sect2); 641 SkTSpan<SkDCubic, SkDConic> c1k2; c1k2.debugInit();
495 } 642 SkTSpan<SkDCubic, SkDCubic> c1c2; c1c2.debugInit();
496 643 Dump(&q1q2);
497 void DumpCoin(SkTSect<SkDCubic>* sect1) { 644 Dump(&q1k2);
498 sect1->dumpCoin(); 645 Dump(&q1c2);
499 } 646 Dump(&k1q2);
500 647 Dump(&k1k2);
501 void DumpCoin(SkTSect<SkDQuad>* sect1) { 648 Dump(&k1c2);
502 sect1->dumpCoin(); 649 Dump(&c1q2);
503 } 650 Dump(&c1k2);
504 651 Dump(&c1c2);
505 void DumpCoinCurves(SkTSect<SkDCubic>* sect1) { 652 }
506 sect1->dumpCoinCurves(); 653
507 } 654 template <typename TCurve, typename OppCurve>
508 655 void DumpCoin(const SkTSpan<TCurve, OppCurve>* span) {
509 void DumpCoinCurves(SkTSect<SkDQuad>* sect1) { 656 span->dumpCoin();
510 sect1->dumpCoinCurves(); 657 }
511 } 658
512 659 void DontCallDumpSpanCoin();
513 void DumpCurves(const SkTSect<SkDQuad>* sect) { 660 void DontCallDumpSpanCoin() { // exists to instantiate the templates
514 sect->dumpCurves(); 661 SkTSpan<SkDQuad, SkDQuad> q1q2; q1q2.debugInit();
515 } 662 SkTSpan<SkDQuad, SkDConic> q1k2; q1k2.debugInit();
516 663 SkTSpan<SkDQuad, SkDCubic> q1c2; q1c2.debugInit();
517 void DumpCurves(const SkTSect<SkDCubic>* sect) { 664 SkTSpan<SkDConic, SkDQuad> k1q2; k1q2.debugInit();
518 sect->dumpCurves(); 665 SkTSpan<SkDConic, SkDConic> k1k2; k1k2.debugInit();
666 SkTSpan<SkDConic, SkDCubic> k1c2; k1c2.debugInit();
667 SkTSpan<SkDCubic, SkDQuad> c1q2; c1q2.debugInit();
668 SkTSpan<SkDCubic, SkDConic> c1k2; c1k2.debugInit();
669 SkTSpan<SkDCubic, SkDCubic> c1c2; c1c2.debugInit();
670 DumpCoin(&q1q2);
671 DumpCoin(&q1k2);
672 DumpCoin(&q1c2);
673 DumpCoin(&k1q2);
674 DumpCoin(&k1k2);
675 DumpCoin(&k1c2);
676 DumpCoin(&c1q2);
677 DumpCoin(&c1k2);
678 DumpCoin(&c1c2);
519 } 679 }
520 680
521 static void dumpTestCase(const SkDQuad& quad1, const SkDQuad& quad2, int testNo) { 681 static void dumpTestCase(const SkDQuad& quad1, const SkDQuad& quad2, int testNo) {
522 SkDebugf("\n<div id=\"quad%d\">\n", testNo); 682 SkDebugf("\n<div id=\"quad%d\">\n", testNo);
523 quad1.dumpInner(); 683 quad1.dumpInner();
524 SkDebugf("}}, "); 684 SkDebugf("}}, ");
525 quad2.dump(); 685 quad2.dump();
526 SkDebugf("</div>\n\n"); 686 SkDebugf("</div>\n\n");
527 } 687 }
528 688
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 void SkOpSegment::dumpCoin() const { 1056 void SkOpSegment::dumpCoin() const {
897 const SkOpSpan* span = &fHead; 1057 const SkOpSpan* span = &fHead;
898 do { 1058 do {
899 span->dumpCoin(); 1059 span->dumpCoin();
900 } while ((span = span->next()->upCastable())); 1060 } while ((span = span->next()->upCastable()));
901 } 1061 }
902 1062
903 void SkOpSegment::dumpPts() const { 1063 void SkOpSegment::dumpPts() const {
904 int last = SkPathOpsVerbToPoints(fVerb); 1064 int last = SkPathOpsVerbToPoints(fVerb);
905 SkDebugf("seg=%d {{", this->debugID()); 1065 SkDebugf("seg=%d {{", this->debugID());
1066 if (fVerb == SkPath::kConic_Verb) {
1067 SkDebugf("{");
1068 }
906 int index = 0; 1069 int index = 0;
907 do { 1070 do {
908 SkDPoint::Dump(fPts[index]); 1071 SkDPoint::Dump(fPts[index]);
909 SkDebugf(", "); 1072 SkDebugf(", ");
910 } while (++index < last); 1073 } while (++index < last);
911 SkDPoint::Dump(fPts[index]); 1074 SkDPoint::Dump(fPts[index]);
912 SkDebugf("}}\n"); 1075 SkDebugf("}}");
1076 if (fVerb == SkPath::kConic_Verb) {
1077 SkDebugf(", %1.9gf}", fWeight);
1078 }
1079 SkDebugf("\n");
913 } 1080 }
914 1081
915 void SkCoincidentSpans::dump() const { 1082 void SkCoincidentSpans::dump() const {
916 SkDebugf("- seg=%d span=%d ptT=%d ", fCoinPtTStart->segment()->debugID(), 1083 SkDebugf("- seg=%d span=%d ptT=%d ", fCoinPtTStart->segment()->debugID(),
917 fCoinPtTStart->span()->debugID(), fCoinPtTStart->debugID()); 1084 fCoinPtTStart->span()->debugID(), fCoinPtTStart->debugID());
918 fCoinPtTStart->dumpBase(); 1085 fCoinPtTStart->dumpBase();
919 SkDebugf(" span=%d ptT=%d ", fCoinPtTEnd->span()->debugID(), fCoinPtTEnd->de bugID()); 1086 SkDebugf(" span=%d ptT=%d ", fCoinPtTEnd->span()->debugID(), fCoinPtTEnd->de bugID());
920 fCoinPtTEnd->dumpBase(); 1087 fCoinPtTEnd->dumpBase();
921 if (fCoinPtTStart->segment()->operand()) { 1088 if (fCoinPtTStart->segment()->operand()) {
922 SkDebugf(" operand"); 1089 SkDebugf(" operand");
(...skipping 18 matching lines...) Expand all
941 1108
942 void SkOpCoincidence::dump() const { 1109 void SkOpCoincidence::dump() const {
943 SkCoincidentSpans* span = fHead; 1110 SkCoincidentSpans* span = fHead;
944 while (span) { 1111 while (span) {
945 span->dump(); 1112 span->dump();
946 span = span->fNext; 1113 span = span->fNext;
947 } 1114 }
948 } 1115 }
949 1116
950 void SkOpContour::dump() { 1117 void SkOpContour::dump() {
951 SkDebugf("contour=%d count=%d\n", this->debugID(), fCount); 1118 SkDebugf("contour=%d count=%d op=%d xor=%d\n", this->debugID(), fCount, fOpe rand, fXor);
952 if (!fCount) { 1119 if (!fCount) {
953 return; 1120 return;
954 } 1121 }
955 const SkOpSegment* segment = &fHead; 1122 const SkOpSegment* segment = &fHead;
956 PATH_OPS_DEBUG_CODE(fIndent = 0); 1123 SkDEBUGCODE(fIndent = 0);
957 indentDump(); 1124 indentDump();
958 do { 1125 do {
959 segment->dump(); 1126 segment->dump();
960 } while ((segment = segment->next())); 1127 } while ((segment = segment->next()));
961 outdentDump(); 1128 outdentDump();
962 } 1129 }
963 1130
964 void SkOpContour::dumpAll() { 1131 void SkOpContour::dumpAll() {
965 SkDebugf("contour=%d count=%d\n", this->debugID(), fCount); 1132 SkDebugf("contour=%d count=%d op=%d xor=%d\n", this->debugID(), fCount, fOpe rand, fXor);
966 if (!fCount) { 1133 if (!fCount) {
967 return; 1134 return;
968 } 1135 }
969 const SkOpSegment* segment = &fHead; 1136 const SkOpSegment* segment = &fHead;
970 PATH_OPS_DEBUG_CODE(fIndent = 0); 1137 SkDEBUGCODE(fIndent = 0);
971 indentDump(); 1138 indentDump();
972 do { 1139 do {
973 segment->dumpAll(); 1140 segment->dumpAll();
974 } while ((segment = segment->next())); 1141 } while ((segment = segment->next()));
975 outdentDump(); 1142 outdentDump();
976 } 1143 }
977 1144
978 1145
979 void SkOpContour::dumpAngles() const { 1146 void SkOpContour::dumpAngles() const {
980 SkDebugf("contour=%d\n", this->debugID()); 1147 SkDebugf("contour=%d\n", this->debugID());
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
1190 SkPathOpsDebug::DumpContoursPt(contours, segmentID); 1357 SkPathOpsDebug::DumpContoursPt(contours, segmentID);
1191 } 1358 }
1192 1359
1193 void DumpPts(const SkTDArray<SkOpContour* >* contours) { 1360 void DumpPts(const SkTDArray<SkOpContour* >* contours) {
1194 SkPathOpsDebug::DumpContoursPts(contours); 1361 SkPathOpsDebug::DumpContoursPts(contours);
1195 } 1362 }
1196 1363
1197 #if DEBUG_T_SECT_DUMP > 1 1364 #if DEBUG_T_SECT_DUMP > 1
1198 int gDumpTSectNum; 1365 int gDumpTSectNum;
1199 #endif 1366 #endif
OLDNEW
« no previous file with comments | « tests/PathOpsDCubicTest.cpp ('k') | tests/PathOpsExtendedTest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698