aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/effects/GrEllipseEffect.fp
diff options
context:
space:
mode:
authorGravatar Ethan Nicholas <ethannicholas@google.com>2017-08-16 16:41:30 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-08-16 23:05:15 +0000
commit88d99c63878c2d3d340120f0321676f72afcb4f0 (patch)
tree5b957dbf2f78ef7a15aa3810f8922c915508683f /src/gpu/effects/GrEllipseEffect.fp
parenta26d219a929f4e70f8597dfd57a53348c4bba905 (diff)
Switched highp float to highfloat and mediump float to half.
The ultimate goal is to end up with "float" and "half", but this intermediate step uses "highfloat" so that it is clear if I missed a "float" somewhere. Once this lands, a subsequent CL will switch all "highfloats" back to "floats". Bug: skia: Change-Id: Ia13225c7a0a0a2901e07665891c473d2500ddcca Reviewed-on: https://skia-review.googlesource.com/31000 Commit-Queue: Ethan Nicholas <ethannicholas@google.com> Reviewed-by: Brian Salomon <bsalomon@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;