From 2c0ef6a69dde06662d77fe9d2e80c4adb9b076cd Mon Sep 17 00:00:00 2001 From: Henrique Nakashima Date: Fri, 31 Aug 2018 16:00:10 +0000 Subject: 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 Reviewed-by: Lei Zhang Reviewed-by: Ryan Harrison --- core/fpdfapi/render/cpdf_renderstatus.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'core') 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& 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& 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); -- cgit v1.2.3