summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-06-25 19:07:43 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-06-25 19:07:43 +0000
commit8256f1f063793da1e0b4c34884a4e52d5df935c2 (patch)
treeb74b6f29e1761680a85fb8161cccfc70defa93ab
parent5339261bb3498566dffe063401b5fa16d32b7c79 (diff)
downloadpdfium-8256f1f063793da1e0b4c34884a4e52d5df935c2.tar.xz
Make DrawRadialShading() slightly more compact.
Change-Id: Ic0e528d01338a349deb1ee5a91372b132959e4ae Reviewed-on: https://pdfium-review.googlesource.com/35971 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
-rw-r--r--core/fpdfapi/render/cpdf_renderstatus.cpp32
1 files changed, 9 insertions, 23 deletions
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<CFX_DIBitmap>& 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<CFX_DIBitmap>& pBitmap,
continue;
}
index = 0;
- }
- if (index >= kShadingSteps) {
+ } else if (index >= kShadingSteps) {
if (!bEndExtend) {
continue;
}