| 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 "SkOpEdgeBuilder.h" | 7 #include "SkOpEdgeBuilder.h" |
| 8 #include "SkPathOpsCommon.h" | 8 #include "SkPathOpsCommon.h" |
| 9 #include "SkPathWriter.h" | 9 #include "SkPathWriter.h" |
| 10 #include "SkTSort.h" | 10 #include "SkTSort.h" |
| 11 | 11 |
| 12 static int contourRangeCheckY(const SkTDArray<SkOpContour*>& contourList, SkOpSe
gment** currentPtr, | 12 static int contourRangeCheckY(const SkTArray<SkOpContour*, true>& contourList, S
kOpSegment** currentPtr, |
| 13 int* indexPtr, int* endIndexPtr, double* bestHit,
SkScalar* bestDx, | 13 int* indexPtr, int* endIndexPtr, double* bestHit,
SkScalar* bestDx, |
| 14 bool* tryAgain, double* midPtr, bool opp) { | 14 bool* tryAgain, double* midPtr, bool opp) { |
| 15 const int index = *indexPtr; | 15 const int index = *indexPtr; |
| 16 const int endIndex = *endIndexPtr; | 16 const int endIndex = *endIndexPtr; |
| 17 const double mid = *midPtr; | 17 const double mid = *midPtr; |
| 18 const SkOpSegment* current = *currentPtr; | 18 const SkOpSegment* current = *currentPtr; |
| 19 double tAtMid = current->tAtMid(index, endIndex, mid); | 19 double tAtMid = current->tAtMid(index, endIndex, mid); |
| 20 SkPoint basePt = current->xyAtT(tAtMid); | 20 SkPoint basePt = current->xyAtT(tAtMid); |
| 21 int contourCount = contourList.count(); | 21 int contourCount = contourList.count(); |
| 22 SkScalar bestY = SK_ScalarMin; | 22 SkScalar bestY = SK_ScalarMin; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 } | 90 } |
| 91 result = bestSeg->windingAtT(*bestHit, bestTIndex, bestOpp, bestDx); | 91 result = bestSeg->windingAtT(*bestHit, bestTIndex, bestOpp, bestDx); |
| 92 SkASSERT(result == SK_MinS32 || *bestDx); | 92 SkASSERT(result == SK_MinS32 || *bestDx); |
| 93 } | 93 } |
| 94 double baseT = current->t(index); | 94 double baseT = current->t(index); |
| 95 double endT = current->t(endIndex); | 95 double endT = current->t(endIndex); |
| 96 *bestHit = baseT + mid * (endT - baseT); | 96 *bestHit = baseT + mid * (endT - baseT); |
| 97 return result; | 97 return result; |
| 98 } | 98 } |
| 99 | 99 |
| 100 SkOpSegment* FindUndone(SkTDArray<SkOpContour*>& contourList, int* start, int* e
nd) { | 100 SkOpSegment* FindUndone(SkTArray<SkOpContour*, true>& contourList, int* start, i
nt* end) { |
| 101 int contourCount = contourList.count(); | 101 int contourCount = contourList.count(); |
| 102 SkOpSegment* result; | 102 SkOpSegment* result; |
| 103 for (int cIndex = 0; cIndex < contourCount; ++cIndex) { | 103 for (int cIndex = 0; cIndex < contourCount; ++cIndex) { |
| 104 SkOpContour* contour = contourList[cIndex]; | 104 SkOpContour* contour = contourList[cIndex]; |
| 105 result = contour->undoneSegment(start, end); | 105 result = contour->undoneSegment(start, end); |
| 106 if (result) { | 106 if (result) { |
| 107 return result; | 107 return result; |
| 108 } | 108 } |
| 109 } | 109 } |
| 110 return NULL; | 110 return NULL; |
| 111 } | 111 } |
| 112 | 112 |
| 113 SkOpSegment* FindChase(SkTDArray<SkOpSpan*>& chase, int& tIndex, int& endIndex)
{ | 113 SkOpSegment* FindChase(SkTDArray<SkOpSpan*>& chase, int& tIndex, int& endIndex)
{ |
| 114 while (chase.count()) { | 114 while (chase.count()) { |
| 115 SkOpSpan* span; | 115 SkOpSpan* span; |
| 116 chase.pop(&span); | 116 chase.pop(&span); |
| 117 const SkOpSpan& backPtr = span->fOther->span(span->fOtherIndex); | 117 const SkOpSpan& backPtr = span->fOther->span(span->fOtherIndex); |
| 118 SkOpSegment* segment = backPtr.fOther; | 118 SkOpSegment* segment = backPtr.fOther; |
| 119 tIndex = backPtr.fOtherIndex; | 119 tIndex = backPtr.fOtherIndex; |
| 120 SkTDArray<SkOpAngle> angles; | 120 SkSTArray<SkOpAngle::kStackBasedCount, SkOpAngle, true> angles; |
| 121 int done = 0; | 121 int done = 0; |
| 122 if (segment->activeAngle(tIndex, &done, &angles)) { | 122 if (segment->activeAngle(tIndex, &done, &angles)) { |
| 123 SkOpAngle* last = angles.end() - 1; | 123 SkOpAngle* last = angles.end() - 1; |
| 124 tIndex = last->start(); | 124 tIndex = last->start(); |
| 125 endIndex = last->end(); | 125 endIndex = last->end(); |
| 126 #if TRY_ROTATE | 126 #if TRY_ROTATE |
| 127 *chase.insert(0) = span; | 127 *chase.insert(0) = span; |
| 128 #else | 128 #else |
| 129 *chase.append() = span; | 129 *chase.append() = span; |
| 130 #endif | 130 #endif |
| 131 return last->segment(); | 131 return last->segment(); |
| 132 } | 132 } |
| 133 if (done == angles.count()) { | 133 if (done == angles.count()) { |
| 134 continue; | 134 continue; |
| 135 } | 135 } |
| 136 SkTDArray<SkOpAngle*> sorted; | 136 SkSTArray<SkOpAngle::kStackBasedCount, SkOpAngle*, true> sorted; |
| 137 bool sortable = SkOpSegment::SortAngles(angles, &sorted, | 137 bool sortable = SkOpSegment::SortAngles(angles, &sorted, |
| 138 SkOpSegment::kMayBeUnordered_SortAngleKind); | 138 SkOpSegment::kMayBeUnordered_SortAngleKind); |
| 139 int angleCount = sorted.count(); | 139 int angleCount = sorted.count(); |
| 140 #if DEBUG_SORT | 140 #if DEBUG_SORT |
| 141 sorted[0]->segment()->debugShowSort(__FUNCTION__, sorted, 0, 0, 0); | 141 sorted[0]->segment()->debugShowSort(__FUNCTION__, sorted, 0, 0, 0); |
| 142 #endif | 142 #endif |
| 143 if (!sortable) { | 143 if (!sortable) { |
| 144 continue; | 144 continue; |
| 145 } | 145 } |
| 146 // find first angle, initialize winding to computed fWindSum | 146 // find first angle, initialize winding to computed fWindSum |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 break; | 201 break; |
| 202 } | 202 } |
| 203 } while (++nextIndex != lastIndex); | 203 } while (++nextIndex != lastIndex); |
| 204 *chase.insert(0) = span; | 204 *chase.insert(0) = span; |
| 205 return segment; | 205 return segment; |
| 206 } | 206 } |
| 207 return NULL; | 207 return NULL; |
| 208 } | 208 } |
| 209 | 209 |
| 210 #if DEBUG_ACTIVE_SPANS || DEBUG_ACTIVE_SPANS_FIRST_ONLY | 210 #if DEBUG_ACTIVE_SPANS || DEBUG_ACTIVE_SPANS_FIRST_ONLY |
| 211 void DebugShowActiveSpans(SkTDArray<SkOpContour*>& contourList) { | 211 void DebugShowActiveSpans(SkTArray<SkOpContour*, true>& contourList) { |
| 212 int index; | 212 int index; |
| 213 for (index = 0; index < contourList.count(); ++ index) { | 213 for (index = 0; index < contourList.count(); ++ index) { |
| 214 contourList[index]->debugShowActiveSpans(); | 214 contourList[index]->debugShowActiveSpans(); |
| 215 } | 215 } |
| 216 } | 216 } |
| 217 #endif | 217 #endif |
| 218 | 218 |
| 219 static SkOpSegment* findSortableTop(const SkTDArray<SkOpContour*>& contourList, | 219 static SkOpSegment* findSortableTop(const SkTArray<SkOpContour*, true>& contourL
ist, |
| 220 int* index, int* endIndex, SkPoint* topLeft,
bool* unsortable, | 220 int* index, int* endIndex, SkPoint* topLeft,
bool* unsortable, |
| 221 bool* done, bool onlySortable) { | 221 bool* done, bool onlySortable) { |
| 222 SkOpSegment* result; | 222 SkOpSegment* result; |
| 223 do { | 223 do { |
| 224 SkPoint bestXY = {SK_ScalarMax, SK_ScalarMax}; | 224 SkPoint bestXY = {SK_ScalarMax, SK_ScalarMax}; |
| 225 int contourCount = contourList.count(); | 225 int contourCount = contourList.count(); |
| 226 SkOpSegment* topStart = NULL; | 226 SkOpSegment* topStart = NULL; |
| 227 *done = true; | 227 *done = true; |
| 228 for (int cIndex = 0; cIndex < contourCount; ++cIndex) { | 228 for (int cIndex = 0; cIndex < contourCount; ++cIndex) { |
| 229 SkOpContour* contour = contourList[cIndex]; | 229 SkOpContour* contour = contourList[cIndex]; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 246 } | 246 } |
| 247 if (!topStart) { | 247 if (!topStart) { |
| 248 return NULL; | 248 return NULL; |
| 249 } | 249 } |
| 250 *topLeft = bestXY; | 250 *topLeft = bestXY; |
| 251 result = topStart->findTop(index, endIndex, unsortable, onlySortable); | 251 result = topStart->findTop(index, endIndex, unsortable, onlySortable); |
| 252 } while (!result); | 252 } while (!result); |
| 253 return result; | 253 return result; |
| 254 } | 254 } |
| 255 | 255 |
| 256 static int rightAngleWinding(const SkTDArray<SkOpContour*>& contourList, | 256 static int rightAngleWinding(const SkTArray<SkOpContour*, true>& contourList, |
| 257 SkOpSegment** current, int* index, int* endIndex, d
ouble* tHit, | 257 SkOpSegment** current, int* index, int* endIndex, d
ouble* tHit, |
| 258 SkScalar* hitDx, bool* tryAgain, bool opp) { | 258 SkScalar* hitDx, bool* tryAgain, bool opp) { |
| 259 double test = 0.9; | 259 double test = 0.9; |
| 260 int contourWinding; | 260 int contourWinding; |
| 261 do { | 261 do { |
| 262 contourWinding = contourRangeCheckY(contourList, current, index, endInde
x, tHit, hitDx, | 262 contourWinding = contourRangeCheckY(contourList, current, index, endInde
x, tHit, hitDx, |
| 263 tryAgain, &test, opp); | 263 tryAgain, &test, opp); |
| 264 if (contourWinding != SK_MinS32 || *tryAgain) { | 264 if (contourWinding != SK_MinS32 || *tryAgain) { |
| 265 return contourWinding; | 265 return contourWinding; |
| 266 } | 266 } |
| 267 test /= 2; | 267 test /= 2; |
| 268 } while (!approximately_negative(test)); | 268 } while (!approximately_negative(test)); |
| 269 SkASSERT(0); // should be OK to comment out, but interested when this hits | 269 SkASSERT(0); // should be OK to comment out, but interested when this hits |
| 270 return contourWinding; | 270 return contourWinding; |
| 271 } | 271 } |
| 272 | 272 |
| 273 static void skipVertical(const SkTDArray<SkOpContour*>& contourList, | 273 static void skipVertical(const SkTArray<SkOpContour*, true>& contourList, |
| 274 SkOpSegment** current, int* index, int* endIndex) { | 274 SkOpSegment** current, int* index, int* endIndex) { |
| 275 if (!(*current)->isVertical(*index, *endIndex)) { | 275 if (!(*current)->isVertical(*index, *endIndex)) { |
| 276 return; | 276 return; |
| 277 } | 277 } |
| 278 int contourCount = contourList.count(); | 278 int contourCount = contourList.count(); |
| 279 for (int cIndex = 0; cIndex < contourCount; ++cIndex) { | 279 for (int cIndex = 0; cIndex < contourCount; ++cIndex) { |
| 280 SkOpContour* contour = contourList[cIndex]; | 280 SkOpContour* contour = contourList[cIndex]; |
| 281 if (contour->done()) { | 281 if (contour->done()) { |
| 282 continue; | 282 continue; |
| 283 } | 283 } |
| 284 *current = contour->nonVerticalSegment(index, endIndex); | 284 *current = contour->nonVerticalSegment(index, endIndex); |
| 285 if (*current) { | 285 if (*current) { |
| 286 return; | 286 return; |
| 287 } | 287 } |
| 288 } | 288 } |
| 289 } | 289 } |
| 290 | 290 |
| 291 SkOpSegment* FindSortableTop(const SkTDArray<SkOpContour*>& contourList, bool* f
irstContour, | 291 SkOpSegment* FindSortableTop(const SkTArray<SkOpContour*, true>& contourList, bo
ol* firstContour, |
| 292 int* indexPtr, int* endIndexPtr, SkPoint* topLeft,
bool* unsortable, | 292 int* indexPtr, int* endIndexPtr, SkPoint* topLeft,
bool* unsortable, |
| 293 bool* done, bool binary) { | 293 bool* done, bool binary) { |
| 294 SkOpSegment* current = findSortableTop(contourList, indexPtr, endIndexPtr, t
opLeft, unsortable, | 294 SkOpSegment* current = findSortableTop(contourList, indexPtr, endIndexPtr, t
opLeft, unsortable, |
| 295 done, true); | 295 done, true); |
| 296 if (!current) { | 296 if (!current) { |
| 297 return NULL; | 297 return NULL; |
| 298 } | 298 } |
| 299 const int index = *indexPtr; | 299 const int index = *indexPtr; |
| 300 const int endIndex = *endIndexPtr; | 300 const int endIndex = *endIndexPtr; |
| 301 if (*firstContour) { | 301 if (*firstContour) { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 break; | 337 break; |
| 338 } | 338 } |
| 339 oppContourWinding = rightAngleWinding(contourList, ¤t, indexPtr, e
ndIndexPtr, &tHit, | 339 oppContourWinding = rightAngleWinding(contourList, ¤t, indexPtr, e
ndIndexPtr, &tHit, |
| 340 &hitOppDx, &tryAgain, true); | 340 &hitOppDx, &tryAgain, true); |
| 341 } while (tryAgain); | 341 } while (tryAgain); |
| 342 current->initWinding(*indexPtr, *endIndexPtr, tHit, contourWinding, hitDx, o
ppContourWinding, | 342 current->initWinding(*indexPtr, *endIndexPtr, tHit, contourWinding, hitDx, o
ppContourWinding, |
| 343 hitOppDx); | 343 hitOppDx); |
| 344 return current; | 344 return current; |
| 345 } | 345 } |
| 346 | 346 |
| 347 void FixOtherTIndex(SkTDArray<SkOpContour*>* contourList) { | 347 void FixOtherTIndex(SkTArray<SkOpContour*, true>* contourList) { |
| 348 int contourCount = (*contourList).count(); | 348 int contourCount = (*contourList).count(); |
| 349 for (int cTest = 0; cTest < contourCount; ++cTest) { | 349 for (int cTest = 0; cTest < contourCount; ++cTest) { |
| 350 SkOpContour* contour = (*contourList)[cTest]; | 350 SkOpContour* contour = (*contourList)[cTest]; |
| 351 contour->fixOtherTIndex(); | 351 contour->fixOtherTIndex(); |
| 352 } | 352 } |
| 353 } | 353 } |
| 354 | 354 |
| 355 void SortSegments(SkTDArray<SkOpContour*>* contourList) { | 355 void SortSegments(SkTArray<SkOpContour*, true>* contourList) { |
| 356 int contourCount = (*contourList).count(); | 356 int contourCount = (*contourList).count(); |
| 357 for (int cTest = 0; cTest < contourCount; ++cTest) { | 357 for (int cTest = 0; cTest < contourCount; ++cTest) { |
| 358 SkOpContour* contour = (*contourList)[cTest]; | 358 SkOpContour* contour = (*contourList)[cTest]; |
| 359 contour->sortSegments(); | 359 contour->sortSegments(); |
| 360 } | 360 } |
| 361 } | 361 } |
| 362 | 362 |
| 363 void MakeContourList(SkTArray<SkOpContour>& contours, SkTDArray<SkOpContour*>& l
ist, | 363 void MakeContourList(SkTArray<SkOpContour>& contours, SkTArray<SkOpContour*, tru
e>& list, |
| 364 bool evenOdd, bool oppEvenOdd) { | 364 bool evenOdd, bool oppEvenOdd) { |
| 365 int count = contours.count(); | 365 int count = contours.count(); |
| 366 if (count == 0) { | 366 if (count == 0) { |
| 367 return; | 367 return; |
| 368 } | 368 } |
| 369 for (int index = 0; index < count; ++index) { | 369 for (int index = 0; index < count; ++index) { |
| 370 SkOpContour& contour = contours[index]; | 370 SkOpContour& contour = contours[index]; |
| 371 contour.setOppXor(contour.operand() ? evenOdd : oppEvenOdd); | 371 contour.setOppXor(contour.operand() ? evenOdd : oppEvenOdd); |
| 372 *list.append() = &contour; | 372 list.push_back(&contour); |
| 373 } | 373 } |
| 374 SkTQSort<SkOpContour>(list.begin(), list.end() - 1); | 374 SkTQSort<SkOpContour>(list.begin(), list.end() - 1); |
| 375 } | 375 } |
| 376 | 376 |
| 377 static bool approximatelyEqual(const SkPoint& a, const SkPoint& b) { | 377 static bool approximatelyEqual(const SkPoint& a, const SkPoint& b) { |
| 378 return AlmostEqualUlps(a.fX, b.fX) && AlmostEqualUlps(a.fY, b.fY); | 378 return AlmostEqualUlps(a.fX, b.fX) && AlmostEqualUlps(a.fY, b.fY); |
| 379 } | 379 } |
| 380 | 380 |
| 381 class DistanceLessThan { | 381 class DistanceLessThan { |
| 382 public: | 382 public: |
| (...skipping 13 matching lines...) Expand all Loading... |
| 396 */ | 396 */ |
| 397 void Assemble(const SkPathWriter& path, SkPathWriter* simple) { | 397 void Assemble(const SkPathWriter& path, SkPathWriter* simple) { |
| 398 #if DEBUG_PATH_CONSTRUCTION | 398 #if DEBUG_PATH_CONSTRUCTION |
| 399 SkDebugf("%s\n", __FUNCTION__); | 399 SkDebugf("%s\n", __FUNCTION__); |
| 400 #endif | 400 #endif |
| 401 SkTArray<SkOpContour> contours; | 401 SkTArray<SkOpContour> contours; |
| 402 SkOpEdgeBuilder builder(path, contours); | 402 SkOpEdgeBuilder builder(path, contours); |
| 403 builder.finish(); | 403 builder.finish(); |
| 404 int count = contours.count(); | 404 int count = contours.count(); |
| 405 int outer; | 405 int outer; |
| 406 SkTDArray<int> runs; // indices of partial contours | 406 SkTArray<int, true> runs(count); // indices of partial contours |
| 407 for (outer = 0; outer < count; ++outer) { | 407 for (outer = 0; outer < count; ++outer) { |
| 408 const SkOpContour& eContour = contours[outer]; | 408 const SkOpContour& eContour = contours[outer]; |
| 409 const SkPoint& eStart = eContour.start(); | 409 const SkPoint& eStart = eContour.start(); |
| 410 const SkPoint& eEnd = eContour.end(); | 410 const SkPoint& eEnd = eContour.end(); |
| 411 #if DEBUG_ASSEMBLE | 411 #if DEBUG_ASSEMBLE |
| 412 SkDebugf("%s contour", __FUNCTION__); | 412 SkDebugf("%s contour", __FUNCTION__); |
| 413 if (!approximatelyEqual(eStart, eEnd)) { | 413 if (!approximatelyEqual(eStart, eEnd)) { |
| 414 SkDebugf("[%d]", runs.count()); | 414 SkDebugf("[%d]", runs.count()); |
| 415 } else { | 415 } else { |
| 416 SkDebugf(" "); | 416 SkDebugf(" "); |
| 417 } | 417 } |
| 418 SkDebugf(" start=(%1.9g,%1.9g) end=(%1.9g,%1.9g)\n", | 418 SkDebugf(" start=(%1.9g,%1.9g) end=(%1.9g,%1.9g)\n", |
| 419 eStart.fX, eStart.fY, eEnd.fX, eEnd.fY); | 419 eStart.fX, eStart.fY, eEnd.fX, eEnd.fY); |
| 420 #endif | 420 #endif |
| 421 if (approximatelyEqual(eStart, eEnd)) { | 421 if (approximatelyEqual(eStart, eEnd)) { |
| 422 eContour.toPath(simple); | 422 eContour.toPath(simple); |
| 423 continue; | 423 continue; |
| 424 } | 424 } |
| 425 *runs.append() = outer; | 425 runs.push_back(outer); |
| 426 } | 426 } |
| 427 count = runs.count(); | 427 count = runs.count(); |
| 428 if (count == 0) { | 428 if (count == 0) { |
| 429 return; | 429 return; |
| 430 } | 430 } |
| 431 SkTDArray<int> sLink, eLink; | 431 SkTArray<int, true> sLink, eLink; |
| 432 sLink.setCount(count); | 432 sLink.push_back_n(count); |
| 433 eLink.setCount(count); | 433 eLink.push_back_n(count); |
| 434 int rIndex, iIndex; | 434 int rIndex, iIndex; |
| 435 for (rIndex = 0; rIndex < count; ++rIndex) { | 435 for (rIndex = 0; rIndex < count; ++rIndex) { |
| 436 sLink[rIndex] = eLink[rIndex] = SK_MaxS32; | 436 sLink[rIndex] = eLink[rIndex] = SK_MaxS32; |
| 437 } | 437 } |
| 438 SkTDArray<double> distances; | |
| 439 const int ends = count * 2; // all starts and ends | 438 const int ends = count * 2; // all starts and ends |
| 440 const int entries = (ends - 1) * count; // folded triangle : n * (n - 1) /
2 | 439 const int entries = (ends - 1) * count; // folded triangle : n * (n - 1) /
2 |
| 441 distances.setCount(entries); | 440 SkTArray<double, true> distances; |
| 441 distances.push_back_n(entries); |
| 442 for (rIndex = 0; rIndex < ends - 1; ++rIndex) { | 442 for (rIndex = 0; rIndex < ends - 1; ++rIndex) { |
| 443 outer = runs[rIndex >> 1]; | 443 outer = runs[rIndex >> 1]; |
| 444 const SkOpContour& oContour = contours[outer]; | 444 const SkOpContour& oContour = contours[outer]; |
| 445 const SkPoint& oPt = rIndex & 1 ? oContour.end() : oContour.start(); | 445 const SkPoint& oPt = rIndex & 1 ? oContour.end() : oContour.start(); |
| 446 const int row = rIndex < count - 1 ? rIndex * ends : (ends - rIndex - 2) | 446 const int row = rIndex < count - 1 ? rIndex * ends : (ends - rIndex - 2) |
| 447 * ends - rIndex - 1; | 447 * ends - rIndex - 1; |
| 448 for (iIndex = rIndex + 1; iIndex < ends; ++iIndex) { | 448 for (iIndex = rIndex + 1; iIndex < ends; ++iIndex) { |
| 449 int inner = runs[iIndex >> 1]; | 449 int inner = runs[iIndex >> 1]; |
| 450 const SkOpContour& iContour = contours[inner]; | 450 const SkOpContour& iContour = contours[inner]; |
| 451 const SkPoint& iPt = iIndex & 1 ? iContour.end() : iContour.start(); | 451 const SkPoint& iPt = iIndex & 1 ? iContour.end() : iContour.start(); |
| 452 double dx = iPt.fX - oPt.fX; | 452 double dx = iPt.fX - oPt.fX; |
| 453 double dy = iPt.fY - oPt.fY; | 453 double dy = iPt.fY - oPt.fY; |
| 454 double dist = dx * dx + dy * dy; | 454 double dist = dx * dx + dy * dy; |
| 455 distances[row + iIndex] = dist; // oStart distance from iStart | 455 distances[row + iIndex] = dist; // oStart distance from iStart |
| 456 } | 456 } |
| 457 } | 457 } |
| 458 SkTDArray<int> sortedDist; | 458 SkTArray<int, true> sortedDist; |
| 459 sortedDist.setCount(entries); | 459 sortedDist.push_back_n(entries); |
| 460 for (rIndex = 0; rIndex < entries; ++rIndex) { | 460 for (rIndex = 0; rIndex < entries; ++rIndex) { |
| 461 sortedDist[rIndex] = rIndex; | 461 sortedDist[rIndex] = rIndex; |
| 462 } | 462 } |
| 463 SkTQSort<int>(sortedDist.begin(), sortedDist.end() - 1, DistanceLessThan(dis
tances.begin())); | 463 SkTQSort<int>(sortedDist.begin(), sortedDist.end() - 1, DistanceLessThan(dis
tances.begin())); |
| 464 int remaining = count; // number of start/end pairs | 464 int remaining = count; // number of start/end pairs |
| 465 for (rIndex = 0; rIndex < entries; ++rIndex) { | 465 for (rIndex = 0; rIndex < entries; ++rIndex) { |
| 466 int pair = sortedDist[rIndex]; | 466 int pair = sortedDist[rIndex]; |
| 467 int row = pair / ends; | 467 int row = pair / ends; |
| 468 int col = pair - row * ends; | 468 int col = pair - row * ends; |
| 469 int thingOne = row < col ? row : ends - row - 2; | 469 int thingOne = row < col ? row : ends - row - 2; |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 } | 575 } |
| 576 } | 576 } |
| 577 } while (rIndex < count); | 577 } while (rIndex < count); |
| 578 #if DEBUG_ASSEMBLE | 578 #if DEBUG_ASSEMBLE |
| 579 for (rIndex = 0; rIndex < count; ++rIndex) { | 579 for (rIndex = 0; rIndex < count; ++rIndex) { |
| 580 SkASSERT(sLink[rIndex] == SK_MaxS32); | 580 SkASSERT(sLink[rIndex] == SK_MaxS32); |
| 581 SkASSERT(eLink[rIndex] == SK_MaxS32); | 581 SkASSERT(eLink[rIndex] == SK_MaxS32); |
| 582 } | 582 } |
| 583 #endif | 583 #endif |
| 584 } | 584 } |
| OLD | NEW |