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

Unified Diff: src/core/SkDistanceFieldGen.cpp

Issue 1545893003: sdf: use linear edge distance approximation for all gradient directions (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years 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/SkDistanceFieldGen.cpp
diff --git a/src/core/SkDistanceFieldGen.cpp b/src/core/SkDistanceFieldGen.cpp
index 30354e09f83cb783c49ee018af74b3d8e236b272..c147151c3b21def3fcef267e30b972b86593152c 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) {
« 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