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
This commit is contained in:
mtklein 2016-01-19 12:35:24 -08:00 committed by Commit bot
parent 3bd5aba2a0
commit 8a87bb4d5c

View File

@ -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) {