| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 #include "SkAddIntersections.h" | 7 #include "SkAddIntersections.h" |
| 8 #include "SkOpCoincidence.h" | 8 #include "SkOpCoincidence.h" |
| 9 #include "SkOpEdgeBuilder.h" | 9 #include "SkOpEdgeBuilder.h" |
| 10 #include "SkPathOpsCommon.h" | 10 #include "SkPathOpsCommon.h" |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 /* | 191 /* |
| 192 check start and end of each contour | 192 check start and end of each contour |
| 193 if not the same, record them | 193 if not the same, record them |
| 194 match them up | 194 match them up |
| 195 connect closest | 195 connect closest |
| 196 reassemble contour pieces into new path | 196 reassemble contour pieces into new path |
| 197 */ | 197 */ |
| 198 void Assemble(const SkPathWriter& path, SkPathWriter* simple) { | 198 void Assemble(const SkPathWriter& path, SkPathWriter* simple) { |
| 199 SkChunkAlloc allocator(4096); // FIXME: constant-ize, tune | 199 SkChunkAlloc allocator(4096); // FIXME: constant-ize, tune |
| 200 SkOpContourHead contour; | 200 SkOpContourHead contour; |
| 201 SkOpGlobalState globalState(NULL, &contour); | 201 SkOpGlobalState globalState(NULL, &contour SkDEBUGPARAMS(NULL)); |
| 202 #if DEBUG_SHOW_TEST_NAME | 202 #if DEBUG_SHOW_TEST_NAME |
| 203 SkDebugf("</div>\n"); | 203 SkDebugf("</div>\n"); |
| 204 #endif | 204 #endif |
| 205 #if DEBUG_PATH_CONSTRUCTION | 205 #if DEBUG_PATH_CONSTRUCTION |
| 206 SkDebugf("%s\n", __FUNCTION__); | 206 SkDebugf("%s\n", __FUNCTION__); |
| 207 #endif | 207 #endif |
| 208 SkOpEdgeBuilder builder(path, &contour, &allocator, &globalState); | 208 SkOpEdgeBuilder builder(path, &contour, &allocator, &globalState); |
| 209 builder.finish(&allocator); | 209 builder.finish(&allocator); |
| 210 SkTDArray<const SkOpContour* > runs; // indices of partial contours | 210 SkTDArray<const SkOpContour* > runs; // indices of partial contours |
| 211 const SkOpContour* eContour = builder.head(); | 211 const SkOpContour* eContour = builder.head(); |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 } while ((contour = contour->next())); | 401 } while ((contour = contour->next())); |
| 402 } | 402 } |
| 403 | 403 |
| 404 static void calcAngles(SkOpContourHead* contourList, SkChunkAlloc* allocator) { | 404 static void calcAngles(SkOpContourHead* contourList, SkChunkAlloc* allocator) { |
| 405 SkOpContour* contour = contourList; | 405 SkOpContour* contour = contourList; |
| 406 do { | 406 do { |
| 407 contour->calcAngles(allocator); | 407 contour->calcAngles(allocator); |
| 408 } while ((contour = contour->next())); | 408 } while ((contour = contour->next())); |
| 409 } | 409 } |
| 410 | 410 |
| 411 static void findCollapsed(SkOpContourHead* contourList) { |
| 412 SkOpContour* contour = contourList; |
| 413 do { |
| 414 contour->findCollapsed(); |
| 415 } while ((contour = contour->next())); |
| 416 } |
| 417 |
| 411 static bool missingCoincidence(SkOpContourHead* contourList, | 418 static bool missingCoincidence(SkOpContourHead* contourList, |
| 412 SkOpCoincidence* coincidence, SkChunkAlloc* allocator) { | 419 SkOpCoincidence* coincidence, SkChunkAlloc* allocator) { |
| 413 SkOpContour* contour = contourList; | 420 SkOpContour* contour = contourList; |
| 414 bool result = false; | 421 bool result = false; |
| 415 do { | 422 do { |
| 416 result |= contour->missingCoincidence(coincidence, allocator); | 423 result |= contour->missingCoincidence(coincidence, allocator); |
| 417 } while ((contour = contour->next())); | 424 } while ((contour = contour->next())); |
| 418 return result; | 425 return result; |
| 419 } | 426 } |
| 420 | 427 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 437 do { | 444 do { |
| 438 contour->sortAngles(); | 445 contour->sortAngles(); |
| 439 } while ((contour = contour->next())); | 446 } while ((contour = contour->next())); |
| 440 } | 447 } |
| 441 | 448 |
| 442 bool HandleCoincidence(SkOpContourHead* contourList, SkOpCoincidence* coincidenc
e, | 449 bool HandleCoincidence(SkOpContourHead* contourList, SkOpCoincidence* coincidenc
e, |
| 443 SkChunkAlloc* allocator) { | 450 SkChunkAlloc* allocator) { |
| 444 SkOpGlobalState* globalState = contourList->globalState(); | 451 SkOpGlobalState* globalState = contourList->globalState(); |
| 445 // combine t values when multiple intersections occur on some segments but n
ot others | 452 // combine t values when multiple intersections occur on some segments but n
ot others |
| 446 moveMultiples(contourList); | 453 moveMultiples(contourList); |
| 454 findCollapsed(contourList); |
| 447 // move t values and points together to eliminate small/tiny gaps | 455 // move t values and points together to eliminate small/tiny gaps |
| 448 moveNearby(contourList); | 456 moveNearby(contourList); |
| 449 align(contourList); // give all span members common values | 457 align(contourList); // give all span members common values |
| 450 coincidence->fixAligned(); // aligning may have marked a coincidence pt-t d
eleted | 458 coincidence->fixAligned(); // aligning may have marked a coincidence pt-t d
eleted |
| 451 #if DEBUG_VALIDATE | 459 #if DEBUG_VALIDATE |
| 452 globalState->setPhase(SkOpGlobalState::kIntersecting); | 460 globalState->setPhase(SkOpGlobalState::kIntersecting); |
| 453 #endif | 461 #endif |
| 454 // look for intersections on line segments formed by moving end points | 462 // look for intersections on line segments formed by moving end points |
| 455 addAlignIntersections(contourList, allocator); | 463 addAlignIntersections(contourList, allocator); |
| 456 coincidence->addMissing(allocator); | 464 coincidence->addMissing(allocator); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 486 if (!coincidence->apply()) { | 494 if (!coincidence->apply()) { |
| 487 return false; | 495 return false; |
| 488 } | 496 } |
| 489 } | 497 } |
| 490 #if DEBUG_ACTIVE_SPANS | 498 #if DEBUG_ACTIVE_SPANS |
| 491 coincidence->debugShowCoincidence(); | 499 coincidence->debugShowCoincidence(); |
| 492 DebugShowActiveSpans(contourList); | 500 DebugShowActiveSpans(contourList); |
| 493 #endif | 501 #endif |
| 494 return true; | 502 return true; |
| 495 } | 503 } |
| OLD | NEW |