Clean up CStretchEngine

- Remove CStretchEngine::FixedFromFloat(), since its only caller in
  ProgressiveDecoder is gone.
- Stop exposing TotalBytesForWeightCount() in the header, since it has
  no external callers now.

Change-Id: I72f7a1c2a5efbdd702005a024f7eb4d0ad1c43c3
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/122593
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Tom Sepez <tsepez@google.com>
diff --git a/core/fxge/dib/cstretchengine.cpp b/core/fxge/dib/cstretchengine.cpp
index 0e67e15..299b87d 100644
--- a/core/fxge/dib/cstretchengine.cpp
+++ b/core/fxge/dib/cstretchengine.cpp
@@ -26,6 +26,21 @@
     std::is_trivially_destructible<CStretchEngine::PixelWeight>::value,
     "PixelWeight storage may be re-used without invoking its destructor");
 
+namespace {
+
+size_t TotalBytesForWeightCount(size_t weight_count) {
+  // Always room for one weight even for empty ranges due to declaration
+  // of m_Weights[1] in the header. Don't shrink below this since
+  // CalculateWeights() relies on this later.
+  const size_t extra_weights = weight_count > 0 ? weight_count - 1 : 0;
+  FX_SAFE_SIZE_T total_bytes = extra_weights;
+  total_bytes *= sizeof(CStretchEngine::PixelWeight::m_Weights[0]);
+  total_bytes += sizeof(CStretchEngine::PixelWeight);
+  return total_bytes.ValueOrDie();
+}
+
+}  // namespace
+
 // static
 bool CStretchEngine::UseInterpolateBilinear(
     const FXDIB_ResampleOptions& options,
@@ -39,19 +54,6 @@
              static_cast<long long>(src_width) * src_height / abs(dest_width);
 }
 
-// static
-size_t CStretchEngine::PixelWeight::TotalBytesForWeightCount(
-    size_t weight_count) {
-  // Always room for one weight even for empty ranges due to declaration
-  // of m_Weights[1] in the header. Don't shrink below this since
-  // CalculateWeights() relies on this later.
-  const size_t extra_weights = weight_count > 0 ? weight_count - 1 : 0;
-  FX_SAFE_SIZE_T total_bytes = extra_weights;
-  total_bytes *= sizeof(m_Weights[0]);
-  total_bytes += sizeof(PixelWeight);
-  return total_bytes.ValueOrDie();
-}
-
 CStretchEngine::WeightTable::WeightTable() = default;
 
 CStretchEngine::WeightTable::~WeightTable() = default;
@@ -85,7 +87,7 @@
   const double scale = static_cast<double>(src_len) / dest_len;
   const double base = dest_len < 0 ? src_len : 0;
   const size_t weight_count = static_cast<size_t>(ceil(fabs(scale))) + 1;
-  m_ItemSizeBytes = PixelWeight::TotalBytesForWeightCount(weight_count);
+  m_ItemSizeBytes = TotalBytesForWeightCount(weight_count);
 
   const size_t dest_range = static_cast<size_t>(dest_max - dest_min);
   const size_t kMaxTableItemsAllowed = kMaxTableBytesAllowed / m_ItemSizeBytes;
diff --git a/core/fxge/dib/cstretchengine.h b/core/fxge/dib/cstretchengine.h
index 96c786d..2783a63 100644
--- a/core/fxge/dib/cstretchengine.h
+++ b/core/fxge/dib/cstretchengine.h
@@ -32,10 +32,6 @@
     return static_cast<uint32_t>(FXSYS_round(d * kFixedPointOne));
   }
 
-  static inline uint32_t FixedFromFloat(float f) {
-    return static_cast<uint32_t>(FXSYS_roundf(f * kFixedPointOne));
-  }
-
   static inline uint8_t PixelFromFixed(uint32_t fixed) {
     return static_cast<uint8_t>(fixed >> kFixedPointBits);
   }
@@ -49,8 +45,6 @@
                                      int src_height);
 
   struct PixelWeight {
-    static size_t TotalBytesForWeightCount(size_t weight_count);
-
     void SetStartEnd(int src_start, int src_end, size_t weight_count) {
       CHECK_LT(src_end - src_start, static_cast<int>(weight_count));
       m_SrcStart = src_start;