From 85f019a8e7d33cbba368a6c6b75fd091269e14a1 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Fri, 17 Mar 2017 15:14:19 -0700 Subject: Add pdfium::clamp() as a placeholder for std::clamp(). 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 Reviewed-by: Tom Sepez --- core/fpdfapi/render/cpdf_imagerenderer.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'core/fpdfapi/render') diff --git a/core/fpdfapi/render/cpdf_imagerenderer.cpp b/core/fpdfapi/render/cpdf_imagerenderer.cpp index 7903ad4a62..d3778452a3 100644 --- a/core/fpdfapi/render/cpdf_imagerenderer.cpp +++ b/core/fpdfapi/render/cpdf_imagerenderer.cpp @@ -30,6 +30,7 @@ #include "core/fxge/cfx_fxgedevice.h" #include "core/fxge/cfx_pathdata.h" #include "third_party/base/ptr_util.h" +#include "third_party/base/stl_util.h" #ifdef _SKIA_SUPPORT_ #include "core/fxge/skia/fx_skia_device.h" @@ -273,11 +274,11 @@ void CPDF_ImageRenderer::CalculateDrawImage(CFX_FxgeDevice* pBitmapDevice1, continue; } int orig = (*dest_scan - matte_b) * 255 / alpha + matte_b; - *dest_scan++ = std::min(std::max(orig, 0), 255); + *dest_scan++ = pdfium::clamp(orig, 0, 255); orig = (*dest_scan - matte_g) * 255 / alpha + matte_g; - *dest_scan++ = std::min(std::max(orig, 0), 255); + *dest_scan++ = pdfium::clamp(orig, 0, 255); orig = (*dest_scan - matte_r) * 255 / alpha + matte_r; - *dest_scan++ = std::min(std::max(orig, 0), 255); + *dest_scan++ = pdfium::clamp(orig, 0, 255); dest_scan++; } } -- cgit v1.2.3