Avoid passing gradient-layout Y coordinate to colorizer.
The Y coordinate isn't meant to be interpreted as a coordinate. It's
used as a side channel for the discard signal.
Change-Id: Idbdd470c78c49a8b0a28eb05a93905c95b3282d1
Bug: skia:10548
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/307297
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
diff --git a/src/gpu/gradients/GrClampedGradientEffect.fp b/src/gpu/gradients/GrClampedGradientEffect.fp
index 7704609..400346c 100644
--- a/src/gpu/gradients/GrClampedGradientEffect.fp
+++ b/src/gpu/gradients/GrClampedGradientEffect.fp
@@ -38,7 +38,8 @@
} else if (t.x > 1.0) {
sk_OutColor = rightBorderColor;
} else {
- sk_OutColor = sample(colorizer, t.xy);
+ // Always sample from (x, 0), discarding y, since the layout FP can use y as a side-channel.
+ sk_OutColor = sample(colorizer, t.x0);
}
@if (makePremul) {
diff --git a/src/gpu/gradients/GrTiledGradientEffect.fp b/src/gpu/gradients/GrTiledGradientEffect.fp
index 626a4fc..370f48a 100644
--- a/src/gpu/gradients/GrTiledGradientEffect.fp
+++ b/src/gpu/gradients/GrTiledGradientEffect.fp
@@ -23,7 +23,7 @@
// preserves opacity is false)
sk_OutColor = half4(0);
} else {
- @if(mirror) {
+ @if (mirror) {
half t_1 = t.x - 1;
half tiled_t = t_1 - 2 * floor(t_1 * 0.5) - 1;
if (sk_Caps.mustDoOpBetweenFloorAndAbs) {
@@ -38,9 +38,8 @@
t.x = fract(t.x);
}
- // t.x has been tiled (repeat or mirrored), but pass through remaining 3 components
- // unmodified.
- sk_OutColor = sample(colorizer, t.xy);
+ // Always sample from (x, 0), discarding y, since the layout FP can use y as a side-channel.
+ sk_OutColor = sample(colorizer, t.x0);
}
@if (makePremul) {
diff --git a/src/gpu/gradients/generated/GrClampedGradientEffect.cpp b/src/gpu/gradients/generated/GrClampedGradientEffect.cpp
index 2f5b0a3..29a8644 100644
--- a/src/gpu/gradients/generated/GrClampedGradientEffect.cpp
+++ b/src/gpu/gradients/generated/GrClampedGradientEffect.cpp
@@ -51,8 +51,8 @@
args.fOutputColor, args.fOutputColor,
args.fUniformHandler->getUniformCStr(leftBorderColorVar), args.fOutputColor,
args.fUniformHandler->getUniformCStr(rightBorderColorVar));
- SkString _coords1767("float2(t.xy)");
- SkString _sample1767 = this->invokeChild(0, args, _coords1767.c_str());
+ SkString _coords1868("float2(half2(t.x, 0))");
+ SkString _sample1868 = this->invokeChild(0, args, _coords1868.c_str());
fragBuilder->codeAppendf(
R"SkSL(
%s = %s;
@@ -61,7 +61,7 @@
%s.xyz *= %s.w;
}
)SkSL",
- args.fOutputColor, _sample1767.c_str(), (_outer.makePremul ? "true" : "false"),
+ args.fOutputColor, _sample1868.c_str(), (_outer.makePremul ? "true" : "false"),
args.fOutputColor, args.fOutputColor);
}
diff --git a/src/gpu/gradients/generated/GrTiledGradientEffect.cpp b/src/gpu/gradients/generated/GrTiledGradientEffect.cpp
index 9ad5ca7..235b9d4 100644
--- a/src/gpu/gradients/generated/GrTiledGradientEffect.cpp
+++ b/src/gpu/gradients/generated/GrTiledGradientEffect.cpp
@@ -49,8 +49,8 @@
_sample453.c_str(),
(_outer.childProcessor(1)->preservesOpaqueInput() ? "true" : "false"),
args.fOutputColor, (_outer.mirror ? "true" : "false"));
- SkString _coords1464("float2(t.xy)");
- SkString _sample1464 = this->invokeChild(0, args, _coords1464.c_str());
+ SkString _coords1451("float2(half2(t.x, 0))");
+ SkString _sample1451 = this->invokeChild(0, args, _coords1451.c_str());
fragBuilder->codeAppendf(
R"SkSL(
%s = %s;
@@ -59,7 +59,7 @@
%s.xyz *= %s.w;
}
)SkSL",
- args.fOutputColor, _sample1464.c_str(), (_outer.makePremul ? "true" : "false"),
+ args.fOutputColor, _sample1451.c_str(), (_outer.makePremul ? "true" : "false"),
args.fOutputColor, args.fOutputColor);
}