summaryrefslogtreecommitdiff
path: root/core/fpdfapi/page/cpdf_allstates.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_allstates.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_allstates.cpp')
-rw-r--r--core/fpdfapi/page/cpdf_allstates.cpp15
1 files changed, 5 insertions, 10 deletions
diff --git a/core/fpdfapi/page/cpdf_allstates.cpp b/core/fpdfapi/page/cpdf_allstates.cpp
index a30696e8b7..c67d3152c0 100644
--- a/core/fpdfapi/page/cpdf_allstates.cpp
+++ b/core/fpdfapi/page/cpdf_allstates.cpp
@@ -14,14 +14,7 @@
#include "core/fpdfapi/parser/cpdf_array.h"
#include "core/fpdfapi/parser/cpdf_dictionary.h"
#include "core/fxge/cfx_graphstatedata.h"
-
-namespace {
-
-float ClipFloat(float f) {
- return std::max(0.0f, std::min(1.0f, f));
-}
-
-} // namespace
+#include "third_party/base/stl_util.h"
CPDF_AllStates::CPDF_AllStates()
: m_TextLeading(0), m_TextRise(0), m_TextHorzScale(1.0f) {}
@@ -117,10 +110,12 @@ void CPDF_AllStates::ProcessExtGS(CPDF_Dictionary* pGS,
}
break;
case FXBSTR_ID('C', 'A', 0, 0):
- m_GeneralState.SetStrokeAlpha(ClipFloat(pObject->GetNumber()));
+ m_GeneralState.SetStrokeAlpha(
+ pdfium::clamp(pObject->GetNumber(), 0.0f, 1.0f));
break;
case FXBSTR_ID('c', 'a', 0, 0):
- m_GeneralState.SetFillAlpha(ClipFloat(pObject->GetNumber()));
+ m_GeneralState.SetFillAlpha(
+ pdfium::clamp(pObject->GetNumber(), 0.0f, 1.0f));
break;
case FXBSTR_ID('O', 'P', 0, 0):
m_GeneralState.SetStrokeOP(!!pObject->GetInteger());