static SkOpSegment* findTopSegment(const SkTArray<SkOpContour*, true>& contourList, int* index, int* endIndex, SkPoint* topLeft, bool* unsortable, bool* done, bool firstPass) { SkOpSegment* result; const SkOpSegment* lastTopStart = NULL; int lastIndex = -1, lastEndIndex = -1; do { SkPoint bestXY = {SK_ScalarMax, SK_ScalarMax}; int contourCount = contourList.count(); SkOpSegment* topStart = NULL; *done = true; for (int cIndex = 0; cIndex < contourCount; ++cIndex) { SkOpContour* contour = contourList[cIndex]; if (contour->done()) { continue; } const SkPathOpsBounds& bounds = contour->bounds(); if (bounds.fBottom < topLeft->fY) { *done = false; continue; } if (bounds.fBottom == topLeft->fY && bounds.fRight < topLeft->fX) { *done = false; continue; } contour->topSortableSegment(*topLeft, &bestXY, &topStart); if (!contour->done()) { *done = false; } } if (!topStart) { return NULL; } *topLeft = bestXY; result = topStart->findTop(index, endIndex, unsortable, firstPass); if (!result) { if (lastTopStart == topStart && lastIndex == *index && lastEndIndex == *endIndex) { *done = true; return NULL; } lastTopStart = topStart; lastIndex = *index; lastEndIndex = *endIndex; } } while (!result); return result; }
static void skipVertical(const SkTArray<SkOpContour*, true>& contourList, SkOpSegment** current, int* index, int* endIndex) { if (!(*current)->isVertical(*index, *endIndex)) { return; } int contourCount = contourList.count(); for (int cIndex = 0; cIndex < contourCount; ++cIndex) { SkOpContour* contour = contourList[cIndex]; if (contour->done()) { continue; } *current = contour->nonVerticalSegment(index, endIndex); if (*current) { return; } } }