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

Side by Side Diff: tests/PathOpsTSectDebug.h

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/PathOpsSkpTest.cpp ('k') | tests/PathOpsTestCommon.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 "SkPathOpsTSect.h" 8 #include "SkPathOpsTSect.h"
9 9
10 template<typename TCurve> 10 template<typename TCurve, typename OppCurve>
11 const SkTSpan<TCurve>* SkTSect<TCurve>::debugSpan(int id) const { 11 void SkTCoincident<TCurve, OppCurve>::dump() const {
12 const SkTSpan<TCurve>* test = fHead; 12 SkDebugf("t=%1.9g pt=(%1.9g,%1.9g)%s\n", fPerpT, fPerpPt.fX, fPerpPt.fY,
13 fCoincident ? " coincident" : "");
14 }
15
16 template<typename TCurve, typename OppCurve>
17 const SkTSpan<TCurve, OppCurve>* SkTSect<TCurve, OppCurve>::debugSpan(int id) co nst {
18 const SkTSpan<TCurve, OppCurve>* test = fHead;
13 do { 19 do {
14 if (test->debugID() == id) { 20 if (test->debugID() == id) {
15 return test; 21 return test;
16 } 22 }
17 } while ((test = test->next())); 23 } while ((test = test->next()));
18 #ifndef SK_RELEASE
19 test = fOppSect->fHead;
20 do {
21 if (test->debugID() == id) {
22 return test;
23 }
24 } while ((test = test->next()));
25 #endif
26 return NULL; 24 return NULL;
27 } 25 }
28 26
29 template<typename TCurve> 27 template<typename TCurve, typename OppCurve>
30 const SkTSpan<TCurve>* SkTSect<TCurve>::debugT(double t) const { 28 const SkTSpan<TCurve, OppCurve>* SkTSect<TCurve, OppCurve>::debugT(double t) con st {
31 const SkTSpan<TCurve>* test = fHead; 29 const SkTSpan<TCurve, OppCurve>* test = fHead;
32 const SkTSpan<TCurve>* closest = NULL; 30 const SkTSpan<TCurve, OppCurve>* closest = NULL;
33 double bestDist = DBL_MAX; 31 double bestDist = DBL_MAX;
34 do { 32 do {
35 if (between(test->fStartT, t, test->fEndT)) { 33 if (between(test->fStartT, t, test->fEndT)) {
36 return test; 34 return test;
37 } 35 }
38 double testDist = SkTMin(fabs(test->fStartT - t), fabs(test->fEndT - t)) ; 36 double testDist = SkTMin(fabs(test->fStartT - t), fabs(test->fEndT - t)) ;
39 if (bestDist > testDist) { 37 if (bestDist > testDist) {
40 bestDist = testDist; 38 bestDist = testDist;
41 closest = test; 39 closest = test;
42 } 40 }
43 } while ((test = test->next())); 41 } while ((test = test->next()));
44 SkASSERT(closest); 42 SkASSERT(closest);
45 return closest; 43 return closest;
46 } 44 }
47 45
48 template<typename TCurve> 46 template<typename TCurve, typename OppCurve>
49 void SkTSect<TCurve>::dump() const { 47 void SkTSect<TCurve, OppCurve>::dump() const {
50 dumpCommon(fHead); 48 dumpCommon(fHead);
51 } 49 }
52 50
53 extern int gDumpTSectNum; 51 extern int gDumpTSectNum;
54 52
55 template<typename TCurve> 53 template<typename TCurve, typename OppCurve>
56 void SkTSect<TCurve>::dumpBoth(SkTSect* opp) const { 54 void SkTSect<TCurve, OppCurve>::dumpBoth(SkTSect<OppCurve, TCurve>* opp) const {
57 #if DEBUG_T_SECT_DUMP <= 2 55 #if DEBUG_T_SECT_DUMP <= 2
58 #if DEBUG_T_SECT_DUMP == 2 56 #if DEBUG_T_SECT_DUMP == 2
59 SkDebugf("%d ", ++gDumpTSectNum); 57 SkDebugf("%d ", ++gDumpTSectNum);
60 #endif 58 #endif
61 this->dump(); 59 this->dump();
62 SkDebugf(" "); 60 SkDebugf(" ");
63 opp->dump(); 61 opp->dump();
64 SkDebugf("\n"); 62 SkDebugf("\n");
65 #elif DEBUG_T_SECT_DUMP == 3 63 #elif DEBUG_T_SECT_DUMP == 3
66 SkDebugf("<div id=\"sect%d\">\n", ++gDumpTSectNum); 64 SkDebugf("<div id=\"sect%d\">\n", ++gDumpTSectNum);
67 if (this->fHead) { 65 if (this->fHead) {
68 this->dumpCurves(); 66 this->dumpCurves();
69 } 67 }
70 if (opp->fHead) { 68 if (opp->fHead) {
71 PATH_OPS_DEBUG_CODE(opp->dumpCurves()); 69 opp->dumpCurves();
72 } 70 }
73 SkDebugf("</div>\n\n"); 71 SkDebugf("</div>\n\n");
74 #endif 72 #endif
75 } 73 }
76 74
77 template<typename TCurve> 75 template<typename TCurve, typename OppCurve>
78 void SkTSect<TCurve>::dumpBounds(int id) const { 76 void SkTSect<TCurve, OppCurve>::dumpBounded(int id) const {
79 const SkTSpan<TCurve>* bounded = debugSpan(id); 77 const SkTSpan<TCurve, OppCurve>* bounded = debugSpan(id);
80 if (!bounded) { 78 if (!bounded) {
81 SkDebugf("no span matches %d\n", id); 79 SkDebugf("no span matches %d\n", id);
82 return; 80 return;
83 } 81 }
84 const SkTSpan<TCurve>* test = bounded->debugOpp()->fHead; 82 const SkTSpan<OppCurve, TCurve>* test = bounded->debugOpp()->fHead;
85 do { 83 do {
86 if (test->findOppSpan(bounded)) { 84 if (test->findOppSpan(bounded)) {
87 test->dump(); 85 test->dump();
88 } 86 }
89 } while ((test = test->next())); 87 } while ((test = test->next()));
90 } 88 }
91 89
92 template<typename TCurve> 90 template<typename TCurve, typename OppCurve>
93 void SkTSect<TCurve>::dumpCoin() const { 91 void SkTSect<TCurve, OppCurve>::dumpBounds() const {
92 const SkTSpan<TCurve, OppCurve>* test = fHead;
93 do {
94 test->dumpBounds();
95 } while ((test = test->next()));
96 }
97
98 template<typename TCurve, typename OppCurve>
99 void SkTSect<TCurve, OppCurve>::dumpCoin() const {
94 dumpCommon(fCoincident); 100 dumpCommon(fCoincident);
95 } 101 }
96 102
97 template<typename TCurve> 103 template<typename TCurve, typename OppCurve>
98 void SkTSect<TCurve>::dumpCoinCurves() const { 104 void SkTSect<TCurve, OppCurve>::dumpCoinCurves() const {
99 dumpCommonCurves(fCoincident); 105 dumpCommonCurves(fCoincident);
100 } 106 }
101 107
102 template<typename TCurve> 108 template<typename TCurve, typename OppCurve>
103 void SkTSect<TCurve>::dumpCommon(const SkTSpan<TCurve>* test) const { 109 void SkTSect<TCurve, OppCurve>::dumpCommon(const SkTSpan<TCurve, OppCurve>* test ) const {
104 SkDebugf("id=%d", debugID()); 110 SkDebugf("id=%d", debugID());
105 if (!test) { 111 if (!test) {
106 SkDebugf(" (empty)"); 112 SkDebugf(" (empty)");
107 return; 113 return;
108 } 114 }
109 do { 115 do {
110 SkDebugf(" "); 116 SkDebugf(" ");
111 test->dump(); 117 test->dump();
112 } while ((test = test->next())); 118 } while ((test = test->next()));
113 } 119 }
114 120
115 template<typename TCurve> 121 template<typename TCurve, typename OppCurve>
116 void SkTSect<TCurve>::dumpCommonCurves(const SkTSpan<TCurve>* test) const { 122 void SkTSect<TCurve, OppCurve>::dumpCommonCurves(const SkTSpan<TCurve, OppCurve> * test) const {
117 do { 123 do {
118 test->fPart.dumpID(test->debugID()); 124 test->fPart.dumpID(test->debugID());
119 } while ((test = test->next())); 125 } while ((test = test->next()));
120 } 126 }
121 127
122 template<typename TCurve> 128 template<typename TCurve, typename OppCurve>
123 void SkTSect<TCurve>::dumpCurves() const { 129 void SkTSect<TCurve, OppCurve>::dumpCurves() const {
124 dumpCommonCurves(fHead); 130 dumpCommonCurves(fHead);
125 } 131 }
126 132
127 template<typename TCurve> 133 template<typename TCurve, typename OppCurve>
128 const SkTSpan<TCurve>* SkTSpan<TCurve>::debugSpan(int id) const { 134 const SkTSpan<TCurve, OppCurve>* SkTSpan<TCurve, OppCurve>::debugSpan(int id) co nst {
129 return PATH_OPS_DEBUG_RELEASE(fDebugSect->debugSpan(id), NULL); 135 return SkDEBUGRELEASE(fDebugSect->debugSpan(id), NULL);
130 } 136 }
131 137
132 template<typename TCurve> 138 template<typename TCurve, typename OppCurve>
133 const SkTSpan<TCurve>* SkTSpan<TCurve>::debugT(double t) const { 139 const SkTSpan<TCurve, OppCurve>* SkTSpan<TCurve, OppCurve>::debugT(double t) con st {
134 return PATH_OPS_DEBUG_RELEASE(fDebugSect->debugT(t), NULL); 140 return SkDEBUGRELEASE(fDebugSect->debugT(t), NULL);
135 } 141 }
136 142
137 template<typename TCurve> 143 template<typename TCurve, typename OppCurve>
138 void SkTSpan<TCurve>::dump() const { 144 void SkTSpan<TCurve, OppCurve>::dump() const {
139 dumpID(); 145 dumpID();
140 SkDebugf("=(%g,%g) [", fStartT, fEndT); 146 SkDebugf("=(%g,%g) [", fStartT, fEndT);
141 const SkTSpanBounded<TCurve>* testBounded = fBounded; 147 const SkTSpanBounded<OppCurve, TCurve>* testBounded = fBounded;
142 while (testBounded) { 148 while (testBounded) {
143 const SkTSpan* span = testBounded->fBounded; 149 const SkTSpan<OppCurve, TCurve>* span = testBounded->fBounded;
144 const SkTSpanBounded<TCurve>* next = testBounded->fNext; 150 const SkTSpanBounded<OppCurve, TCurve>* next = testBounded->fNext;
145 span->dumpID(); 151 span->dumpID();
146 if (next) { 152 if (next) {
147 SkDebugf(","); 153 SkDebugf(",");
148 } 154 }
149 testBounded = next; 155 testBounded = next;
150 } 156 }
151 SkDebugf("]"); 157 SkDebugf("]");
152 } 158 }
153 159
154 template<typename TCurve> 160 template<typename TCurve, typename OppCurve>
155 void SkTSpan<TCurve>::dumpBounds(int id) const { 161 void SkTSpan<TCurve, OppCurve>::dumpBounded(int id) const {
156 PATH_OPS_DEBUG_CODE(fDebugSect->dumpBounds(id)); 162 SkDEBUGCODE(fDebugSect->dumpBounded(id));
157 } 163 }
158 164
159 template<typename TCurve> 165 template<typename TCurve, typename OppCurve>
160 void SkTSpan<TCurve>::dumpID() const { 166 void SkTSpan<TCurve, OppCurve>::dumpBounds() const {
167 dumpID();
168 SkDebugf(" bounds=(%1.9g,%1.9g, %1.9g,%1.9g) boundsMax=%1.9g%s\n",
169 fBounds.fLeft, fBounds.fTop, fBounds.fRight, fBounds.fBottom, fBound sMax,
170 fCollapsed ? " collapsed" : "");
171 }
172
173 template<typename TCurve, typename OppCurve>
174 void SkTSpan<TCurve, OppCurve>::dumpCoin() const {
175 dumpID();
176 SkDebugf(" coinStart ");
177 fCoinStart.dump();
178 SkDebugf(" coinEnd ");
179 fCoinEnd.dump();
180 }
181
182 template<typename TCurve, typename OppCurve>
183 void SkTSpan<TCurve, OppCurve>::dumpID() const {
161 if (fCoinStart.isCoincident()) { 184 if (fCoinStart.isCoincident()) {
162 SkDebugf("%c", '*'); 185 SkDebugf("%c", '*');
163 } 186 }
164 SkDebugf("%d", debugID()); 187 SkDebugf("%d", debugID());
165 if (fCoinEnd.isCoincident()) { 188 if (fCoinEnd.isCoincident()) {
166 SkDebugf("%c", '*'); 189 SkDebugf("%c", '*');
167 } 190 }
168 } 191 }
OLDNEW
« no previous file with comments | « tests/PathOpsSkpTest.cpp ('k') | tests/PathOpsTestCommon.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698