From 9e90e7987de10832b505cc0b46abf502b6f5eb7a Mon Sep 17 00:00:00 2001 From: Henrique Nakashima Date: Wed, 29 Aug 2018 21:23:38 +0000 Subject: Fix radial shading when center of start point is on the border of an end circle. Radial shading is done between two circles with their own centers and radii. When one has a radius of 0 and is located on or very close to the border of the other circle, a should be 0, but is not due to rounding errors unless the circles are aligned in x or y. Bug: pdfium:1140 Change-Id: Ief2efa91f3f16f7bed439aa471b258fa4d680acf Reviewed-on: https://pdfium-review.googlesource.com/41590 Reviewed-by: Ryan Harrison Commit-Queue: Henrique Nakashima --- core/fpdfapi/render/cpdf_renderstatus.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp index 9965cbb945..95d3cbe5de 100644 --- a/core/fpdfapi/render/cpdf_renderstatus.cpp +++ b/core/fpdfapi/render/cpdf_renderstatus.cpp @@ -50,6 +50,7 @@ #include "core/fpdfdoc/cpdf_occontext.h" #include "core/fxcrt/autorestorer.h" #include "core/fxcrt/fx_safe_types.h" +#include "core/fxcrt/fx_system.h" #include "core/fxcrt/maybe_owned.h" #include "core/fxge/cfx_defaultrenderdevice.h" #include "core/fxge/cfx_graphstatedata.h" @@ -262,6 +263,9 @@ void DrawRadialShading(const RetainPtr& pBitmap, 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; + int width = pBitmap->GetWidth(); int height = pBitmap->GetHeight(); int pitch = pBitmap->GetPitch(); @@ -285,7 +289,7 @@ 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) { + if (a == 0.0f) { s = -c / b; } else { float b2_4ac = (b * b) - 4 * (a * c); -- cgit v1.2.3