diff options
author | Yuqian Li <liyuqian@google.com> | 2017-12-28 10:04:04 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-12-28 15:23:00 +0000 |
commit | fa8bc34f2884655c7699ae60e4c6536ac86ddecb (patch) | |
tree | 223b13648a53c333e63c535db248f566fe21dc1b /src/shaders | |
parent | b2a8e1c29fd51609015e90191e194224ee0ae139 (diff) |
Fix bug of a + (b - a) == 0 for small positive b and huge a (e.g., 1e18)
I am unable to make a MSAN build to work locally. But I think that this
should fix the problem by looking at the gradient of the fuzzer:
Z.createRadialGradient(1.94159387872, 138.616510533, 2.22085316544e+18,
10.3399911492, 176.149195942, 153.078363987);
Bug: chromium:797184
Change-Id: I16c571a378742c4ef50afe9c5baba791da7fc208
Reviewed-on: https://skia-review.googlesource.com/89541
Commit-Queue: Yuqian Li <liyuqian@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Diffstat (limited to 'src/shaders')
-rw-r--r-- | src/shaders/gradients/SkTwoPointConicalGradient_gpu.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/shaders/gradients/SkTwoPointConicalGradient_gpu.cpp b/src/shaders/gradients/SkTwoPointConicalGradient_gpu.cpp index 975f7bb381..a2721b464f 100644 --- a/src/shaders/gradients/SkTwoPointConicalGradient_gpu.cpp +++ b/src/shaders/gradients/SkTwoPointConicalGradient_gpu.cpp @@ -455,7 +455,9 @@ TwoPointConicalEffect::Data::Data(const SkTwoPointConicalGradient& shader, SkMat fType = kStrip_Type; } else { // focal case fType = kFocal_Type; - if (SkScalarNearlyZero(shader.getEndRadius())) { + // We want to check if the end radius is zero and if so we swap it with the start + // radius. Because of numerical precision, we check if r0 + (r1-r0) is zero + if (SkScalarNearlyZero(fRadius0 + fDiffRadius)) { // swap r0, r1 matrix.postTranslate(-1, 0); matrix.postScale(-1, 1); |