Enable Skia to render with two more text rendering options.

Currently, rendering text with Skia doesn't support the option to
use optimization for LCD display or disabling anti-aliasing, because
CFX_SkiaDeviceDriver::DrawDeviceText() doesn't take any rendering
options as its parameters.

This CL adds a parameter |options| of struct CFX_RenderOptions to
DrawDeviceText(), so that we can pass text rendering options into
CFX_SkiaDeviceDriver and affect the Skia rendering results. This
change also makes it possible to add more rendering options for Skia
in the future.

This CL also adds the Skia expected results for testing
FPDF_RenderPageBitmap() with rendering flags FPDF_LCD_TEXT (enables LCD
optimization) and FPDF_RENDER_NO_SMOOTHTEXT (disables anti-aliasing),
so that these tests can pass for Skia.

Bug: pdfium:1522
Change-Id: I7e83939cb3bc40eca624c43eb7b2fa25d7c019b2
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/69350
Commit-Queue: Hui Yingst <nigi@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/core/fxge/agg/fx_agg_driver.cpp b/core/fxge/agg/fx_agg_driver.cpp
index 5d7fde4..6d6381a 100644
--- a/core/fxge/agg/fx_agg_driver.cpp
+++ b/core/fxge/agg/fx_agg_driver.cpp
@@ -1151,7 +1151,8 @@
                                          CFX_Font* pFont,
                                          const CFX_Matrix& mtObject2Device,
                                          float font_size,
-                                         uint32_t color) {
+                                         uint32_t color,
+                                         const CFX_TextRenderOptions& options) {
   return false;
 }
 #endif  // !defined(OS_APPLE)
diff --git a/core/fxge/agg/fx_agg_driver.h b/core/fxge/agg/fx_agg_driver.h
index 2fcf235..85a5754 100644
--- a/core/fxge/agg/fx_agg_driver.h
+++ b/core/fxge/agg/fx_agg_driver.h
@@ -99,7 +99,8 @@
                       CFX_Font* pFont,
                       const CFX_Matrix& mtObject2Device,
                       float font_size,
-                      uint32_t color) override;
+                      uint32_t color,
+                      const CFX_TextRenderOptions& options) override;
   int GetDriverType() const override;
 
   bool RenderRasterizer(agg::rasterizer_scanline_aa& rasterizer,
diff --git a/core/fxge/apple/fx_apple_platform.cpp b/core/fxge/apple/fx_apple_platform.cpp
index 4d927ef..b97a3b4 100644
--- a/core/fxge/apple/fx_apple_platform.cpp
+++ b/core/fxge/apple/fx_apple_platform.cpp
@@ -102,12 +102,14 @@
   }
 }
 
-bool CFX_AggDeviceDriver::DrawDeviceText(int nChars,
-                                         const TextCharPos* pCharPos,
-                                         CFX_Font* pFont,
-                                         const CFX_Matrix& mtObject2Device,
-                                         float font_size,
-                                         uint32_t argb) {
+bool CFX_AggDeviceDriver::DrawDeviceText(
+    int nChars,
+    const TextCharPos* pCharPos,
+    CFX_Font* pFont,
+    const CFX_Matrix& mtObject2Device,
+    float font_size,
+    uint32_t argb,
+    const CFX_TextRenderOptions& /*options*/) {
   if (!pFont)
     return false;
 
diff --git a/core/fxge/cfx_renderdevice.cpp b/core/fxge/cfx_renderdevice.cpp
index 0b13aed..9ff5f6e 100644
--- a/core/fxge/cfx_renderdevice.cpp
+++ b/core/fxge/cfx_renderdevice.cpp
@@ -824,10 +824,53 @@
                                       const CFX_Matrix& mtText2Device,
                                       uint32_t fill_color,
                                       const CFX_TextRenderOptions& options) {
+  // |anti_alias| and |bNormal| don't affect Skia/SkiaPaths rendering.
+  int anti_alias = FT_RENDER_MODE_MONO;
+  bool bNormal = false;
+  const bool is_text_smooth = options.IsSmooth();
+  // |text_options| has the potential to affect all derived classes of
+  // RenderDeviceDriverIface. But now it only affects Skia rendering.
+  CFX_TextRenderOptions text_options(options);
+  if (is_text_smooth) {
+    if (GetDeviceType() == DeviceType::kDisplay && m_bpp > 1) {
+      if (!CFX_GEModule::Get()->GetFontMgr()->FTLibrarySupportsHinting()) {
+        // Some Freetype implementations (like the one packaged with Fedora) do
+        // not support hinting due to patents 6219025, 6239783, 6307566,
+        // 6225973, 6243070, 6393145, 6421054, 6282327, and 6624828; the latest
+        // one expires 10/7/19.  This makes LCD anti-aliasing very ugly, so we
+        // instead fall back on NORMAL anti-aliasing.
+        anti_alias = FT_RENDER_MODE_NORMAL;
+#if defined(_SKIA_SUPPORT_) || defined(_SKIA_SUPPORT_PATHS_)
+        // Since |anti_alias| doesn't affect Skia rendering, and Skia only
+        // follows strictly to the options provided by |text_options|, we need
+        // to update |text_options| so that Skia falls back on normal
+        // anti-aliasing as well.
+        text_options.aliasing_type = CFX_TextRenderOptions::kAntiAliasing;
+#endif
+      } else if ((m_RenderCaps & (FXRC_ALPHA_OUTPUT | FXRC_CMYK_OUTPUT))) {
+        // Whether Skia uses LCD optimization should strictly follow the
+        // rendering options provided by |text_options|. No change needs to be
+        // done for |text_options| here.
+        anti_alias = FT_RENDER_MODE_LCD;
+        bNormal = true;
+      } else if (m_bpp < 16) {
+        // This case doesn't apply to Skia since Skia always have |m_bpp| = 32.
+        anti_alias = FT_RENDER_MODE_NORMAL;
+      } else {
+        // Whether Skia uses LCD optimization should strictly follow the
+        // rendering options provided by |text_options|. No change needs to be
+        // done for |text_options| here.
+        anti_alias = FT_RENDER_MODE_LCD;
+        bNormal = !pFont->GetFaceRec() ||
+                  options.aliasing_type != CFX_TextRenderOptions::kLcd;
+      }
+    }
+  }
+
   if (GetDeviceType() != DeviceType::kDisplay) {
     if (ShouldDrawDeviceText(pFont, options) &&
         m_pDeviceDriver->DrawDeviceText(nChars, pCharPos, pFont, mtText2Device,
-                                        font_size, fill_color)) {
+                                        font_size, fill_color, text_options)) {
       return true;
     }
     if (FXARGB_A(fill_color) < 255)
@@ -835,11 +878,11 @@
   } else if (options.native_text) {
     if (ShouldDrawDeviceText(pFont, options) &&
         m_pDeviceDriver->DrawDeviceText(nChars, pCharPos, pFont, mtText2Device,
-                                        font_size, fill_color)) {
+                                        font_size, fill_color, text_options)) {
       return true;
     }
   }
-  bool is_text_smooth = options.IsSmooth();
+
   CFX_Matrix char2device = mtText2Device;
   CFX_Matrix text2Device = mtText2Device;
   char2device.Scale(font_size, -font_size);
@@ -853,32 +896,8 @@
                           path_options);
     }
   }
-  int anti_alias = FT_RENDER_MODE_MONO;
-  bool bNormal = false;
-  if (is_text_smooth) {
-    if (GetDeviceType() == DeviceType::kDisplay && m_bpp > 1) {
-      if (!CFX_GEModule::Get()->GetFontMgr()->FTLibrarySupportsHinting()) {
-        // Some Freetype implementations (like the one packaged with Fedora) do
-        // not support hinting due to patents 6219025, 6239783, 6307566,
-        // 6225973, 6243070, 6393145, 6421054, 6282327, and 6624828; the latest
-        // one expires 10/7/19.  This makes LCD antialiasing very ugly, so we
-        // instead fall back on NORMAL antialiasing.
-        anti_alias = FT_RENDER_MODE_NORMAL;
-      } else if ((m_RenderCaps & (FXRC_ALPHA_OUTPUT | FXRC_CMYK_OUTPUT))) {
-        anti_alias = FT_RENDER_MODE_LCD;
-        bNormal = true;
-      } else if (m_bpp < 16) {
-        anti_alias = FT_RENDER_MODE_NORMAL;
-      } else {
-        anti_alias = FT_RENDER_MODE_LCD;
-        bNormal = !pFont->GetFaceRec() ||
-                  options.aliasing_type != CFX_TextRenderOptions::kLcd;
-      }
-    }
-  }
   std::vector<TextGlyphPos> glyphs(nChars);
   CFX_Matrix deviceCtm = char2device;
-  CFX_TextRenderOptions native_text_options(options);
 
   for (size_t i = 0; i < glyphs.size(); ++i) {
     TextGlyphPos& glyph = glyphs[i];
@@ -898,11 +917,11 @@
       new_matrix.Concat(deviceCtm);
       glyph.m_pGlyph = pFont->LoadGlyphBitmap(
           charpos.m_GlyphIndex, charpos.m_bFontStyle, new_matrix,
-          charpos.m_FontCharWidth, anti_alias, &native_text_options);
+          charpos.m_FontCharWidth, anti_alias, &text_options);
     } else {
       glyph.m_pGlyph = pFont->LoadGlyphBitmap(
           charpos.m_GlyphIndex, charpos.m_bFontStyle, deviceCtm,
-          charpos.m_FontCharWidth, anti_alias, &native_text_options);
+          charpos.m_FontCharWidth, anti_alias, &text_options);
     }
   }
   if (anti_alias < FT_RENDER_MODE_LCD && glyphs.size() > 1)
diff --git a/core/fxge/cfx_textrenderoptions.h b/core/fxge/cfx_textrenderoptions.h
index ea85770..64136d4 100644
--- a/core/fxge/cfx_textrenderoptions.h
+++ b/core/fxge/cfx_textrenderoptions.h
@@ -41,4 +41,16 @@
   bool native_text = true;
 };
 
+inline bool operator==(const CFX_TextRenderOptions& lhs,
+                       const CFX_TextRenderOptions& rhs) {
+  return lhs.aliasing_type == rhs.aliasing_type &&
+         lhs.font_is_cid == rhs.font_is_cid &&
+         lhs.native_text == rhs.native_text;
+}
+
+inline bool operator!=(const CFX_TextRenderOptions& lhs,
+                       const CFX_TextRenderOptions& rhs) {
+  return !(lhs == rhs);
+}
+
 #endif  // CORE_FXGE_CFX_TEXTRENDEROPTIONS_H_
diff --git a/core/fxge/renderdevicedriver_iface.cpp b/core/fxge/renderdevicedriver_iface.cpp
index 782a796..569afcf 100644
--- a/core/fxge/renderdevicedriver_iface.cpp
+++ b/core/fxge/renderdevicedriver_iface.cpp
@@ -59,12 +59,14 @@
   return false;
 }
 
-bool RenderDeviceDriverIface::DrawDeviceText(int nChars,
-                                             const TextCharPos* pCharPos,
-                                             CFX_Font* pFont,
-                                             const CFX_Matrix& mtObject2Device,
-                                             float font_size,
-                                             uint32_t color) {
+bool RenderDeviceDriverIface::DrawDeviceText(
+    int nChars,
+    const TextCharPos* pCharPos,
+    CFX_Font* pFont,
+    const CFX_Matrix& mtObject2Device,
+    float font_size,
+    uint32_t color,
+    const CFX_TextRenderOptions& options) {
   return false;
 }
 
diff --git a/core/fxge/renderdevicedriver_iface.h b/core/fxge/renderdevicedriver_iface.h
index aaa4540..f3b4d2a 100644
--- a/core/fxge/renderdevicedriver_iface.h
+++ b/core/fxge/renderdevicedriver_iface.h
@@ -25,6 +25,7 @@
 class PauseIndicatorIface;
 class TextCharPos;
 struct CFX_FillRenderOptions;
+struct CFX_TextRenderOptions;
 struct FX_RECT;
 
 enum class DeviceType : bool {
@@ -101,7 +102,8 @@
                               CFX_Font* pFont,
                               const CFX_Matrix& mtObject2Device,
                               float font_size,
-                              uint32_t color);
+                              uint32_t color,
+                              const CFX_TextRenderOptions& options);
   virtual int GetDriverType() const;
   virtual void ClearDriver();
   virtual bool DrawShading(const CPDF_ShadingPattern* pPattern,
diff --git a/core/fxge/skia/fx_skia_device.cpp b/core/fxge/skia/fx_skia_device.cpp
index e540098..0d4a875 100644
--- a/core/fxge/skia/fx_skia_device.cpp
+++ b/core/fxge/skia/fx_skia_device.cpp
@@ -27,6 +27,7 @@
 #include "core/fxge/cfx_graphstatedata.h"
 #include "core/fxge/cfx_pathdata.h"
 #include "core/fxge/cfx_renderdevice.h"
+#include "core/fxge/cfx_textrenderoptions.h"
 #include "core/fxge/dib/cfx_bitmapcomposer.h"
 #include "core/fxge/dib/cfx_dibitmap.h"
 #include "core/fxge/dib/cfx_imagerenderer.h"
@@ -302,6 +303,17 @@
              : SkPathFillType::kWinding;
 }
 
+SkFont::Edging GetFontEdgingType(const CFX_TextRenderOptions& text_options) {
+  if (text_options.aliasing_type == CFX_TextRenderOptions::kAliasing)
+    return SkFont::Edging::kAlias;
+
+  if (text_options.aliasing_type == CFX_TextRenderOptions::kAntiAliasing)
+    return SkFont::Edging::kAntiAlias;
+
+  ASSERT(text_options.aliasing_type == CFX_TextRenderOptions::kLcd);
+  return SkFont::Edging::kSubpixelAntiAlias;
+}
+
 bool IsEvenOddFillType(SkPathFillType fill) {
   return fill == SkPathFillType::kEvenOdd ||
          fill == SkPathFillType::kInverseEvenOdd;
@@ -865,7 +877,8 @@
                 CFX_Font* pFont,
                 const CFX_Matrix& matrix,
                 float font_size,
-                uint32_t color) {
+                uint32_t color,
+                const CFX_TextRenderOptions& options) {
     if (m_debugDisable)
       return false;
     Dump(__func__);
@@ -879,7 +892,7 @@
     int drawIndex = std::min(m_drawIndex, m_commands.count());
     if (Accumulator::kPath == m_type || drawIndex != m_commandIndex ||
         (Accumulator::kText == m_type &&
-         (FontChanged(pFont, matrix, font_size, scaleX, color) ||
+         (FontChanged(pFont, matrix, font_size, scaleX, color, options) ||
           hasRSX == m_rsxform.isEmpty()))) {
       Flush();
     }
@@ -899,6 +912,7 @@
       m_drawIndex = m_commandIndex;
       m_type = Accumulator::kText;
       m_pFont = pFont;
+      m_textOptions = options;
     }
     if (!hasRSX && !m_rsxform.isEmpty())
       FlushText();
@@ -970,6 +984,7 @@
     font.setSkewX(tanf(m_italicAngle * FX_PI / 180.0));
     font.setSize(SkTAbs(m_fontSize));
     font.setSubpixel(true);
+    font.setEdging(GetFontEdgingType(m_textOptions));
 
     SkCanvas* skCanvas = m_pDriver->SkiaCanvas();
     SkAutoCanvasRestore scoped_save_restore(skCanvas, /*doSave=*/true);
@@ -1021,6 +1036,7 @@
     m_pFont = nullptr;
     m_italicAngle = 0;
     m_isSubstFontBold = false;
+    m_textOptions = CFX_TextRenderOptions();
   }
 
   bool IsEmpty() const { return !m_commands.count(); }
@@ -1178,14 +1194,16 @@
                    const CFX_Matrix& matrix,
                    float font_size,
                    float scaleX,
-                   uint32_t color) const {
+                   uint32_t color,
+                   const CFX_TextRenderOptions& options) const {
     CFX_TypeFace* typeface =
         pFont->GetFaceRec() ? pFont->GetDeviceCache() : nullptr;
     return typeface != m_pTypeFace.get() || MatrixChanged(&matrix) ||
            font_size != m_fontSize || scaleX != m_scaleX ||
            color != m_fillColor ||
            pFont->GetSubstFontItalicAngle() != m_italicAngle ||
-           pFont->IsSubstFontBold() != m_isSubstFontBold;
+           pFont->IsSubstFontBold() != m_isSubstFontBold ||
+           options != m_textOptions;
   }
 
   bool MatrixChanged(const CFX_Matrix* pMatrix) const {
@@ -1510,6 +1528,7 @@
   CFX_GraphStateData m_drawState;
   CFX_Matrix m_clipMatrix;
   CFX_FillRenderOptions m_fillOptions;
+  CFX_TextRenderOptions m_textOptions;
   UnownedPtr<CFX_SkiaDeviceDriver> const m_pDriver;
   sk_sp<CFX_TypeFace> m_pTypeFace;
   float m_fontSize = 0;
@@ -1669,14 +1688,16 @@
   m_pBitmap->PreMultiply();
 }
 
-bool CFX_SkiaDeviceDriver::DrawDeviceText(int nChars,
-                                          const TextCharPos* pCharPos,
-                                          CFX_Font* pFont,
-                                          const CFX_Matrix& mtObject2Device,
-                                          float font_size,
-                                          uint32_t color) {
+bool CFX_SkiaDeviceDriver::DrawDeviceText(
+    int nChars,
+    const TextCharPos* pCharPos,
+    CFX_Font* pFont,
+    const CFX_Matrix& mtObject2Device,
+    float font_size,
+    uint32_t color,
+    const CFX_TextRenderOptions& options) {
   if (m_pCache->DrawText(nChars, pCharPos, pFont, mtObject2Device, font_size,
-                         color)) {
+                         color, options)) {
     return true;
   }
   sk_sp<SkTypeface> typeface(SkSafeRef(pFont->GetDeviceCache()));
@@ -1691,6 +1712,7 @@
   font.setSize(SkTAbs(font_size));
   font.setSubpixel(true);
   font.setSkewX(tanf(pFont->GetSubstFontItalicAngle() * FX_PI / 180.0));
+  font.setEdging(GetFontEdgingType(options));
 
   SkAutoCanvasRestore scoped_save_restore(m_pCanvas, /*doSave=*/true);
   SkScalar flip = font_size < 0 ? -1 : 1;
diff --git a/core/fxge/skia/fx_skia_device.h b/core/fxge/skia/fx_skia_device.h
index cc73c2e..2e94b5b 100644
--- a/core/fxge/skia/fx_skia_device.h
+++ b/core/fxge/skia/fx_skia_device.h
@@ -138,7 +138,8 @@
                       CFX_Font* pFont,
                       const CFX_Matrix& mtObject2Device,
                       float font_size,
-                      uint32_t color) override;
+                      uint32_t color,
+                      const CFX_TextRenderOptions& options) override;
 
   int GetDriverType() const override;
 
diff --git a/core/fxge/skia/fx_skia_device_embeddertest.cpp b/core/fxge/skia/fx_skia_device_embeddertest.cpp
index 4001fbc..f35588d 100644
--- a/core/fxge/skia/fx_skia_device_embeddertest.cpp
+++ b/core/fxge/skia/fx_skia_device_embeddertest.cpp
@@ -8,6 +8,7 @@
 #include "core/fxge/cfx_graphstatedata.h"
 #include "core/fxge/cfx_pathdata.h"
 #include "core/fxge/cfx_renderdevice.h"
+#include "core/fxge/cfx_textrenderoptions.h"
 #include "core/fxge/skia/fx_skia_device.h"
 #include "core/fxge/text_char_pos.h"
 #include "fpdfsdk/cpdfsdk_helpers.h"
@@ -58,6 +59,7 @@
   CFX_Matrix matrix2;
   matrix2.Translate(1, 0);
   CFX_GraphStateData graphState;
+  CFX_TextRenderOptions text_options;
   if (state.m_save == State::Save::kYes)
     driver->SaveState();
   if (state.m_clip != State::Clip::kNo)
@@ -68,7 +70,7 @@
                      BlendMode::kNormal);
   } else if (state.m_graphic == State::Graphic::kText) {
     driver->DrawDeviceText(SK_ARRAY_COUNT(charPos), charPos, &font, matrix,
-                           fontSize, 0xFF445566);
+                           fontSize, 0xFF445566, text_options);
   }
   if (state.m_save == State::Save::kYes)
     driver->RestoreState(true);
@@ -92,7 +94,7 @@
                      BlendMode::kNormal);
   } else if (state.m_graphic == State::Graphic::kText) {
     driver->DrawDeviceText(SK_ARRAY_COUNT(charPos), charPos, &font, matrix2,
-                           fontSize, 0xFF445566);
+                           fontSize, 0xFF445566, text_options);
   }
   if (state.m_save == State::Save::kYes)
     driver->RestoreState(false);
diff --git a/core/fxge/win32/fx_win32_print.cpp b/core/fxge/win32/fx_win32_print.cpp
index 3be1a24..8ab7614 100644
--- a/core/fxge/win32/fx_win32_print.cpp
+++ b/core/fxge/win32/fx_win32_print.cpp
@@ -201,12 +201,14 @@
                        FXDIB_ResampleOptions(), blend_type);
 }
 
-bool CGdiPrinterDriver::DrawDeviceText(int nChars,
-                                       const TextCharPos* pCharPos,
-                                       CFX_Font* pFont,
-                                       const CFX_Matrix& mtObject2Device,
-                                       float font_size,
-                                       uint32_t color) {
+bool CGdiPrinterDriver::DrawDeviceText(
+    int nChars,
+    const TextCharPos* pCharPos,
+    CFX_Font* pFont,
+    const CFX_Matrix& mtObject2Device,
+    float font_size,
+    uint32_t color,
+    const CFX_TextRenderOptions& /*options*/) {
 #if defined(PDFIUM_PRINT_TEXT_WITH_GDI)
   if (!g_pdfium_print_text_with_gdi)
     return false;
@@ -507,12 +509,14 @@
   return m_PSRenderer.DrawDIBits(pBitmap, color, matrix, options);
 }
 
-bool CPSPrinterDriver::DrawDeviceText(int nChars,
-                                      const TextCharPos* pCharPos,
-                                      CFX_Font* pFont,
-                                      const CFX_Matrix& mtObject2Device,
-                                      float font_size,
-                                      uint32_t color) {
+bool CPSPrinterDriver::DrawDeviceText(
+    int nChars,
+    const TextCharPos* pCharPos,
+    CFX_Font* pFont,
+    const CFX_Matrix& mtObject2Device,
+    float font_size,
+    uint32_t color,
+    const CFX_TextRenderOptions& /*options*/) {
   return m_PSRenderer.DrawText(nChars, pCharPos, pFont, mtObject2Device,
                                font_size, color);
 }
@@ -621,12 +625,14 @@
   return false;
 }
 
-bool CTextOnlyPrinterDriver::DrawDeviceText(int nChars,
-                                            const TextCharPos* pCharPos,
-                                            CFX_Font* pFont,
-                                            const CFX_Matrix& mtObject2Device,
-                                            float font_size,
-                                            uint32_t color) {
+bool CTextOnlyPrinterDriver::DrawDeviceText(
+    int nChars,
+    const TextCharPos* pCharPos,
+    CFX_Font* pFont,
+    const CFX_Matrix& mtObject2Device,
+    float font_size,
+    uint32_t color,
+    const CFX_TextRenderOptions& /*options*/) {
   if (g_pdfium_print_mode != 1)
     return false;
   if (nChars < 1 || !pFont || !pFont->IsEmbedded() || !pFont->IsTTFont())
diff --git a/core/fxge/win32/win32_int.h b/core/fxge/win32/win32_int.h
index 09a6d1e..d28d6e2 100644
--- a/core/fxge/win32/win32_int.h
+++ b/core/fxge/win32/win32_int.h
@@ -213,7 +213,8 @@
                       CFX_Font* pFont,
                       const CFX_Matrix& mtObject2Device,
                       float font_size,
-                      uint32_t color) override;
+                      uint32_t color,
+                      const CFX_TextRenderOptions& options) override;
 
   const int m_HorzSize;
   const int m_VertSize;
@@ -276,7 +277,8 @@
                       CFX_Font* pFont,
                       const CFX_Matrix& mtObject2Device,
                       float font_size,
-                      uint32_t color) override;
+                      uint32_t color,
+                      const CFX_TextRenderOptions& options) override;
 
   HDC m_hDC;
   const bool m_bCmykOutput;
@@ -340,7 +342,8 @@
                       CFX_Font* pFont,
                       const CFX_Matrix& mtObject2Device,
                       float font_size,
-                      uint32_t color) override;
+                      uint32_t color,
+                      const CFX_TextRenderOptions& options) override;
 
   HDC m_hDC;
   const int m_Width;
diff --git a/fpdfsdk/fpdf_view_embeddertest.cpp b/fpdfsdk/fpdf_view_embeddertest.cpp
index a3ba17d..a5acb83 100644
--- a/fpdfsdk/fpdf_view_embeddertest.cpp
+++ b/fpdfsdk/fpdf_view_embeddertest.cpp
@@ -1341,9 +1341,17 @@
   TestRenderPageBitmapWithFlags(page, FPDF_RENDER_NO_SMOOTHPATH,
                                 kHelloWorldChecksum);
 
-// TODO(crbug.com/pdfium/1522) Fix and enable the tests for FPDF_LCD_TEXT and
-// FPDF_RENDER_NO_SMOOTHTEXT flags for Skia and SkiaPaths.
-#if !defined(_SKIA_SUPPORT_) && !defined(_SKIA_SUPPORT_PATHS_)
+#if defined(_SKIA_SUPPORT_) || defined(_SKIA_SUPPORT_PATHS_)
+#if defined(OS_WIN)
+  static const char kLcdTextChecksum[] = "fa4b12e9db8316f699624250307e5106";
+#elif defined(OS_APPLE)
+  static const char kLcdTextChecksum[] = "b0a33a2ab9f26d225bbad1c714d95beb";
+#else
+  static const char kLcdTextChecksum[] = "693563ed2a3f1f6545856377be4bf3b3";
+#endif
+  static const char kNoSmoothtextChecksum[] =
+      "18156d2a55ae142c3870da7229650890";
+#else
 #if defined(OS_WIN)
   static const char kLcdTextChecksum[] = "6e32f5a9c46e4e0730481081fe80617d";
   static const char kNoSmoothtextChecksum[] =
@@ -1357,6 +1365,7 @@
   static const char kNoSmoothtextChecksum[] =
       "3d01e234120b783a3fffb27273ea1ea8";
 #endif
+#endif  // defined(_SKIA_SUPPORT_) || defined(_SKIA_SUPPORT_PATHS_)
 
   TestRenderPageBitmapWithFlags(page, FPDF_LCD_TEXT, kLcdTextChecksum);
   TestRenderPageBitmapWithFlags(page, FPDF_RENDER_NO_SMOOTHTEXT,
@@ -1366,7 +1375,6 @@
   // will be ignored.
   TestRenderPageBitmapWithFlags(page, FPDF_LCD_TEXT | FPDF_RENDER_NO_SMOOTHTEXT,
                                 kNoSmoothtextChecksum);
-#endif  // !defined(_SKIA_SUPPORT_) && !defined(_SKIA_SUPPORT_PATHS_)
 
   UnloadPage(page);
 }