Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Unified Diff: src/core/SkScan_Path.cpp

Issue 1647223002: batch merge new edges (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: remove extra paren Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkScan_Path.cpp
diff --git a/src/core/SkScan_Path.cpp b/src/core/SkScan_Path.cpp
index 804148db360c4d93e2dfb7aae4c45e967940c120..077d9a0a24da321d53ac0f7ed1e98045d8af91fb 100644
--- a/src/core/SkScan_Path.cpp
+++ b/src/core/SkScan_Path.cpp
@@ -61,7 +61,21 @@ static void backward_insert_edge_based_on_x(SkEdge* edge SkDECLAREPARAM(int, cur
}
}
+#ifndef SK_SUPPORT_LEGACY_INSERT_NEW_EDGES
+// Start from the right side, searching backwards for the point to begin the new edge list
+// insertion, marching forwards from here. The implementation could have started from the left
+// of the prior insertion, and search to the right, or with some additional caching, binary
+// search the starting point. More work could be done to determine optimal new edge insertion.
+static SkEdge* backward_insert_start(SkEdge* prev, SkFixed x) {
+ while (prev->fX > x) {
+ prev = prev->fPrev;
+ }
+ return prev;
+}
+#endif
+
static void insert_new_edges(SkEdge* newEdge, int curr_y) {
+#ifdef SK_SUPPORT_LEGACY_INSERT_NEW_EDGES
SkASSERT(newEdge->fFirstY >= curr_y);
while (newEdge->fFirstY == curr_y) {
@@ -69,6 +83,36 @@ static void insert_new_edges(SkEdge* newEdge, int curr_y) {
backward_insert_edge_based_on_x(newEdge SkPARAM(curr_y));
newEdge = next;
}
+#else
+ if (newEdge->fFirstY != curr_y) {
+ return;
+ }
+ SkEdge* prev = newEdge->fPrev;
+ if (prev->fX <= newEdge->fX) {
+ return;
+ }
+ // find first x pos to insert
+ SkEdge* start = backward_insert_start(prev, newEdge->fX);
+ // insert the lot, fixing up the links as we go
+ do {
+ SkEdge* next = newEdge->fNext;
+ do {
+ if (start->fNext == newEdge) {
+ goto nextEdge;
+ }
+ SkEdge* after = start->fNext;
+ if (after->fX >= newEdge->fX) {
+ break;
+ }
+ start = after;
+ } while (true);
+ remove_edge(newEdge);
+ insert_edge_after(newEdge, start);
+nextEdge:
+ start = newEdge;
+ newEdge = next;
+ } while (newEdge->fFirstY == curr_y);
+#endif
}
#ifdef SK_DEBUG
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698