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

Unified Diff: src/gpu/effects/GrDistanceFieldTextureEffect.cpp

Issue 227593010: Move distance field generation to the glyph cache (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Move GrFontScaler back to public interface Created 6 years, 8 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 | « src/gpu/SkGrFontScaler.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/effects/GrDistanceFieldTextureEffect.cpp
diff --git a/src/gpu/effects/GrDistanceFieldTextureEffect.cpp b/src/gpu/effects/GrDistanceFieldTextureEffect.cpp
index 8a023cd1d08073ddc5c0fecb42b45a619d4a87ce..b332c7d2cfe875d15a414627494551e0b7a546a7 100755
--- a/src/gpu/effects/GrDistanceFieldTextureEffect.cpp
+++ b/src/gpu/effects/GrDistanceFieldTextureEffect.cpp
@@ -13,10 +13,7 @@
#include "GrTBackendEffectFactory.h"
#include "GrTexture.h"
-// The distance field is constructed as unsigned char values, so that the zero value is at 128,
-// and the range is [-4, 4 - 1/255). Hence our multiplier is 8 - 1/32 and zero threshold is 128/255.
-#define MULTIPLIER "7.96875"
-#define THRESHOLD "0.50196078431"
+#include "SkDistanceFieldGen.h"
class GrGLDistanceFieldTextureEffect : public GrGLVertexEffect {
public:
@@ -58,7 +55,8 @@ public:
fsCoordName.c_str(),
kVec2f_GrSLType);
builder->fsCodeAppend(";\n");
- builder->fsCodeAppend("\tfloat distance = " MULTIPLIER "*(texColor.r - " THRESHOLD ");\n");
+ builder->fsCodeAppend("\tfloat distance = "
+ SK_DistanceFieldMultiplier "*(texColor.r - " SK_DistanceFieldThreshold ");\n");
// we adjust for the effect of the transformation on the distance by using
// the length of the gradient of the texture coordinates. We use st coordinates
@@ -239,20 +237,22 @@ public:
builder->fsAppendTextureLookup(samplers[0], "uv", kVec2f_GrSLType);
builder->fsCodeAppend(";\n");
builder->fsCodeAppend("\tvec3 distance;\n");
- builder->fsCodeAppend("\tdistance.y = " MULTIPLIER "*(texColor.r - " THRESHOLD ");\n");
+ builder->fsCodeAppend("\tdistance.y = "
+ SK_DistanceFieldMultiplier "*(texColor.r - " SK_DistanceFieldThreshold ");\n");
// red is distance to left offset
builder->fsCodeAppend("\tvec2 uv_adjusted = uv - offset;\n");
builder->fsCodeAppend("\ttexColor = ");
builder->fsAppendTextureLookup(samplers[0], "uv_adjusted", kVec2f_GrSLType);
builder->fsCodeAppend(";\n");
- builder->fsCodeAppend("\tdistance.x = " MULTIPLIER "*(texColor.r - " THRESHOLD ");\n");
+ builder->fsCodeAppend("\tdistance.x = "
+ SK_DistanceFieldMultiplier "*(texColor.r - " SK_DistanceFieldThreshold ");\n");
// blue is distance to right offset
builder->fsCodeAppend("\tuv_adjusted = uv + offset;\n");
builder->fsCodeAppend("\ttexColor = ");
builder->fsAppendTextureLookup(samplers[0], "uv_adjusted", kVec2f_GrSLType);
builder->fsCodeAppend(";\n");
- builder->fsCodeAppend("\tdistance.z = " MULTIPLIER "*(texColor.r - " THRESHOLD ");\n");
-
+ builder->fsCodeAppend("\tdistance.z = "
+ SK_DistanceFieldMultiplier "*(texColor.r - " SK_DistanceFieldThreshold ");\n");
// we adjust for the effect of the transformation on the distance by using
// the length of the gradient of the texture coordinates. We use st coordinates
// to ensure we're mapping 1:1 from texel space to pixel space.
« no previous file with comments | « src/gpu/SkGrFontScaler.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698