CPDF_RenderOptions::bForceDownSample is always false.

So remove it. In turn, FXDIB_ResampleOptions::bInterpolateDownsample is
now always false, so remove it. In turn, StartQuickStrech() and
ContinueQuickStretch() are now unused, so remove them. In turn,
m_bFlipX, m_bFlipY, and m_LineIndex are now unused, so remove them.

It is just as well since forced downsampling without any interpolation
always looks terrible ...

Change-Id: I798bec7494d0ffa0744a80b220dc29276b2de220
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/64930
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fpdfapi/render/cpdf_imagerenderer.cpp b/core/fpdfapi/render/cpdf_imagerenderer.cpp
index 3277949..4f5dde2 100644
--- a/core/fpdfapi/render/cpdf_imagerenderer.cpp
+++ b/core/fpdfapi/render/cpdf_imagerenderer.cpp
@@ -110,9 +110,7 @@
     m_pDIBBase = pClone;
   }
   m_ResampleOptions = FXDIB_ResampleOptions();
-  if (GetRenderOptions().GetOptions().bForceDownsample)
-    m_ResampleOptions.bInterpolateDownsample = true;
-  else if (GetRenderOptions().GetOptions().bForceHalftone)
+  if (GetRenderOptions().GetOptions().bForceHalftone)
     m_ResampleOptions.bHalftone = true;
 
   if (m_pRenderStatus->GetRenderDevice()->GetDeviceType() !=
@@ -377,7 +375,7 @@
 }
 
 bool CPDF_ImageRenderer::StartDIBBase() {
-  if (!m_ResampleOptions.bInterpolateDownsample && m_pDIBBase->GetBPP() > 1) {
+  if (m_pDIBBase->GetBPP() > 1) {
     FX_SAFE_SIZE_T image_size = m_pDIBBase->GetBPP();
     image_size /= 8;
     image_size *= m_pDIBBase->GetWidth();
diff --git a/core/fpdfapi/render/cpdf_renderoptions.h b/core/fpdfapi/render/cpdf_renderoptions.h
index 8efeb40..84f7e4c 100644
--- a/core/fpdfapi/render/cpdf_renderoptions.h
+++ b/core/fpdfapi/render/cpdf_renderoptions.h
@@ -22,7 +22,6 @@
 
     bool bClearType = false;
     bool bPrintGraphicText = false;
-    bool bForceDownsample = false;
     bool bPrintPreview = false;
     bool bBGRStripe = false;
     bool bNoNativeText = false;
diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp
index 2b305f4..b72602a 100644
--- a/core/fpdfapi/render/cpdf_renderstatus.cpp
+++ b/core/fpdfapi/render/cpdf_renderstatus.cpp
@@ -999,7 +999,6 @@
       CPDF_RenderOptions options = m_Options;
       options.GetOptions().bForceHalftone = true;
       options.GetOptions().bRectAA = true;
-      options.GetOptions().bForceDownsample = false;
 
       const auto* pForm = static_cast<const CPDF_Form*>(pType3Char->form());
       const CPDF_Dictionary* pFormResource =
diff --git a/core/fxge/dib/cfx_imagestretcher.cpp b/core/fxge/dib/cfx_imagestretcher.cpp
index 3e97563..1499e8a 100644
--- a/core/fxge/dib/cfx_imagestretcher.cpp
+++ b/core/fxge/dib/cfx_imagestretcher.cpp
@@ -53,14 +53,11 @@
     : m_pDest(pDest),
       m_pSource(pSource),
       m_ResampleOptions(options),
-      m_bFlipX(false),
-      m_bFlipY(false),
       m_DestWidth(dest_width),
       m_DestHeight(dest_height),
       m_ClipRect(bitmap_rect),
       m_DestFormat(GetStretchedFormat(*pSource)),
-      m_DestBPP(GetBppFromFormat(m_DestFormat)),
-      m_LineIndex(0) {
+      m_DestBPP(GetBppFromFormat(m_DestFormat)) {
   ASSERT(m_ClipRect.Valid());
 }
 
@@ -121,15 +118,10 @@
                                m_DestFormat, nullptr)) {
     return false;
   }
-
-  if (m_ResampleOptions.bInterpolateDownsample)
-    return StartQuickStretch();
   return StartStretch();
 }
 
 bool CFX_ImageStretcher::Continue(PauseIndicatorIface* pPause) {
-  if (m_ResampleOptions.bInterpolateDownsample)
-    return ContinueQuickStretch(pPause);
   return ContinueStretch(pPause);
 }
 
@@ -152,76 +144,3 @@
 bool CFX_ImageStretcher::ContinueStretch(PauseIndicatorIface* pPause) {
   return m_pStretchEngine && m_pStretchEngine->Continue(pPause);
 }
-
-bool CFX_ImageStretcher::StartQuickStretch() {
-  if (m_DestWidth < 0) {
-    m_bFlipX = true;
-    m_DestWidth = -m_DestWidth;
-  }
-  if (m_DestHeight < 0) {
-    m_bFlipY = true;
-    m_DestHeight = -m_DestHeight;
-  }
-  uint32_t size = m_ClipRect.Width();
-  if (size && m_DestBPP > static_cast<int>(INT_MAX / size))
-    return false;
-
-  size *= m_DestBPP;
-  m_pScanline.reset(FX_Alloc(uint8_t, FxAlignToBoundary<4>(size / 8)));
-  if (m_pSource->m_pAlphaMask) {
-    m_pMaskScanline.reset(
-        FX_Alloc(uint8_t, FxAlignToBoundary<4>(m_ClipRect.Width())));
-  }
-  if (SourceSizeWithinLimit(m_pSource->GetWidth(), m_pSource->GetHeight())) {
-    ContinueQuickStretch(nullptr);
-    return false;
-  }
-  return true;
-}
-
-bool CFX_ImageStretcher::ContinueQuickStretch(PauseIndicatorIface* pPause) {
-  if (!m_pScanline)
-    return false;
-
-  int result_width = m_ClipRect.Width();
-  int result_height = m_ClipRect.Height();
-  int src_height = m_pSource->GetHeight();
-  for (; m_LineIndex < result_height; ++m_LineIndex) {
-    int dest_y;
-    FX_SAFE_INT64 calc_buf;
-    if (m_bFlipY) {
-      dest_y = result_height - m_LineIndex - 1;
-      calc_buf = m_DestHeight;
-      calc_buf -= dest_y;
-      calc_buf -= m_ClipRect.top;
-      calc_buf -= 1;
-      calc_buf *= src_height;
-      calc_buf /= m_DestHeight;
-    } else {
-      dest_y = m_LineIndex;
-      calc_buf = dest_y;
-      calc_buf += m_ClipRect.top;
-      calc_buf *= src_height;
-      calc_buf /= m_DestHeight;
-    }
-
-    int src_y;
-    if (!calc_buf.AssignIfValid(&src_y))
-      return false;
-
-    src_y = pdfium::clamp(src_y, 0, src_height - 1);
-    if (m_pSource->SkipToScanline(src_y, pPause))
-      return true;
-
-    m_pSource->DownSampleScanline(src_y, m_pScanline.get(), m_DestBPP,
-                                  m_DestWidth, m_bFlipX, m_ClipRect.left,
-                                  result_width);
-    if (m_pMaskScanline) {
-      m_pSource->m_pAlphaMask->DownSampleScanline(
-          src_y, m_pMaskScanline.get(), 1, m_DestWidth, m_bFlipX,
-          m_ClipRect.left, result_width);
-    }
-    m_pDest->ComposeScanline(dest_y, m_pScanline.get(), m_pMaskScanline.get());
-  }
-  return false;
-}
diff --git a/core/fxge/dib/cfx_imagestretcher.h b/core/fxge/dib/cfx_imagestretcher.h
index 1086a85..1ed9695 100644
--- a/core/fxge/dib/cfx_imagestretcher.h
+++ b/core/fxge/dib/cfx_imagestretcher.h
@@ -36,9 +36,7 @@
   RetainPtr<CFX_DIBBase> source();
 
  private:
-  bool StartQuickStretch();
   bool StartStretch();
-  bool ContinueQuickStretch(PauseIndicatorIface* pPause);
   bool ContinueStretch(PauseIndicatorIface* pPause);
 
   UnownedPtr<ScanlineComposerIface> const m_pDest;
@@ -47,14 +45,11 @@
   std::unique_ptr<uint8_t, FxFreeDeleter> m_pScanline;
   std::unique_ptr<uint8_t, FxFreeDeleter> m_pMaskScanline;
   const FXDIB_ResampleOptions m_ResampleOptions;
-  bool m_bFlipX;
-  bool m_bFlipY;
   int m_DestWidth;
   int m_DestHeight;
   const FX_RECT m_ClipRect;
   const FXDIB_Format m_DestFormat;
   const int m_DestBPP;
-  int m_LineIndex;
 };
 
 #endif  // CORE_FXGE_DIB_CFX_IMAGESTRETCHER_H_
diff --git a/core/fxge/dib/cfx_imagetransformer.cpp b/core/fxge/dib/cfx_imagetransformer.cpp
index 446b881..3c02603 100644
--- a/core/fxge/dib/cfx_imagetransformer.cpp
+++ b/core/fxge/dib/cfx_imagetransformer.cpp
@@ -584,7 +584,7 @@
 }
 
 bool CFX_ImageTransformer::IsBilinear() const {
-  return !m_ResampleOptions.bInterpolateDownsample && !IsBiCubic();
+  return !IsBiCubic();
 }
 
 bool CFX_ImageTransformer::IsBiCubic() const {
diff --git a/core/fxge/dib/cstretchengine.cpp b/core/fxge/dib/cstretchengine.cpp
index 827a2c9..8636430 100644
--- a/core/fxge/dib/cstretchengine.cpp
+++ b/core/fxge/dib/cstretchengine.cpp
@@ -255,7 +255,6 @@
   m_ExtraMaskPitch = GetPitchRoundUpTo4Bytes(m_DestClip.Width() * 8);
   if (options.bNoSmoothing) {
     m_ResampleOptions.bNoSmoothing = true;
-    m_ResampleOptions.bInterpolateDownsample = options.bInterpolateDownsample;
   } else {
     bool bInterpol =
         options.bInterpolateBilinear || options.bInterpolateBicubic;
diff --git a/core/fxge/dib/cstretchengine_unittest.cpp b/core/fxge/dib/cstretchengine_unittest.cpp
index bd783d6..5bd92a0 100644
--- a/core/fxge/dib/cstretchengine_unittest.cpp
+++ b/core/fxge/dib/cstretchengine_unittest.cpp
@@ -26,7 +26,6 @@
   dib_source->Load(nullptr, stream.Get());
   CStretchEngine engine(nullptr, FXDIB_8bppRgb, 500, 500, clip_rect, dib_source,
                         FXDIB_ResampleOptions());
-  EXPECT_FALSE(engine.m_ResampleOptions.bInterpolateDownsample);
   EXPECT_TRUE(engine.m_ResampleOptions.bInterpolateBilinear);
   EXPECT_FALSE(engine.m_ResampleOptions.bInterpolateBicubic);
   EXPECT_FALSE(engine.m_ResampleOptions.bHalftone);
diff --git a/core/fxge/dib/fx_dib_main.cpp b/core/fxge/dib/fx_dib_main.cpp
index 4b3510e..031fe65 100644
--- a/core/fxge/dib/fx_dib_main.cpp
+++ b/core/fxge/dib/fx_dib_main.cpp
@@ -58,8 +58,8 @@
 FXDIB_ResampleOptions::FXDIB_ResampleOptions() = default;
 
 bool FXDIB_ResampleOptions::HasAnyOptions() const {
-  return bInterpolateDownsample || bInterpolateBilinear ||
-         bInterpolateBicubic || bHalftone || bNoSmoothing || bLossy;
+  return bInterpolateBilinear || bInterpolateBicubic || bHalftone ||
+         bNoSmoothing || bLossy;
 }
 
 FX_RECT FXDIB_SwapClipBox(const FX_RECT& clip,
diff --git a/core/fxge/fx_dib.h b/core/fxge/fx_dib.h
index e16957c..662ede9 100644
--- a/core/fxge/fx_dib.h
+++ b/core/fxge/fx_dib.h
@@ -51,7 +51,6 @@
 
   bool HasAnyOptions() const;
 
-  bool bInterpolateDownsample = false;
   bool bInterpolateBilinear = false;
   bool bInterpolateBicubic = false;
   bool bHalftone = false;