diff options
author | Lei Zhang <thestig@chromium.org> | 2018-07-03 21:10:46 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-07-03 21:10:46 +0000 |
commit | 98a004ce39b944ca3341c8bdd06d06432b39cdb3 (patch) | |
tree | 0e68937236c9dec05cc011174c375801fd6cadda /core/fxcodec | |
parent | 6ef10bb80315d50c99adc0dd0212437ea4916873 (diff) | |
download | pdfium-98a004ce39b944ca3341c8bdd06d06432b39cdb3.tar.xz |
M68: Better determine if ICC colorspaces can be used for blending.
Implement CPDF_ColorSpace::IsNormal() and check it when rendering. While
IsNormal() is trivial for most colorspaces, it needs to be implemented
separately for ICC colorspaces.
This fixes a rendering regression from commit 1c0de38c.
BUG=chromium:847346
TBR=hnakashima@chromium.org
Change-Id: Iaafed3f8ee40b26ac2cbfbdf2251407f7935311b
Reviewed-on: https://pdfium-review.googlesource.com/36571
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
(cherry picked from commit 2895880fa8354b273b4e2b72e61a5b78d1985fa8)
Reviewed-on: https://pdfium-review.googlesource.com/37013
Reviewed-by: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'core/fxcodec')
-rw-r--r-- | core/fxcodec/codec/ccodec_iccmodule.h | 6 | ||||
-rw-r--r-- | core/fxcodec/codec/fx_codec_icc.cpp | 20 |
2 files changed, 20 insertions, 6 deletions
diff --git a/core/fxcodec/codec/ccodec_iccmodule.h b/core/fxcodec/codec/ccodec_iccmodule.h index c304b4bb8e..0d60c3fd4a 100644 --- a/core/fxcodec/codec/ccodec_iccmodule.h +++ b/core/fxcodec/codec/ccodec_iccmodule.h @@ -22,12 +22,16 @@ class CLcmsCmm { public: - CLcmsCmm(int srcComponents, cmsHTRANSFORM transform, bool isLab); + CLcmsCmm(int srcComponents, + cmsHTRANSFORM transform, + bool isLab, + bool bNormal); ~CLcmsCmm(); cmsHTRANSFORM m_hTransform; int m_nSrcComponents; bool m_bLab; + const bool m_bNormal; }; class CCodec_IccModule { diff --git a/core/fxcodec/codec/fx_codec_icc.cpp b/core/fxcodec/codec/fx_codec_icc.cpp index 29b37d19ac..208257d228 100644 --- a/core/fxcodec/codec/fx_codec_icc.cpp +++ b/core/fxcodec/codec/fx_codec_icc.cpp @@ -30,10 +30,14 @@ bool Check3Components(cmsColorSpaceSignature cs, bool bDst) { } // namespace -CLcmsCmm::CLcmsCmm(int srcComponents, cmsHTRANSFORM hTransform, bool isLab) +CLcmsCmm::CLcmsCmm(int srcComponents, + cmsHTRANSFORM hTransform, + bool isLab, + bool bNormal) : m_hTransform(hTransform), m_nSrcComponents(srcComponents), - m_bLab(isLab) {} + m_bLab(isLab), + m_bNormal(bNormal) {} CLcmsCmm::~CLcmsCmm() { cmsDeleteTransform(m_hTransform); @@ -59,8 +63,6 @@ std::unique_ptr<CLcmsCmm> CCodec_IccModule::CreateTransform_sRGB( cmsCloseProfile(srcProfile); return nullptr; } - int srcFormat; - bool bLab = false; cmsColorSpaceSignature srcCS = cmsGetColorSpace(srcProfile); *nSrcComponents = cmsChannelsOf(srcCS); @@ -71,6 +73,9 @@ std::unique_ptr<CLcmsCmm> CCodec_IccModule::CreateTransform_sRGB( return nullptr; } + int srcFormat; + bool bLab = false; + bool bNormal = false; if (srcCS == cmsSigLabData) { srcFormat = COLORSPACE_SH(PT_Lab) | CHANNELS_SH(*nSrcComponents) | BYTES_SH(0); @@ -78,6 +83,10 @@ std::unique_ptr<CLcmsCmm> CCodec_IccModule::CreateTransform_sRGB( } else { srcFormat = COLORSPACE_SH(PT_ANY) | CHANNELS_SH(*nSrcComponents) | BYTES_SH(1); + // TODO(thestig): Check to see if lcms2 supports more colorspaces that can + // be considered normal. + bNormal = srcCS == cmsSigGrayData || srcCS == cmsSigRgbData || + srcCS == cmsSigCmykData; } cmsColorSpaceSignature dstCS = cmsGetColorSpace(dstProfile); if (!Check3Components(dstCS, true)) { @@ -109,7 +118,8 @@ std::unique_ptr<CLcmsCmm> CCodec_IccModule::CreateTransform_sRGB( cmsCloseProfile(dstProfile); return nullptr; } - auto pCmm = pdfium::MakeUnique<CLcmsCmm>(*nSrcComponents, hTransform, bLab); + auto pCmm = + pdfium::MakeUnique<CLcmsCmm>(*nSrcComponents, hTransform, bLab, bNormal); cmsCloseProfile(srcProfile); cmsCloseProfile(dstProfile); return pCmm; |