Remove CFX_ScanlineCompositor::m_Transform.

Now that it is clearer what `m_Transform` stores, replace it with direct
checks against existing member variables. Store a new `m_bClip` variable
for the one 1 bit of missing info.

Change-Id: If523cff8554f785bbd6e3b02f929f4b1e50d0454
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/102710
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fxge/dib/cfx_scanlinecompositor.cpp b/core/fxge/dib/cfx_scanlinecompositor.cpp
index 61f63e1..92e4268 100644
--- a/core/fxge/dib/cfx_scanlinecompositor.cpp
+++ b/core/fxge/dib/cfx_scanlinecompositor.cpp
@@ -2232,6 +2232,7 @@
   m_DestFormat = dest_format;
   m_BlendType = blend_type;
   m_bRgbByteOrder = bRgbByteOrder;
+  m_bClip = bClip;
   if (GetBppFromFormat(dest_format) == 1)
     return false;
 
@@ -2243,24 +2244,10 @@
     InitSourceMask(mask_color);
     return true;
   }
-  if (GetBppFromFormat(m_SrcFormat) <= 8) {
-    if (dest_format == FXDIB_Format::k8bppMask)
-      return true;
-
+  if (GetBppFromFormat(m_SrcFormat) <= 8 &&
+      dest_format != FXDIB_Format::k8bppMask) {
     InitSourcePalette(src_format, dest_format, src_palette);
-    PalTransform pal_transform;
-    pal_transform.dest_is_argb = dest_format == FXDIB_Format::kArgb;
-    pal_transform.dest_has_alpha = GetIsAlphaFromFormat(dest_format);
-    pal_transform.src_is_1_bit = GetBppFromFormat(src_format) == 1;
-    m_Transform = pal_transform;
-    return true;
   }
-  RgbTransform rgb_transform;
-  rgb_transform.src_has_alpha = GetIsAlphaFromFormat(src_format);
-  rgb_transform.dest_has_alpha = GetIsAlphaFromFormat(dest_format);
-  rgb_transform.is_normal_blend = blend_type == BlendMode::kNormal;
-  rgb_transform.clip = bClip;
-  m_Transform = rgb_transform;
   return true;
 }
 
@@ -2330,15 +2317,14 @@
     pdfium::span<const uint8_t> clip_scan) {
   int src_Bpp = GetCompsFromFormat(m_SrcFormat);
   int dest_Bpp = GetCompsFromFormat(m_DestFormat);
-  const auto& rgb_transform = absl::get<RgbTransform>(m_Transform);
   if (m_bRgbByteOrder) {
-    if (rgb_transform.src_has_alpha) {
-      if (rgb_transform.dest_has_alpha) {
+    if (GetIsAlphaFromFormat(m_SrcFormat)) {
+      if (GetIsAlphaFromFormat(m_DestFormat)) {
         CompositeRow_Argb2Argb_RgbByteOrder(dest_scan, src_scan, width,
                                             m_BlendType, clip_scan);
         return;
       }
-      if (rgb_transform.is_normal_blend) {
+      if (m_BlendType == BlendMode::kNormal) {
         CompositeRow_Argb2Rgb_NoBlend_RgbByteOrder(dest_scan, src_scan, width,
                                                    dest_Bpp, clip_scan);
         return;
@@ -2348,9 +2334,9 @@
       return;
     }
 
-    if (rgb_transform.dest_has_alpha) {
-      if (rgb_transform.is_normal_blend) {
-        if (rgb_transform.clip) {
+    if (GetIsAlphaFromFormat(m_DestFormat)) {
+      if (m_BlendType == BlendMode::kNormal) {
+        if (m_bClip) {
           CompositeRow_Rgb2Argb_NoBlend_Clip_RgbByteOrder(
               dest_scan, src_scan, width, src_Bpp, clip_scan);
           return;
@@ -2359,7 +2345,7 @@
                                                           width, src_Bpp);
         return;
       }
-      if (rgb_transform.clip) {
+      if (m_bClip) {
         CompositeRow_Rgb2Argb_Blend_Clip_RgbByteOrder(
             dest_scan, src_scan, width, m_BlendType, src_Bpp, clip_scan);
         return;
@@ -2369,8 +2355,8 @@
       return;
     }
 
-    if (rgb_transform.is_normal_blend) {
-      if (rgb_transform.clip) {
+    if (m_BlendType == BlendMode::kNormal) {
+      if (m_bClip) {
         CompositeRow_Rgb2Rgb_NoBlend_Clip_RgbByteOrder(
             dest_scan, src_scan, width, dest_Bpp, src_Bpp, clip_scan);
         return;
@@ -2379,7 +2365,7 @@
           dest_scan, src_scan, width, dest_Bpp, src_Bpp);
       return;
     }
-    if (rgb_transform.clip) {
+    if (m_bClip) {
       CompositeRow_Rgb2Rgb_Blend_Clip_RgbByteOrder(dest_scan, src_scan, width,
                                                    m_BlendType, dest_Bpp,
                                                    src_Bpp, clip_scan);
@@ -2412,13 +2398,13 @@
     return;
   }
 
-  if (rgb_transform.src_has_alpha) {
-    if (rgb_transform.dest_has_alpha) {
+  if (GetIsAlphaFromFormat(m_SrcFormat)) {
+    if (GetIsAlphaFromFormat(m_DestFormat)) {
       CompositeRow_Argb2Argb(dest_scan, src_scan, width, m_BlendType,
                              clip_scan);
       return;
     }
-    if (rgb_transform.is_normal_blend) {
+    if (m_BlendType == BlendMode::kNormal) {
       CompositeRow_Argb2Rgb_NoBlend(dest_scan, src_scan, width, dest_Bpp,
                                     clip_scan);
       return;
@@ -2428,9 +2414,9 @@
     return;
   }
 
-  if (rgb_transform.dest_has_alpha) {
-    if (rgb_transform.is_normal_blend) {
-      if (rgb_transform.clip) {
+  if (GetIsAlphaFromFormat(m_DestFormat)) {
+    if (m_BlendType == BlendMode::kNormal) {
+      if (m_bClip) {
         CompositeRow_Rgb2Argb_NoBlend_Clip(dest_scan, src_scan, width, src_Bpp,
                                            clip_scan);
         return;
@@ -2438,7 +2424,7 @@
       CompositeRow_Rgb2Argb_NoBlend_NoClip(dest_scan, src_scan, width, src_Bpp);
       return;
     }
-    if (rgb_transform.clip) {
+    if (m_bClip) {
       CompositeRow_Rgb2Argb_Blend_Clip(dest_scan, src_scan, width, m_BlendType,
                                        src_Bpp, clip_scan);
       return;
@@ -2448,8 +2434,8 @@
     return;
   }
 
-  if (rgb_transform.is_normal_blend) {
-    if (rgb_transform.clip) {
+  if (m_BlendType == BlendMode::kNormal) {
+    if (m_bClip) {
       CompositeRow_Rgb2Rgb_NoBlend_Clip(dest_scan, src_scan, width, dest_Bpp,
                                         src_Bpp, clip_scan);
       return;
@@ -2458,7 +2444,7 @@
                                         src_Bpp);
     return;
   }
-  if (rgb_transform.clip) {
+  if (m_bClip) {
     CompositeRow_Rgb2Rgb_Blend_Clip(dest_scan, src_scan, width, m_BlendType,
                                     dest_Bpp, src_Bpp, clip_scan);
     return;
@@ -2509,44 +2495,46 @@
     return;
   }
 
-  const auto& pal_transform = absl::get<PalTransform>(m_Transform);
   if (GetBppFromFormat(m_DestFormat) == 8) {
     DCHECK(!GetIsAlphaFromFormat(m_DestFormat));
-    if (pal_transform.src_is_1_bit) {
+    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;
   }
 
-  if (pal_transform.dest_is_argb) {
-    if (!pal_transform.dest_has_alpha) {
+  if (m_DestFormat == FXDIB_Format::kArgb) {
+    if (!GetIsAlphaFromFormat(m_DestFormat)) {
       return;
     }
-    if (pal_transform.src_is_1_bit) {
+    if (m_SrcFormat == FXDIB_Format::k1bppRgb) {
       CompositeRow_1bppRgb2Argb_NoBlend(dest_scan, src_scan, src_left, width,
                                         m_SrcPalette.Get32BitPalette(),
                                         clip_scan);
       return;
     }
+    DCHECK_EQ(m_SrcFormat, FXDIB_Format::k8bppRgb);
     CompositeRow_8bppRgb2Argb_NoBlend(
         dest_scan, src_scan, width, m_SrcPalette.Get32BitPalette(), clip_scan);
     return;
   }
 
-  if (!pal_transform.src_is_1_bit) {
+  if (m_SrcFormat == FXDIB_Format::k8bppRgb) {
     CompositeRow_8bppRgb2Rgb_NoBlend(
         dest_scan, src_scan, m_SrcPalette.Get32BitPalette(), width,
         GetCompsFromFormat(m_DestFormat), clip_scan);
     return;
   }
 
-  if (pal_transform.dest_has_alpha) {
+  DCHECK_EQ(m_SrcFormat, FXDIB_Format::k1bppRgb);
+  if (GetIsAlphaFromFormat(m_DestFormat)) {
     // TODO(thestig): Check if empty span argument is always empty.
     CompositeRow_1bppRgb2Rgba_NoBlend(dest_scan, src_scan, src_left, width,
                                       m_SrcPalette.Get32BitPalette(), clip_scan,
diff --git a/core/fxge/dib/cfx_scanlinecompositor.h b/core/fxge/dib/cfx_scanlinecompositor.h
index c0202ea..6a59ef2 100644
--- a/core/fxge/dib/cfx_scanlinecompositor.h
+++ b/core/fxge/dib/cfx_scanlinecompositor.h
@@ -11,7 +11,6 @@
 
 #include "core/fxcrt/fx_memory_wrappers.h"
 #include "core/fxge/dib/fx_dib.h"
-#include "third_party/abseil-cpp/absl/types/variant.h"
 #include "third_party/base/span.h"
 
 class CFX_ScanlineCompositor {
@@ -79,18 +78,6 @@
 
   void InitSourceMask(uint32_t mask_color);
 
-  struct PalTransform {
-    bool dest_is_argb;
-    bool dest_has_alpha;
-    bool src_is_1_bit;  // False = 8 bit.
-  };
-  struct RgbTransform {
-    bool src_has_alpha;
-    bool dest_has_alpha;
-    bool is_normal_blend;
-    bool clip;
-  };
-  absl::variant<PalTransform, RgbTransform> m_Transform;
   FXDIB_Format m_SrcFormat;
   FXDIB_Format m_DestFormat;
   Palette m_SrcPalette;
@@ -100,6 +87,7 @@
   int m_MaskBlue;
   BlendMode m_BlendType = BlendMode::kNormal;
   bool m_bRgbByteOrder = false;
+  bool m_bClip = false;
 };
 
 #endif  // CORE_FXGE_DIB_CFX_SCANLINECOMPOSITOR_H_