summaryrefslogtreecommitdiff
path: root/core/fpdfapi/render/cpdf_renderstatus.cpp
diff options
context:
space:
mode:
authorHenrique Nakashima <hnakashima@chromium.org>2018-08-29 21:23:38 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-08-29 21:23:38 +0000
commit9e90e7987de10832b505cc0b46abf502b6f5eb7a (patch)
tree920e1502184d8d48c4b1007058293f2d9a149a44 /core/fpdfapi/render/cpdf_renderstatus.cpp
parent456e9703276d803f633d5e8a6b5ee485f4e4207a (diff)
downloadpdfium-9e90e7987de10832b505cc0b46abf502b6f5eb7a.tar.xz
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 <rharrison@chromium.org> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
Diffstat (limited to 'core/fpdfapi/render/cpdf_renderstatus.cpp')
-rw-r--r--core/fpdfapi/render/cpdf_renderstatus.cpp6
1 files changed, 5 insertions, 1 deletions
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<CFX_DIBitmap>& 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<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) {
+ if (a == 0.0f) {
s = -c / b;
} else {
float b2_4ac = (b * b) - 4 * (a * c);