Remove arguments from CFX_DIBitmap::LoadChannel()

Then rename to SetUniformOpaqueAlpha(), which seems to describe
what it does. Then re-arrange the logic to simplify structure.

Change-Id: I58a3a5795cca224c08de1a34311790a5e8b1f88d
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/75530
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/core/fxge/dib/cfx_dibbase.cpp b/core/fxge/dib/cfx_dibbase.cpp
index f73e6c3..e63f67e 100644
--- a/core/fxge/dib/cfx_dibbase.cpp
+++ b/core/fxge/dib/cfx_dibbase.cpp
@@ -982,10 +982,9 @@
   if (GetIsAlphaFromFormat(dest_format)) {
     bool ret;
     if (dest_format == FXDIB_Format::kArgb) {
-      ret = pSrcAlpha
-                ? pClone->LoadChannelFromAlpha(CFX_DIBitmap::Channel::kAlpha,
-                                               pSrcAlpha)
-                : pClone->LoadChannel(CFX_DIBitmap::Channel::kAlpha, 0xff);
+      ret = pSrcAlpha ? pClone->LoadChannelFromAlpha(
+                            CFX_DIBitmap::Channel::kAlpha, pSrcAlpha)
+                      : pClone->SetUniformOpaqueAlpha();
     } else {
       ret = pClone->SetAlphaMask(pSrcAlpha, nullptr);
     }
diff --git a/core/fxge/dib/cfx_dibitmap.cpp b/core/fxge/dib/cfx_dibitmap.cpp
index d22ee2e..e2d49bf 100644
--- a/core/fxge/dib/cfx_dibitmap.cpp
+++ b/core/fxge/dib/cfx_dibitmap.cpp
@@ -358,59 +358,32 @@
   return true;
 }
 
-bool CFX_DIBitmap::LoadChannel(Channel destChannel, int value) {
+bool CFX_DIBitmap::SetUniformOpaqueAlpha() {
   if (!m_pBuffer)
     return false;
 
-  int destOffset;
-  if (destChannel == CFX_DIBitmap::Channel::kAlpha) {
-    if (IsMask()) {
-      if (!ConvertFormat(FXDIB_Format::k8bppMask)) {
-        return false;
-      }
-      destOffset = 0;
-    } else {
-      destOffset = 0;
-      if (!ConvertFormat(FXDIB_Format::kArgb))
-        return false;
-
-      if (GetFormat() == FXDIB_Format::kArgb)
-        destOffset = 3;
-    }
-  } else {
-    if (IsMask()) {
+  if (IsMask()) {
+    if (!ConvertFormat(FXDIB_Format::k8bppMask))
       return false;
-    }
-    if (GetBPP() < 24) {
-      if (HasAlpha()) {
-        if (!ConvertFormat(FXDIB_Format::kArgb))
-          return false;
-      } else {
-#if defined(OS_APPLE)
-        constexpr FXDIB_Format kPlatformFormat = FXDIB_Format::kRgb;
-#else
-        constexpr FXDIB_Format kPlatformFormat = FXDIB_Format::kRgb32;
-#endif
-        if (!ConvertFormat(kPlatformFormat))
-          return false;
-      }
-    }
-    destOffset = kChannelOffset[static_cast<size_t>(destChannel)];
+  } else {
+    if (!ConvertFormat(FXDIB_Format::kArgb))
+      return false;
   }
-  int Bpp = GetBPP() / 8;
+  const int Bpp = GetBPP() / 8;
   if (Bpp == 1) {
-    memset(m_pBuffer.Get(), value, m_Height * m_Pitch);
+    memset(m_pBuffer.Get(), 0xff, m_Height * m_Pitch);
     return true;
   }
-  if (destChannel == CFX_DIBitmap::Channel::kAlpha && m_pAlphaMask) {
-    memset(m_pAlphaMask->GetBuffer(), value,
+  if (m_pAlphaMask) {
+    memset(m_pAlphaMask->GetBuffer(), 0xff,
            m_pAlphaMask->GetHeight() * m_pAlphaMask->GetPitch());
     return true;
   }
+  const int destOffset = GetFormat() == FXDIB_Format::kArgb ? 3 : 0;
   for (int row = 0; row < m_Height; row++) {
     uint8_t* scan_line = m_pBuffer.Get() + row * m_Pitch + destOffset;
     for (int col = 0; col < m_Width; col++) {
-      *scan_line = value;
+      *scan_line = 0xff;
       scan_line += Bpp;
     }
   }
diff --git a/core/fxge/dib/cfx_dibitmap.h b/core/fxge/dib/cfx_dibitmap.h
index 57da0b4..0397a8b 100644
--- a/core/fxge/dib/cfx_dibitmap.h
+++ b/core/fxge/dib/cfx_dibitmap.h
@@ -68,7 +68,7 @@
 
   bool LoadChannelFromAlpha(Channel destChannel,
                             const RetainPtr<CFX_DIBBase>& pSrcBitmap);
-  bool LoadChannel(Channel destChannel, int value);
+  bool SetUniformOpaqueAlpha();
 
   bool MultiplyAlpha(int alpha);
   bool MultiplyAlpha(const RetainPtr<CFX_DIBBase>& pSrcBitmap);
diff --git a/core/fxge/win32/cgdi_display_driver.cpp b/core/fxge/win32/cgdi_display_driver.cpp
index f1e48aa..127cf0d 100644
--- a/core/fxge/win32/cgdi_display_driver.cpp
+++ b/core/fxge/win32/cgdi_display_driver.cpp
@@ -62,8 +62,8 @@
       ret = false;
     }
   }
-  if (pBitmap->HasAlpha() && ret)
-    pBitmap->LoadChannel(CFX_DIBitmap::Channel::kAlpha, 0xff);
+  if (ret && pBitmap->HasAlpha())
+    pBitmap->SetUniformOpaqueAlpha();
 
   DeleteObject(hbmp);
   DeleteObject(hDCMemory);