Reland "SkSL is now pickier about type conversions"
This is a reland of 91c1d08bc391c997418512b9599f3acd3b2c985d
Original change's description:
> SkSL is now pickier about type conversions
>
> Bug: skia:
> Change-Id: I4e8b8f229f4e4344f160b0dbb41832764d0b75bd
> Reviewed-on: https://skia-review.googlesource.com/c/188311
> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
> Reviewed-by: Brian Salomon <bsalomon@google.com>
Bug: skia:
Change-Id: I727cad061afc0a5ee6f4d2df789330d809dd110a
Reviewed-on: https://skia-review.googlesource.com/c/189643
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
diff --git a/src/gpu/ccpr/GrCCCubicShader.cpp b/src/gpu/ccpr/GrCCCubicShader.cpp
index f869c73..7336bb0 100644
--- a/src/gpu/ccpr/GrCCCubicShader.cpp
+++ b/src/gpu/ccpr/GrCCCubicShader.cpp
@@ -128,7 +128,7 @@
// Wind is the sign of both L and/or M. Take the sign of whichever has the larger magnitude.
// (In reality, either would be fine because we chop cubics with more than a half pixel of
// padding around the L & M lines, so neither should approach zero.)
- f->codeAppend ("half wind = sign(l + m);");
+ f->codeAppend ("half wind = sign(half(l + m));");
f->codeAppendf("%s *= wind;", outputCoverage);
if (fCornerCoverage.fsIn()) {
@@ -144,7 +144,9 @@
code->append ("float f = k*k*k - l*m;");
code->appendf("float2 grad = %s.xy * k + %s.zw;", gradMatrix, gradMatrix);
code->append ("float fwidth = abs(grad.x) + abs(grad.y);");
- code->appendf("%s = min(0.5 - f/fwidth, 1);", outputCoverage); // Curve coverage.
- code->appendf("half d = min(%s.w, 0);", klmAndEdge); // Flat edge opposite the curve.
- code->appendf("%s = max(%s + d, 0);", outputCoverage, outputCoverage); // Total hull coverage.
+ code->appendf("float curve_coverage = min(0.5 - f/fwidth, 1);");
+ // Flat edge opposite the curve.
+ code->appendf("float edge_coverage = min(%s.w, 0);", klmAndEdge);
+ // Total hull coverage.
+ code->appendf("%s = max(half(curve_coverage + edge_coverage), 0);", outputCoverage);
}