diff options
author | Lei Zhang <thestig@chromium.org> | 2018-04-12 19:51:56 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-04-12 19:51:56 +0000 |
commit | 9e625db795ca7e112d692bda7200b69a873d75f7 (patch) | |
tree | e97bbad731acb17c61cf62e67381c394886de390 /core/fpdfapi/page/cpdf_color.cpp | |
parent | 80a6cbe0a427e155de8555bc867af745d10f9777 (diff) | |
download | pdfium-9e625db795ca7e112d692bda7200b69a873d75f7.tar.xz |
Slightly simplify CPDF_Color::SetColorSpace().
All the callers pass in a valid colorspace. SetColorSpace() is the only
caller to CPDF_ColorSpace::GetDefaultColor(). Also adjust that method to
make it harder to use incorrectly.
Change-Id: I5cf7b6d2abef630e1b9443043b13d1c2b5bed18a
Reviewed-on: https://pdfium-review.googlesource.com/30351
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'core/fpdfapi/page/cpdf_color.cpp')
-rw-r--r-- | core/fpdfapi/page/cpdf_color.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/core/fpdfapi/page/cpdf_color.cpp b/core/fpdfapi/page/cpdf_color.cpp index d364e8e822..73e3d36ec4 100644 --- a/core/fpdfapi/page/cpdf_color.cpp +++ b/core/fpdfapi/page/cpdf_color.cpp @@ -60,6 +60,7 @@ bool CPDF_Color::IsPatternInternal() const { } void CPDF_Color::SetColorSpace(CPDF_ColorSpace* pCS) { + ASSERT(pCS); if (m_pCS == pCS) { if (!m_pBuffer) m_pBuffer = pCS->CreateBuf(); @@ -72,10 +73,10 @@ void CPDF_Color::SetColorSpace(CPDF_ColorSpace* pCS) { ReleaseColorSpace(); m_pCS = pCS; - if (pCS) { + if (IsPatternInternal()) m_pBuffer = pCS->CreateBuf(); - pCS->GetDefaultColor(m_pBuffer); - } + else + m_pBuffer = pCS->CreateBufAndSetDefaultColor(); } void CPDF_Color::SetValue(const float* comps) { |