diff options
Diffstat (limited to 'gfx/skia/skia/src/core/SkScan_Path.cpp')
-rw-r--r-- | gfx/skia/skia/src/core/SkScan_Path.cpp | 61 |
1 files changed, 30 insertions, 31 deletions
diff --git a/gfx/skia/skia/src/core/SkScan_Path.cpp b/gfx/skia/skia/src/core/SkScan_Path.cpp index 5e00e3abe..d15d2d54b 100644 --- a/gfx/skia/skia/src/core/SkScan_Path.cpp +++ b/gfx/skia/skia/src/core/SkScan_Path.cpp @@ -241,17 +241,9 @@ static bool update_edge(SkEdge* edge, int last_y) { return false; } -// Unexpected conditions for which we need to return
-#define ASSERT_RETURN(cond) \
- do { \
- if (!(cond)) { \
- SkASSERT(false); \
- return; \
- } \
- } while (0)
-
-// Needs Y to only change once (looser than convex in X)
-static void walk_simple_edges(SkEdge* prevHead, SkBlitter* blitter, int start_y, int stop_y) { +static void walk_convex_edges(SkEdge* prevHead, SkPath::FillType, + SkBlitter* blitter, int start_y, int stop_y, + PrePostProc proc) { validate_sort(prevHead->fNext); SkEdge* leftE = prevHead->fNext; @@ -266,28 +258,30 @@ static void walk_simple_edges(SkEdge* prevHead, SkBlitter* blitter, int start_y, // not lining up, so we take the max. int local_top = SkMax32(leftE->fFirstY, riteE->fFirstY); #endif - ASSERT_RETURN(local_top >= start_y); + SkASSERT(local_top >= start_y); - while (local_top < stop_y) { + for (;;) { SkASSERT(leftE->fFirstY <= stop_y); SkASSERT(riteE->fFirstY <= stop_y); + if (leftE->fX > riteE->fX || (leftE->fX == riteE->fX && + leftE->fDX > riteE->fDX)) { + SkTSwap(leftE, riteE); + } + int local_bot = SkMin32(leftE->fLastY, riteE->fLastY); local_bot = SkMin32(local_bot, stop_y - 1); - ASSERT_RETURN(local_top <= local_bot); + SkASSERT(local_top <= local_bot); SkFixed left = leftE->fX; SkFixed dLeft = leftE->fDX; SkFixed rite = riteE->fX; SkFixed dRite = riteE->fDX; int count = local_bot - local_top; - ASSERT_RETURN(count >= 0); + SkASSERT(count >= 0); if (0 == (dLeft | dRite)) { int L = SkFixedRoundToInt(left); int R = SkFixedRoundToInt(rite); - if (L > R) { - SkTSwap(L, R); - } if (L < R) { count += 1; blitter->blitRect(L, local_top, R - L, count); @@ -297,9 +291,6 @@ static void walk_simple_edges(SkEdge* prevHead, SkBlitter* blitter, int start_y, do { int L = SkFixedRoundToInt(left); int R = SkFixedRoundToInt(rite); - if (L > R) { - SkTSwap(L, R); - } if (L < R) { blitter->blitH(L, local_top, R - L); } @@ -312,21 +303,28 @@ static void walk_simple_edges(SkEdge* prevHead, SkBlitter* blitter, int start_y, leftE->fX = left; riteE->fX = rite; - if (!update_edge(leftE, local_bot)) { + if (update_edge(leftE, local_bot)) { if (currE->fFirstY >= stop_y) { - return; // we're done + break; } leftE = currE; currE = currE->fNext; - ASSERT_RETURN(leftE->fFirstY == local_top); } - if (!update_edge(riteE, local_bot)) { + if (update_edge(riteE, local_bot)) { if (currE->fFirstY >= stop_y) { - return; // we're done + break; } riteE = currE; currE = currE->fNext; - ASSERT_RETURN(riteE->fFirstY == local_top); + } + + SkASSERT(leftE); + SkASSERT(riteE); + + // check our bottom clip + SkASSERT(local_top == local_bot + 1); + if (local_top >= stop_y) { + break; } } } @@ -502,9 +500,9 @@ void sk_fill_path(const SkPath& path, const SkIRect* clipRect, SkBlitter* blitte proc = PrePostInverseBlitterProc; } - // count >= 2 is required as the convex walker does not handle missing right edges - if (path.isConvex() && (nullptr == proc) && count >= 2) { - walk_simple_edges(&headEdge, blitter, start_y, stop_y); + if (path.isConvex() && (nullptr == proc)) { + SkASSERT(count >= 2); // convex walker does not handle missing right edges + walk_convex_edges(&headEdge, path.getFillType(), blitter, start_y, stop_y, nullptr); } else { int rightEdge; if (clipRect) { @@ -768,7 +766,8 @@ static void sk_fill_triangle(const SkPoint pts[], const SkIRect* clipRect, if (clipRect && start_y < clipRect->fTop) { start_y = clipRect->fTop; } - walk_simple_edges(&headEdge, blitter, start_y, stop_y); + walk_convex_edges(&headEdge, SkPath::kEvenOdd_FillType, blitter, start_y, stop_y, nullptr); +// walk_edges(&headEdge, SkPath::kEvenOdd_FillType, blitter, start_y, stop_y, nullptr); } void SkScan::FillTriangle(const SkPoint pts[], const SkRasterClip& clip, |