diff options
author | Lei Zhang <thestig@chromium.org> | 2018-06-29 20:38:59 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-06-29 20:38:59 +0000 |
commit | 1839a4bc01a6c6fe6a22474d2c6d4f09a9772371 (patch) | |
tree | 7e42e737ea68a70ce999eb59253ffc8281060f45 | |
parent | f7155bf3c8fa8cf4593f2517ef3f005e3190609f (diff) | |
download | pdfium-1839a4bc01a6c6fe6a22474d2c6d4f09a9772371.tar.xz |
Clean up CLcmsCmm.
Make members const and private. Fix nits.
Change-Id: I945bc26438f8fbd6904dc1b15513ab9e51170dc7
Reviewed-on: https://pdfium-review.googlesource.com/36631
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
-rw-r--r-- | core/fpdfapi/page/cpdf_colorspace.cpp | 2 | ||||
-rw-r--r-- | core/fxcodec/codec/ccodec_iccmodule.h | 20 | ||||
-rw-r--r-- | core/fxcodec/codec/fx_codec_icc.cpp | 20 |
3 files changed, 24 insertions, 18 deletions
diff --git a/core/fpdfapi/page/cpdf_colorspace.cpp b/core/fpdfapi/page/cpdf_colorspace.cpp index b78fe9acfc..0138b81ca1 100644 --- a/core/fpdfapi/page/cpdf_colorspace.cpp +++ b/core/fpdfapi/page/cpdf_colorspace.cpp @@ -1019,7 +1019,7 @@ bool CPDF_ICCBasedCS::IsNormal() const { if (m_pProfile->IsSRGB()) return true; if (m_pProfile->transform()) - return m_pProfile->transform()->m_bNormal; + return m_pProfile->transform()->IsNormal(); if (m_pAlterCS) return m_pAlterCS->IsNormal(); return false; diff --git a/core/fxcodec/codec/ccodec_iccmodule.h b/core/fxcodec/codec/ccodec_iccmodule.h index 0d60c3fd4a..38d9ec8686 100644 --- a/core/fxcodec/codec/ccodec_iccmodule.h +++ b/core/fxcodec/codec/ccodec_iccmodule.h @@ -22,15 +22,21 @@ class CLcmsCmm { public: - CLcmsCmm(int srcComponents, - cmsHTRANSFORM transform, - bool isLab, + CLcmsCmm(cmsHTRANSFORM transform, + int srcComponents, + bool bIsLab, bool bNormal); ~CLcmsCmm(); - cmsHTRANSFORM m_hTransform; - int m_nSrcComponents; - bool m_bLab; + cmsHTRANSFORM transform() const { return m_hTransform; } + int components() const { return m_nSrcComponents; } + bool IsLab() const { return m_bLab; } + bool IsNormal() const { return m_bNormal; } + + private: + const cmsHTRANSFORM m_hTransform; + const int m_nSrcComponents; + const bool m_bLab; const bool m_bNormal; }; @@ -52,7 +58,7 @@ class CCodec_IccModule { void SetComponents(uint32_t nComponents) { m_nComponents = nComponents; } protected: - uint32_t m_nComponents; + uint32_t m_nComponents = 0; }; #endif // CORE_FXCODEC_CODEC_CCODEC_ICCMODULE_H_ diff --git a/core/fxcodec/codec/fx_codec_icc.cpp b/core/fxcodec/codec/fx_codec_icc.cpp index 60768f63bf..a7c7f98bba 100644 --- a/core/fxcodec/codec/fx_codec_icc.cpp +++ b/core/fxcodec/codec/fx_codec_icc.cpp @@ -25,20 +25,20 @@ bool Check3Components(cmsColorSpaceSignature cs) { } // namespace -CLcmsCmm::CLcmsCmm(int srcComponents, - cmsHTRANSFORM hTransform, - bool isLab, +CLcmsCmm::CLcmsCmm(cmsHTRANSFORM hTransform, + int srcComponents, + bool bIsLab, bool bNormal) : m_hTransform(hTransform), m_nSrcComponents(srcComponents), - m_bLab(isLab), + m_bLab(bIsLab), m_bNormal(bNormal) {} CLcmsCmm::~CLcmsCmm() { cmsDeleteTransform(m_hTransform); } -CCodec_IccModule::CCodec_IccModule() : m_nComponents(0) {} +CCodec_IccModule::CCodec_IccModule() {} CCodec_IccModule::~CCodec_IccModule() {} @@ -111,7 +111,7 @@ std::unique_ptr<CLcmsCmm> CCodec_IccModule::CreateTransform_sRGB( return nullptr; } auto pCmm = - pdfium::MakeUnique<CLcmsCmm>(*nSrcComponents, hTransform, bLab, bNormal); + pdfium::MakeUnique<CLcmsCmm>(hTransform, *nSrcComponents, bLab, bNormal); cmsCloseProfile(srcProfile); cmsCloseProfile(dstProfile); return pCmm; @@ -128,18 +128,18 @@ void CCodec_IccModule::Translate(CLcmsCmm* pTransform, // TODO(npm): Currently the CmsDoTransform method is part of LCMS and it will // apply some member of m_hTransform to the input. We need to go over all the // places which set transform to verify that only nSrcComponents are used. - if (pTransform->m_bLab) { + if (pTransform->IsLab()) { std::vector<double> inputs(std::max(nSrcComponents, 16u)); for (uint32_t i = 0; i < nSrcComponents; ++i) inputs[i] = pSrcValues[i]; - cmsDoTransform(pTransform->m_hTransform, inputs.data(), output, 1); + cmsDoTransform(pTransform->transform(), inputs.data(), output, 1); } else { std::vector<uint8_t> inputs(std::max(nSrcComponents, 16u)); for (uint32_t i = 0; i < nSrcComponents; ++i) { inputs[i] = pdfium::clamp(static_cast<int>(pSrcValues[i] * 255.0f), 0, 255); } - cmsDoTransform(pTransform->m_hTransform, inputs.data(), output, 1); + cmsDoTransform(pTransform->transform(), inputs.data(), output, 1); } pDestValues[0] = output[2] / 255.0f; pDestValues[1] = output[1] / 255.0f; @@ -151,5 +151,5 @@ void CCodec_IccModule::TranslateScanline(CLcmsCmm* pTransform, const unsigned char* pSrc, int32_t pixels) { if (pTransform) - cmsDoTransform(pTransform->m_hTransform, pSrc, pDest, pixels); + cmsDoTransform(pTransform->transform(), pSrc, pDest, pixels); } |