aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2016-01-19 12:35:24 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-01-19 12:35:24 -0800
commit8a87bb4d5c23da83ef406ef87b470afa4217d7a4 (patch)
tree45c6743aeeaf309f9b57418fa5a5b4171f478619
parent3bd5aba2a0e165997f683cf3aa306661e71464f6 (diff)
sdf: use linear edge distance approximation for all gradient directions
Image diff tools tell me there are diffs, but I sure can't see them. This drops edge_distance() off the chart as far as CPU cost goes. BUG=skia:4729 GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1545893003 Review URL: https://codereview.chromium.org/1545893003
-rwxr-xr-xsrc/core/SkDistanceFieldGen.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/core/SkDistanceFieldGen.cpp b/src/core/SkDistanceFieldGen.cpp
index 147aefad79..f1ebfa558a 100755
--- a/src/core/SkDistanceFieldGen.cpp
+++ b/src/core/SkDistanceFieldGen.cpp
@@ -107,6 +107,9 @@ static void init_glyph_data(DFData* data, unsigned char* edges, const unsigned c
// computes the distance to an edge given an edge normal vector and a pixel's alpha value
// assumes that direction has been pre-normalized
static float edge_distance(const SkPoint& direction, float alpha) {
+#if 1 // formula (1)
+ return 0.5f - alpha;
+#else // formula (4)
float dx = direction.fX;
float dy = direction.fY;
float distance;
@@ -143,6 +146,7 @@ static float edge_distance(const SkPoint& direction, float alpha) {
}
return distance;
+#endif
}
static void init_distances(DFData* data, unsigned char* edges, int width, int height) {