added SkSL saturate() function
Bug: skia:8220
Change-Id: Ib2e58ac77345a2aa53302c6c1484d52533556f93
Reviewed-on: https://skia-review.googlesource.com/145371
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
diff --git a/src/gpu/effects/GrDistanceFieldGeoProc.cpp b/src/gpu/effects/GrDistanceFieldGeoProc.cpp
index 59ec5da..099cc7e 100644
--- a/src/gpu/effects/GrDistanceFieldGeoProc.cpp
+++ b/src/gpu/effects/GrDistanceFieldGeoProc.cpp
@@ -152,7 +152,7 @@
// doing gamma-correct rendering (to an sRGB or F16 buffer), then we actually want
// distance mapped linearly to coverage, so use a linear step:
fragBuilder->codeAppend(
- "half val = clamp((distance + afwidth) / (2.0 * afwidth), 0.0, 1.0);");
+ "half val = saturate((distance + afwidth) / (2.0 * afwidth));");
} else {
fragBuilder->codeAppend("half val = smoothstep(-afwidth, afwidth, distance);");
}
@@ -447,7 +447,7 @@
// mapped linearly to coverage, so use a linear step:
if (isGammaCorrect) {
fragBuilder->codeAppend(
- "half val = clamp((distance + afwidth) / (2.0 * afwidth), 0.0, 1.0);");
+ "half val = saturate((distance + afwidth) / (2.0 * afwidth));");
} else {
fragBuilder->codeAppend("half val = smoothstep(-afwidth, afwidth, distance);");
}
@@ -766,7 +766,7 @@
// mapped linearly to coverage, so use a linear step:
if (isGammaCorrect) {
fragBuilder->codeAppendf("%s = "
- "half4(clamp((distance + half3(afwidth)) / half3(2.0 * afwidth), 0.0, 1.0), 1.0);",
+ "half4(saturate((distance + half3(afwidth)) / half3(2.0 * afwidth)), 1.0);",
args.fOutputCoverage);
} else {
fragBuilder->codeAppendf(