diff options
author | Tom Sepez <tsepez@chromium.org> | 2018-10-22 22:43:15 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-10-22 22:43:15 +0000 |
commit | 20f804166944e7707e0a980626bdd9f4a293a32c (patch) | |
tree | 369ac4a24dd9313b7d39394d1a0ce6e3c63d2f77 | |
parent | c87b9348a4f2ffcad1992d26504efa46548b5d83 (diff) | |
download | pdfium-chromium/3589.tar.xz |
Remove third arg to CFX_DIBitmap::LoadChannel()chromium/3589
It is always passed as FXDIB_Alpha. Rename method to indicate its
new purpose, and remove dead code.
Change-Id: Ifaf4faa6b25d1cbd2ff272309764b49de70dc836
Reviewed-on: https://pdfium-review.googlesource.com/c/44491
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
-rw-r--r-- | core/fpdfapi/render/cpdf_renderstatus.cpp | 2 | ||||
-rw-r--r-- | core/fxge/dib/cfx_dibbase.cpp | 2 | ||||
-rw-r--r-- | core/fxge/dib/cfx_dibitmap.cpp | 41 | ||||
-rw-r--r-- | core/fxge/dib/cfx_dibitmap.h | 5 |
4 files changed, 15 insertions, 35 deletions
diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp index 982f69acf9..6943661cf3 100644 --- a/core/fpdfapi/render/cpdf_renderstatus.cpp +++ b/core/fpdfapi/render/cpdf_renderstatus.cpp @@ -2102,7 +2102,7 @@ void CPDF_RenderStatus::DrawShading(const CPDF_ShadingPattern* pPattern, } break; } if (bAlphaMode) - pBitmap->LoadChannel(FXDIB_Red, pBitmap, FXDIB_Alpha); + pBitmap->LoadChannelFromAlpha(FXDIB_Red, pBitmap); if (m_Options.ColorModeIs(CPDF_RenderOptions::kGray)) pBitmap->ConvertColorScale(0, 0xffffff); diff --git a/core/fxge/dib/cfx_dibbase.cpp b/core/fxge/dib/cfx_dibbase.cpp index 65b7e5eded..c70aad69b4 100644 --- a/core/fxge/dib/cfx_dibbase.cpp +++ b/core/fxge/dib/cfx_dibbase.cpp @@ -1056,7 +1056,7 @@ RetainPtr<CFX_DIBitmap> CFX_DIBBase::CloneConvert(FXDIB_Format dest_format) { if (dest_format & 0x0200) { bool ret; if (dest_format == FXDIB_Argb) { - ret = pSrcAlpha ? pClone->LoadChannel(FXDIB_Alpha, pSrcAlpha, FXDIB_Alpha) + ret = pSrcAlpha ? pClone->LoadChannelFromAlpha(FXDIB_Alpha, pSrcAlpha) : pClone->LoadChannel(FXDIB_Alpha, 0xff); } else { ret = pClone->SetAlphaMask(pSrcAlpha, nullptr); diff --git a/core/fxge/dib/cfx_dibitmap.cpp b/core/fxge/dib/cfx_dibitmap.cpp index 3a6eca8228..1ab615a172 100644 --- a/core/fxge/dib/cfx_dibitmap.cpp +++ b/core/fxge/dib/cfx_dibitmap.cpp @@ -278,41 +278,22 @@ void CFX_DIBitmap::TransferEqualFormatsOneBPP( } } -bool CFX_DIBitmap::LoadChannel(FXDIB_Channel destChannel, - const RetainPtr<CFX_DIBBase>& pSrcBitmap, - FXDIB_Channel srcChannel) { +bool CFX_DIBitmap::LoadChannelFromAlpha( + FXDIB_Channel destChannel, + const RetainPtr<CFX_DIBBase>& pSrcBitmap) { if (!m_pBuffer) return false; RetainPtr<CFX_DIBBase> pSrcClone = pSrcBitmap; - int srcOffset; - if (srcChannel == FXDIB_Alpha) { - if (!pSrcBitmap->HasAlpha() && !pSrcBitmap->IsAlphaMask()) - return false; + if (!pSrcBitmap->HasAlpha() && !pSrcBitmap->IsAlphaMask()) + return false; - if (pSrcBitmap->GetBPP() == 1) { - pSrcClone = pSrcBitmap->CloneConvert(FXDIB_8bppMask); - if (!pSrcClone) - return false; - } - srcOffset = pSrcBitmap->GetFormat() == FXDIB_Argb ? 3 : 0; - } else { - if (pSrcBitmap->IsAlphaMask()) + if (pSrcBitmap->GetBPP() == 1) { + pSrcClone = pSrcBitmap->CloneConvert(FXDIB_8bppMask); + if (!pSrcClone) return false; - - if (pSrcBitmap->GetBPP() < 24) { - if (pSrcBitmap->IsCmykImage()) { - pSrcClone = pSrcBitmap->CloneConvert(static_cast<FXDIB_Format>( - (pSrcBitmap->GetFormat() & 0xff00) | 0x20)); - } else { - pSrcClone = pSrcBitmap->CloneConvert(static_cast<FXDIB_Format>( - (pSrcBitmap->GetFormat() & 0xff00) | 0x18)); - } - if (!pSrcClone) - return false; - } - srcOffset = kChannelOffset[srcChannel]; } + int srcOffset = pSrcBitmap->GetFormat() == FXDIB_Argb ? 3 : 0; int destOffset = 0; if (destChannel == FXDIB_Alpha) { if (IsAlphaMask()) { @@ -343,7 +324,7 @@ bool CFX_DIBitmap::LoadChannel(FXDIB_Channel destChannel, } destOffset = kChannelOffset[destChannel]; } - if (srcChannel == FXDIB_Alpha && pSrcClone->m_pAlphaMask) { + if (pSrcClone->m_pAlphaMask) { RetainPtr<CFX_DIBBase> pAlphaMask = pSrcClone->m_pAlphaMask; if (pSrcClone->GetWidth() != m_Width || pSrcClone->GetHeight() != m_Height) { @@ -451,7 +432,7 @@ bool CFX_DIBitmap::MultiplyAlpha(const RetainPtr<CFX_DIBBase>& pSrcBitmap) { return false; if (!IsAlphaMask() && !HasAlpha()) - return LoadChannel(FXDIB_Alpha, pSrcBitmap, FXDIB_Alpha); + return LoadChannelFromAlpha(FXDIB_Alpha, pSrcBitmap); RetainPtr<CFX_DIBitmap> pSrcClone = pSrcBitmap.As<CFX_DIBitmap>(); if (pSrcBitmap->GetWidth() != m_Width || diff --git a/core/fxge/dib/cfx_dibitmap.h b/core/fxge/dib/cfx_dibitmap.h index 63aed7ffc6..8ab83c3eda 100644 --- a/core/fxge/dib/cfx_dibitmap.h +++ b/core/fxge/dib/cfx_dibitmap.h @@ -45,9 +45,8 @@ class CFX_DIBitmap : public CFX_DIBBase { uint32_t GetPixel(int x, int y) const; void SetPixel(int x, int y, uint32_t color); - bool LoadChannel(FXDIB_Channel destChannel, - const RetainPtr<CFX_DIBBase>& pSrcBitmap, - FXDIB_Channel srcChannel); + bool LoadChannelFromAlpha(FXDIB_Channel destChannel, + const RetainPtr<CFX_DIBBase>& pSrcBitmap); bool LoadChannel(FXDIB_Channel destChannel, int value); bool MultiplyAlpha(int alpha); |