[rust png] Extract reusable `PngDecoderDelegate::GetNumberOfComponents`.

This CL just moves `GetNumberOfSrcComponents` from
`progressive_decoder.cpp` into `png_decoder_delegate.cpp`.  This makes
it possible to reuse this little helper in follow-up CLs, where it will
be needed for implementing a Skia-based PNG decoder.

Bug: 444045690
Change-Id: I105021b0fea71e97ba182f84415f04e6af9dd2c9
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/136090
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Ɓukasz Anforowicz <lukasza@google.com>
diff --git a/core/fxcodec/BUILD.gn b/core/fxcodec/BUILD.gn
index 85733fd..e61f710 100644
--- a/core/fxcodec/BUILD.gn
+++ b/core/fxcodec/BUILD.gn
@@ -122,6 +122,8 @@
       sources += [
         "png/png_decoder.cpp",
         "png/png_decoder.h",
+        "png/png_decoder_delegate.cpp",
+        "png/png_decoder_delegate.h",
       ]
       deps += [ "../../third_party:png" ]
     }
diff --git a/core/fxcodec/png/png_decoder_delegate.cpp b/core/fxcodec/png/png_decoder_delegate.cpp
new file mode 100644
index 0000000..f6a210a
--- /dev/null
+++ b/core/fxcodec/png/png_decoder_delegate.cpp
@@ -0,0 +1,27 @@
+// Copyright 2025 The PDFium Authors
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "core/fxcodec/png/png_decoder_delegate.h"
+
+#include "core/fxcrt/notreached.h"
+
+namespace fxcodec {
+
+// static
+int PngDecoderDelegate::GetNumberOfComponents(EncodedColorType color_type) {
+  switch (color_type) {
+    case EncodedColorType::kGrayscale:
+      return 1;
+    case EncodedColorType::kGrayscaleWithAlpha:
+      return 2;
+    case EncodedColorType::kTruecolor:
+      return 3;
+    case EncodedColorType::kIndexedColor:
+    case EncodedColorType::kTruecolorWithAlpha:
+      return 4;
+  }
+  NOTREACHED();
+}
+
+}  // namespace fxcodec
diff --git a/core/fxcodec/png/png_decoder_delegate.h b/core/fxcodec/png/png_decoder_delegate.h
index a28e18c..a158da5 100644
--- a/core/fxcodec/png/png_decoder_delegate.h
+++ b/core/fxcodec/png/png_decoder_delegate.h
@@ -68,6 +68,11 @@
   // Called by `PngDecoder` Communicates that `line`th row has been decoded
   // enough to be displayed.
   virtual void PngFillScanlineBufCompleted(int line) = 0;
+
+  // Helper to get the number of components in the given `color_type`.  For
+  // example, when called with `EncodedColorType::kTruecolor` (RGB) the helper
+  // will return `3`.
+  static int GetNumberOfComponents(EncodedColorType color_type);
 };
 
 }  // namespace fxcodec
diff --git a/core/fxcodec/progressive_decoder.cpp b/core/fxcodec/progressive_decoder.cpp
index 6104534..25c5355 100644
--- a/core/fxcodec/progressive_decoder.cpp
+++ b/core/fxcodec/progressive_decoder.cpp
@@ -39,6 +39,7 @@
 
 #ifdef PDF_ENABLE_XFA_PNG
 #include "core/fxcodec/png/png_decoder.h"
+#include "core/fxcodec/png/png_decoder_delegate.h"
 #endif  // PDF_ENABLE_XFA_PNG
 
 #ifdef PDF_ENABLE_XFA_TIFF
@@ -76,23 +77,6 @@
   }
 }
 
-#ifdef PDF_ENABLE_XFA_PNG
-int GetNumberOfSrcComponents(PngEncodedColorType color_type) {
-  switch (color_type) {
-    case PngEncodedColorType::kGrayscale:
-      return 1;
-    case PngEncodedColorType::kGrayscaleWithAlpha:
-      return 2;
-    case PngEncodedColorType::kTruecolor:
-      return 3;
-    case PngEncodedColorType::kIndexedColor:
-    case PngEncodedColorType::kTruecolorWithAlpha:
-      return 4;
-  }
-  NOTREACHED();
-}
-#endif
-
 }  // namespace
 
 ProgressiveDecoder::ProgressiveDecoder() = default;
@@ -112,7 +96,7 @@
     src_height_ = height;
     src_bpc_ = bpc;
     src_pass_number_ = pass;
-    src_components_ = GetNumberOfSrcComponents(src_color_type);
+    src_components_ = PngDecoderDelegate::GetNumberOfComponents(src_color_type);
     return false;
   }
   switch (device_bitmap_->GetFormat()) {