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

Side by Side Diff: tests/PathOpsTSectDebug.h

Issue 1037573004: cumulative pathops patch (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix pathopsinverse gm 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>
11 const SkTSpan<TCurve>* SkTSect<TCurve>::debugSpan(int id) const {
12 const SkTSpan<TCurve>* test = fHead;
13 do {
14 if (test->debugID() == id) {
15 return test;
16 }
17 } 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;
27 }
28
29 template<typename TCurve>
30 const SkTSpan<TCurve>* SkTSect<TCurve>::debugT(double t) const {
31 const SkTSpan<TCurve>* test = fHead;
32 const SkTSpan<TCurve>* closest = NULL;
33 double bestDist = DBL_MAX;
34 do {
35 if (between(test->fStartT, t, test->fEndT)) {
36 return test;
37 }
38 double testDist = SkTMin(fabs(test->fStartT - t), fabs(test->fEndT - t)) ;
39 if (bestDist > testDist) {
40 bestDist = testDist;
41 closest = test;
42 }
43 } while ((test = test->next()));
44 SkASSERT(closest);
45 return closest;
46 }
47
48 template<typename TCurve>
11 void SkTSect<TCurve>::dump() const { 49 void SkTSect<TCurve>::dump() const {
50 dumpCommon(fHead);
51 }
52
53 extern int gDumpTSectNum;
54
55 template<typename TCurve>
56 void SkTSect<TCurve>::dumpBoth(SkTSect* opp) const {
57 #if DEBUG_T_SECT_DUMP <= 2
58 #if DEBUG_T_SECT_DUMP == 2
59 SkDebugf("%d ", ++gDumpTSectNum);
60 #endif
61 this->dump();
62 SkDebugf(" ");
63 opp->dump();
64 SkDebugf("\n");
65 #elif DEBUG_T_SECT_DUMP == 3
66 SkDebugf("<div id=\"sect%d\">\n", ++gDumpTSectNum);
67 if (this->fHead) {
68 this->dumpCurves();
69 }
70 if (opp->fHead) {
71 PATH_OPS_DEBUG_CODE(opp->dumpCurves());
72 }
73 SkDebugf("</div>\n\n");
74 #endif
75 }
76
77 template<typename TCurve>
78 void SkTSect<TCurve>::dumpBounds(int id) const {
79 const SkTSpan<TCurve>* bounded = debugSpan(id);
80 if (!bounded) {
81 SkDebugf("no span matches %d\n", id);
82 return;
83 }
84 const SkTSpan<TCurve>* test = bounded->debugOpp()->fHead;
85 do {
86 if (test->findOppSpan(bounded)) {
87 test->dump();
88 }
89 } while ((test = test->next()));
90 }
91
92 template<typename TCurve>
93 void SkTSect<TCurve>::dumpCoin() const {
94 dumpCommon(fCoincident);
95 }
96
97 template<typename TCurve>
98 void SkTSect<TCurve>::dumpCoinCurves() const {
99 dumpCommonCurves(fCoincident);
100 }
101
102 template<typename TCurve>
103 void SkTSect<TCurve>::dumpCommon(const SkTSpan<TCurve>* test) const {
12 SkDebugf("id=%d", debugID()); 104 SkDebugf("id=%d", debugID());
13 const SkTSpan<TCurve>* test = fHead;
14 if (!test) { 105 if (!test) {
15 SkDebugf(" (empty)"); 106 SkDebugf(" (empty)");
16 return; 107 return;
17 } 108 }
18 do { 109 do {
19 SkDebugf(" "); 110 SkDebugf(" ");
20 test->dump(this); 111 test->dump();
21 } while ((test = test->next())); 112 } while ((test = test->next()));
22 } 113 }
23 114
24 template<typename TCurve> 115 template<typename TCurve>
25 void SkTSect<TCurve>::dumpBoth(const SkTSect& opp) const { 116 void SkTSect<TCurve>::dumpCommonCurves(const SkTSpan<TCurve>* test) const {
26 dump(); 117 do {
27 SkDebugf(" "); 118 test->fPart.dumpID(test->debugID());
28 opp.dump(); 119 } while ((test = test->next()));
29 SkDebugf("\n");
30 }
31
32 template<typename TCurve>
33 void SkTSect<TCurve>::dumpBoth(const SkTSect* opp) const {
34 dumpBoth(*opp);
35 } 120 }
36 121
37 template<typename TCurve> 122 template<typename TCurve>
38 void SkTSect<TCurve>::dumpCurves() const { 123 void SkTSect<TCurve>::dumpCurves() const {
39 const SkTSpan<TCurve>* test = fHead; 124 dumpCommonCurves(fHead);
40 do {
41 test->fPart.dump();
42 } while ((test = test->next()));
43 } 125 }
44 126
45 #if !DEBUG_T_SECT
46 template<typename TCurve> 127 template<typename TCurve>
47 int SkTSpan<TCurve>::debugID(const SkTSect<TCurve>* sect) const { 128 const SkTSpan<TCurve>* SkTSpan<TCurve>::debugSpan(int id) const {
48 if (!sect) { 129 return PATH_OPS_DEBUG_RELEASE(fDebugSect->debugSpan(id), NULL);
49 return -1;
50 }
51 int id = 1;
52 const SkTSpan* test = sect->fHead;
53 while (test && test != this) {
54 ++id;
55 test = test->fNext;
56 }
57 return id;
58 } 130 }
59 #endif
60 131
61 template<typename TCurve> 132 template<typename TCurve>
62 void SkTSpan<TCurve>::dumpID(const SkTSect<TCurve>* sect) const { 133 const SkTSpan<TCurve>* SkTSpan<TCurve>::debugT(double t) const {
134 return PATH_OPS_DEBUG_RELEASE(fDebugSect->debugT(t), NULL);
135 }
136
137 template<typename TCurve>
138 void SkTSpan<TCurve>::dump() const {
139 dumpID();
140 SkDebugf("=(%g,%g) [", fStartT, fEndT);
141 const SkTSpanBounded<TCurve>* testBounded = fBounded;
142 while (testBounded) {
143 const SkTSpan* span = testBounded->fBounded;
144 const SkTSpanBounded<TCurve>* next = testBounded->fNext;
145 span->dumpID();
146 if (next) {
147 SkDebugf(",");
148 }
149 testBounded = next;
150 }
151 SkDebugf("]");
152 }
153
154 template<typename TCurve>
155 void SkTSpan<TCurve>::dumpBounds(int id) const {
156 PATH_OPS_DEBUG_CODE(fDebugSect->dumpBounds(id));
157 }
158
159 template<typename TCurve>
160 void SkTSpan<TCurve>::dumpID() const {
63 if (fCoinStart.isCoincident()) { 161 if (fCoinStart.isCoincident()) {
64 SkDebugf("%c", '*'); 162 SkDebugf("%c", '*');
65 } 163 }
66 SkDebugf("%d", debugID(sect)); 164 SkDebugf("%d", debugID());
67 if (fCoinEnd.isCoincident()) { 165 if (fCoinEnd.isCoincident()) {
68 SkDebugf("%c", '*'); 166 SkDebugf("%c", '*');
69 } 167 }
70 } 168 }
71
72 template<typename TCurve>
73 void SkTSpan<TCurve>::dump(const SkTSect<TCurve>* sect) const {
74 dumpID(sect);
75 SkDebugf("=(%g,%g) [", fStartT, fEndT);
76 for (int index = 0; index < fBounded.count(); ++index) {
77 SkTSpan* span = fBounded[index];
78 span->dumpID(sect);
79 if (index < fBounded.count() - 1) {
80 SkDebugf(",");
81 }
82 }
83 SkDebugf("]");
84 }
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