diff options
author | Lei Zhang <thestig@chromium.org> | 2016-01-11 11:59:17 -0800 |
---|---|---|
committer | Lei Zhang <thestig@chromium.org> | 2016-01-11 11:59:17 -0800 |
commit | 375a86403b7fa8d17d7b142c270e2d8e33bb924f (patch) | |
tree | 1db1ffddb2bbbcd429cd1d7954b1949bfa54e1ab /core/src/fpdfapi | |
parent | 492961df3011ccc25646eae12ac6e6dcfe7f26da (diff) | |
download | pdfium-375a86403b7fa8d17d7b142c270e2d8e33bb924f.tar.xz |
Merge to XFA: Switch most min/max macros to std::min/max.
Fix lint errors along the way.
R=tsepez@chromium.org
TBR=tsepez@chromium.org
Review URL: https://codereview.chromium.org/1567343002 .
(cherry picked from commit 9adfbb0920a258e916003b1ee9515e97879db82a)
Review URL: https://codereview.chromium.org/1577503002 .
Diffstat (limited to 'core/src/fpdfapi')
-rw-r--r-- | core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp | 60 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp | 5 |
2 files changed, 38 insertions, 27 deletions
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp index 168cbf3a61..87b9e025bc 100644 --- a/core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp +++ b/core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp @@ -8,6 +8,8 @@ #include <limits.h> +#include <algorithm> + #include "core/include/fpdfapi/fpdf_page.h" #include "core/include/fpdfapi/fpdf_module.h" #include "core/include/fxcodec/fx_codec.h" @@ -41,6 +43,24 @@ int ComponentsForFamily(int family) { return 4; } +void ReverseRGB(uint8_t* pDestBuf, const uint8_t* pSrcBuf, int pixels) { + if (pDestBuf == pSrcBuf) { + for (int i = 0; i < pixels; i++) { + uint8_t temp = pDestBuf[2]; + pDestBuf[2] = pDestBuf[0]; + pDestBuf[0] = temp; + pDestBuf += 3; + } + } else { + for (int i = 0; i < pixels; i++) { + *pDestBuf++ = pSrcBuf[2]; + *pDestBuf++ = pSrcBuf[1]; + *pDestBuf++ = pSrcBuf[0]; + pSrcBuf += 3; + } + } +} + } // namespace CPDF_DeviceCS::CPDF_DeviceCS(CPDF_Document* pDoc, int family) @@ -82,9 +102,9 @@ FX_BOOL CPDF_DeviceCS::GetRGB(FX_FLOAT* pBuf, AdobeCMYK_to_sRGB(pBuf[0], pBuf[1], pBuf[2], pBuf[3], R, G, B); } else { FX_FLOAT k = pBuf[3]; - R = 1.0f - FX_MIN(1.0f, pBuf[0] + k); - G = 1.0f - FX_MIN(1.0f, pBuf[1] + k); - B = 1.0f - FX_MIN(1.0f, pBuf[2] + k); + R = 1.0f - std::min(1.0f, pBuf[0] + k); + G = 1.0f - std::min(1.0f, pBuf[1] + k); + B = 1.0f - std::min(1.0f, pBuf[2] + k); } } else { ASSERT(m_Family == PDFCS_PATTERN); @@ -148,22 +168,7 @@ FX_BOOL CPDF_DeviceCS::v_SetCMYK(FX_FLOAT* pBuf, } return FALSE; } -static void ReverseRGB(uint8_t* pDestBuf, const uint8_t* pSrcBuf, int pixels) { - if (pDestBuf == pSrcBuf) - for (int i = 0; i < pixels; i++) { - uint8_t temp = pDestBuf[2]; - pDestBuf[2] = pDestBuf[0]; - pDestBuf[0] = temp; - pDestBuf += 3; - } - else - for (int i = 0; i < pixels; i++) { - *pDestBuf++ = pSrcBuf[2]; - *pDestBuf++ = pSrcBuf[1]; - *pDestBuf++ = pSrcBuf[0]; - pSrcBuf += 3; - } -} + void CPDF_DeviceCS::TranslateImageLine(uint8_t* pDestBuf, const uint8_t* pSrcBuf, int pixels, @@ -196,9 +201,9 @@ void CPDF_DeviceCS::TranslateImageLine(uint8_t* pDestBuf, pDestBuf[2], pDestBuf[1], pDestBuf[0]); } else { uint8_t k = pSrcBuf[3]; - pDestBuf[2] = 255 - FX_MIN(255, pSrcBuf[0] + k); - pDestBuf[1] = 255 - FX_MIN(255, pSrcBuf[1] + k); - pDestBuf[0] = 255 - FX_MIN(255, pSrcBuf[2] + k); + pDestBuf[2] = 255 - std::min(255, pSrcBuf[0] + k); + pDestBuf[1] = 255 - std::min(255, pSrcBuf[1] + k); + pDestBuf[0] = 255 - std::min(255, pSrcBuf[2] + k); } pSrcBuf += 4; pDestBuf += 3; @@ -1012,11 +1017,13 @@ CPDF_ColorSpace* CPDF_PatternCS::GetBaseCS() const { } class CPDF_SeparationCS : public CPDF_ColorSpace { public: - CPDF_SeparationCS(CPDF_Document* pDoc) + explicit CPDF_SeparationCS(CPDF_Document* pDoc) : CPDF_ColorSpace(pDoc, PDFCS_SEPARATION, 1), m_pAltCS(nullptr), m_pFunc(nullptr) {} ~CPDF_SeparationCS() override; + + // CPDF_ColorSpace: void GetDefaultValue(int iComponent, FX_FLOAT& value, FX_FLOAT& min, @@ -1109,11 +1116,13 @@ void CPDF_SeparationCS::EnableStdConversion(FX_BOOL bEnabled) { } class CPDF_DeviceNCS : public CPDF_ColorSpace { public: - CPDF_DeviceNCS(CPDF_Document* pDoc) + explicit CPDF_DeviceNCS(CPDF_Document* pDoc) : CPDF_ColorSpace(pDoc, PDFCS_DEVICEN, 0), m_pAltCS(nullptr), m_pFunc(nullptr) {} ~CPDF_DeviceNCS() override; + + // CPDF_ColorSpace: void GetDefaultValue(int iComponent, FX_FLOAT& value, FX_FLOAT& min, @@ -1183,10 +1192,11 @@ void CPDF_DeviceNCS::EnableStdConversion(FX_BOOL bEnabled) { m_pAltCS->EnableStdConversion(bEnabled); } } + CPDF_ColorSpace* CPDF_ColorSpace::GetStockCS(int family) { return CPDF_ModuleMgr::Get()->GetPageModule()->GetStockCS(family); - ; } + CPDF_ColorSpace* _CSFromName(const CFX_ByteString& name) { if (name == "DeviceRGB" || name == "RGB") { return CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB); diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp index c74aea9a21..f690c209a0 100644 --- a/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp +++ b/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp @@ -6,6 +6,7 @@ #include "render_int.h" +#include <algorithm> #include <memory> #include <vector> @@ -573,8 +574,8 @@ DIB_COMP_DATA* CPDF_DIBSource::GetDecodeAndMaskArray(FX_BOOL& bDefaultDecode, for (FX_DWORD i = 0; i < m_nComponents; i++) { int min_num = pArray->GetInteger(i * 2); int max_num = pArray->GetInteger(i * 2 + 1); - pCompData[i].m_ColorKeyMin = FX_MAX(min_num, 0); - pCompData[i].m_ColorKeyMax = FX_MIN(max_num, max_data); + pCompData[i].m_ColorKeyMin = std::max(min_num, 0); + pCompData[i].m_ColorKeyMax = std::min(max_num, max_data); } } bColorKey = TRUE; |