From 20f804166944e7707e0a980626bdd9f4a293a32c Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Mon, 22 Oct 2018 22:43:15 +0000 Subject: Remove third arg to CFX_DIBitmap::LoadChannel() 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 Commit-Queue: Tom Sepez --- core/fpdfapi/render/cpdf_renderstatus.cpp | 2 +- core/fxge/dib/cfx_dibbase.cpp | 2 +- core/fxge/dib/cfx_dibitmap.cpp | 41 +++++++++---------------------- 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_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& pSrcBitmap, - FXDIB_Channel srcChannel) { +bool CFX_DIBitmap::LoadChannelFromAlpha( + FXDIB_Channel destChannel, + const RetainPtr& pSrcBitmap) { if (!m_pBuffer) return false; RetainPtr 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( - (pSrcBitmap->GetFormat() & 0xff00) | 0x20)); - } else { - pSrcClone = pSrcBitmap->CloneConvert(static_cast( - (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 pAlphaMask = pSrcClone->m_pAlphaMask; if (pSrcClone->GetWidth() != m_Width || pSrcClone->GetHeight() != m_Height) { @@ -451,7 +432,7 @@ bool CFX_DIBitmap::MultiplyAlpha(const RetainPtr& pSrcBitmap) { return false; if (!IsAlphaMask() && !HasAlpha()) - return LoadChannel(FXDIB_Alpha, pSrcBitmap, FXDIB_Alpha); + return LoadChannelFromAlpha(FXDIB_Alpha, pSrcBitmap); RetainPtr pSrcClone = pSrcBitmap.As(); 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& pSrcBitmap, - FXDIB_Channel srcChannel); + bool LoadChannelFromAlpha(FXDIB_Channel destChannel, + const RetainPtr& pSrcBitmap); bool LoadChannel(FXDIB_Channel destChannel, int value); bool MultiplyAlpha(int alpha); -- cgit v1.2.3