diff options
author | Henrique Nakashima <hnakashima@chromium.org> | 2018-08-31 16:00:10 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-08-31 16:00:10 +0000 |
commit | 2c0ef6a69dde06662d77fe9d2e80c4adb9b076cd (patch) | |
tree | 8a6b8d40db3c4b1767c92f717b34c294361772bc /core/fpdfapi | |
parent | b2d25960b75685aaed5ec1a0ac60975cd033a448 (diff) | |
download | pdfium-2c0ef6a69dde06662d77fe9d2e80c4adb9b076cd.tar.xz |
Fix radial shading when start circle is a point in the center of end circle.
The bug also requires end circle to be tiny (radius of < 0.01).
Bug: pdfium:1140
Change-Id: I2b355f44f0383334b8988fe41f82cb3f587e9909
Reviewed-on: https://pdfium-review.googlesource.com/41672
Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'core/fpdfapi')
-rw-r--r-- | core/fpdfapi/render/cpdf_renderstatus.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp index 95d3cbe5de..c9b98f3bb6 100644 --- a/core/fpdfapi/render/cpdf_renderstatus.cpp +++ b/core/fpdfapi/render/cpdf_renderstatus.cpp @@ -260,11 +260,10 @@ void DrawRadialShading(const RetainPtr<CFX_DIBitmap>& pBitmap, FXARGB_TODIB(ArgbEncode(alpha, FXSYS_round(R * 255), FXSYS_round(G * 255), FXSYS_round(B * 255))); } - float a = ((start_x - end_x) * (start_x - end_x)) + - ((start_y - end_y) * (start_y - end_y)) - - ((start_r - end_r) * (start_r - end_r)); - if (IsFloatZero(a)) - a = 0.0f; + const float a = ((start_x - end_x) * (start_x - end_x)) + + ((start_y - end_y) * (start_y - end_y)) - + ((start_r - end_r) * (start_r - end_r)); + const bool a_is_float_zero = IsFloatZero(a); int width = pBitmap->GetWidth(); int height = pBitmap->GetHeight(); @@ -289,7 +288,9 @@ void DrawRadialShading(const RetainPtr<CFX_DIBitmap>& pBitmap, float c = ((pos.x - start_x) * (pos.x - start_x)) + ((pos.y - start_y) * (pos.y - start_y)) - (start_r * start_r); float s; - if (a == 0.0f) { + if (IsFloatZero(b)) { + s = sqrt(-c / a); + } else if (a_is_float_zero) { s = -c / b; } else { float b2_4ac = (b * b) - 4 * (a * c); |