re-land of new SkSL precisions
Bug: skia:
Change-Id: Ic1deb3db2cbda6ca45f93dee99832971a36a2119
Reviewed-on: https://skia-review.googlesource.com/47841
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
diff --git a/src/gpu/effects/GrCircleEffect.cpp b/src/gpu/effects/GrCircleEffect.cpp
index b764559..7b4a9f7 100644
--- a/src/gpu/effects/GrCircleEffect.cpp
+++ b/src/gpu/effects/GrCircleEffect.cpp
@@ -24,14 +24,15 @@
const GrCircleEffect& _outer = args.fFp.cast<GrCircleEffect>();
(void)_outer;
prevRadius = -1.0;
- fCircleVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kVec4f_GrSLType,
+ fCircleVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf4_GrSLType,
kDefault_GrSLPrecision, "circle");
fragBuilder->codeAppendf(
- "float2 prevCenter;\nfloat prevRadius = %f;\nfloat d;\n@if (%d == 2 || %d == 3) "
- "{\n d = (length((%s.xy - sk_FragCoord.xy) * %s.w) - 1.0) * %s.z;\n} else {\n "
- " d = (1.0 - length((%s.xy - sk_FragCoord.xy) * %s.w)) * %s.z;\n}\n@if ((%d == 1 "
- "|| %d == 3) || %d == 4) {\n d = clamp(d, 0.0, 1.0);\n} else {\n d = d > 0.5 "
- "? 1.0 : 0.0;\n}\n%s = %s * d;\n",
+ "half2 prevCenter;\nhalf prevRadius = %f;\nhalf d;\n@if (%d == 2 || %d == 3) {\n "
+ " d = (highfloat(length((%s.xy - half2(sk_FragCoord.xy)) * %s.w)) - 1.0) * "
+ "%s.z;\n} else {\n d = half((1.0 - highfloat(length((%s.xy - "
+ "half2(sk_FragCoord.xy)) * %s.w))) * highfloat(%s.z));\n}\n@if ((%d == 1 || %d == "
+ "3) || %d == 4) {\n d = half(clamp(highfloat(d), 0.0, 1.0));\n} else {\n d = "
+ "half(highfloat(d) > 0.5 ? 1.0 : 0.0);\n}\n%s = %s * d;\n",
prevRadius, _outer.edgeType(), _outer.edgeType(),
args.fUniformHandler->getUniformCStr(fCircleVar),
args.fUniformHandler->getUniformCStr(fCircleVar),
@@ -40,7 +41,7 @@
args.fUniformHandler->getUniformCStr(fCircleVar),
args.fUniformHandler->getUniformCStr(fCircleVar), _outer.edgeType(),
_outer.edgeType(), _outer.edgeType(), args.fOutputColor,
- args.fInputColor ? args.fInputColor : "float4(1)");
+ args.fInputColor ? args.fInputColor : "half4(1)");
}
private: