aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-05-09 12:07:31 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-05-09 12:07:31 +0000
commit0a71a9cc372c2fd42e3b1623321878aaa27aa103 (patch)
tree2e281347de0873227f40a0be6f13e417feb9cfd1 /src
parent331e2dc8eb69b093bf012d8dcd1ab652d67fc36b (diff)
experimental faster sort
git-svn-id: http://skia.googlecode.com/svn/trunk@3872 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r--src/core/SkScan_Path.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/core/SkScan_Path.cpp b/src/core/SkScan_Path.cpp
index 8a3d718f03..5450ea0870 100644
--- a/src/core/SkScan_Path.cpp
+++ b/src/core/SkScan_Path.cpp
@@ -15,6 +15,10 @@
#include "SkRasterClip.h"
#include "SkRegion.h"
#include "SkTemplates.h"
+#include "SkTSort.h"
+
+// undefine this to get faster inline sort
+#define SK_USE_STD_SORT_FOR_EDGES
#define kEDGE_HEAD_Y SK_MinS32
#define kEDGE_TAIL_Y SK_MaxS32
@@ -374,6 +378,7 @@ static void PrePostInverseBlitterProc(SkBlitter* blitter, int y, bool isStart) {
#pragma warning ( pop )
#endif
+#ifdef SK_USE_STD_SORT_FOR_EDGES
extern "C" {
static int edge_compare(const void* a, const void* b) {
const SkEdge* edgea = *(const SkEdge**)a;
@@ -393,9 +398,26 @@ extern "C" {
return (valuea < valueb) ? -1 : (valuea > valueb);
}
}
+#else
+static bool operator<(const SkEdge& a, const SkEdge& b) {
+ int valuea = a.fFirstY;
+ int valueb = b.fFirstY;
+
+ if (valuea == valueb) {
+ valuea = a.fX;
+ valueb = b.fX;
+ }
+
+ return valuea < valueb;
+}
+#endif
static SkEdge* sort_edges(SkEdge* list[], int count, SkEdge** last) {
+#ifdef SK_USE_STD_SORT_FOR_EDGES
qsort(list, count, sizeof(SkEdge*), edge_compare);
+#else
+ SkTQSort(list, list + count - 1);
+#endif
// now make the edges linked in sorted order
for (int i = 1; i < count; i++) {