gfx/skia/trunk/src/pathops/SkAddIntersections.cpp

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 /*
michael@0 2 * Copyright 2012 Google Inc.
michael@0 3 *
michael@0 4 * Use of this source code is governed by a BSD-style license that can be
michael@0 5 * found in the LICENSE file.
michael@0 6 */
michael@0 7 #include "SkAddIntersections.h"
michael@0 8 #include "SkPathOpsBounds.h"
michael@0 9
michael@0 10 #if DEBUG_ADD_INTERSECTING_TS
michael@0 11
michael@0 12 static void debugShowLineIntersection(int pts, const SkIntersectionHelper& wt,
michael@0 13 const SkIntersectionHelper& wn, const SkIntersections& i) {
michael@0 14 SkASSERT(i.used() == pts);
michael@0 15 if (!pts) {
michael@0 16 SkDebugf("%s no intersect " LINE_DEBUG_STR " " LINE_DEBUG_STR "\n",
michael@0 17 __FUNCTION__, LINE_DEBUG_DATA(wt.pts()), LINE_DEBUG_DATA(wn.pts()));
michael@0 18 return;
michael@0 19 }
michael@0 20 SkDebugf("%s " T_DEBUG_STR(wtTs, 0) " " LINE_DEBUG_STR " " PT_DEBUG_STR, __FUNCTION__,
michael@0 21 i[0][0], LINE_DEBUG_DATA(wt.pts()), PT_DEBUG_DATA(i, 0));
michael@0 22 if (pts == 2) {
michael@0 23 SkDebugf(" " T_DEBUG_STR(wtTs, 1) " " PT_DEBUG_STR, i[0][1], PT_DEBUG_DATA(i, 1));
michael@0 24 }
michael@0 25 SkDebugf(" wnTs[0]=%g " LINE_DEBUG_STR, i[1][0], LINE_DEBUG_DATA(wn.pts()));
michael@0 26 if (pts == 2) {
michael@0 27 SkDebugf(" " T_DEBUG_STR(wnTs, 1), i[1][1]);
michael@0 28 }
michael@0 29 SkDebugf("\n");
michael@0 30 }
michael@0 31
michael@0 32 static void debugShowQuadLineIntersection(int pts, const SkIntersectionHelper& wt,
michael@0 33 const SkIntersectionHelper& wn,
michael@0 34 const SkIntersections& i) {
michael@0 35 SkASSERT(i.used() == pts);
michael@0 36 if (!pts) {
michael@0 37 SkDebugf("%s no intersect " QUAD_DEBUG_STR " " LINE_DEBUG_STR "\n",
michael@0 38 __FUNCTION__, QUAD_DEBUG_DATA(wt.pts()), LINE_DEBUG_DATA(wn.pts()));
michael@0 39 return;
michael@0 40 }
michael@0 41 SkDebugf("%s " T_DEBUG_STR(wtTs, 0) " " QUAD_DEBUG_STR " " PT_DEBUG_STR, __FUNCTION__,
michael@0 42 i[0][0], QUAD_DEBUG_DATA(wt.pts()), PT_DEBUG_DATA(i, 0));
michael@0 43 for (int n = 1; n < pts; ++n) {
michael@0 44 SkDebugf(" " TX_DEBUG_STR(wtTs) " " PT_DEBUG_STR, n, i[0][n], PT_DEBUG_DATA(i, n));
michael@0 45 }
michael@0 46 SkDebugf(" wnTs[0]=%g " LINE_DEBUG_STR, i[1][0], LINE_DEBUG_DATA(wn.pts()));
michael@0 47 for (int n = 1; n < pts; ++n) {
michael@0 48 SkDebugf(" " TX_DEBUG_STR(wnTs), n, i[1][n]);
michael@0 49 }
michael@0 50 SkDebugf("\n");
michael@0 51 }
michael@0 52
michael@0 53 static void debugShowQuadIntersection(int pts, const SkIntersectionHelper& wt,
michael@0 54 const SkIntersectionHelper& wn, const SkIntersections& i) {
michael@0 55 SkASSERT(i.used() == pts);
michael@0 56 if (!pts) {
michael@0 57 SkDebugf("%s no intersect " QUAD_DEBUG_STR " " QUAD_DEBUG_STR "\n",
michael@0 58 __FUNCTION__, QUAD_DEBUG_DATA(wt.pts()), QUAD_DEBUG_DATA(wn.pts()));
michael@0 59 return;
michael@0 60 }
michael@0 61 SkDebugf("%s " T_DEBUG_STR(wtTs, 0) " " QUAD_DEBUG_STR " " PT_DEBUG_STR, __FUNCTION__,
michael@0 62 i[0][0], QUAD_DEBUG_DATA(wt.pts()), PT_DEBUG_DATA(i, 0));
michael@0 63 for (int n = 1; n < pts; ++n) {
michael@0 64 SkDebugf(" " TX_DEBUG_STR(wtTs) " " PT_DEBUG_STR, n, i[0][n], PT_DEBUG_DATA(i, n));
michael@0 65 }
michael@0 66 SkDebugf(" wnTs[0]=%g " QUAD_DEBUG_STR, i[1][0], QUAD_DEBUG_DATA(wn.pts()));
michael@0 67 for (int n = 1; n < pts; ++n) {
michael@0 68 SkDebugf(" " TX_DEBUG_STR(wnTs), n, i[1][n]);
michael@0 69 }
michael@0 70 SkDebugf("\n");
michael@0 71 }
michael@0 72
michael@0 73 static void debugShowCubicLineIntersection(int pts, const SkIntersectionHelper& wt,
michael@0 74 const SkIntersectionHelper& wn, const SkIntersections& i) {
michael@0 75 SkASSERT(i.used() == pts);
michael@0 76 if (!pts) {
michael@0 77 SkDebugf("%s no intersect " CUBIC_DEBUG_STR " " LINE_DEBUG_STR "\n",
michael@0 78 __FUNCTION__, CUBIC_DEBUG_DATA(wt.pts()), LINE_DEBUG_DATA(wn.pts()));
michael@0 79 return;
michael@0 80 }
michael@0 81 SkDebugf("%s " T_DEBUG_STR(wtTs, 0) " " CUBIC_DEBUG_STR " " PT_DEBUG_STR, __FUNCTION__,
michael@0 82 i[0][0], CUBIC_DEBUG_DATA(wt.pts()), PT_DEBUG_DATA(i, 0));
michael@0 83 for (int n = 1; n < pts; ++n) {
michael@0 84 SkDebugf(" " TX_DEBUG_STR(wtTs) " " PT_DEBUG_STR, n, i[0][n], PT_DEBUG_DATA(i, n));
michael@0 85 }
michael@0 86 SkDebugf(" wnTs[0]=%g " LINE_DEBUG_STR, i[1][0], LINE_DEBUG_DATA(wn.pts()));
michael@0 87 for (int n = 1; n < pts; ++n) {
michael@0 88 SkDebugf(" " TX_DEBUG_STR(wnTs), n, i[1][n]);
michael@0 89 }
michael@0 90 SkDebugf("\n");
michael@0 91 }
michael@0 92
michael@0 93 static void debugShowCubicQuadIntersection(int pts, const SkIntersectionHelper& wt,
michael@0 94 const SkIntersectionHelper& wn, const SkIntersections& i) {
michael@0 95 SkASSERT(i.used() == pts);
michael@0 96 if (!pts) {
michael@0 97 SkDebugf("%s no intersect " CUBIC_DEBUG_STR " " QUAD_DEBUG_STR "\n",
michael@0 98 __FUNCTION__, CUBIC_DEBUG_DATA(wt.pts()), QUAD_DEBUG_DATA(wn.pts()));
michael@0 99 return;
michael@0 100 }
michael@0 101 SkDebugf("%s " T_DEBUG_STR(wtTs, 0) " " CUBIC_DEBUG_STR " " PT_DEBUG_STR, __FUNCTION__,
michael@0 102 i[0][0], CUBIC_DEBUG_DATA(wt.pts()), PT_DEBUG_DATA(i, 0));
michael@0 103 for (int n = 1; n < pts; ++n) {
michael@0 104 SkDebugf(" " TX_DEBUG_STR(wtTs) " " PT_DEBUG_STR, n, i[0][n], PT_DEBUG_DATA(i, n));
michael@0 105 }
michael@0 106 SkDebugf(" wnTs[0]=%g " QUAD_DEBUG_STR, i[1][0], QUAD_DEBUG_DATA(wn.pts()));
michael@0 107 for (int n = 1; n < pts; ++n) {
michael@0 108 SkDebugf(" " TX_DEBUG_STR(wnTs), n, i[1][n]);
michael@0 109 }
michael@0 110 SkDebugf("\n");
michael@0 111 }
michael@0 112
michael@0 113 static void debugShowCubicIntersection(int pts, const SkIntersectionHelper& wt,
michael@0 114 const SkIntersectionHelper& wn, const SkIntersections& i) {
michael@0 115 SkASSERT(i.used() == pts);
michael@0 116 if (!pts) {
michael@0 117 SkDebugf("%s no intersect " CUBIC_DEBUG_STR " " CUBIC_DEBUG_STR "\n",
michael@0 118 __FUNCTION__, CUBIC_DEBUG_DATA(wt.pts()), CUBIC_DEBUG_DATA(wn.pts()));
michael@0 119 return;
michael@0 120 }
michael@0 121 SkDebugf("%s " T_DEBUG_STR(wtTs, 0) " " CUBIC_DEBUG_STR " " PT_DEBUG_STR, __FUNCTION__,
michael@0 122 i[0][0], CUBIC_DEBUG_DATA(wt.pts()), PT_DEBUG_DATA(i, 0));
michael@0 123 for (int n = 1; n < pts; ++n) {
michael@0 124 SkDebugf(" " TX_DEBUG_STR(wtTs) " " PT_DEBUG_STR, n, i[0][n], PT_DEBUG_DATA(i, n));
michael@0 125 }
michael@0 126 SkDebugf(" wnTs[0]=%g " CUBIC_DEBUG_STR, i[1][0], CUBIC_DEBUG_DATA(wn.pts()));
michael@0 127 for (int n = 1; n < pts; ++n) {
michael@0 128 SkDebugf(" " TX_DEBUG_STR(wnTs), n, i[1][n]);
michael@0 129 }
michael@0 130 SkDebugf("\n");
michael@0 131 }
michael@0 132
michael@0 133 static void debugShowCubicIntersection(int pts, const SkIntersectionHelper& wt,
michael@0 134 const SkIntersections& i) {
michael@0 135 SkASSERT(i.used() == pts);
michael@0 136 if (!pts) {
michael@0 137 SkDebugf("%s no self intersect " CUBIC_DEBUG_STR "\n", __FUNCTION__,
michael@0 138 CUBIC_DEBUG_DATA(wt.pts()));
michael@0 139 return;
michael@0 140 }
michael@0 141 SkDebugf("%s " T_DEBUG_STR(wtTs, 0) " " CUBIC_DEBUG_STR " " PT_DEBUG_STR, __FUNCTION__,
michael@0 142 i[0][0], CUBIC_DEBUG_DATA(wt.pts()), PT_DEBUG_DATA(i, 0));
michael@0 143 SkDebugf(" " T_DEBUG_STR(wtTs, 1), i[1][0]);
michael@0 144 SkDebugf("\n");
michael@0 145 }
michael@0 146
michael@0 147 #else
michael@0 148 static void debugShowLineIntersection(int , const SkIntersectionHelper& ,
michael@0 149 const SkIntersectionHelper& , const SkIntersections& ) {
michael@0 150 }
michael@0 151
michael@0 152 static void debugShowQuadLineIntersection(int , const SkIntersectionHelper& ,
michael@0 153 const SkIntersectionHelper& , const SkIntersections& ) {
michael@0 154 }
michael@0 155
michael@0 156 static void debugShowQuadIntersection(int , const SkIntersectionHelper& ,
michael@0 157 const SkIntersectionHelper& , const SkIntersections& ) {
michael@0 158 }
michael@0 159
michael@0 160 static void debugShowCubicLineIntersection(int , const SkIntersectionHelper& ,
michael@0 161 const SkIntersectionHelper& , const SkIntersections& ) {
michael@0 162 }
michael@0 163
michael@0 164 static void debugShowCubicQuadIntersection(int , const SkIntersectionHelper& ,
michael@0 165 const SkIntersectionHelper& , const SkIntersections& ) {
michael@0 166 }
michael@0 167
michael@0 168 static void debugShowCubicIntersection(int , const SkIntersectionHelper& ,
michael@0 169 const SkIntersectionHelper& , const SkIntersections& ) {
michael@0 170 }
michael@0 171
michael@0 172 static void debugShowCubicIntersection(int , const SkIntersectionHelper& ,
michael@0 173 const SkIntersections& ) {
michael@0 174 }
michael@0 175 #endif
michael@0 176
michael@0 177 bool AddIntersectTs(SkOpContour* test, SkOpContour* next) {
michael@0 178 if (test != next) {
michael@0 179 if (AlmostLessUlps(test->bounds().fBottom, next->bounds().fTop)) {
michael@0 180 return false;
michael@0 181 }
michael@0 182 // OPTIMIZATION: outset contour bounds a smidgen instead?
michael@0 183 if (!SkPathOpsBounds::Intersects(test->bounds(), next->bounds())) {
michael@0 184 return true;
michael@0 185 }
michael@0 186 }
michael@0 187 SkIntersectionHelper wt;
michael@0 188 wt.init(test);
michael@0 189 bool foundCommonContour = test == next;
michael@0 190 do {
michael@0 191 SkIntersectionHelper wn;
michael@0 192 wn.init(next);
michael@0 193 if (test == next && !wn.startAfter(wt)) {
michael@0 194 continue;
michael@0 195 }
michael@0 196 do {
michael@0 197 if (!SkPathOpsBounds::Intersects(wt.bounds(), wn.bounds())) {
michael@0 198 continue;
michael@0 199 }
michael@0 200 int pts = 0;
michael@0 201 SkIntersections ts;
michael@0 202 bool swap = false;
michael@0 203 switch (wt.segmentType()) {
michael@0 204 case SkIntersectionHelper::kHorizontalLine_Segment:
michael@0 205 swap = true;
michael@0 206 switch (wn.segmentType()) {
michael@0 207 case SkIntersectionHelper::kHorizontalLine_Segment:
michael@0 208 case SkIntersectionHelper::kVerticalLine_Segment:
michael@0 209 case SkIntersectionHelper::kLine_Segment: {
michael@0 210 pts = ts.lineHorizontal(wn.pts(), wt.left(),
michael@0 211 wt.right(), wt.y(), wt.xFlipped());
michael@0 212 debugShowLineIntersection(pts, wn, wt, ts);
michael@0 213 break;
michael@0 214 }
michael@0 215 case SkIntersectionHelper::kQuad_Segment: {
michael@0 216 pts = ts.quadHorizontal(wn.pts(), wt.left(),
michael@0 217 wt.right(), wt.y(), wt.xFlipped());
michael@0 218 debugShowQuadLineIntersection(pts, wn, wt, ts);
michael@0 219 break;
michael@0 220 }
michael@0 221 case SkIntersectionHelper::kCubic_Segment: {
michael@0 222 pts = ts.cubicHorizontal(wn.pts(), wt.left(),
michael@0 223 wt.right(), wt.y(), wt.xFlipped());
michael@0 224 debugShowCubicLineIntersection(pts, wn, wt, ts);
michael@0 225 break;
michael@0 226 }
michael@0 227 default:
michael@0 228 SkASSERT(0);
michael@0 229 }
michael@0 230 break;
michael@0 231 case SkIntersectionHelper::kVerticalLine_Segment:
michael@0 232 swap = true;
michael@0 233 switch (wn.segmentType()) {
michael@0 234 case SkIntersectionHelper::kHorizontalLine_Segment:
michael@0 235 case SkIntersectionHelper::kVerticalLine_Segment:
michael@0 236 case SkIntersectionHelper::kLine_Segment: {
michael@0 237 pts = ts.lineVertical(wn.pts(), wt.top(),
michael@0 238 wt.bottom(), wt.x(), wt.yFlipped());
michael@0 239 debugShowLineIntersection(pts, wn, wt, ts);
michael@0 240 break;
michael@0 241 }
michael@0 242 case SkIntersectionHelper::kQuad_Segment: {
michael@0 243 pts = ts.quadVertical(wn.pts(), wt.top(),
michael@0 244 wt.bottom(), wt.x(), wt.yFlipped());
michael@0 245 debugShowQuadLineIntersection(pts, wn, wt, ts);
michael@0 246 break;
michael@0 247 }
michael@0 248 case SkIntersectionHelper::kCubic_Segment: {
michael@0 249 pts = ts.cubicVertical(wn.pts(), wt.top(),
michael@0 250 wt.bottom(), wt.x(), wt.yFlipped());
michael@0 251 debugShowCubicLineIntersection(pts, wn, wt, ts);
michael@0 252 break;
michael@0 253 }
michael@0 254 default:
michael@0 255 SkASSERT(0);
michael@0 256 }
michael@0 257 break;
michael@0 258 case SkIntersectionHelper::kLine_Segment:
michael@0 259 switch (wn.segmentType()) {
michael@0 260 case SkIntersectionHelper::kHorizontalLine_Segment:
michael@0 261 pts = ts.lineHorizontal(wt.pts(), wn.left(),
michael@0 262 wn.right(), wn.y(), wn.xFlipped());
michael@0 263 debugShowLineIntersection(pts, wt, wn, ts);
michael@0 264 break;
michael@0 265 case SkIntersectionHelper::kVerticalLine_Segment:
michael@0 266 pts = ts.lineVertical(wt.pts(), wn.top(),
michael@0 267 wn.bottom(), wn.x(), wn.yFlipped());
michael@0 268 debugShowLineIntersection(pts, wt, wn, ts);
michael@0 269 break;
michael@0 270 case SkIntersectionHelper::kLine_Segment: {
michael@0 271 pts = ts.lineLine(wt.pts(), wn.pts());
michael@0 272 debugShowLineIntersection(pts, wt, wn, ts);
michael@0 273 break;
michael@0 274 }
michael@0 275 case SkIntersectionHelper::kQuad_Segment: {
michael@0 276 swap = true;
michael@0 277 pts = ts.quadLine(wn.pts(), wt.pts());
michael@0 278 debugShowQuadLineIntersection(pts, wn, wt, ts);
michael@0 279 break;
michael@0 280 }
michael@0 281 case SkIntersectionHelper::kCubic_Segment: {
michael@0 282 swap = true;
michael@0 283 pts = ts.cubicLine(wn.pts(), wt.pts());
michael@0 284 debugShowCubicLineIntersection(pts, wn, wt, ts);
michael@0 285 break;
michael@0 286 }
michael@0 287 default:
michael@0 288 SkASSERT(0);
michael@0 289 }
michael@0 290 break;
michael@0 291 case SkIntersectionHelper::kQuad_Segment:
michael@0 292 switch (wn.segmentType()) {
michael@0 293 case SkIntersectionHelper::kHorizontalLine_Segment:
michael@0 294 pts = ts.quadHorizontal(wt.pts(), wn.left(),
michael@0 295 wn.right(), wn.y(), wn.xFlipped());
michael@0 296 debugShowQuadLineIntersection(pts, wt, wn, ts);
michael@0 297 break;
michael@0 298 case SkIntersectionHelper::kVerticalLine_Segment:
michael@0 299 pts = ts.quadVertical(wt.pts(), wn.top(),
michael@0 300 wn.bottom(), wn.x(), wn.yFlipped());
michael@0 301 debugShowQuadLineIntersection(pts, wt, wn, ts);
michael@0 302 break;
michael@0 303 case SkIntersectionHelper::kLine_Segment: {
michael@0 304 pts = ts.quadLine(wt.pts(), wn.pts());
michael@0 305 debugShowQuadLineIntersection(pts, wt, wn, ts);
michael@0 306 break;
michael@0 307 }
michael@0 308 case SkIntersectionHelper::kQuad_Segment: {
michael@0 309 pts = ts.quadQuad(wt.pts(), wn.pts());
michael@0 310 debugShowQuadIntersection(pts, wt, wn, ts);
michael@0 311 break;
michael@0 312 }
michael@0 313 case SkIntersectionHelper::kCubic_Segment: {
michael@0 314 swap = true;
michael@0 315 pts = ts.cubicQuad(wn.pts(), wt.pts());
michael@0 316 debugShowCubicQuadIntersection(pts, wn, wt, ts);
michael@0 317 break;
michael@0 318 }
michael@0 319 default:
michael@0 320 SkASSERT(0);
michael@0 321 }
michael@0 322 break;
michael@0 323 case SkIntersectionHelper::kCubic_Segment:
michael@0 324 switch (wn.segmentType()) {
michael@0 325 case SkIntersectionHelper::kHorizontalLine_Segment:
michael@0 326 pts = ts.cubicHorizontal(wt.pts(), wn.left(),
michael@0 327 wn.right(), wn.y(), wn.xFlipped());
michael@0 328 debugShowCubicLineIntersection(pts, wt, wn, ts);
michael@0 329 break;
michael@0 330 case SkIntersectionHelper::kVerticalLine_Segment:
michael@0 331 pts = ts.cubicVertical(wt.pts(), wn.top(),
michael@0 332 wn.bottom(), wn.x(), wn.yFlipped());
michael@0 333 debugShowCubicLineIntersection(pts, wt, wn, ts);
michael@0 334 break;
michael@0 335 case SkIntersectionHelper::kLine_Segment: {
michael@0 336 pts = ts.cubicLine(wt.pts(), wn.pts());
michael@0 337 debugShowCubicLineIntersection(pts, wt, wn, ts);
michael@0 338 break;
michael@0 339 }
michael@0 340 case SkIntersectionHelper::kQuad_Segment: {
michael@0 341 pts = ts.cubicQuad(wt.pts(), wn.pts());
michael@0 342 debugShowCubicQuadIntersection(pts, wt, wn, ts);
michael@0 343 break;
michael@0 344 }
michael@0 345 case SkIntersectionHelper::kCubic_Segment: {
michael@0 346 pts = ts.cubicCubic(wt.pts(), wn.pts());
michael@0 347 debugShowCubicIntersection(pts, wt, wn, ts);
michael@0 348 break;
michael@0 349 }
michael@0 350 default:
michael@0 351 SkASSERT(0);
michael@0 352 }
michael@0 353 break;
michael@0 354 default:
michael@0 355 SkASSERT(0);
michael@0 356 }
michael@0 357 if (!foundCommonContour && pts > 0) {
michael@0 358 test->addCross(next);
michael@0 359 next->addCross(test);
michael@0 360 foundCommonContour = true;
michael@0 361 }
michael@0 362 // in addition to recording T values, record matching segment
michael@0 363 if (pts == 2) {
michael@0 364 if (wn.segmentType() <= SkIntersectionHelper::kLine_Segment
michael@0 365 && wt.segmentType() <= SkIntersectionHelper::kLine_Segment) {
michael@0 366 if (wt.addCoincident(wn, ts, swap)) {
michael@0 367 continue;
michael@0 368 }
michael@0 369 ts.cleanUpCoincidence(); // prefer (t == 0 or t == 1)
michael@0 370 pts = 1;
michael@0 371 } else if (wn.segmentType() >= SkIntersectionHelper::kQuad_Segment
michael@0 372 && wt.segmentType() >= SkIntersectionHelper::kQuad_Segment
michael@0 373 && ts.isCoincident(0)) {
michael@0 374 SkASSERT(ts.coincidentUsed() == 2);
michael@0 375 if (wt.addCoincident(wn, ts, swap)) {
michael@0 376 continue;
michael@0 377 }
michael@0 378 ts.cleanUpCoincidence(); // prefer (t == 0 or t == 1)
michael@0 379 pts = 1;
michael@0 380 }
michael@0 381 }
michael@0 382 if (pts >= 2) {
michael@0 383 for (int pt = 0; pt < pts - 1; ++pt) {
michael@0 384 const SkDPoint& point = ts.pt(pt);
michael@0 385 const SkDPoint& next = ts.pt(pt + 1);
michael@0 386 if (wt.isPartial(ts[swap][pt], ts[swap][pt + 1], point, next)
michael@0 387 && wn.isPartial(ts[!swap][pt], ts[!swap][pt + 1], point, next)) {
michael@0 388 if (!wt.addPartialCoincident(wn, ts, pt, swap)) {
michael@0 389 // remove extra point if two map to same float values
michael@0 390 ts.cleanUpCoincidence(); // prefer (t == 0 or t == 1)
michael@0 391 pts = 1;
michael@0 392 }
michael@0 393 }
michael@0 394 }
michael@0 395 }
michael@0 396 for (int pt = 0; pt < pts; ++pt) {
michael@0 397 SkASSERT(ts[0][pt] >= 0 && ts[0][pt] <= 1);
michael@0 398 SkASSERT(ts[1][pt] >= 0 && ts[1][pt] <= 1);
michael@0 399 SkPoint point = ts.pt(pt).asSkPoint();
michael@0 400 int testTAt = wt.addT(wn, point, ts[swap][pt]);
michael@0 401 int nextTAt = wn.addT(wt, point, ts[!swap][pt]);
michael@0 402 wt.addOtherT(testTAt, ts[!swap][pt], nextTAt);
michael@0 403 wn.addOtherT(nextTAt, ts[swap][pt], testTAt);
michael@0 404 }
michael@0 405 } while (wn.advance());
michael@0 406 } while (wt.advance());
michael@0 407 return true;
michael@0 408 }
michael@0 409
michael@0 410 void AddSelfIntersectTs(SkOpContour* test) {
michael@0 411 SkIntersectionHelper wt;
michael@0 412 wt.init(test);
michael@0 413 do {
michael@0 414 if (wt.segmentType() != SkIntersectionHelper::kCubic_Segment) {
michael@0 415 continue;
michael@0 416 }
michael@0 417 SkIntersections ts;
michael@0 418 int pts = ts.cubic(wt.pts());
michael@0 419 debugShowCubicIntersection(pts, wt, ts);
michael@0 420 if (!pts) {
michael@0 421 continue;
michael@0 422 }
michael@0 423 SkASSERT(pts == 1);
michael@0 424 SkASSERT(ts[0][0] >= 0 && ts[0][0] <= 1);
michael@0 425 SkASSERT(ts[1][0] >= 0 && ts[1][0] <= 1);
michael@0 426 SkPoint point = ts.pt(0).asSkPoint();
michael@0 427 int testTAt = wt.addSelfT(wt, point, ts[0][0]);
michael@0 428 int nextTAt = wt.addT(wt, point, ts[1][0]);
michael@0 429 wt.addOtherT(testTAt, ts[1][0], nextTAt);
michael@0 430 wt.addOtherT(nextTAt, ts[0][0], testTAt);
michael@0 431 } while (wt.advance());
michael@0 432 }
michael@0 433
michael@0 434 // resolve any coincident pairs found while intersecting, and
michael@0 435 // see if coincidence is formed by clipping non-concident segments
michael@0 436 void CoincidenceCheck(SkTArray<SkOpContour*, true>* contourList, int total) {
michael@0 437 int contourCount = (*contourList).count();
michael@0 438 for (int cIndex = 0; cIndex < contourCount; ++cIndex) {
michael@0 439 SkOpContour* contour = (*contourList)[cIndex];
michael@0 440 contour->addCoincidentPoints();
michael@0 441 }
michael@0 442 for (int cIndex = 0; cIndex < contourCount; ++cIndex) {
michael@0 443 SkOpContour* contour = (*contourList)[cIndex];
michael@0 444 contour->calcCoincidentWinding();
michael@0 445 }
michael@0 446 for (int cIndex = 0; cIndex < contourCount; ++cIndex) {
michael@0 447 SkOpContour* contour = (*contourList)[cIndex];
michael@0 448 contour->calcPartialCoincidentWinding();
michael@0 449 }
michael@0 450 }

mercurial