Fix lost precision case in SkComputeRadialSteps.
With large offsets, we can end up with a tiny change in angle at each radial step, so that rotSin and rotCos can get truncated to 0 and/or 1, respectively. This means that we won't sweep the entire radial distance, throwing future calculations off. Instead in this case we should fail. Bug: oss-fuzz:21826 Change-Id: I24f5b1ac315a3697d2ea00ee4bd73652ec3e16dd Reviewed-on: https://skia-review.googlesource.com/c/skia/+/392377 Commit-Queue: Jim Van Verth <jvanverth@google.com> Reviewed-by: Kevin Lubick <kjlubick@google.com>
This commit is contained in:
parent
3144a1e698
commit
ffeee9bfde
@ -494,6 +494,11 @@ bool SkComputeRadialSteps(const SkVector& v1, const SkVector& v2, SkScalar offse
|
||||
SkScalar dTheta = steps > 0 ? theta / steps : 0;
|
||||
*rotSin = SkScalarSin(dTheta);
|
||||
*rotCos = SkScalarCos(dTheta);
|
||||
// Our offset may be so large that we end up with a tiny dTheta, in which case we
|
||||
// lose precision when computing rotSin and rotCos.
|
||||
if (steps > 0 && (*rotSin == 0 || *rotCos == 1)) {
|
||||
return false;
|
||||
}
|
||||
*n = steps;
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user