aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkScan_Path.cpp
diff options
context:
space:
mode:
authorGravatar reed <reed@chromium.org>2015-02-06 18:07:39 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-02-06 18:07:39 -0800
commitc319d075eab86cacfd7aba27859b72bbf8fc0a64 (patch)
treed19705f00b81f38bb5f47f14a3e3e411a5a1283c /src/core/SkScan_Path.cpp
parent70f00046a4f207fd49e4fdf85614d93b224f6f7f (diff)
Revert of faster edge re-sort, drop trailing edges (patchset #4 id:60001 of https://codereview.chromium.org/891613003/)
Reason for revert: may be breaking layouttests... Original issue's description: > faster edge re-sort, drop trailing edges > > 1. drop edges that are wholly on the right (in the non-convex walker) > 2. scan and swap once, instead of swapping as we go during re-sort > > BUG=skia: > > Committed: https://skia.googlesource.com/skia/+/38f1c00772539dcbeccbfa3c45d94bdc4acf3518 TBR=caryclark@google.com,reed@google.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia: Review URL: https://codereview.chromium.org/910493002
Diffstat (limited to 'src/core/SkScan_Path.cpp')
-rw-r--r--src/core/SkScan_Path.cpp59
1 files changed, 26 insertions, 33 deletions
diff --git a/src/core/SkScan_Path.cpp b/src/core/SkScan_Path.cpp
index bf56aca3f1..5d9e0ca2a6 100644
--- a/src/core/SkScan_Path.cpp
+++ b/src/core/SkScan_Path.cpp
@@ -45,23 +45,34 @@ static inline void remove_edge(SkEdge* edge) {
edge->fNext->fPrev = edge->fPrev;
}
-static inline void insert_edge_after(SkEdge* edge, SkEdge* afterMe) {
- edge->fPrev = afterMe;
- edge->fNext = afterMe->fNext;
- afterMe->fNext->fPrev = edge;
- afterMe->fNext = edge;
+static inline void swap_edges(SkEdge* prev, SkEdge* next) {
+ SkASSERT(prev->fNext == next && next->fPrev == prev);
+
+ // remove prev from the list
+ prev->fPrev->fNext = next;
+ next->fPrev = prev->fPrev;
+
+ // insert prev after next
+ prev->fNext = next->fNext;
+ next->fNext->fPrev = prev;
+ next->fNext = prev;
+ prev->fPrev = next;
}
static void backward_insert_edge_based_on_x(SkEdge* edge SkDECLAREPARAM(int, curr_y)) {
SkFixed x = edge->fX;
- SkEdge* prev = edge->fPrev;
- while (prev->fX > x) {
- prev = prev->fPrev;
- }
- if (prev->fNext != edge) {
- remove_edge(edge);
- insert_edge_after(edge, prev);
+ for (;;) {
+ SkEdge* prev = edge->fPrev;
+
+ // add 1 to curr_y since we may have added new edges (built from curves)
+ // that start on the next scanline
+ SkASSERT(prev && prev->fFirstY <= curr_y + 1);
+
+ if (prev->fX <= x) {
+ break;
+ }
+ swap_edges(prev, edge);
}
}
@@ -102,7 +113,7 @@ typedef void (*PrePostProc)(SkBlitter* blitter, int y, bool isStartOfScanline);
static void walk_edges(SkEdge* prevHead, SkPath::FillType fillType,
SkBlitter* blitter, int start_y, int stop_y,
- PrePostProc proc, int rightClip) {
+ PrePostProc proc) {
validate_sort(prevHead->fNext);
int curr_y = start_y;
@@ -172,14 +183,6 @@ static void walk_edges(SkEdge* prevHead, SkPath::FillType fillType,
SkASSERT(currE);
}
- // was our right-edge culled away?
- if (in_interval) {
- int width = rightClip - left;
- if (width > 0) {
- blitter->blitH(left, curr_y, width);
- }
- }
-
if (proc) {
proc(blitter, curr_y, PREPOST_END); // post-proc
}
@@ -433,10 +436,7 @@ void sk_fill_path(const SkPath& path, const SkIRect* clipRect, SkBlitter* blitte
SkEdgeBuilder builder;
- // If we're convex, then we need both edges, even the right edge is past the clip
- const bool cullToTheRight = !path.isConvex();
-
- int count = builder.build(path, clipRect, shiftEdgesUp, cullToTheRight);
+ int count = builder.build(path, clipRect, shiftEdgesUp);
SkEdge** list = builder.edgeList();
if (count < 2) {
@@ -500,17 +500,10 @@ void sk_fill_path(const SkPath& path, const SkIRect* clipRect, SkBlitter* blitte
proc = PrePostInverseBlitterProc;
}
- int rightEdge;
- if (clipRect) {
- rightEdge = clipRect->right();
- } else {
- rightEdge = SkScalarRoundToInt(path.getBounds().right());
- }
-
if (path.isConvex() && (NULL == proc)) {
walk_convex_edges(&headEdge, path.getFillType(), blitter, start_y, stop_y, NULL);
} else {
- walk_edges(&headEdge, path.getFillType(), blitter, start_y, stop_y, proc, rightEdge);
+ walk_edges(&headEdge, path.getFillType(), blitter, start_y, stop_y, proc);
}
}