Move struct PixelWeight to cstretchengine.h

It is currently in fx_dib.h, but it is more closely related to the
code and classes in cstretchengine.h.

Change-Id: I91671c9c246e1003b19af26f37bc7cc6a80bf216
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/82150
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/core/fxge/dib/cstretchengine.cpp b/core/fxge/dib/cstretchengine.cpp
index f486338..4465d3a 100644
--- a/core/fxge/dib/cstretchengine.cpp
+++ b/core/fxge/dib/cstretchengine.cpp
@@ -7,8 +7,10 @@
 #include "core/fxge/dib/cstretchengine.h"
 
 #include <algorithm>
+#include <type_traits>
 #include <utility>
 
+#include "core/fxcrt/fx_safe_types.h"
 #include "core/fxcrt/pauseindicator_iface.h"
 #include "core/fxge/dib/cfx_dibbase.h"
 #include "core/fxge/dib/cfx_dibitmap.h"
@@ -17,6 +19,10 @@
 #include "third_party/base/check.h"
 #include "third_party/base/stl_util.h"
 
+static_assert(
+    std::is_trivially_destructible<PixelWeight>::value,
+    "PixelWeight storage may be re-used without invoking its destructor");
+
 namespace {
 
 constexpr uint32_t kFixedPointBits = 16;
@@ -36,6 +42,15 @@
 
 }  // namespace
 
+// static
+size_t PixelWeight::TotalBytesForWeightCount(size_t weight_count) {
+  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::CWeightTable::CWeightTable() = default;
 
 CStretchEngine::CWeightTable::~CWeightTable() = default;
diff --git a/core/fxge/dib/cstretchengine.h b/core/fxge/dib/cstretchengine.h
index 600212f..8a2901a 100644
--- a/core/fxge/dib/cstretchengine.h
+++ b/core/fxge/dib/cstretchengine.h
@@ -14,12 +14,44 @@
 #include "core/fxcrt/retain_ptr.h"
 #include "core/fxcrt/unowned_ptr.h"
 #include "core/fxge/dib/fx_dib.h"
+#include "third_party/base/check_op.h"
 #include "third_party/base/span.h"
 
 class CFX_DIBBase;
 class PauseIndicatorIface;
 class ScanlineComposerIface;
 
+struct PixelWeight {
+  static size_t TotalBytesForWeightCount(size_t weight_count);
+
+  void SetStartEnd(int src_start, int src_end, size_t weight_count) {
+    CHECK_LT(static_cast<size_t>(src_end - src_start), weight_count);
+    m_SrcStart = src_start;
+    m_SrcEnd = src_end;
+  }
+
+  uint32_t GetWeightForPosition(int position) const {
+    CHECK_GE(position, m_SrcStart);
+    CHECK_LE(position, m_SrcEnd);
+    return m_Weights[position - m_SrcStart];
+  }
+
+  void SetWeightForPosition(int position, uint32_t weight) {
+    CHECK_GE(position, m_SrcStart);
+    CHECK_LE(position, m_SrcEnd);
+    m_Weights[position - m_SrcStart] = weight;
+  }
+
+  void RemoveLastWeight() {
+    CHECK_GT(m_SrcEnd, m_SrcStart);
+    --m_SrcEnd;
+  }
+
+  int m_SrcStart;
+  int m_SrcEnd;           // Note: inclusive.
+  uint32_t m_Weights[1];  // Not really 1, variable size.
+};
+
 class CStretchEngine {
  public:
   CStretchEngine(ScanlineComposerIface* pDestBitmap,
diff --git a/core/fxge/dib/fx_dib.cpp b/core/fxge/dib/fx_dib.cpp
index 9bdc12d..1f67cd8 100644
--- a/core/fxge/dib/fx_dib.cpp
+++ b/core/fxge/dib/fx_dib.cpp
@@ -7,16 +7,10 @@
 #include "core/fxge/dib/fx_dib.h"
 
 #include <tuple>
-#include <type_traits>
 #include <utility>
 
 #include "build/build_config.h"
 #include "core/fxcrt/fx_extension.h"
-#include "core/fxcrt/fx_safe_types.h"
-
-static_assert(
-    std::is_trivially_destructible<PixelWeight>::value,
-    "PixelWeight storage may be re-used without invoking its destructor");
 
 #if defined(OS_WIN)
 static_assert(sizeof(FX_COLORREF) == sizeof(COLORREF),
@@ -38,15 +32,6 @@
   }
 }
 
-// static
-size_t PixelWeight::TotalBytesForWeightCount(size_t weight_count) {
-  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();
-}
-
 FXDIB_ResampleOptions::FXDIB_ResampleOptions() = default;
 
 bool FXDIB_ResampleOptions::HasAnyOptions() const {
diff --git a/core/fxge/dib/fx_dib.h b/core/fxge/dib/fx_dib.h
index 5cb271e..b1d8b3f 100644
--- a/core/fxge/dib/fx_dib.h
+++ b/core/fxge/dib/fx_dib.h
@@ -13,7 +13,6 @@
 #include <utility>
 
 #include "core/fxcrt/fx_coordinates.h"
-#include "third_party/base/check_op.h"
 
 #if defined(PDF_ENABLE_XFA)
 #include "core/fxcrt/widestring.h"
@@ -30,37 +29,6 @@
   kArgb = 0x220,
 };
 
-struct PixelWeight {
-  static size_t TotalBytesForWeightCount(size_t weight_count);
-
-  void SetStartEnd(int src_start, int src_end, size_t weight_count) {
-    CHECK_LT(static_cast<size_t>(src_end - src_start), weight_count);
-    m_SrcStart = src_start;
-    m_SrcEnd = src_end;
-  }
-
-  uint32_t GetWeightForPosition(int position) const {
-    CHECK_GE(position, m_SrcStart);
-    CHECK_LE(position, m_SrcEnd);
-    return m_Weights[position - m_SrcStart];
-  }
-
-  void SetWeightForPosition(int position, uint32_t weight) {
-    CHECK_GE(position, m_SrcStart);
-    CHECK_LE(position, m_SrcEnd);
-    m_Weights[position - m_SrcStart] = weight;
-  }
-
-  void RemoveLastWeight() {
-    CHECK_GT(m_SrcEnd, m_SrcStart);
-    --m_SrcEnd;
-  }
-
-  int m_SrcStart;
-  int m_SrcEnd;           // Note: inclusive.
-  uint32_t m_Weights[1];  // Not really 1, variable size.
-};
-
 using FX_ARGB = uint32_t;
 using FX_CMYK = uint32_t;