summaryrefslogtreecommitdiff
path: root/core/fpdfapi/page/cpdf_colorspace.cpp
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2017-03-17 15:14:19 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-03-17 22:54:26 +0000
commit85f019a8e7d33cbba368a6c6b75fd091269e14a1 (patch)
tree8dcf6fcd98309a48ebbd9e46cc8c0d23a57c0965 /core/fpdfapi/page/cpdf_colorspace.cpp
parent240fe6d79f234896a966ddce0b9a125776dc9171 (diff)
downloadpdfium-85f019a8e7d33cbba368a6c6b75fd091269e14a1.tar.xz
Add pdfium::clamp() as a placeholder for std::clamp().chromium/3046
Ue it to fix a typo as well. BUG=pdfium:634 Change-Id: I2d686242ffb841aedc2fae6a3cf7a00bea667404 Reviewed-on: https://pdfium-review.googlesource.com/3113 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fpdfapi/page/cpdf_colorspace.cpp')
-rw-r--r--core/fpdfapi/page/cpdf_colorspace.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/core/fpdfapi/page/cpdf_colorspace.cpp b/core/fpdfapi/page/cpdf_colorspace.cpp
index 1aaa1440a4..cc4afa55c9 100644
--- a/core/fpdfapi/page/cpdf_colorspace.cpp
+++ b/core/fpdfapi/page/cpdf_colorspace.cpp
@@ -24,6 +24,7 @@
#include "core/fxcodec/fx_codec.h"
#include "core/fxcrt/cfx_maybe_owned.h"
#include "core/fxcrt/fx_memory.h"
+#include "third_party/base/stl_util.h"
namespace {
@@ -227,7 +228,7 @@ class CPDF_DeviceNCS : public CPDF_ColorSpace {
};
float RGB_Conversion(float colorComponent) {
- colorComponent = std::min(std::max(colorComponent, 0.0f), 1.0f);
+ colorComponent = pdfium::clamp(colorComponent, 0.0f, 1.0f);
int scale = std::max(static_cast<int>(colorComponent * 1023), 0);
if (scale < 192)
return g_sRGBSamples1[scale] / 255.0f;
@@ -686,11 +687,12 @@ void CPDF_LabCS::GetDefaultValue(int iComponent,
*min = 0.0f;
*max = 100 * 1.0f;
*value = 0.0f;
- } else {
- *min = m_Ranges[iComponent * 2 - 2];
- *max = m_Ranges[iComponent * 2 - 1];
- *value = std::min(std::max(0.0f, *min), *max);
+ return;
}
+
+ *min = m_Ranges[iComponent * 2 - 2];
+ *max = m_Ranges[iComponent * 2 - 1];
+ *value = pdfium::clamp(0.0f, *min, *max);
}
bool CPDF_LabCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) {