Harden initial LinearGradient4f tiling
Even with verified/finite inputs, fx can sometimes collapse to infinity. When that happens, attempting to apply repeat/mirror tiling produces NaN results and things go south. Catch these degenerate cases and tile to 0 (for lack of a better idea). Note: leaving fx == +/- inf in clamp mode should be safe. BUG=oss-fuzz:6622 Change-Id: I65711020057856b47045f67a52d906336ad1f173 Reviewed-on: https://skia-review.googlesource.com/114090 Reviewed-by: Kevin Lubick <kjlubick@google.com> Commit-Queue: Florin Malita <fmalita@chromium.org>
This commit is contained in:
parent
df574048f5
commit
40481bb392
@ -56,7 +56,7 @@ SkScalar pinFx<SkShader::kClamp_TileMode>(SkScalar fx) {
|
||||
|
||||
template<>
|
||||
SkScalar pinFx<SkShader::kRepeat_TileMode>(SkScalar fx) {
|
||||
SkScalar f = SkScalarFraction(fx);
|
||||
SkScalar f = SkScalarIsFinite(fx) ? SkScalarFraction(fx) : 0;
|
||||
if (f < 0) {
|
||||
f = SkTMin(f + 1, nextafterf(1, 0));
|
||||
}
|
||||
@ -67,7 +67,7 @@ SkScalar pinFx<SkShader::kRepeat_TileMode>(SkScalar fx) {
|
||||
|
||||
template<>
|
||||
SkScalar pinFx<SkShader::kMirror_TileMode>(SkScalar fx) {
|
||||
SkScalar f = SkScalarMod(fx, 2.0f);
|
||||
SkScalar f = SkScalarIsFinite(fx) ? SkScalarMod(fx, 2.0f) : 0;
|
||||
if (f < 0) {
|
||||
f = SkTMin(f + 2, nextafterf(2, 0));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user