diff options
author | Lei Zhang <thestig@chromium.org> | 2018-06-29 18:39:50 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-06-29 18:39:50 +0000 |
commit | 2895880fa8354b273b4e2b72e61a5b78d1985fa8 (patch) | |
tree | 0df028f2ac4a8548df7817246d13f04326bf6bba /core/fpdfapi/page | |
parent | ae82b696f236bc5bd1375532bcf867fcc6aa9126 (diff) | |
download | pdfium-2895880fa8354b273b4e2b72e61a5b78d1985fa8.tar.xz |
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
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>
Diffstat (limited to 'core/fpdfapi/page')
-rw-r--r-- | core/fpdfapi/page/cpdf_colorspace.cpp | 23 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_colorspace.h | 2 |
2 files changed, 21 insertions, 4 deletions
diff --git a/core/fpdfapi/page/cpdf_colorspace.cpp b/core/fpdfapi/page/cpdf_colorspace.cpp index cf1f25063f..b78fe9acfc 100644 --- a/core/fpdfapi/page/cpdf_colorspace.cpp +++ b/core/fpdfapi/page/cpdf_colorspace.cpp @@ -207,8 +207,7 @@ class CPDF_ICCBasedCS : public CPDF_ColorSpace { int image_width, int image_height, bool bTransMask) const override; - - bool IsSRGB() const { return m_pProfile->IsSRGB(); } + bool IsNormal() const override; private: // If no valid ICC profile or using sRGB, try looking for an alternate. @@ -595,6 +594,12 @@ void CPDF_ColorSpace::EnableStdConversion(bool bEnabled) { m_dwStdConversion--; } +bool CPDF_ColorSpace::IsNormal() const { + return GetFamily() == PDFCS_DEVICEGRAY || GetFamily() == PDFCS_DEVICERGB || + GetFamily() == PDFCS_DEVICECMYK || GetFamily() == PDFCS_CALGRAY || + GetFamily() == PDFCS_CALRGB; +} + CPDF_PatternCS* CPDF_ColorSpace::AsPatternCS() { NOTREACHED(); return nullptr; @@ -909,7 +914,7 @@ bool CPDF_ICCBasedCS::GetRGB(const float* pBuf, float* G, float* B) const { ASSERT(m_pProfile); - if (IsSRGB()) { + if (m_pProfile->IsSRGB()) { *R = pBuf[0]; *G = pBuf[1]; *B = pBuf[2]; @@ -947,7 +952,7 @@ void CPDF_ICCBasedCS::TranslateImageLine(uint8_t* pDestBuf, int image_width, int image_height, bool bTransMask) const { - if (IsSRGB()) { + if (m_pProfile->IsSRGB()) { ReverseRGB(pDestBuf, pSrcBuf, pixels); return; } @@ -1010,6 +1015,16 @@ void CPDF_ICCBasedCS::TranslateImageLine(uint8_t* pDestBuf, } } +bool CPDF_ICCBasedCS::IsNormal() const { + if (m_pProfile->IsSRGB()) + return true; + if (m_pProfile->transform()) + return m_pProfile->transform()->m_bNormal; + if (m_pAlterCS) + return m_pAlterCS->IsNormal(); + return false; +} + bool CPDF_ICCBasedCS::FindAlternateProfile( CPDF_Document* pDoc, const CPDF_Dictionary* pDict, diff --git a/core/fpdfapi/page/cpdf_colorspace.h b/core/fpdfapi/page/cpdf_colorspace.h index fba63917f7..1789e21c58 100644 --- a/core/fpdfapi/page/cpdf_colorspace.h +++ b/core/fpdfapi/page/cpdf_colorspace.h @@ -85,6 +85,8 @@ class CPDF_ColorSpace { bool bTransMask) const; virtual void EnableStdConversion(bool bEnabled); + virtual bool IsNormal() const; + // Only call these 3 methods below if GetFamily() returns |PDFCS_PATTERN|. // Returns |this| as a CPDF_PatternCS* if |this| is a pattern. |