Replace most GetBppFromFormat() calls in CFX_ScanlineCompositor.

Since GetBppFromFormat() checks oftentimes only return true for 1 or 2
formats, just list out the FXDIB_Formats directly. This makes it easier
to see what checks are really looking for, when the actually
bits-per-pixel value is not needed.

Change-Id: If50047e8e15cd69cff7cb6167578bed198119ed2
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/102732
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fxge/dib/cfx_bitmapcomposer.cpp b/core/fxge/dib/cfx_bitmapcomposer.cpp
index 5f8a5ee..fe31d4f 100644
--- a/core/fxge/dib/cfx_bitmapcomposer.cpp
+++ b/core/fxge/dib/cfx_bitmapcomposer.cpp
@@ -86,7 +86,7 @@
   if (m_SrcFormat == FXDIB_Format::k8bppMask) {
     m_Compositor.CompositeByteMaskLine(dest_scan, src_scan, dest_width,
                                        clip_scan);
-  } else if (GetBppFromFormat(m_SrcFormat) == 8) {
+  } else if (m_SrcFormat == FXDIB_Format::k8bppRgb) {
     m_Compositor.CompositePalBitmapLine(dest_scan, src_scan, 0, dest_width,
                                         clip_scan);
   } else {
diff --git a/core/fxge/dib/cfx_scanlinecompositor.cpp b/core/fxge/dib/cfx_scanlinecompositor.cpp
index 74f0cf8..64b2621 100644
--- a/core/fxge/dib/cfx_scanlinecompositor.cpp
+++ b/core/fxge/dib/cfx_scanlinecompositor.cpp
@@ -2232,18 +2232,23 @@
   m_BlendType = blend_type;
   m_bRgbByteOrder = bRgbByteOrder;
   m_bClip = bClip;
-  if (GetBppFromFormat(m_DestFormat) == 1)
+  if (m_DestFormat == FXDIB_Format::k1bppMask ||
+      m_DestFormat == FXDIB_Format::k1bppRgb) {
     return false;
+  }
 
-  if (m_bRgbByteOrder && GetBppFromFormat(m_DestFormat) == 8)
+  if (m_bRgbByteOrder && (m_DestFormat == FXDIB_Format::k8bppMask ||
+                          m_DestFormat == FXDIB_Format::k8bppRgb)) {
     return false;
+  }
 
   if (m_SrcFormat == FXDIB_Format::k1bppMask ||
       m_SrcFormat == FXDIB_Format::k8bppMask) {
     InitSourceMask(mask_color);
     return true;
   }
-  if (GetBppFromFormat(m_SrcFormat) <= 8 &&
+  if ((m_SrcFormat == FXDIB_Format::k1bppRgb ||
+       m_SrcFormat == FXDIB_Format::k8bppRgb) &&
       m_DestFormat != FXDIB_Format::k8bppMask) {
     InitSourcePalette(src_palette);
   }
@@ -2258,14 +2263,16 @@
   if (m_DestFormat == FXDIB_Format::k8bppMask)
     return;
 
-  if (GetBppFromFormat(m_DestFormat) == 8)
+  if (m_DestFormat == FXDIB_Format::k8bppRgb)
     m_MaskRed = FXRGB2GRAY(m_MaskRed, m_MaskGreen, m_MaskBlue);
 }
 
 void CFX_ScanlineCompositor::InitSourcePalette(
     pdfium::span<const uint32_t> src_palette) {
+  DCHECK_NE(m_DestFormat, FXDIB_Format::k8bppMask);
+
   m_SrcPalette.Reset();
-  const bool bIsDestBpp8 = GetBppFromFormat(m_DestFormat) == 8;
+  const bool bIsDestBpp8 = m_DestFormat == FXDIB_Format::k8bppRgb;
   const size_t pal_count = static_cast<size_t>(1)
                            << GetBppFromFormat(m_SrcFormat);
 
@@ -2312,6 +2319,10 @@
     pdfium::span<const uint8_t> src_scan,
     int width,
     pdfium::span<const uint8_t> clip_scan) {
+  DCHECK(m_SrcFormat == FXDIB_Format::kRgb ||
+         m_SrcFormat == FXDIB_Format::kRgb32 ||
+         m_SrcFormat == FXDIB_Format::kArgb);
+
   int src_Bpp = GetCompsFromFormat(m_SrcFormat);
   int dest_Bpp = GetCompsFromFormat(m_DestFormat);
   if (m_bRgbByteOrder) {
@@ -2382,7 +2393,7 @@
     return;
   }
 
-  if (GetBppFromFormat(m_DestFormat) == 8) {
+  if (m_DestFormat == FXDIB_Format::k8bppRgb) {
     if (m_SrcFormat == FXDIB_Format::kArgb) {
       CompositeRow_Argb2Gray(dest_scan, src_scan, width, m_BlendType,
                              clip_scan);
@@ -2393,6 +2404,9 @@
     return;
   }
 
+  // TODO(thestig): Tighten this check.
+  DCHECK_NE(GetBppFromFormat(m_DestFormat), 8);
+
   if (m_SrcFormat == FXDIB_Format::kArgb) {
     if (m_DestFormat == FXDIB_Format::kArgb) {
       CompositeRow_Argb2Argb(dest_scan, src_scan, width, m_BlendType,
@@ -2454,6 +2468,9 @@
     int src_left,
     int width,
     pdfium::span<const uint8_t> clip_scan) {
+  DCHECK(m_SrcFormat == FXDIB_Format::k1bppRgb ||
+         m_SrcFormat == FXDIB_Format::k8bppRgb);
+
   if (m_bRgbByteOrder) {
     if (m_SrcFormat == FXDIB_Format::k1bppRgb) {
       if (m_DestFormat == FXDIB_Format::k8bppRgb) {
@@ -2490,20 +2507,22 @@
     return;
   }
 
-  if (GetBppFromFormat(m_DestFormat) == 8) {
+  if (m_DestFormat == FXDIB_Format::k8bppRgb) {
     if (m_SrcFormat == FXDIB_Format::k1bppRgb) {
       CompositeRow_1bppPal2Gray(dest_scan, src_scan, src_left,
                                 m_SrcPalette.Get8BitPalette(), width,
                                 m_BlendType, clip_scan);
       return;
     }
-    DCHECK_EQ(m_SrcFormat, FXDIB_Format::k8bppRgb);
     CompositeRow_8bppPal2Gray(dest_scan, src_scan,
                               m_SrcPalette.Get8BitPalette(), width, m_BlendType,
                               clip_scan);
     return;
   }
 
+  // TODO(thestig): Tighten this check.
+  DCHECK_NE(GetBppFromFormat(m_DestFormat), 8);
+
   if (m_DestFormat == FXDIB_Format::kArgb) {
     if (m_SrcFormat == FXDIB_Format::k1bppRgb) {
       CompositeRow_1bppRgb2Argb_NoBlend(dest_scan, src_scan, src_left, width,
@@ -2511,7 +2530,6 @@
                                         clip_scan);
       return;
     }
-    DCHECK_EQ(m_SrcFormat, FXDIB_Format::k8bppRgb);
     CompositeRow_8bppRgb2Argb_NoBlend(
         dest_scan, src_scan, width, m_SrcPalette.Get32BitPalette(), clip_scan);
     return;
@@ -2524,7 +2542,6 @@
     return;
   }
 
-  DCHECK_EQ(m_SrcFormat, FXDIB_Format::k1bppRgb);
   if (m_DestFormat == FXDIB_Format::kArgb) {
     // TODO(thestig): Check if empty span argument is always empty.
     CompositeRow_1bppRgb2Rgba_NoBlend(dest_scan, src_scan, src_left, width,
@@ -2547,13 +2564,15 @@
                                clip_scan);
     return;
   }
-
-  if (GetBppFromFormat(m_DestFormat) == 8) {
+  if (m_DestFormat == FXDIB_Format::k8bppRgb) {
     CompositeRow_ByteMask2Gray(dest_scan, src_scan, m_MaskAlpha, m_MaskRed,
                                width, clip_scan);
     return;
   }
 
+  // TODO(thestig): Tighten this check.
+  DCHECK_NE(GetBppFromFormat(m_DestFormat), 8);
+
   if (m_bRgbByteOrder) {
     if (m_DestFormat == FXDIB_Format::kArgb) {
       CompositeRow_ByteMask2Argb_RgbByteOrder(
@@ -2597,12 +2616,15 @@
     return;
   }
 
-  if (GetBppFromFormat(m_DestFormat) == 8) {
+  if (m_DestFormat == FXDIB_Format::k8bppRgb) {
     CompositeRow_BitMask2Gray(dest_scan, src_scan, m_MaskAlpha, m_MaskRed,
                               src_left, width, clip_scan);
     return;
   }
 
+  // TODO(thestig): Tighten this check.
+  DCHECK_NE(GetBppFromFormat(m_DestFormat), 8);
+
   if (m_bRgbByteOrder) {
     if (m_DestFormat == FXDIB_Format::kArgb) {
       CompositeRow_BitMask2Argb_RgbByteOrder(