caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
Cary Clark | f394912 | 2018-08-07 16:38:21 -0400 | [diff] [blame^] | 8 | #include "PathOpsDebug.h" |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 9 | #include "PathOpsTSectDebug.h" |
| 10 | #include "SkOpCoincidence.h" |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 11 | #include "SkOpContour.h" |
| 12 | #include "SkIntersectionHelper.h" |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 13 | #include "SkMutex.h" |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 14 | #include "SkOpSegment.h" |
caryclark | 19eb3b2 | 2014-07-18 05:08:14 -0700 | [diff] [blame] | 15 | #include "SkString.h" |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 16 | |
Cary Clark | f394912 | 2018-08-07 16:38:21 -0400 | [diff] [blame^] | 17 | bool PathOpsDebug::gJson; |
| 18 | bool PathOpsDebug::gOutFirst; |
| 19 | FILE* PathOpsDebug::gOut; |
| 20 | |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 21 | inline void DebugDumpDouble(double x) { |
| 22 | if (x == floor(x)) { |
| 23 | SkDebugf("%.0f", x); |
| 24 | } else { |
| 25 | SkDebugf("%1.19g", x); |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | inline void DebugDumpFloat(float x) { |
| 30 | if (x == floorf(x)) { |
| 31 | SkDebugf("%.0f", x); |
| 32 | } else { |
| 33 | SkDebugf("%1.9gf", x); |
| 34 | } |
| 35 | } |
| 36 | |
caryclark | 65f5531 | 2014-11-13 06:58:52 -0800 | [diff] [blame] | 37 | inline void DebugDumpHexFloat(float x) { |
| 38 | SkDebugf("SkBits2Float(0x%08x)", SkFloat2Bits(x)); |
| 39 | } |
caryclark | 19eb3b2 | 2014-07-18 05:08:14 -0700 | [diff] [blame] | 40 | |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 41 | // if not defined by PathOpsDebug.cpp ... |
| 42 | #if !defined SK_DEBUG && FORCE_RELEASE |
| 43 | bool SkPathOpsDebug::ValidWind(int wind) { |
| 44 | return wind > SK_MinS32 + 0xFFFF && wind < SK_MaxS32 - 0xFFFF; |
| 45 | } |
| 46 | |
| 47 | void SkPathOpsDebug::WindingPrintf(int wind) { |
| 48 | if (wind == SK_MinS32) { |
| 49 | SkDebugf("?"); |
| 50 | } else { |
| 51 | SkDebugf("%d", wind); |
| 52 | } |
| 53 | } |
| 54 | #endif |
| 55 | |
caryclark | 55888e4 | 2016-07-18 10:01:36 -0700 | [diff] [blame] | 56 | static void DumpID(int id) { |
| 57 | SkDebugf("} "); |
| 58 | if (id >= 0) { |
| 59 | SkDebugf("id=%d", id); |
| 60 | } |
| 61 | SkDebugf("\n"); |
| 62 | } |
| 63 | |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 64 | void SkDConic::dump() const { |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 65 | dumpInner(); |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 66 | SkDebugf("},\n"); |
| 67 | } |
| 68 | |
| 69 | void SkDConic::dumpID(int id) const { |
| 70 | dumpInner(); |
caryclark | 55888e4 | 2016-07-18 10:01:36 -0700 | [diff] [blame] | 71 | DumpID(id); |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 72 | } |
| 73 | |
| 74 | void SkDConic::dumpInner() const { |
caryclark | 26ad22a | 2015-10-16 09:03:38 -0700 | [diff] [blame] | 75 | SkDebugf("{"); |
| 76 | fPts.dumpInner(); |
| 77 | SkDebugf("}}, %1.9gf", fWeight); |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 78 | } |
| 79 | |
| 80 | void SkDCubic::dump() const { |
| 81 | this->dumpInner(); |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 82 | SkDebugf("}},\n"); |
reed | 0dc4dd6 | 2015-03-24 13:55:33 -0700 | [diff] [blame] | 83 | } |
| 84 | |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 85 | void SkDCubic::dumpID(int id) const { |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 86 | this->dumpInner(); |
caryclark | 55888e4 | 2016-07-18 10:01:36 -0700 | [diff] [blame] | 87 | SkDebugf("}"); |
| 88 | DumpID(id); |
reed | 0dc4dd6 | 2015-03-24 13:55:33 -0700 | [diff] [blame] | 89 | } |
| 90 | |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 91 | static inline bool double_is_NaN(double x) { return x != x; } |
| 92 | |
| 93 | void SkDCubic::dumpInner() const { |
| 94 | SkDebugf("{{"); |
| 95 | int index = 0; |
reed | 0dc4dd6 | 2015-03-24 13:55:33 -0700 | [diff] [blame] | 96 | do { |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 97 | if (index != 0) { |
| 98 | if (double_is_NaN(fPts[index].fX) && double_is_NaN(fPts[index].fY)) { |
| 99 | return; |
reed | 0dc4dd6 | 2015-03-24 13:55:33 -0700 | [diff] [blame] | 100 | } |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 101 | SkDebugf(", "); |
reed | 0dc4dd6 | 2015-03-24 13:55:33 -0700 | [diff] [blame] | 102 | } |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 103 | fPts[index].dump(); |
| 104 | } while (++index < 3); |
| 105 | if (double_is_NaN(fPts[index].fX) && double_is_NaN(fPts[index].fY)) { |
reed | 0dc4dd6 | 2015-03-24 13:55:33 -0700 | [diff] [blame] | 106 | return; |
| 107 | } |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 108 | SkDebugf(", "); |
reed | 0dc4dd6 | 2015-03-24 13:55:33 -0700 | [diff] [blame] | 109 | fPts[index].dump(); |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 110 | } |
| 111 | |
caryclark | 55888e4 | 2016-07-18 10:01:36 -0700 | [diff] [blame] | 112 | void SkDCurve::dump() const { |
| 113 | dumpID(-1); |
| 114 | } |
| 115 | |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 116 | void SkDCurve::dumpID(int id) const { |
| 117 | #ifndef SK_RELEASE |
| 118 | switch(fVerb) { |
| 119 | case SkPath::kLine_Verb: |
| 120 | fLine.dumpID(id); |
| 121 | break; |
| 122 | case SkPath::kQuad_Verb: |
| 123 | fQuad.dumpID(id); |
| 124 | break; |
| 125 | case SkPath::kConic_Verb: |
| 126 | fConic.dumpID(id); |
| 127 | break; |
| 128 | case SkPath::kCubic_Verb: |
| 129 | fCubic.dumpID(id); |
| 130 | break; |
| 131 | default: |
| 132 | SkASSERT(0); |
| 133 | } |
| 134 | #else |
| 135 | fCubic.dumpID(id); |
| 136 | #endif |
| 137 | } |
| 138 | |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 139 | void SkDLine::dump() const { |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 140 | this->dumpInner(); |
| 141 | SkDebugf("}},\n"); |
| 142 | } |
| 143 | |
| 144 | void SkDLine::dumpID(int id) const { |
| 145 | this->dumpInner(); |
caryclark | 55888e4 | 2016-07-18 10:01:36 -0700 | [diff] [blame] | 146 | SkDebugf("}"); |
| 147 | DumpID(id); |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 148 | } |
| 149 | |
| 150 | void SkDLine::dumpInner() const { |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 151 | SkDebugf("{{"); |
| 152 | fPts[0].dump(); |
| 153 | SkDebugf(", "); |
| 154 | fPts[1].dump(); |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 155 | } |
| 156 | |
| 157 | void SkDPoint::dump() const { |
| 158 | SkDebugf("{"); |
| 159 | DebugDumpDouble(fX); |
| 160 | SkDebugf(", "); |
| 161 | DebugDumpDouble(fY); |
| 162 | SkDebugf("}"); |
| 163 | } |
| 164 | |
| 165 | void SkDPoint::Dump(const SkPoint& pt) { |
| 166 | SkDebugf("{"); |
| 167 | DebugDumpFloat(pt.fX); |
| 168 | SkDebugf(", "); |
| 169 | DebugDumpFloat(pt.fY); |
| 170 | SkDebugf("}"); |
| 171 | } |
| 172 | |
caryclark | 65f5531 | 2014-11-13 06:58:52 -0800 | [diff] [blame] | 173 | void SkDPoint::DumpHex(const SkPoint& pt) { |
| 174 | SkDebugf("{"); |
| 175 | DebugDumpHexFloat(pt.fX); |
| 176 | SkDebugf(", "); |
| 177 | DebugDumpHexFloat(pt.fY); |
| 178 | SkDebugf("}"); |
| 179 | } |
| 180 | |
| 181 | void SkDQuad::dump() const { |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 182 | dumpInner(); |
| 183 | SkDebugf("}},\n"); |
caryclark | 65f5531 | 2014-11-13 06:58:52 -0800 | [diff] [blame] | 184 | } |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 185 | |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 186 | void SkDQuad::dumpID(int id) const { |
| 187 | dumpInner(); |
caryclark | 55888e4 | 2016-07-18 10:01:36 -0700 | [diff] [blame] | 188 | SkDebugf("}"); |
| 189 | DumpID(id); |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 190 | } |
| 191 | |
| 192 | void SkDQuad::dumpInner() const { |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 193 | SkDebugf("{{"); |
| 194 | int index = 0; |
| 195 | do { |
| 196 | fPts[index].dump(); |
| 197 | SkDebugf(", "); |
| 198 | } while (++index < 2); |
| 199 | fPts[index].dump(); |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 200 | } |
| 201 | |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 202 | void SkIntersections::dump() const { |
| 203 | SkDebugf("used=%d of %d", fUsed, fMax); |
| 204 | for (int index = 0; index < fUsed; ++index) { |
| 205 | SkDebugf(" t=(%s%1.9g,%s%1.9g) pt=(%1.9g,%1.9g)", |
| 206 | fIsCoincident[0] & (1 << index) ? "*" : "", fT[0][index], |
| 207 | fIsCoincident[1] & (1 << index) ? "*" : "", fT[1][index], |
| 208 | fPt[index].fX, fPt[index].fY); |
| 209 | if (index < 2 && fNearlySame[index]) { |
| 210 | SkDebugf(" pt2=(%1.9g,%1.9g)",fPt2[index].fX, fPt2[index].fY); |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 211 | } |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 212 | } |
| 213 | SkDebugf("\n"); |
| 214 | } |
| 215 | |
Cary Clark | b8421ed | 2018-03-14 15:55:02 -0400 | [diff] [blame] | 216 | namespace SkOpDebug { |
| 217 | |
| 218 | const ::SkOpAngle* AngleAngle(const ::SkOpAngle* angle, int id) { |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 219 | return angle->debugAngle(id); |
| 220 | } |
| 221 | |
Cary Clark | b8421ed | 2018-03-14 15:55:02 -0400 | [diff] [blame] | 222 | ::SkOpContour* AngleContour(::SkOpAngle* angle, int id) { |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 223 | return angle->debugContour(id); |
| 224 | } |
| 225 | |
Cary Clark | b8421ed | 2018-03-14 15:55:02 -0400 | [diff] [blame] | 226 | const ::SkOpPtT* AnglePtT(const ::SkOpAngle* angle, int id) { |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 227 | return angle->debugPtT(id); |
| 228 | } |
| 229 | |
Cary Clark | b8421ed | 2018-03-14 15:55:02 -0400 | [diff] [blame] | 230 | const ::SkOpSegment* AngleSegment(const ::SkOpAngle* angle, int id) { |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 231 | return angle->debugSegment(id); |
| 232 | } |
| 233 | |
Cary Clark | b8421ed | 2018-03-14 15:55:02 -0400 | [diff] [blame] | 234 | const ::SkOpSpanBase* AngleSpan(const ::SkOpAngle* angle, int id) { |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 235 | return angle->debugSpan(id); |
| 236 | } |
| 237 | |
Cary Clark | b8421ed | 2018-03-14 15:55:02 -0400 | [diff] [blame] | 238 | const ::SkOpAngle* ContourAngle(::SkOpContour* contour, int id) { |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 239 | return contour->debugAngle(id); |
| 240 | } |
| 241 | |
Cary Clark | b8421ed | 2018-03-14 15:55:02 -0400 | [diff] [blame] | 242 | ::SkOpContour* ContourContour(::SkOpContour* contour, int id) { |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 243 | return contour->debugContour(id); |
| 244 | } |
| 245 | |
Cary Clark | b8421ed | 2018-03-14 15:55:02 -0400 | [diff] [blame] | 246 | const ::SkOpPtT* ContourPtT(::SkOpContour* contour, int id) { |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 247 | return contour->debugPtT(id); |
| 248 | } |
| 249 | |
Cary Clark | b8421ed | 2018-03-14 15:55:02 -0400 | [diff] [blame] | 250 | const ::SkOpSegment* ContourSegment(::SkOpContour* contour, int id) { |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 251 | return contour->debugSegment(id); |
| 252 | } |
| 253 | |
Cary Clark | b8421ed | 2018-03-14 15:55:02 -0400 | [diff] [blame] | 254 | const ::SkOpSpanBase* ContourSpan(::SkOpContour* contour, int id) { |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 255 | return contour->debugSpan(id); |
| 256 | } |
| 257 | |
Cary Clark | b8421ed | 2018-03-14 15:55:02 -0400 | [diff] [blame] | 258 | const ::SkOpAngle* CoincidenceAngle(::SkOpCoincidence* coin, int id) { |
caryclark | 27c8eb8 | 2015-07-06 11:38:33 -0700 | [diff] [blame] | 259 | return coin->debugAngle(id); |
| 260 | } |
| 261 | |
Cary Clark | b8421ed | 2018-03-14 15:55:02 -0400 | [diff] [blame] | 262 | ::SkOpContour* CoincidenceContour(::SkOpCoincidence* coin, int id) { |
caryclark | 27c8eb8 | 2015-07-06 11:38:33 -0700 | [diff] [blame] | 263 | return coin->debugContour(id); |
| 264 | } |
| 265 | |
Cary Clark | b8421ed | 2018-03-14 15:55:02 -0400 | [diff] [blame] | 266 | const ::SkOpPtT* CoincidencePtT(::SkOpCoincidence* coin, int id) { |
caryclark | 27c8eb8 | 2015-07-06 11:38:33 -0700 | [diff] [blame] | 267 | return coin->debugPtT(id); |
| 268 | } |
| 269 | |
Cary Clark | b8421ed | 2018-03-14 15:55:02 -0400 | [diff] [blame] | 270 | const ::SkOpSegment* CoincidenceSegment(::SkOpCoincidence* coin, int id) { |
caryclark | 27c8eb8 | 2015-07-06 11:38:33 -0700 | [diff] [blame] | 271 | return coin->debugSegment(id); |
| 272 | } |
| 273 | |
Cary Clark | b8421ed | 2018-03-14 15:55:02 -0400 | [diff] [blame] | 274 | const ::SkOpSpanBase* CoincidenceSpan(::SkOpCoincidence* coin, int id) { |
caryclark | 27c8eb8 | 2015-07-06 11:38:33 -0700 | [diff] [blame] | 275 | return coin->debugSpan(id); |
| 276 | } |
| 277 | |
Cary Clark | b8421ed | 2018-03-14 15:55:02 -0400 | [diff] [blame] | 278 | const ::SkOpAngle* PtTAngle(const ::SkOpPtT* ptT, int id) { |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 279 | return ptT->debugAngle(id); |
| 280 | } |
| 281 | |
Cary Clark | b8421ed | 2018-03-14 15:55:02 -0400 | [diff] [blame] | 282 | ::SkOpContour* PtTContour(::SkOpPtT* ptT, int id) { |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 283 | return ptT->debugContour(id); |
| 284 | } |
| 285 | |
Cary Clark | b8421ed | 2018-03-14 15:55:02 -0400 | [diff] [blame] | 286 | const ::SkOpPtT* PtTPtT(const ::SkOpPtT* ptT, int id) { |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 287 | return ptT->debugPtT(id); |
| 288 | } |
| 289 | |
Cary Clark | b8421ed | 2018-03-14 15:55:02 -0400 | [diff] [blame] | 290 | const ::SkOpSegment* PtTSegment(const ::SkOpPtT* ptT, int id) { |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 291 | return ptT->debugSegment(id); |
| 292 | } |
| 293 | |
Cary Clark | b8421ed | 2018-03-14 15:55:02 -0400 | [diff] [blame] | 294 | const ::SkOpSpanBase* PtTSpan(const ::SkOpPtT* ptT, int id) { |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 295 | return ptT->debugSpan(id); |
| 296 | } |
| 297 | |
Cary Clark | b8421ed | 2018-03-14 15:55:02 -0400 | [diff] [blame] | 298 | const ::SkOpAngle* SegmentAngle(const ::SkOpSegment* span, int id) { |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 299 | return span->debugAngle(id); |
| 300 | } |
| 301 | |
Cary Clark | b8421ed | 2018-03-14 15:55:02 -0400 | [diff] [blame] | 302 | ::SkOpContour* SegmentContour(::SkOpSegment* span, int id) { |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 303 | return span->debugContour(id); |
| 304 | } |
| 305 | |
Cary Clark | b8421ed | 2018-03-14 15:55:02 -0400 | [diff] [blame] | 306 | const ::SkOpPtT* SegmentPtT(const ::SkOpSegment* span, int id) { |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 307 | return span->debugPtT(id); |
| 308 | } |
| 309 | |
Cary Clark | b8421ed | 2018-03-14 15:55:02 -0400 | [diff] [blame] | 310 | const ::SkOpSegment* SegmentSegment(const ::SkOpSegment* span, int id) { |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 311 | return span->debugSegment(id); |
| 312 | } |
| 313 | |
Cary Clark | b8421ed | 2018-03-14 15:55:02 -0400 | [diff] [blame] | 314 | const ::SkOpSpanBase* SegmentSpan(const ::SkOpSegment* span, int id) { |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 315 | return span->debugSpan(id); |
| 316 | } |
| 317 | |
Cary Clark | b8421ed | 2018-03-14 15:55:02 -0400 | [diff] [blame] | 318 | const ::SkOpAngle* SpanAngle(const ::SkOpSpanBase* span, int id) { |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 319 | return span->debugAngle(id); |
| 320 | } |
| 321 | |
Cary Clark | b8421ed | 2018-03-14 15:55:02 -0400 | [diff] [blame] | 322 | ::SkOpContour* SpanContour(::SkOpSpanBase* span, int id) { |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 323 | return span->debugContour(id); |
| 324 | } |
| 325 | |
Cary Clark | b8421ed | 2018-03-14 15:55:02 -0400 | [diff] [blame] | 326 | const ::SkOpPtT* SpanPtT(const ::SkOpSpanBase* span, int id) { |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 327 | return span->debugPtT(id); |
| 328 | } |
| 329 | |
Cary Clark | b8421ed | 2018-03-14 15:55:02 -0400 | [diff] [blame] | 330 | const ::SkOpSegment* SpanSegment(const ::SkOpSpanBase* span, int id) { |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 331 | return span->debugSegment(id); |
| 332 | } |
| 333 | |
Cary Clark | b8421ed | 2018-03-14 15:55:02 -0400 | [diff] [blame] | 334 | const ::SkOpSpanBase* SpanSpan(const ::SkOpSpanBase* span, int id) { |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 335 | return span->debugSpan(id); |
| 336 | } |
| 337 | |
Cary Clark | b8421ed | 2018-03-14 15:55:02 -0400 | [diff] [blame] | 338 | } // namespace SkPathOpsDebug |
| 339 | |
Cary Clark | ab87d7a | 2016-10-04 10:01:04 -0400 | [diff] [blame] | 340 | #if DEBUG_COIN |
| 341 | void SkPathOpsDebug::DumpCoinDict() { |
Cary Clark | b8421ed | 2018-03-14 15:55:02 -0400 | [diff] [blame] | 342 | SkPathOpsDebug::gCoinSumChangedDict.dump("unused coin algorithm", false); |
| 343 | SkPathOpsDebug::gCoinSumVisitedDict.dump("visited coin function", true); |
Cary Clark | ab87d7a | 2016-10-04 10:01:04 -0400 | [diff] [blame] | 344 | } |
| 345 | |
| 346 | void SkPathOpsDebug::CoinDict::dump(const char* str, bool visitCheck) const { |
| 347 | int count = fDict.count(); |
| 348 | for (int index = 0; index < count; ++index) { |
| 349 | const auto& entry = fDict[index]; |
| 350 | if (visitCheck || entry.fGlitchType == kUninitialized_Glitch) { |
| 351 | SkDebugf("%s %s : line %d iteration %d", str, entry.fFunctionName, |
| 352 | entry.fLineNumber, entry.fIteration); |
| 353 | DumpGlitchType(entry.fGlitchType); |
| 354 | SkDebugf("\n"); |
| 355 | } |
| 356 | } |
| 357 | } |
| 358 | #endif |
| 359 | |
caryclark | 624637c | 2015-05-11 07:21:27 -0700 | [diff] [blame] | 360 | void SkOpContour::dumpContours() const { |
| 361 | SkOpContour* contour = this->globalState()->contourHead(); |
| 362 | do { |
| 363 | contour->dump(); |
| 364 | } while ((contour = contour->next())); |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 365 | } |
| 366 | |
caryclark | 624637c | 2015-05-11 07:21:27 -0700 | [diff] [blame] | 367 | void SkOpContour::dumpContoursAll() const { |
| 368 | SkOpContour* contour = this->globalState()->contourHead(); |
| 369 | do { |
| 370 | contour->dumpAll(); |
| 371 | } while ((contour = contour->next())); |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 372 | } |
| 373 | |
caryclark | 624637c | 2015-05-11 07:21:27 -0700 | [diff] [blame] | 374 | void SkOpContour::dumpContoursAngles() const { |
| 375 | SkOpContour* contour = this->globalState()->contourHead(); |
| 376 | do { |
| 377 | contour->dumpAngles(); |
| 378 | } while ((contour = contour->next())); |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 379 | } |
| 380 | |
caryclark | 624637c | 2015-05-11 07:21:27 -0700 | [diff] [blame] | 381 | void SkOpContour::dumpContoursPts() const { |
| 382 | SkOpContour* contour = this->globalState()->contourHead(); |
| 383 | do { |
| 384 | contour->dumpPts(); |
| 385 | } while ((contour = contour->next())); |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 386 | } |
| 387 | |
caryclark | 624637c | 2015-05-11 07:21:27 -0700 | [diff] [blame] | 388 | void SkOpContour::dumpContoursPt(int segmentID) const { |
| 389 | SkOpContour* contour = this->globalState()->contourHead(); |
| 390 | do { |
| 391 | contour->dumpPt(segmentID); |
| 392 | } while ((contour = contour->next())); |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 393 | } |
| 394 | |
caryclark | 624637c | 2015-05-11 07:21:27 -0700 | [diff] [blame] | 395 | void SkOpContour::dumpContoursSegment(int segmentID) const { |
| 396 | SkOpContour* contour = this->globalState()->contourHead(); |
| 397 | do { |
| 398 | contour->dumpSegment(segmentID); |
| 399 | } while ((contour = contour->next())); |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 400 | } |
| 401 | |
caryclark | 624637c | 2015-05-11 07:21:27 -0700 | [diff] [blame] | 402 | void SkOpContour::dumpContoursSpan(int spanID) const { |
| 403 | SkOpContour* contour = this->globalState()->contourHead(); |
| 404 | do { |
| 405 | contour->dumpSpan(spanID); |
| 406 | } while ((contour = contour->next())); |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 407 | } |
| 408 | |
caryclark | 624637c | 2015-05-11 07:21:27 -0700 | [diff] [blame] | 409 | void SkOpContour::dumpContoursSpans() const { |
| 410 | SkOpContour* contour = this->globalState()->contourHead(); |
| 411 | do { |
| 412 | contour->dumpSpans(); |
| 413 | } while ((contour = contour->next())); |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 414 | } |
| 415 | |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 416 | template <typename TCurve, typename OppCurve> |
| 417 | const SkTSpan<TCurve, OppCurve>* DebugSpan(const SkTSect<TCurve, OppCurve>* sect, int id) { |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 418 | return sect->debugSpan(id); |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 419 | } |
| 420 | |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 421 | void DontCallDebugSpan(int id); |
| 422 | void DontCallDebugSpan(int id) { // exists to instantiate the templates |
| 423 | SkDQuad quad; |
| 424 | SkDConic conic; |
| 425 | SkDCubic cubic; |
caryclark | e25a4f6 | 2016-07-26 09:26:29 -0700 | [diff] [blame] | 426 | SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 427 | SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 428 | SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 429 | SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 430 | SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 431 | SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 432 | SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 433 | SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 434 | SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 435 | DebugSpan(&q1q2, id); |
| 436 | DebugSpan(&q1k2, id); |
| 437 | DebugSpan(&q1c2, id); |
| 438 | DebugSpan(&k1q2, id); |
| 439 | DebugSpan(&k1k2, id); |
| 440 | DebugSpan(&k1c2, id); |
| 441 | DebugSpan(&c1q2, id); |
| 442 | DebugSpan(&c1k2, id); |
| 443 | DebugSpan(&c1c2, id); |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 444 | } |
| 445 | |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 446 | template <typename TCurve, typename OppCurve> |
| 447 | const SkTSpan<TCurve, OppCurve>* DebugT(const SkTSect<TCurve, OppCurve>* sect, double t) { |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 448 | return sect->debugT(t); |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 449 | } |
| 450 | |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 451 | void DontCallDebugT(double t); |
| 452 | void DontCallDebugT(double t) { // exists to instantiate the templates |
| 453 | SkDQuad quad; |
| 454 | SkDConic conic; |
| 455 | SkDCubic cubic; |
caryclark | e25a4f6 | 2016-07-26 09:26:29 -0700 | [diff] [blame] | 456 | SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 457 | SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 458 | SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 459 | SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 460 | SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 461 | SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 462 | SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 463 | SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 464 | SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 465 | DebugT(&q1q2, t); |
| 466 | DebugT(&q1k2, t); |
| 467 | DebugT(&q1c2, t); |
| 468 | DebugT(&k1q2, t); |
| 469 | DebugT(&k1k2, t); |
| 470 | DebugT(&k1c2, t); |
| 471 | DebugT(&c1q2, t); |
| 472 | DebugT(&c1k2, t); |
| 473 | DebugT(&c1c2, t); |
caryclark | dac1d17 | 2014-06-17 05:15:38 -0700 | [diff] [blame] | 474 | } |
| 475 | |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 476 | template <typename TCurve, typename OppCurve> |
| 477 | void Dump(const SkTSect<TCurve, OppCurve>* sect) { |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 478 | sect->dump(); |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 479 | } |
| 480 | |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 481 | void DontCallDumpTSect(); |
| 482 | void DontCallDumpTSect() { // exists to instantiate the templates |
| 483 | SkDQuad quad; |
| 484 | SkDConic conic; |
| 485 | SkDCubic cubic; |
caryclark | e25a4f6 | 2016-07-26 09:26:29 -0700 | [diff] [blame] | 486 | SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 487 | SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 488 | SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 489 | SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 490 | SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 491 | SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 492 | SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 493 | SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 494 | SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 495 | Dump(&q1q2); |
| 496 | Dump(&q1k2); |
| 497 | Dump(&q1c2); |
| 498 | Dump(&k1q2); |
| 499 | Dump(&k1k2); |
| 500 | Dump(&k1c2); |
| 501 | Dump(&c1q2); |
| 502 | Dump(&c1k2); |
| 503 | Dump(&c1c2); |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 504 | } |
| 505 | |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 506 | template <typename TCurve, typename OppCurve> |
| 507 | void DumpBoth(SkTSect<TCurve, OppCurve>* sect1, SkTSect<OppCurve, TCurve>* sect2) { |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 508 | sect1->dumpBoth(sect2); |
caryclark | dac1d17 | 2014-06-17 05:15:38 -0700 | [diff] [blame] | 509 | } |
| 510 | |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 511 | void DontCallDumpBoth(); |
| 512 | void DontCallDumpBoth() { // exists to instantiate the templates |
| 513 | SkDQuad quad; |
| 514 | SkDConic conic; |
| 515 | SkDCubic cubic; |
caryclark | e25a4f6 | 2016-07-26 09:26:29 -0700 | [diff] [blame] | 516 | SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 517 | SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 518 | SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 519 | SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 520 | SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 521 | SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 522 | SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 523 | SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 524 | SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 525 | DumpBoth(&q1q2, &q1q2); |
| 526 | DumpBoth(&q1k2, &k1q2); |
| 527 | DumpBoth(&q1c2, &c1q2); |
| 528 | DumpBoth(&k1q2, &q1k2); |
| 529 | DumpBoth(&k1k2, &k1k2); |
| 530 | DumpBoth(&k1c2, &c1k2); |
| 531 | DumpBoth(&c1q2, &q1c2); |
| 532 | DumpBoth(&c1k2, &k1c2); |
| 533 | DumpBoth(&c1c2, &c1c2); |
caryclark | dac1d17 | 2014-06-17 05:15:38 -0700 | [diff] [blame] | 534 | } |
| 535 | |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 536 | template <typename TCurve, typename OppCurve> |
| 537 | void DumpBounded(SkTSect<TCurve, OppCurve>* sect1, int id) { |
| 538 | sect1->dumpBounded(id); |
| 539 | } |
| 540 | |
| 541 | void DontCallDumpBounded(); |
| 542 | void DontCallDumpBounded() { |
| 543 | SkDQuad quad; |
| 544 | SkDConic conic; |
| 545 | SkDCubic cubic; |
caryclark | e25a4f6 | 2016-07-26 09:26:29 -0700 | [diff] [blame] | 546 | SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 547 | SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 548 | SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 549 | SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 550 | SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 551 | SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 552 | SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 553 | SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 554 | SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 555 | DumpBounded(&q1q2, 0); |
| 556 | DumpBounded(&q1k2, 0); |
| 557 | DumpBounded(&q1c2, 0); |
| 558 | DumpBounded(&k1q2, 0); |
| 559 | DumpBounded(&k1k2, 0); |
| 560 | DumpBounded(&k1c2, 0); |
| 561 | DumpBounded(&c1q2, 0); |
| 562 | DumpBounded(&c1k2, 0); |
| 563 | DumpBounded(&c1c2, 0); |
| 564 | } |
| 565 | |
| 566 | template <typename TCurve, typename OppCurve> |
| 567 | void DumpBounds(SkTSect<TCurve, OppCurve>* sect1) { |
| 568 | sect1->dumpBounds(); |
| 569 | } |
| 570 | |
| 571 | void DontCallDumpBounds(); |
| 572 | void DontCallDumpBounds() { |
| 573 | SkDQuad quad; |
| 574 | SkDConic conic; |
| 575 | SkDCubic cubic; |
caryclark | e25a4f6 | 2016-07-26 09:26:29 -0700 | [diff] [blame] | 576 | SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 577 | SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 578 | SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 579 | SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 580 | SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 581 | SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 582 | SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 583 | SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 584 | SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 585 | DumpBounds(&q1q2); |
| 586 | DumpBounds(&q1k2); |
| 587 | DumpBounds(&q1c2); |
| 588 | DumpBounds(&k1q2); |
| 589 | DumpBounds(&k1k2); |
| 590 | DumpBounds(&k1c2); |
| 591 | DumpBounds(&c1q2); |
| 592 | DumpBounds(&c1k2); |
| 593 | DumpBounds(&c1c2); |
| 594 | } |
| 595 | |
| 596 | template <typename TCurve, typename OppCurve> |
| 597 | void DumpCoin(SkTSect<TCurve, OppCurve>* sect1) { |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 598 | sect1->dumpCoin(); |
caryclark | dac1d17 | 2014-06-17 05:15:38 -0700 | [diff] [blame] | 599 | } |
| 600 | |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 601 | void DontCallDumpCoin(); |
| 602 | void DontCallDumpCoin() { // exists to instantiate the templates |
| 603 | SkDQuad quad; |
| 604 | SkDConic conic; |
| 605 | SkDCubic cubic; |
caryclark | e25a4f6 | 2016-07-26 09:26:29 -0700 | [diff] [blame] | 606 | SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 607 | SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 608 | SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 609 | SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 610 | SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 611 | SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 612 | SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 613 | SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 614 | SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 615 | DumpCoin(&q1q2); |
| 616 | DumpCoin(&q1k2); |
| 617 | DumpCoin(&q1c2); |
| 618 | DumpCoin(&k1q2); |
| 619 | DumpCoin(&k1k2); |
| 620 | DumpCoin(&k1c2); |
| 621 | DumpCoin(&c1q2); |
| 622 | DumpCoin(&c1k2); |
| 623 | DumpCoin(&c1c2); |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 624 | } |
| 625 | |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 626 | template <typename TCurve, typename OppCurve> |
| 627 | void DumpCoinCurves(SkTSect<TCurve, OppCurve>* sect1) { |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 628 | sect1->dumpCoinCurves(); |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 629 | } |
| 630 | |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 631 | void DontCallDumpCoinCurves(); |
| 632 | void DontCallDumpCoinCurves() { // exists to instantiate the templates |
| 633 | SkDQuad quad; |
| 634 | SkDConic conic; |
| 635 | SkDCubic cubic; |
caryclark | e25a4f6 | 2016-07-26 09:26:29 -0700 | [diff] [blame] | 636 | SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 637 | SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 638 | SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 639 | SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 640 | SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 641 | SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 642 | SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 643 | SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 644 | SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 645 | DumpCoinCurves(&q1q2); |
| 646 | DumpCoinCurves(&q1k2); |
| 647 | DumpCoinCurves(&q1c2); |
| 648 | DumpCoinCurves(&k1q2); |
| 649 | DumpCoinCurves(&k1k2); |
| 650 | DumpCoinCurves(&k1c2); |
| 651 | DumpCoinCurves(&c1q2); |
| 652 | DumpCoinCurves(&c1k2); |
| 653 | DumpCoinCurves(&c1c2); |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 654 | } |
| 655 | |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 656 | template <typename TCurve, typename OppCurve> |
| 657 | void DumpCurves(const SkTSect<TCurve, OppCurve>* sect) { |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 658 | sect->dumpCurves(); |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 659 | } |
| 660 | |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 661 | void DontCallDumpCurves(); |
| 662 | void DontCallDumpCurves() { // exists to instantiate the templates |
| 663 | SkDQuad quad; |
| 664 | SkDConic conic; |
| 665 | SkDCubic cubic; |
caryclark | e25a4f6 | 2016-07-26 09:26:29 -0700 | [diff] [blame] | 666 | SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 667 | SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 668 | SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 669 | SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 670 | SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 671 | SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 672 | SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 673 | SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
| 674 | SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1)); |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 675 | DumpCurves(&q1q2); |
| 676 | DumpCurves(&q1k2); |
| 677 | DumpCurves(&q1c2); |
| 678 | DumpCurves(&k1q2); |
| 679 | DumpCurves(&k1k2); |
| 680 | DumpCurves(&k1c2); |
| 681 | DumpCurves(&c1q2); |
| 682 | DumpCurves(&c1k2); |
| 683 | DumpCurves(&c1c2); |
| 684 | } |
| 685 | |
| 686 | template <typename TCurve, typename OppCurve> |
| 687 | void Dump(const SkTSpan<TCurve, OppCurve>* span) { |
| 688 | span->dump(); |
| 689 | } |
| 690 | |
| 691 | void DontCallDumpTSpan(); |
| 692 | void DontCallDumpTSpan() { // exists to instantiate the templates |
| 693 | SkTSpan<SkDQuad, SkDQuad> q1q2; q1q2.debugInit(); |
| 694 | SkTSpan<SkDQuad, SkDConic> q1k2; q1k2.debugInit(); |
| 695 | SkTSpan<SkDQuad, SkDCubic> q1c2; q1c2.debugInit(); |
| 696 | SkTSpan<SkDConic, SkDQuad> k1q2; k1q2.debugInit(); |
| 697 | SkTSpan<SkDConic, SkDConic> k1k2; k1k2.debugInit(); |
| 698 | SkTSpan<SkDConic, SkDCubic> k1c2; k1c2.debugInit(); |
| 699 | SkTSpan<SkDCubic, SkDQuad> c1q2; c1q2.debugInit(); |
| 700 | SkTSpan<SkDCubic, SkDConic> c1k2; c1k2.debugInit(); |
| 701 | SkTSpan<SkDCubic, SkDCubic> c1c2; c1c2.debugInit(); |
| 702 | Dump(&q1q2); |
| 703 | Dump(&q1k2); |
| 704 | Dump(&q1c2); |
| 705 | Dump(&k1q2); |
| 706 | Dump(&k1k2); |
| 707 | Dump(&k1c2); |
| 708 | Dump(&c1q2); |
| 709 | Dump(&c1k2); |
| 710 | Dump(&c1c2); |
| 711 | } |
| 712 | |
| 713 | template <typename TCurve, typename OppCurve> |
caryclark | 26ad22a | 2015-10-16 09:03:38 -0700 | [diff] [blame] | 714 | void DumpAll(const SkTSpan<TCurve, OppCurve>* span) { |
| 715 | span->dumpAll(); |
| 716 | } |
| 717 | |
| 718 | void DontCallDumpSpanAll(); |
| 719 | void DontCallDumpSpanAll() { // exists to instantiate the templates |
| 720 | SkTSpan<SkDQuad, SkDQuad> q1q2; q1q2.debugInit(); |
| 721 | SkTSpan<SkDQuad, SkDConic> q1k2; q1k2.debugInit(); |
| 722 | SkTSpan<SkDQuad, SkDCubic> q1c2; q1c2.debugInit(); |
| 723 | SkTSpan<SkDConic, SkDQuad> k1q2; k1q2.debugInit(); |
| 724 | SkTSpan<SkDConic, SkDConic> k1k2; k1k2.debugInit(); |
| 725 | SkTSpan<SkDConic, SkDCubic> k1c2; k1c2.debugInit(); |
| 726 | SkTSpan<SkDCubic, SkDQuad> c1q2; c1q2.debugInit(); |
| 727 | SkTSpan<SkDCubic, SkDConic> c1k2; c1k2.debugInit(); |
| 728 | SkTSpan<SkDCubic, SkDCubic> c1c2; c1c2.debugInit(); |
| 729 | DumpAll(&q1q2); |
| 730 | DumpAll(&q1k2); |
| 731 | DumpAll(&q1c2); |
| 732 | DumpAll(&k1q2); |
| 733 | DumpAll(&k1k2); |
| 734 | DumpAll(&k1c2); |
| 735 | DumpAll(&c1q2); |
| 736 | DumpAll(&c1k2); |
| 737 | DumpAll(&c1c2); |
| 738 | } |
| 739 | |
| 740 | template <typename TCurve, typename OppCurve> |
| 741 | void DumpBounded(const SkTSpan<TCurve, OppCurve>* span) { |
| 742 | span->dumpBounded(0); |
| 743 | } |
| 744 | |
| 745 | void DontCallDumpSpanBounded(); |
| 746 | void DontCallDumpSpanBounded() { // exists to instantiate the templates |
| 747 | SkTSpan<SkDQuad, SkDQuad> q1q2; q1q2.debugInit(); |
| 748 | SkTSpan<SkDQuad, SkDConic> q1k2; q1k2.debugInit(); |
| 749 | SkTSpan<SkDQuad, SkDCubic> q1c2; q1c2.debugInit(); |
| 750 | SkTSpan<SkDConic, SkDQuad> k1q2; k1q2.debugInit(); |
| 751 | SkTSpan<SkDConic, SkDConic> k1k2; k1k2.debugInit(); |
| 752 | SkTSpan<SkDConic, SkDCubic> k1c2; k1c2.debugInit(); |
| 753 | SkTSpan<SkDCubic, SkDQuad> c1q2; c1q2.debugInit(); |
| 754 | SkTSpan<SkDCubic, SkDConic> c1k2; c1k2.debugInit(); |
| 755 | SkTSpan<SkDCubic, SkDCubic> c1c2; c1c2.debugInit(); |
| 756 | DumpBounded(&q1q2); |
| 757 | DumpBounded(&q1k2); |
| 758 | DumpBounded(&q1c2); |
| 759 | DumpBounded(&k1q2); |
| 760 | DumpBounded(&k1k2); |
| 761 | DumpBounded(&k1c2); |
| 762 | DumpBounded(&c1q2); |
| 763 | DumpBounded(&c1k2); |
| 764 | DumpBounded(&c1c2); |
| 765 | } |
| 766 | |
| 767 | template <typename TCurve, typename OppCurve> |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 768 | void DumpCoin(const SkTSpan<TCurve, OppCurve>* span) { |
| 769 | span->dumpCoin(); |
| 770 | } |
| 771 | |
| 772 | void DontCallDumpSpanCoin(); |
| 773 | void DontCallDumpSpanCoin() { // exists to instantiate the templates |
| 774 | SkTSpan<SkDQuad, SkDQuad> q1q2; q1q2.debugInit(); |
| 775 | SkTSpan<SkDQuad, SkDConic> q1k2; q1k2.debugInit(); |
| 776 | SkTSpan<SkDQuad, SkDCubic> q1c2; q1c2.debugInit(); |
| 777 | SkTSpan<SkDConic, SkDQuad> k1q2; k1q2.debugInit(); |
| 778 | SkTSpan<SkDConic, SkDConic> k1k2; k1k2.debugInit(); |
| 779 | SkTSpan<SkDConic, SkDCubic> k1c2; k1c2.debugInit(); |
| 780 | SkTSpan<SkDCubic, SkDQuad> c1q2; c1q2.debugInit(); |
| 781 | SkTSpan<SkDCubic, SkDConic> c1k2; c1k2.debugInit(); |
| 782 | SkTSpan<SkDCubic, SkDCubic> c1c2; c1c2.debugInit(); |
| 783 | DumpCoin(&q1q2); |
| 784 | DumpCoin(&q1k2); |
| 785 | DumpCoin(&q1c2); |
| 786 | DumpCoin(&k1q2); |
| 787 | DumpCoin(&k1k2); |
| 788 | DumpCoin(&k1c2); |
| 789 | DumpCoin(&c1q2); |
| 790 | DumpCoin(&c1k2); |
| 791 | DumpCoin(&c1c2); |
caryclark | dac1d17 | 2014-06-17 05:15:38 -0700 | [diff] [blame] | 792 | } |
| 793 | |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 794 | static void dumpTestCase(const SkDQuad& quad1, const SkDQuad& quad2, int testNo) { |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 795 | SkDebugf("\n<div id=\"quad%d\">\n", testNo); |
| 796 | quad1.dumpInner(); |
| 797 | SkDebugf("}}, "); |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 798 | quad2.dump(); |
| 799 | SkDebugf("</div>\n\n"); |
| 800 | } |
| 801 | |
| 802 | static void dumpTestTrailer() { |
| 803 | SkDebugf("</div>\n\n<script type=\"text/javascript\">\n\n"); |
| 804 | SkDebugf(" var testDivs = [\n"); |
| 805 | } |
| 806 | |
| 807 | static void dumpTestList(int testNo, double min) { |
| 808 | SkDebugf(" quad%d,", testNo); |
| 809 | if (min > 0) { |
| 810 | SkDebugf(" // %1.9g", min); |
| 811 | } |
| 812 | SkDebugf("\n"); |
| 813 | } |
| 814 | |
| 815 | void DumpQ(const SkDQuad& quad1, const SkDQuad& quad2, int testNo) { |
| 816 | SkDebugf("\n"); |
| 817 | dumpTestCase(quad1, quad2, testNo); |
| 818 | dumpTestTrailer(); |
| 819 | dumpTestList(testNo, 0); |
| 820 | SkDebugf("\n"); |
| 821 | } |
| 822 | |
| 823 | void DumpT(const SkDQuad& quad, double t) { |
| 824 | SkDLine line = {{quad.ptAtT(t), quad[0]}}; |
| 825 | line.dump(); |
| 826 | } |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 827 | |
| 828 | const SkOpAngle* SkOpAngle::debugAngle(int id) const { |
| 829 | return this->segment()->debugAngle(id); |
| 830 | } |
| 831 | |
caryclark | 55888e4 | 2016-07-18 10:01:36 -0700 | [diff] [blame] | 832 | const SkOpCoincidence* SkOpAngle::debugCoincidence() const { |
| 833 | return this->segment()->debugCoincidence(); |
| 834 | } |
| 835 | |
caryclark | 30b9fdd | 2016-08-31 14:36:29 -0700 | [diff] [blame] | 836 | SkOpContour* SkOpAngle::debugContour(int id) const { |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 837 | return this->segment()->debugContour(id); |
| 838 | } |
| 839 | |
| 840 | const SkOpPtT* SkOpAngle::debugPtT(int id) const { |
| 841 | return this->segment()->debugPtT(id); |
| 842 | } |
| 843 | |
| 844 | const SkOpSegment* SkOpAngle::debugSegment(int id) const { |
| 845 | return this->segment()->debugSegment(id); |
| 846 | } |
| 847 | |
caryclark | 624637c | 2015-05-11 07:21:27 -0700 | [diff] [blame] | 848 | int SkOpAngle::debugSign() const { |
| 849 | SkASSERT(fStart->t() != fEnd->t()); |
| 850 | return fStart->t() < fEnd->t() ? -1 : 1; |
| 851 | } |
| 852 | |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 853 | const SkOpSpanBase* SkOpAngle::debugSpan(int id) const { |
| 854 | return this->segment()->debugSpan(id); |
| 855 | } |
| 856 | |
| 857 | void SkOpAngle::dump() const { |
| 858 | dumpOne(true); |
| 859 | SkDebugf("\n"); |
| 860 | } |
| 861 | |
| 862 | void SkOpAngle::dumpOne(bool functionHeader) const { |
| 863 | // fSegment->debugValidate(); |
| 864 | const SkOpSegment* segment = this->segment(); |
| 865 | const SkOpSpan& mSpan = *fStart->starter(fEnd); |
| 866 | if (functionHeader) { |
| 867 | SkDebugf("%s ", __FUNCTION__); |
| 868 | } |
| 869 | SkDebugf("[%d", segment->debugID()); |
| 870 | SkDebugf("/%d", debugID()); |
| 871 | SkDebugf("] next="); |
| 872 | if (fNext) { |
| 873 | SkDebugf("%d", fNext->fStart->segment()->debugID()); |
| 874 | SkDebugf("/%d", fNext->debugID()); |
| 875 | } else { |
| 876 | SkDebugf("?"); |
| 877 | } |
| 878 | SkDebugf(" sect=%d/%d ", fSectorStart, fSectorEnd); |
| 879 | SkDebugf(" s=%1.9g [%d] e=%1.9g [%d]", fStart->t(), fStart->debugID(), |
| 880 | fEnd->t(), fEnd->debugID()); |
caryclark | 624637c | 2015-05-11 07:21:27 -0700 | [diff] [blame] | 881 | SkDebugf(" sgn=%d windVal=%d", this->debugSign(), mSpan.windValue()); |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 882 | |
| 883 | SkDebugf(" windSum="); |
| 884 | SkPathOpsDebug::WindingPrintf(mSpan.windSum()); |
| 885 | if (mSpan.oppValue() != 0 || mSpan.oppSum() != SK_MinS32) { |
| 886 | SkDebugf(" oppVal=%d", mSpan.oppValue()); |
| 887 | SkDebugf(" oppSum="); |
| 888 | SkPathOpsDebug::WindingPrintf(mSpan.oppSum()); |
| 889 | } |
| 890 | if (mSpan.done()) { |
| 891 | SkDebugf(" done"); |
| 892 | } |
| 893 | if (unorderable()) { |
| 894 | SkDebugf(" unorderable"); |
| 895 | } |
| 896 | if (segment->operand()) { |
| 897 | SkDebugf(" operand"); |
| 898 | } |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 899 | } |
| 900 | |
| 901 | void SkOpAngle::dumpTo(const SkOpSegment* segment, const SkOpAngle* to) const { |
| 902 | const SkOpAngle* first = this; |
| 903 | const SkOpAngle* next = this; |
| 904 | const char* indent = ""; |
| 905 | do { |
| 906 | SkDebugf("%s", indent); |
| 907 | next->dumpOne(false); |
| 908 | if (segment == next->fStart->segment()) { |
| 909 | if (this == fNext) { |
| 910 | SkDebugf(" << from"); |
| 911 | } |
| 912 | if (to == fNext) { |
| 913 | SkDebugf(" << to"); |
| 914 | } |
| 915 | } |
| 916 | SkDebugf("\n"); |
| 917 | indent = " "; |
| 918 | next = next->fNext; |
| 919 | } while (next && next != first); |
| 920 | } |
| 921 | |
| 922 | void SkOpAngle::dumpCurves() const { |
| 923 | const SkOpAngle* first = this; |
| 924 | const SkOpAngle* next = this; |
| 925 | do { |
caryclark | eed356d | 2016-09-14 07:18:20 -0700 | [diff] [blame] | 926 | next->fPart.fCurve.dumpID(next->segment()->debugID()); |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 927 | next = next->fNext; |
| 928 | } while (next && next != first); |
| 929 | } |
| 930 | |
| 931 | void SkOpAngle::dumpLoop() const { |
| 932 | const SkOpAngle* first = this; |
| 933 | const SkOpAngle* next = this; |
| 934 | do { |
| 935 | next->dumpOne(false); |
| 936 | SkDebugf("\n"); |
| 937 | next = next->fNext; |
| 938 | } while (next && next != first); |
| 939 | } |
| 940 | |
| 941 | void SkOpAngle::dumpTest() const { |
| 942 | const SkOpAngle* first = this; |
| 943 | const SkOpAngle* next = this; |
| 944 | do { |
| 945 | SkDebugf("{ "); |
| 946 | SkOpSegment* segment = next->segment(); |
| 947 | segment->dumpPts(); |
| 948 | SkDebugf(", %d, %1.9g, %1.9g, {} },\n", SkPathOpsVerbToPoints(segment->verb()) + 1, |
| 949 | next->start()->t(), next->end()->t()); |
| 950 | next = next->fNext; |
| 951 | } while (next && next != first); |
| 952 | } |
| 953 | |
| 954 | bool SkOpPtT::debugMatchID(int id) const { |
| 955 | int limit = this->debugLoopLimit(false); |
| 956 | int loop = 0; |
| 957 | const SkOpPtT* ptT = this; |
| 958 | do { |
| 959 | if (ptT->debugID() == id) { |
| 960 | return true; |
| 961 | } |
| 962 | } while ((!limit || ++loop <= limit) && (ptT = ptT->next()) && ptT != this); |
| 963 | return false; |
| 964 | } |
| 965 | |
| 966 | const SkOpAngle* SkOpPtT::debugAngle(int id) const { |
| 967 | return this->span()->debugAngle(id); |
| 968 | } |
| 969 | |
caryclark | 30b9fdd | 2016-08-31 14:36:29 -0700 | [diff] [blame] | 970 | SkOpContour* SkOpPtT::debugContour(int id) const { |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 971 | return this->span()->debugContour(id); |
| 972 | } |
| 973 | |
caryclark | 55888e4 | 2016-07-18 10:01:36 -0700 | [diff] [blame] | 974 | const SkOpCoincidence* SkOpPtT::debugCoincidence() const { |
| 975 | return this->span()->debugCoincidence(); |
| 976 | } |
| 977 | |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 978 | const SkOpPtT* SkOpPtT::debugPtT(int id) const { |
| 979 | return this->span()->debugPtT(id); |
| 980 | } |
| 981 | |
| 982 | const SkOpSegment* SkOpPtT::debugSegment(int id) const { |
| 983 | return this->span()->debugSegment(id); |
| 984 | } |
| 985 | |
| 986 | const SkOpSpanBase* SkOpPtT::debugSpan(int id) const { |
| 987 | return this->span()->debugSpan(id); |
| 988 | } |
| 989 | |
| 990 | void SkOpPtT::dump() const { |
| 991 | SkDebugf("seg=%d span=%d ptT=%d", |
| 992 | this->segment()->debugID(), this->span()->debugID(), this->debugID()); |
| 993 | this->dumpBase(); |
| 994 | SkDebugf("\n"); |
| 995 | } |
| 996 | |
| 997 | void SkOpPtT::dumpAll() const { |
| 998 | contour()->indentDump(); |
| 999 | const SkOpPtT* next = this; |
| 1000 | int limit = debugLoopLimit(true); |
| 1001 | int loop = 0; |
| 1002 | do { |
| 1003 | SkDebugf("%.*s", contour()->debugIndent(), " "); |
| 1004 | SkDebugf("seg=%d span=%d ptT=%d", |
| 1005 | next->segment()->debugID(), next->span()->debugID(), next->debugID()); |
| 1006 | next->dumpBase(); |
| 1007 | SkDebugf("\n"); |
| 1008 | if (limit && ++loop >= limit) { |
| 1009 | SkDebugf("*** abort loop ***\n"); |
| 1010 | break; |
| 1011 | } |
| 1012 | } while ((next = next->fNext) && next != this); |
| 1013 | contour()->outdentDump(); |
| 1014 | } |
| 1015 | |
| 1016 | void SkOpPtT::dumpBase() const { |
caryclark | 55888e4 | 2016-07-18 10:01:36 -0700 | [diff] [blame] | 1017 | SkDebugf(" t=%1.9g pt=(%1.9g,%1.9g)%s%s%s", this->fT, this->fPt.fX, this->fPt.fY, |
| 1018 | this->fCoincident ? " coin" : "", |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 1019 | this->fDuplicatePt ? " dup" : "", this->fDeleted ? " deleted" : ""); |
| 1020 | } |
| 1021 | |
| 1022 | const SkOpAngle* SkOpSpanBase::debugAngle(int id) const { |
| 1023 | return this->segment()->debugAngle(id); |
| 1024 | } |
| 1025 | |
caryclark | 55888e4 | 2016-07-18 10:01:36 -0700 | [diff] [blame] | 1026 | const SkOpCoincidence* SkOpSpanBase::debugCoincidence() const { |
| 1027 | return this->segment()->debugCoincidence(); |
| 1028 | } |
| 1029 | |
caryclark | 30b9fdd | 2016-08-31 14:36:29 -0700 | [diff] [blame] | 1030 | SkOpContour* SkOpSpanBase::debugContour(int id) const { |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 1031 | return this->segment()->debugContour(id); |
| 1032 | } |
| 1033 | |
| 1034 | const SkOpPtT* SkOpSpanBase::debugPtT(int id) const { |
| 1035 | return this->segment()->debugPtT(id); |
| 1036 | } |
| 1037 | |
| 1038 | const SkOpSegment* SkOpSpanBase::debugSegment(int id) const { |
| 1039 | return this->segment()->debugSegment(id); |
| 1040 | } |
| 1041 | |
| 1042 | const SkOpSpanBase* SkOpSpanBase::debugSpan(int id) const { |
| 1043 | return this->segment()->debugSpan(id); |
| 1044 | } |
| 1045 | |
| 1046 | void SkOpSpanBase::dump() const { |
caryclark | 55888e4 | 2016-07-18 10:01:36 -0700 | [diff] [blame] | 1047 | this->dumpHead(); |
| 1048 | this->fPtT.dump(); |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 1049 | } |
| 1050 | |
caryclark | 55888e4 | 2016-07-18 10:01:36 -0700 | [diff] [blame] | 1051 | void SkOpSpanBase::dumpHead() const { |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 1052 | SkDebugf("%.*s", contour()->debugIndent(), " "); |
| 1053 | SkDebugf("seg=%d span=%d", this->segment()->debugID(), this->debugID()); |
| 1054 | this->dumpBase(); |
| 1055 | SkDebugf("\n"); |
caryclark | 55888e4 | 2016-07-18 10:01:36 -0700 | [diff] [blame] | 1056 | } |
| 1057 | |
| 1058 | void SkOpSpanBase::dumpAll() const { |
| 1059 | this->dumpHead(); |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 1060 | this->fPtT.dumpAll(); |
| 1061 | } |
| 1062 | |
| 1063 | void SkOpSpanBase::dumpBase() const { |
| 1064 | if (this->fAligned) { |
| 1065 | SkDebugf(" aligned"); |
| 1066 | } |
| 1067 | if (this->fChased) { |
| 1068 | SkDebugf(" chased"); |
| 1069 | } |
caryclark | 55888e4 | 2016-07-18 10:01:36 -0700 | [diff] [blame] | 1070 | #ifdef SK_DEBUG |
caryclark | 30b9fdd | 2016-08-31 14:36:29 -0700 | [diff] [blame] | 1071 | if (this->fDebugDeleted) { |
caryclark | 55888e4 | 2016-07-18 10:01:36 -0700 | [diff] [blame] | 1072 | SkDebugf(" deleted"); |
| 1073 | } |
| 1074 | #endif |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 1075 | if (!this->final()) { |
| 1076 | this->upCast()->dumpSpan(); |
| 1077 | } |
| 1078 | const SkOpSpanBase* coin = this->coinEnd(); |
| 1079 | if (this != coin) { |
| 1080 | SkDebugf(" coinEnd seg/span=%d/%d", coin->segment()->debugID(), coin->debugID()); |
| 1081 | } else if (this->final() || !this->upCast()->isCoincident()) { |
| 1082 | const SkOpPtT* oPt = this->ptT()->next(); |
| 1083 | SkDebugf(" seg/span=%d/%d", oPt->segment()->debugID(), oPt->span()->debugID()); |
| 1084 | } |
caryclark | 08bc848 | 2015-04-24 09:08:57 -0700 | [diff] [blame] | 1085 | SkDebugf(" adds=%d", fSpanAdds); |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 1086 | } |
| 1087 | |
| 1088 | void SkOpSpanBase::dumpCoin() const { |
| 1089 | const SkOpSpan* span = this->upCastable(); |
| 1090 | if (!span) { |
| 1091 | return; |
| 1092 | } |
| 1093 | if (!span->isCoincident()) { |
| 1094 | return; |
| 1095 | } |
| 1096 | span->dumpCoin(); |
| 1097 | } |
| 1098 | |
| 1099 | void SkOpSpan::dumpCoin() const { |
| 1100 | const SkOpSpan* coincident = fCoincident; |
| 1101 | bool ok = debugCoinLoopCheck(); |
| 1102 | this->dump(); |
| 1103 | int loop = 0; |
| 1104 | do { |
| 1105 | coincident->dump(); |
| 1106 | if (!ok && ++loop > 10) { |
| 1107 | SkDebugf("*** abort loop ***\n"); |
| 1108 | break; |
| 1109 | } |
| 1110 | } while ((coincident = coincident->fCoincident) != this); |
| 1111 | } |
| 1112 | |
| 1113 | bool SkOpSpan::dumpSpan() const { |
| 1114 | SkOpSpan* coin = fCoincident; |
| 1115 | if (this != coin) { |
| 1116 | SkDebugf(" coinStart seg/span=%d/%d", coin->segment()->debugID(), coin->debugID()); |
| 1117 | } |
| 1118 | SkDebugf(" windVal=%d", this->windValue()); |
| 1119 | SkDebugf(" windSum="); |
| 1120 | SkPathOpsDebug::WindingPrintf(this->windSum()); |
| 1121 | if (this->oppValue() != 0 || this->oppSum() != SK_MinS32) { |
| 1122 | SkDebugf(" oppVal=%d", this->oppValue()); |
| 1123 | SkDebugf(" oppSum="); |
| 1124 | SkPathOpsDebug::WindingPrintf(this->oppSum()); |
| 1125 | } |
| 1126 | if (this->done()) { |
| 1127 | SkDebugf(" done"); |
| 1128 | } |
| 1129 | return this != coin; |
| 1130 | } |
| 1131 | |
| 1132 | const SkOpAngle* SkOpSegment::debugAngle(int id) const { |
| 1133 | return this->contour()->debugAngle(id); |
| 1134 | } |
| 1135 | |
caryclark | 55888e4 | 2016-07-18 10:01:36 -0700 | [diff] [blame] | 1136 | |
| 1137 | const SkOpCoincidence* SkOpSegment::debugCoincidence() const { |
| 1138 | return this->contour()->debugCoincidence(); |
| 1139 | } |
| 1140 | |
caryclark | 30b9fdd | 2016-08-31 14:36:29 -0700 | [diff] [blame] | 1141 | SkOpContour* SkOpSegment::debugContour(int id) const { |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 1142 | return this->contour()->debugContour(id); |
| 1143 | } |
| 1144 | |
| 1145 | const SkOpPtT* SkOpSegment::debugPtT(int id) const { |
| 1146 | return this->contour()->debugPtT(id); |
| 1147 | } |
| 1148 | |
| 1149 | const SkOpSegment* SkOpSegment::debugSegment(int id) const { |
| 1150 | return this->contour()->debugSegment(id); |
| 1151 | } |
| 1152 | |
| 1153 | const SkOpSpanBase* SkOpSegment::debugSpan(int id) const { |
| 1154 | return this->contour()->debugSpan(id); |
| 1155 | } |
| 1156 | |
| 1157 | void SkOpSegment::dump() const { |
| 1158 | SkDebugf("%.*s", contour()->debugIndent(), " "); |
| 1159 | this->dumpPts(); |
| 1160 | const SkOpSpanBase* span = &fHead; |
| 1161 | contour()->indentDump(); |
| 1162 | do { |
| 1163 | SkDebugf("%.*s span=%d ", contour()->debugIndent(), " ", span->debugID()); |
| 1164 | span->ptT()->dumpBase(); |
| 1165 | span->dumpBase(); |
| 1166 | SkDebugf("\n"); |
| 1167 | } while (!span->final() && (span = span->upCast()->next())); |
| 1168 | contour()->outdentDump(); |
| 1169 | } |
| 1170 | |
| 1171 | void SkOpSegment::dumpAll() const { |
| 1172 | SkDebugf("%.*s", contour()->debugIndent(), " "); |
| 1173 | this->dumpPts(); |
| 1174 | const SkOpSpanBase* span = &fHead; |
| 1175 | contour()->indentDump(); |
| 1176 | do { |
| 1177 | span->dumpAll(); |
| 1178 | } while (!span->final() && (span = span->upCast()->next())); |
| 1179 | contour()->outdentDump(); |
| 1180 | } |
| 1181 | |
| 1182 | void SkOpSegment::dumpAngles() const { |
| 1183 | SkDebugf("seg=%d\n", debugID()); |
| 1184 | const SkOpSpanBase* span = &fHead; |
| 1185 | do { |
| 1186 | const SkOpAngle* fAngle = span->fromAngle(); |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 1187 | const SkOpAngle* tAngle = span->final() ? nullptr : span->upCast()->toAngle(); |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 1188 | if (fAngle) { |
| 1189 | SkDebugf(" span=%d from=%d ", span->debugID(), fAngle->debugID()); |
| 1190 | fAngle->dumpTo(this, tAngle); |
| 1191 | } |
| 1192 | if (tAngle) { |
| 1193 | SkDebugf(" span=%d to=%d ", span->debugID(), tAngle->debugID()); |
| 1194 | tAngle->dumpTo(this, fAngle); |
| 1195 | } |
| 1196 | } while (!span->final() && (span = span->upCast()->next())); |
| 1197 | } |
| 1198 | |
| 1199 | void SkOpSegment::dumpCoin() const { |
| 1200 | const SkOpSpan* span = &fHead; |
| 1201 | do { |
| 1202 | span->dumpCoin(); |
| 1203 | } while ((span = span->next()->upCastable())); |
| 1204 | } |
| 1205 | |
caryclark | 26ad22a | 2015-10-16 09:03:38 -0700 | [diff] [blame] | 1206 | void SkOpSegment::dumpPtsInner(const char* prefix) const { |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 1207 | int last = SkPathOpsVerbToPoints(fVerb); |
caryclark | 26ad22a | 2015-10-16 09:03:38 -0700 | [diff] [blame] | 1208 | SkDebugf("%s=%d {{", prefix, this->debugID()); |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 1209 | if (fVerb == SkPath::kConic_Verb) { |
| 1210 | SkDebugf("{"); |
| 1211 | } |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 1212 | int index = 0; |
| 1213 | do { |
| 1214 | SkDPoint::Dump(fPts[index]); |
| 1215 | SkDebugf(", "); |
| 1216 | } while (++index < last); |
| 1217 | SkDPoint::Dump(fPts[index]); |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 1218 | SkDebugf("}}"); |
| 1219 | if (fVerb == SkPath::kConic_Verb) { |
| 1220 | SkDebugf(", %1.9gf}", fWeight); |
| 1221 | } |
caryclark | 624637c | 2015-05-11 07:21:27 -0700 | [diff] [blame] | 1222 | } |
| 1223 | |
caryclark | 26ad22a | 2015-10-16 09:03:38 -0700 | [diff] [blame] | 1224 | void SkOpSegment::dumpPts(const char* prefix) const { |
| 1225 | dumpPtsInner(prefix); |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 1226 | SkDebugf("\n"); |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 1227 | } |
| 1228 | |
| 1229 | void SkCoincidentSpans::dump() const { |
| 1230 | SkDebugf("- seg=%d span=%d ptT=%d ", fCoinPtTStart->segment()->debugID(), |
| 1231 | fCoinPtTStart->span()->debugID(), fCoinPtTStart->debugID()); |
| 1232 | fCoinPtTStart->dumpBase(); |
| 1233 | SkDebugf(" span=%d ptT=%d ", fCoinPtTEnd->span()->debugID(), fCoinPtTEnd->debugID()); |
| 1234 | fCoinPtTEnd->dumpBase(); |
| 1235 | if (fCoinPtTStart->segment()->operand()) { |
| 1236 | SkDebugf(" operand"); |
| 1237 | } |
| 1238 | if (fCoinPtTStart->segment()->isXor()) { |
| 1239 | SkDebugf(" xor"); |
| 1240 | } |
| 1241 | SkDebugf("\n"); |
| 1242 | SkDebugf("+ seg=%d span=%d ptT=%d ", fOppPtTStart->segment()->debugID(), |
| 1243 | fOppPtTStart->span()->debugID(), fOppPtTStart->debugID()); |
| 1244 | fOppPtTStart->dumpBase(); |
| 1245 | SkDebugf(" span=%d ptT=%d ", fOppPtTEnd->span()->debugID(), fOppPtTEnd->debugID()); |
| 1246 | fOppPtTEnd->dumpBase(); |
| 1247 | if (fOppPtTStart->segment()->operand()) { |
| 1248 | SkDebugf(" operand"); |
| 1249 | } |
| 1250 | if (fOppPtTStart->segment()->isXor()) { |
| 1251 | SkDebugf(" xor"); |
| 1252 | } |
| 1253 | SkDebugf("\n"); |
| 1254 | } |
| 1255 | |
| 1256 | void SkOpCoincidence::dump() const { |
| 1257 | SkCoincidentSpans* span = fHead; |
| 1258 | while (span) { |
| 1259 | span->dump(); |
caryclark | 55888e4 | 2016-07-18 10:01:36 -0700 | [diff] [blame] | 1260 | span = span->next(); |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 1261 | } |
caryclark | 26ad22a | 2015-10-16 09:03:38 -0700 | [diff] [blame] | 1262 | if (!fTop || fHead == fTop) { |
caryclark | 27c8eb8 | 2015-07-06 11:38:33 -0700 | [diff] [blame] | 1263 | return; |
| 1264 | } |
| 1265 | SkDebugf("top:\n"); |
| 1266 | span = fTop; |
caryclark | 55888e4 | 2016-07-18 10:01:36 -0700 | [diff] [blame] | 1267 | int count = 0; |
caryclark | 27c8eb8 | 2015-07-06 11:38:33 -0700 | [diff] [blame] | 1268 | while (span) { |
| 1269 | span->dump(); |
caryclark | 55888e4 | 2016-07-18 10:01:36 -0700 | [diff] [blame] | 1270 | span = span->next(); |
| 1271 | SkCoincidentSpans* check = fTop; |
| 1272 | ++count; |
| 1273 | for (int index = 0; index < count; ++index) { |
| 1274 | if (span == check) { |
| 1275 | SkDebugf("(loops to #%d)\n", index); |
| 1276 | return; |
| 1277 | } |
| 1278 | check = check->next(); |
| 1279 | } |
caryclark | 27c8eb8 | 2015-07-06 11:38:33 -0700 | [diff] [blame] | 1280 | } |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 1281 | } |
| 1282 | |
caryclark | 624637c | 2015-05-11 07:21:27 -0700 | [diff] [blame] | 1283 | void SkOpContour::dump() const { |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 1284 | SkDebugf("contour=%d count=%d op=%d xor=%d\n", this->debugID(), fCount, fOperand, fXor); |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 1285 | if (!fCount) { |
| 1286 | return; |
| 1287 | } |
| 1288 | const SkOpSegment* segment = &fHead; |
caryclark | 624637c | 2015-05-11 07:21:27 -0700 | [diff] [blame] | 1289 | SkDEBUGCODE(fDebugIndent = 0); |
| 1290 | this->indentDump(); |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 1291 | do { |
| 1292 | segment->dump(); |
| 1293 | } while ((segment = segment->next())); |
caryclark | 624637c | 2015-05-11 07:21:27 -0700 | [diff] [blame] | 1294 | this->outdentDump(); |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 1295 | } |
| 1296 | |
caryclark | 624637c | 2015-05-11 07:21:27 -0700 | [diff] [blame] | 1297 | void SkOpContour::dumpAll() const { |
caryclark | 1049f12 | 2015-04-20 08:31:59 -0700 | [diff] [blame] | 1298 | SkDebugf("contour=%d count=%d op=%d xor=%d\n", this->debugID(), fCount, fOperand, fXor); |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 1299 | if (!fCount) { |
| 1300 | return; |
| 1301 | } |
| 1302 | const SkOpSegment* segment = &fHead; |
caryclark | 624637c | 2015-05-11 07:21:27 -0700 | [diff] [blame] | 1303 | SkDEBUGCODE(fDebugIndent = 0); |
| 1304 | this->indentDump(); |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 1305 | do { |
| 1306 | segment->dumpAll(); |
| 1307 | } while ((segment = segment->next())); |
caryclark | 624637c | 2015-05-11 07:21:27 -0700 | [diff] [blame] | 1308 | this->outdentDump(); |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 1309 | } |
| 1310 | |
| 1311 | |
| 1312 | void SkOpContour::dumpAngles() const { |
| 1313 | SkDebugf("contour=%d\n", this->debugID()); |
| 1314 | const SkOpSegment* segment = &fHead; |
| 1315 | do { |
| 1316 | SkDebugf(" seg=%d ", segment->debugID()); |
| 1317 | segment->dumpAngles(); |
| 1318 | } while ((segment = segment->next())); |
| 1319 | } |
| 1320 | |
| 1321 | void SkOpContour::dumpPt(int index) const { |
| 1322 | const SkOpSegment* segment = &fHead; |
| 1323 | do { |
| 1324 | if (segment->debugID() == index) { |
| 1325 | segment->dumpPts(); |
| 1326 | } |
| 1327 | } while ((segment = segment->next())); |
| 1328 | } |
| 1329 | |
caryclark | 26ad22a | 2015-10-16 09:03:38 -0700 | [diff] [blame] | 1330 | void SkOpContour::dumpPts(const char* prefix) const { |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 1331 | SkDebugf("contour=%d\n", this->debugID()); |
| 1332 | const SkOpSegment* segment = &fHead; |
| 1333 | do { |
caryclark | 26ad22a | 2015-10-16 09:03:38 -0700 | [diff] [blame] | 1334 | SkDebugf(" %s=%d ", prefix, segment->debugID()); |
| 1335 | segment->dumpPts(prefix); |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 1336 | } while ((segment = segment->next())); |
| 1337 | } |
| 1338 | |
caryclark | 26ad22a | 2015-10-16 09:03:38 -0700 | [diff] [blame] | 1339 | void SkOpContour::dumpPtsX(const char* prefix) const { |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 1340 | if (!this->fCount) { |
| 1341 | SkDebugf("<empty>\n"); |
| 1342 | return; |
| 1343 | } |
| 1344 | const SkOpSegment* segment = &fHead; |
| 1345 | do { |
caryclark | 26ad22a | 2015-10-16 09:03:38 -0700 | [diff] [blame] | 1346 | segment->dumpPts(prefix); |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 1347 | } while ((segment = segment->next())); |
| 1348 | } |
| 1349 | |
| 1350 | void SkOpContour::dumpSegment(int index) const { |
| 1351 | debugSegment(index)->dump(); |
| 1352 | } |
| 1353 | |
caryclark | 26ad22a | 2015-10-16 09:03:38 -0700 | [diff] [blame] | 1354 | void SkOpContour::dumpSegments(const char* prefix, SkPathOp op) const { |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 1355 | bool firstOp = false; |
| 1356 | const SkOpContour* c = this; |
| 1357 | do { |
Ben Wagner | 3f98552 | 2017-10-09 10:47:47 -0400 | [diff] [blame] | 1358 | if (!firstOp && c->operand()) { |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 1359 | #if DEBUG_ACTIVE_OP |
| 1360 | SkDebugf("op %s\n", SkPathOpsDebug::kPathOpStr[op]); |
| 1361 | #endif |
| 1362 | firstOp = true; |
| 1363 | } |
caryclark | 26ad22a | 2015-10-16 09:03:38 -0700 | [diff] [blame] | 1364 | c->dumpPtsX(prefix); |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 1365 | } while ((c = c->next())); |
| 1366 | } |
| 1367 | |
| 1368 | void SkOpContour::dumpSpan(int index) const { |
| 1369 | debugSpan(index)->dump(); |
| 1370 | } |
| 1371 | |
| 1372 | void SkOpContour::dumpSpans() const { |
| 1373 | SkDebugf("contour=%d\n", this->debugID()); |
| 1374 | const SkOpSegment* segment = &fHead; |
| 1375 | do { |
| 1376 | SkDebugf(" seg=%d ", segment->debugID()); |
| 1377 | segment->dump(); |
| 1378 | } while ((segment = segment->next())); |
| 1379 | } |
| 1380 | |
caryclark | 03b03ca | 2015-04-23 09:13:37 -0700 | [diff] [blame] | 1381 | void SkOpCurve::dump() const { |
| 1382 | int count = SkPathOpsVerbToPoints(SkDEBUGRELEASE(fVerb, SkPath::kCubic_Verb)); |
| 1383 | SkDebugf("{{"); |
| 1384 | int index; |
| 1385 | for (index = 0; index <= count - 1; ++index) { |
| 1386 | SkDebugf("{%1.9gf,%1.9gf}, ", fPts[index].fX, fPts[index].fY); |
| 1387 | } |
| 1388 | SkDebugf("{%1.9gf,%1.9gf}}}\n", fPts[index].fX, fPts[index].fY); |
| 1389 | } |
| 1390 | |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 1391 | #ifdef SK_DEBUG |
| 1392 | const SkOpAngle* SkOpGlobalState::debugAngle(int id) const { |
caryclark | 624637c | 2015-05-11 07:21:27 -0700 | [diff] [blame] | 1393 | const SkOpContour* contour = fContourHead; |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 1394 | do { |
| 1395 | const SkOpSegment* segment = contour->first(); |
| 1396 | while (segment) { |
| 1397 | const SkOpSpan* span = segment->head(); |
| 1398 | do { |
| 1399 | SkOpAngle* angle = span->fromAngle(); |
| 1400 | if (angle && angle->debugID() == id) { |
| 1401 | return angle; |
| 1402 | } |
| 1403 | angle = span->toAngle(); |
| 1404 | if (angle && angle->debugID() == id) { |
| 1405 | return angle; |
| 1406 | } |
| 1407 | } while ((span = span->next()->upCastable())); |
| 1408 | const SkOpSpanBase* tail = segment->tail(); |
| 1409 | SkOpAngle* angle = tail->fromAngle(); |
| 1410 | if (angle && angle->debugID() == id) { |
| 1411 | return angle; |
| 1412 | } |
| 1413 | segment = segment->next(); |
| 1414 | } |
| 1415 | } while ((contour = contour->next())); |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 1416 | return nullptr; |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 1417 | } |
| 1418 | |
caryclark | 30b9fdd | 2016-08-31 14:36:29 -0700 | [diff] [blame] | 1419 | SkOpContour* SkOpGlobalState::debugContour(int id) const { |
caryclark | 624637c | 2015-05-11 07:21:27 -0700 | [diff] [blame] | 1420 | SkOpContour* contour = fContourHead; |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 1421 | do { |
| 1422 | if (contour->debugID() == id) { |
| 1423 | return contour; |
| 1424 | } |
| 1425 | } while ((contour = contour->next())); |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 1426 | return nullptr; |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 1427 | } |
| 1428 | |
| 1429 | const SkOpPtT* SkOpGlobalState::debugPtT(int id) const { |
caryclark | 624637c | 2015-05-11 07:21:27 -0700 | [diff] [blame] | 1430 | const SkOpContour* contour = fContourHead; |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 1431 | do { |
| 1432 | const SkOpSegment* segment = contour->first(); |
| 1433 | while (segment) { |
| 1434 | const SkOpSpan* span = segment->head(); |
| 1435 | do { |
| 1436 | const SkOpPtT* ptT = span->ptT(); |
| 1437 | if (ptT->debugMatchID(id)) { |
| 1438 | return ptT; |
| 1439 | } |
| 1440 | } while ((span = span->next()->upCastable())); |
| 1441 | const SkOpSpanBase* tail = segment->tail(); |
| 1442 | const SkOpPtT* ptT = tail->ptT(); |
| 1443 | if (ptT->debugMatchID(id)) { |
| 1444 | return ptT; |
| 1445 | } |
| 1446 | segment = segment->next(); |
| 1447 | } |
| 1448 | } while ((contour = contour->next())); |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 1449 | return nullptr; |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 1450 | } |
| 1451 | |
| 1452 | const SkOpSegment* SkOpGlobalState::debugSegment(int id) const { |
caryclark | 624637c | 2015-05-11 07:21:27 -0700 | [diff] [blame] | 1453 | const SkOpContour* contour = fContourHead; |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 1454 | do { |
| 1455 | const SkOpSegment* segment = contour->first(); |
| 1456 | while (segment) { |
| 1457 | if (segment->debugID() == id) { |
| 1458 | return segment; |
| 1459 | } |
| 1460 | segment = segment->next(); |
| 1461 | } |
| 1462 | } while ((contour = contour->next())); |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 1463 | return nullptr; |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 1464 | } |
| 1465 | |
| 1466 | const SkOpSpanBase* SkOpGlobalState::debugSpan(int id) const { |
caryclark | 624637c | 2015-05-11 07:21:27 -0700 | [diff] [blame] | 1467 | const SkOpContour* contour = fContourHead; |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 1468 | do { |
| 1469 | const SkOpSegment* segment = contour->first(); |
| 1470 | while (segment) { |
| 1471 | const SkOpSpan* span = segment->head(); |
| 1472 | do { |
| 1473 | if (span->debugID() == id) { |
| 1474 | return span; |
| 1475 | } |
| 1476 | } while ((span = span->next()->upCastable())); |
| 1477 | const SkOpSpanBase* tail = segment->tail(); |
| 1478 | if (tail->debugID() == id) { |
| 1479 | return tail; |
| 1480 | } |
| 1481 | segment = segment->next(); |
| 1482 | } |
| 1483 | } while ((contour = contour->next())); |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 1484 | return nullptr; |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 1485 | } |
| 1486 | #endif |
| 1487 | |
caryclark | 5435929 | 2015-03-26 07:52:43 -0700 | [diff] [blame] | 1488 | #if DEBUG_T_SECT_DUMP > 1 |
| 1489 | int gDumpTSectNum; |
| 1490 | #endif |
Cary Clark | b8421ed | 2018-03-14 15:55:02 -0400 | [diff] [blame] | 1491 | |
| 1492 | // global path dumps for msvs Visual Studio 17 to use from Immediate Window |
| 1493 | namespace SkOpDebug { |
| 1494 | |
| 1495 | void Dump(const SkOpContour& contour) { |
| 1496 | contour.dump(); |
| 1497 | } |
| 1498 | |
| 1499 | void DumpAll(const SkOpContour& contour) { |
| 1500 | contour.dumpAll(); |
| 1501 | } |
| 1502 | |
| 1503 | void DumpAngles(const SkOpContour& contour) { |
| 1504 | contour.dumpAngles(); |
| 1505 | } |
| 1506 | |
| 1507 | void DumpContours(const SkOpContour& contour) { |
| 1508 | contour.dumpContours(); |
| 1509 | } |
| 1510 | |
| 1511 | void DumpContoursAll(const SkOpContour& contour) { |
| 1512 | contour.dumpContoursAll(); |
| 1513 | } |
| 1514 | |
| 1515 | void DumpContoursAngles(const SkOpContour& contour) { |
| 1516 | contour.dumpContoursAngles(); |
| 1517 | } |
| 1518 | |
| 1519 | void DumpContoursPts(const SkOpContour& contour) { |
| 1520 | contour.dumpContoursPts(); |
| 1521 | } |
| 1522 | |
| 1523 | void DumpContoursPt(const SkOpContour& contour, int segmentID) { |
| 1524 | contour.dumpContoursPt(segmentID); |
| 1525 | } |
| 1526 | |
| 1527 | void DumpContoursSegment(const SkOpContour& contour, int segmentID) { |
| 1528 | contour.dumpContoursSegment(segmentID); |
| 1529 | } |
| 1530 | |
| 1531 | void DumpContoursSpan(const SkOpContour& contour, int segmentID) { |
| 1532 | contour.dumpContoursSpan(segmentID); |
| 1533 | } |
| 1534 | |
| 1535 | void DumpContoursSpans(const SkOpContour& contour) { |
| 1536 | contour.dumpContoursSpans(); |
| 1537 | } |
| 1538 | |
| 1539 | void DumpPt(const SkOpContour& contour, int pt) { |
| 1540 | contour.dumpPt(pt); |
| 1541 | } |
| 1542 | |
| 1543 | void DumpPts(const SkOpContour& contour, const char* prefix) { |
| 1544 | contour.dumpPts(prefix); |
| 1545 | } |
| 1546 | |
| 1547 | void DumpSegment(const SkOpContour& contour, int seg) { |
| 1548 | contour.dumpSegment(seg); |
| 1549 | } |
| 1550 | |
| 1551 | void DumpSegments(const SkOpContour& contour, const char* prefix, SkPathOp op) { |
| 1552 | contour.dumpSegments(prefix, op); |
| 1553 | } |
| 1554 | |
| 1555 | void DumpSpan(const SkOpContour& contour, int span) { |
| 1556 | contour.dumpSpan(span); |
| 1557 | } |
| 1558 | |
| 1559 | void DumpSpans(const SkOpContour& contour ) { |
| 1560 | contour.dumpSpans(); |
| 1561 | } |
| 1562 | |
| 1563 | void Dump(const SkOpSegment& segment) { |
| 1564 | segment.dump(); |
| 1565 | } |
| 1566 | |
| 1567 | void DumpAll(const SkOpSegment& segment) { |
| 1568 | segment.dumpAll(); |
| 1569 | } |
| 1570 | |
| 1571 | void DumpAngles(const SkOpSegment& segment) { |
| 1572 | segment.dumpAngles(); |
| 1573 | } |
| 1574 | |
| 1575 | void DumpCoin(const SkOpSegment& segment) { |
| 1576 | segment.dumpCoin(); |
| 1577 | } |
| 1578 | |
| 1579 | void DumpPts(const SkOpSegment& segment, const char* prefix) { |
| 1580 | segment.dumpPts(prefix); |
| 1581 | } |
| 1582 | |
| 1583 | void Dump(const SkOpPtT& ptT) { |
| 1584 | ptT.dump(); |
| 1585 | } |
| 1586 | |
| 1587 | void DumpAll(const SkOpPtT& ptT) { |
| 1588 | ptT.dumpAll(); |
| 1589 | } |
| 1590 | |
| 1591 | void Dump(const SkOpSpanBase& spanBase) { |
| 1592 | spanBase.dump(); |
| 1593 | } |
| 1594 | |
| 1595 | void DumpCoin(const SkOpSpanBase& spanBase) { |
| 1596 | spanBase.dumpCoin(); |
| 1597 | } |
| 1598 | |
| 1599 | void DumpAll(const SkOpSpanBase& spanBase) { |
| 1600 | spanBase.dumpAll(); |
| 1601 | } |
| 1602 | |
| 1603 | void DumpCoin(const SkOpSpan& span) { |
| 1604 | span.dumpCoin(); |
| 1605 | } |
| 1606 | |
| 1607 | bool DumpSpan(const SkOpSpan& span) { |
| 1608 | return span.dumpSpan(); |
| 1609 | } |
| 1610 | |
| 1611 | void Dump(const SkDConic& conic) { |
| 1612 | conic.dump(); |
| 1613 | } |
| 1614 | |
| 1615 | void DumpID(const SkDConic& conic, int id) { |
| 1616 | conic.dumpID(id); |
| 1617 | } |
| 1618 | |
| 1619 | void Dump(const SkDCubic& cubic) { |
| 1620 | cubic.dump(); |
| 1621 | } |
| 1622 | |
| 1623 | void DumpID(const SkDCubic& cubic, int id) { |
| 1624 | cubic.dumpID(id); |
| 1625 | } |
| 1626 | |
| 1627 | void Dump(const SkDLine& line) { |
| 1628 | line.dump(); |
| 1629 | } |
| 1630 | |
| 1631 | void DumpID(const SkDLine& line, int id) { |
| 1632 | line.dumpID(id); |
| 1633 | } |
| 1634 | |
| 1635 | void Dump(const SkDQuad& quad) { |
| 1636 | quad.dump(); |
| 1637 | } |
| 1638 | |
| 1639 | void DumpID(const SkDQuad& quad, int id) { |
| 1640 | quad.dumpID(id); |
| 1641 | } |
| 1642 | |
| 1643 | void Dump(const SkDPoint& point) { |
| 1644 | point.dump(); |
| 1645 | } |
| 1646 | |
Cary Clark | 1857ddb | 2018-07-11 11:01:43 -0400 | [diff] [blame] | 1647 | void Dump(const SkOpAngle& angle) { |
| 1648 | angle.dump(); |
| 1649 | } |
| 1650 | |
Cary Clark | b8421ed | 2018-03-14 15:55:02 -0400 | [diff] [blame] | 1651 | // dummy definitions to fool msvs Visual Studio 2018 Immediate Window |
| 1652 | #define DummyDefinitions(a, b) \ |
| 1653 | \ |
| 1654 | void Dump(const SkDebugTCoincident##a##b& curve) { \ |
| 1655 | ((const SkTCoincident<SkD##a, SkD##b>& ) curve).dump(); \ |
| 1656 | } \ |
| 1657 | \ |
| 1658 | void Dump(const SkDebugTSect##a##b& curve) { \ |
| 1659 | ((const SkTSect<SkD##a, SkD##b>& ) curve).dump(); \ |
| 1660 | } \ |
| 1661 | \ |
| 1662 | void DumpBoth(const SkDebugTSect##a##b& curve, SkDebugTSect##a##b* opp) { \ |
| 1663 | ((const SkTSect<SkD##a, SkD##b>& ) curve).dumpBoth((SkTSect<SkD##b, SkD##a>* ) opp); \ |
| 1664 | } \ |
| 1665 | \ |
| 1666 | void DumpBounded(const SkDebugTSect##a##b& curve, int id) { \ |
| 1667 | ((const SkTSect<SkD##a, SkD##b>& ) curve).dumpBounded(id); \ |
| 1668 | } \ |
| 1669 | \ |
| 1670 | void DumpBounds(const SkDebugTSect##a##b& curve) { \ |
| 1671 | ((const SkTSect<SkD##a, SkD##b>& ) curve).dumpBounds(); \ |
| 1672 | } \ |
| 1673 | \ |
| 1674 | void DumpCoin(const SkDebugTSect##a##b& curve) { \ |
| 1675 | ((const SkTSect<SkD##a, SkD##b>& ) curve).dumpCoin(); \ |
| 1676 | } \ |
| 1677 | \ |
| 1678 | void DumpCoinCurves(const SkDebugTSect##a##b& curve) { \ |
| 1679 | ((const SkTSect<SkD##a, SkD##b>& ) curve).dumpCoinCurves(); \ |
| 1680 | } \ |
| 1681 | \ |
| 1682 | void DumpCurves(const SkDebugTSect##a##b& curve) { \ |
| 1683 | ((const SkTSect<SkD##a, SkD##b>& ) curve).dumpCurves(); \ |
| 1684 | } \ |
| 1685 | \ |
| 1686 | void Dump(const SkDebugTSpan##a##b& curve) { \ |
| 1687 | ((const SkTSpan<SkD##a, SkD##b>& ) curve).dump(); \ |
| 1688 | } \ |
| 1689 | \ |
| 1690 | void DumpAll(const SkDebugTSpan##a##b& curve) { \ |
| 1691 | ((const SkTSpan<SkD##a, SkD##b>& ) curve).dumpAll(); \ |
| 1692 | } \ |
| 1693 | \ |
| 1694 | void DumpBounded(const SkDebugTSpan##a##b& curve, int id) { \ |
| 1695 | ((const SkTSpan<SkD##a, SkD##b>& ) curve).dumpBounded(id); \ |
| 1696 | } \ |
| 1697 | \ |
| 1698 | void DumpBounds(const SkDebugTSpan##a##b& curve) { \ |
| 1699 | ((const SkTSpan<SkD##a, SkD##b>& ) curve).dumpBounds(); \ |
| 1700 | } \ |
| 1701 | \ |
| 1702 | void DumpCoin(const SkDebugTSpan##a##b& curve) { \ |
| 1703 | ((const SkTSpan<SkD##a, SkD##b>& ) curve).dumpCoin(); \ |
| 1704 | } |
| 1705 | |
| 1706 | DummyDefinitions(Quad, Quad); |
| 1707 | DummyDefinitions(Conic, Quad); |
| 1708 | DummyDefinitions(Conic, Conic); |
| 1709 | DummyDefinitions(Cubic, Quad); |
| 1710 | DummyDefinitions(Cubic, Conic); |
| 1711 | DummyDefinitions(Cubic, Cubic); |
| 1712 | |
| 1713 | #undef DummyDefinitions |
| 1714 | } |