Replace manually-implemented lerp with mix().

Change-Id: I6bf3cac6df654a0b23ced250df90716f6856ed29
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/307197
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
This commit is contained in:
John Stiles 2020-07-31 11:54:52 -04:00 committed by Skia Commit-Bot
parent cec3a60426
commit 2d01ed9460
2 changed files with 3 additions and 3 deletions

View File

@ -5,7 +5,7 @@
* found in the LICENSE file.
*/
// This only supports a 2-color single interval so it is a simple linear interpolation between the
// This only supports a 2-color single interval so it is a simple linear interpolation between the
// two end points based on t. But it serves as a good test for connecting all of the plumbing into a
// functional gradient shader.
@ -17,5 +17,5 @@ void main() {
// Clamping and/or wrapping was already handled by the parent shader so the output color is a
// simple lerp.
sk_OutColor = (1 - t) * start + t * end;
sk_OutColor = mix(start, end, t);
}

View File

@ -35,7 +35,7 @@ public:
"end");
fragBuilder->codeAppendf(
R"SkSL(half t = %s.x;
%s = (1.0 - t) * %s + t * %s;
%s = mix(%s, %s, t);
)SkSL",
args.fInputColor, args.fOutputColor, args.fUniformHandler->getUniformCStr(startVar),
args.fUniformHandler->getUniformCStr(endVar));