Remove |CPDF_RenderOptions::bBGRStripe|.

The variable is never set to true. As a consequence,
|CFX_TextRenderOptions::kBgrStripe| is never used and code that draws
text assuming |CFX_TextRenderOptions::kBgrStripe| can be set is dead
code. Remove them. With |CFX_TextRenderOptions::kBgrStripe| gone,
CFX_TextRenderOptions::IsLcd() is also not as useful, so remove it in
favor of comparing against |CFX_TextRenderOptions::kLcd| directly.

Fix some nits in cfx_textrenderoptions.h along the way.

Change-Id: Ie3ada1e88502e8aa4a67bfc2701db13349fb156c
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/72231
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fpdfapi/render/cpdf_renderoptions.h b/core/fpdfapi/render/cpdf_renderoptions.h
index 850ff72..12f3958 100644
--- a/core/fpdfapi/render/cpdf_renderoptions.h
+++ b/core/fpdfapi/render/cpdf_renderoptions.h
@@ -24,7 +24,6 @@
     Options(const Options& rhs);
 
     bool bClearType = false;
-    bool bBGRStripe = false;
     bool bNoNativeText = false;
     bool bForceHalftone = false;
     bool bRectAA = false;
diff --git a/core/fpdfapi/render/cpdf_textrenderer.cpp b/core/fpdfapi/render/cpdf_textrenderer.cpp
index 520bf85..785496d 100644
--- a/core/fpdfapi/render/cpdf_textrenderer.cpp
+++ b/core/fpdfapi/render/cpdf_textrenderer.cpp
@@ -33,13 +33,11 @@
   if (pFont->IsCIDFont())
     text_options.font_is_cid = true;
 
-  if (options.GetOptions().bNoTextSmooth) {
+  if (options.GetOptions().bNoTextSmooth)
     text_options.aliasing_type = CFX_TextRenderOptions::kAliasing;
-  } else if (options.GetOptions().bClearType) {
-    text_options.aliasing_type = options.GetOptions().bBGRStripe
-                                     ? CFX_TextRenderOptions::kBgrStripe
-                                     : CFX_TextRenderOptions::kLcd;
-  }
+  else if (options.GetOptions().bClearType)
+    text_options.aliasing_type = CFX_TextRenderOptions::kLcd;
+
   if (options.GetOptions().bNoNativeText)
     text_options.native_text = false;
 
diff --git a/core/fxge/cfx_renderdevice.cpp b/core/fxge/cfx_renderdevice.cpp
index ac1beef..0b13aed 100644
--- a/core/fxge/cfx_renderdevice.cpp
+++ b/core/fxge/cfx_renderdevice.cpp
@@ -106,26 +106,11 @@
   return src * alpha / 255;
 }
 
-void Merge(uint8_t src, int channel, int alpha, uint8_t* dest) {
-  *dest = FXDIB_ALPHA_MERGE(*dest, channel, CalcAlpha(src, alpha));
-}
-
 void MergeGammaAdjust(uint8_t src, int channel, int alpha, uint8_t* dest) {
   *dest =
       FXDIB_ALPHA_MERGE(*dest, channel, CalcAlpha(TextGammaAdjust(src), alpha));
 }
 
-void MergeGammaAdjustBgr(const uint8_t* src,
-                         int r,
-                         int g,
-                         int b,
-                         int a,
-                         uint8_t* dest) {
-  MergeGammaAdjust(src[0], b, a, &dest[0]);
-  MergeGammaAdjust(src[1], g, a, &dest[1]);
-  MergeGammaAdjust(src[2], r, a, &dest[2]);
-}
-
 void MergeGammaAdjustRgb(const uint8_t* src,
                          int r,
                          int g,
@@ -229,7 +214,6 @@
                           int start_col,
                           int end_col,
                           bool bNormal,
-                          bool bBGRStripe,
                           int x_subpixel,
                           int a,
                           int r,
@@ -248,49 +232,6 @@
 
     uint8_t* src_scan = src_buf + row * src_pitch + (start_col - left) * 3;
     uint8_t* dest_scan = dest_buf + dest_row * dest_pitch + start_col * Bpp;
-    if (bBGRStripe) {
-      if (x_subpixel == 0) {
-        for (int col = start_col; col < end_col; ++col) {
-          if (has_alpha) {
-            Merge(src_scan[2], r, a, &dest_scan[2]);
-            Merge(src_scan[1], g, a, &dest_scan[1]);
-            Merge(src_scan[0], b, a, &dest_scan[0]);
-          } else {
-            MergeGammaAdjustBgr(&src_scan[0], r, g, b, a, &dest_scan[0]);
-          }
-          SetAlpha(has_alpha, dest_scan);
-          NextPixel(&src_scan, &dest_scan, Bpp);
-        }
-        continue;
-      }
-      if (x_subpixel == 1) {
-        MergeGammaAdjust(src_scan[1], r, a, &dest_scan[2]);
-        MergeGammaAdjust(src_scan[0], g, a, &dest_scan[1]);
-        if (start_col > left)
-          MergeGammaAdjust(src_scan[-1], b, a, &dest_scan[0]);
-        SetAlpha(has_alpha, dest_scan);
-        NextPixel(&src_scan, &dest_scan, Bpp);
-        for (int col = start_col + 1; col < end_col - 1; ++col) {
-          MergeGammaAdjustBgr(&src_scan[-1], r, g, b, a, &dest_scan[0]);
-          SetAlpha(has_alpha, dest_scan);
-          NextPixel(&src_scan, &dest_scan, Bpp);
-        }
-        continue;
-      }
-      MergeGammaAdjust(src_scan[0], r, a, &dest_scan[2]);
-      if (start_col > left) {
-        MergeGammaAdjust(src_scan[-1], g, a, &dest_scan[1]);
-        MergeGammaAdjust(src_scan[-2], b, a, &dest_scan[0]);
-      }
-      SetAlpha(has_alpha, dest_scan);
-      NextPixel(&src_scan, &dest_scan, Bpp);
-      for (int col = start_col + 1; col < end_col - 1; ++col) {
-        MergeGammaAdjustBgr(&src_scan[-2], r, g, b, a, &dest_scan[0]);
-        SetAlpha(has_alpha, dest_scan);
-        NextPixel(&src_scan, &dest_scan, Bpp);
-      }
-      continue;
-    }
     if (x_subpixel == 0) {
       for (int col = start_col; col < end_col; ++col) {
         if (bNormal) {
@@ -930,7 +871,8 @@
         anti_alias = FT_RENDER_MODE_NORMAL;
       } else {
         anti_alias = FT_RENDER_MODE_LCD;
-        bNormal = !pFont->GetFaceRec() || !options.IsLcd();
+        bNormal = !pFont->GetFaceRec() ||
+                  options.aliasing_type != CFX_TextRenderOptions::kLcd;
       }
     }
   }
@@ -1051,10 +993,8 @@
     if (start_col >= end_col)
       continue;
 
-    DrawNormalTextHelper(
-        bitmap, pGlyph, nrows, point->x, point->y, start_col, end_col, bNormal,
-        options.aliasing_type == CFX_TextRenderOptions::kBgrStripe, x_subpixel,
-        a, r, g, b);
+    DrawNormalTextHelper(bitmap, pGlyph, nrows, point->x, point->y, start_col,
+                         end_col, bNormal, x_subpixel, a, r, g, b);
   }
   if (bitmap->IsAlphaMask())
     SetBitMask(bitmap, bmp_rect.left, bmp_rect.top, fill_color);
diff --git a/core/fxge/cfx_textrenderoptions.h b/core/fxge/cfx_textrenderoptions.h
index eecc487..ea85770 100644
--- a/core/fxge/cfx_textrenderoptions.h
+++ b/core/fxge/cfx_textrenderoptions.h
@@ -18,9 +18,6 @@
 
     // LCD optimization, can be enabled when anti-aliasing is allowed.
     kLcd,
-
-    // BGR stripe optimization, can be enabled when LCD optimazation is enabled.
-    kBgrStripe,
   };
 
   static const CFX_TextRenderOptions& LcdOptions();
@@ -29,11 +26,10 @@
   explicit CFX_TextRenderOptions(AliasingType type);
   CFX_TextRenderOptions(const CFX_TextRenderOptions& other);
 
-  // Indicates whether LCD optimazation is enabled.
-  bool IsLcd() const { return aliasing_type >= kLcd; }
-
-  // Indicates whether anti aliasing is enabled.
-  bool IsSmooth() const { return aliasing_type >= kAntiAliasing; }
+  // Indicates whether anti-aliasing is enabled.
+  bool IsSmooth() const {
+    return aliasing_type == kAntiAliasing || aliasing_type == kLcd;
+  }
 
   // Aliasing option for fonts.
   AliasingType aliasing_type = kAntiAliasing;