aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/effects/GrEllipseEffect.fp
diff options
context:
space:
mode:
authorGravatar Ethan Nicholas <ethannicholas@google.com>2017-09-18 14:10:39 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-09-18 18:32:13 +0000
commitf7b8820dc813d1eb0b6b43fe4581dded0da38caf (patch)
tree518d313a9fa571a9f9ca26af7c381664694a4706 /src/gpu/effects/GrEllipseEffect.fp
parent47a540f503bc722393b61c4b822e95b17f200125 (diff)
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>
Diffstat (limited to 'src/gpu/effects/GrEllipseEffect.fp')
-rw-r--r--src/gpu/effects/GrEllipseEffect.fp26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/gpu/effects/GrEllipseEffect.fp b/src/gpu/effects/GrEllipseEffect.fp
index 85c4c96f75..3663d5622e 100644
--- a/src/gpu/effects/GrEllipseEffect.fp
+++ b/src/gpu/effects/GrEllipseEffect.fp
@@ -6,17 +6,17 @@
*/
layout(key) in int edgeType;
-in float2 center;
-in float2 radii;
+in half2 center;
+in half2 radii;
-float2 prevCenter;
-float2 prevRadii = float2(-1);
+half2 prevCenter;
+half2 prevRadii = half2(-1);
// The ellipse uniform is (center.x, center.y, 1 / rx^2, 1 / ry^2)
-// The last two terms can underflow on mediump, so we use highp.
-uniform highp float4 ellipse;
+// The last two terms can underflow with halfs, so we use floats.
+uniform highfloat4 ellipse;
bool useScale = sk_Caps.floatPrecisionVaries;
-layout(when=useScale) uniform float2 scale;
+layout(when=useScale) uniform half2 scale;
@optimizationFlags { kCompatibleWithCoverageAsAlpha_OptimizationFlag }
@@ -50,7 +50,7 @@ layout(when=useScale) uniform float2 scale;
void main() {
// d is the offset to the ellipse center
- float2 d = sk_FragCoord.xy - ellipse.xy;
+ half2 d = sk_FragCoord.xy - ellipse.xy;
// If we're on a device with a "real" mediump then we'll do the distance computation in a space
// that is normalized by the larger radius. The scale uniform will be scale, 1/scale. The
// inverse squared radii uniform values are already in this normalized space. The center is
@@ -58,19 +58,19 @@ void main() {
@if (useScale) {
d *= scale.y;
}
- float2 Z = d * ellipse.zw;
+ half2 Z = d * ellipse.zw;
// implicit is the evaluation of (x/rx)^2 + (y/ry)^2 - 1.
- float implicit = dot(Z, d) - 1;
+ half implicit = dot(Z, d) - 1;
// grad_dot is the squared length of the gradient of the implicit.
- float grad_dot = 4 * dot(Z, Z);
+ half grad_dot = 4 * dot(Z, Z);
// Avoid calling inversesqrt on zero.
grad_dot = max(grad_dot, 1e-4);
- float approx_dist = implicit * inversesqrt(grad_dot);
+ half approx_dist = implicit * inversesqrt(grad_dot);
@if (useScale) {
approx_dist *= scale.x;
}
- float alpha;
+ half alpha;
@switch (edgeType) {
case 0 /* kFillBW_GrProcessorEdgeType */:
alpha = approx_dist > 0.0 ? 0.0 : 1.0;