From 8256f1f063793da1e0b4c34884a4e52d5df935c2 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Mon, 25 Jun 2018 19:07:43 +0000 Subject: Make DrawRadialShading() slightly more compact. Change-Id: Ic0e528d01338a349deb1ee5a91372b132959e4ae Reviewed-on: https://pdfium-review.googlesource.com/35971 Reviewed-by: Henrique Nakashima Commit-Queue: Lei Zhang --- core/fpdfapi/render/cpdf_renderstatus.cpp | 32 +++++++++---------------------- 1 file changed, 9 insertions(+), 23 deletions(-) (limited to 'core') diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp index 1eab9cf233..653d657984 100644 --- a/core/fpdfapi/render/cpdf_renderstatus.cpp +++ b/core/fpdfapi/render/cpdf_renderstatus.cpp @@ -293,27 +293,14 @@ void DrawRadialShading(const RetainPtr& pBitmap, continue; } float root = sqrt(b2_4ac); - float s1, s2; - if (a > 0) { - s1 = (-b - root) / (2 * a); - s2 = (-b + root) / (2 * a); - } else { - s2 = (-b - root) / (2 * a); - s1 = (-b + root) / (2 * a); - } - if (bDecreasing) { - if (s1 >= 0 || bStartExtend) { - s = s1; - } else { - s = s2; - } - } else { - if (s2 <= 1.0f || bEndExtend) { - s = s2; - } else { - s = s1; - } - } + float s1 = (-b - root) / (2 * a); + float s2 = (-b + root) / (2 * a); + if (a <= 0) + std::swap(s1, s2); + if (bDecreasing) + s = (s1 >= 0 || bStartExtend) ? s1 : s2; + else + s = (s2 <= 1.0f || bEndExtend) ? s2 : s1; if ((start_r + s * (end_r - start_r)) < 0) { continue; } @@ -324,8 +311,7 @@ void DrawRadialShading(const RetainPtr& pBitmap, continue; } index = 0; - } - if (index >= kShadingSteps) { + } else if (index >= kShadingSteps) { if (!bEndExtend) { continue; } -- cgit v1.2.3