Mention a restriction for ScanlineComposerIface::SetInfo().

SetInfo() is only called from CFX_ImageStretcher, and CFX_ImageStretcher
limits what formats it calls SetInfo() with. Document this in the
SetInfo() interface, and enforce it in the SetInfo() implementations.
This helps document interactions between CFX_BitmapComposer::SetInfo()
and CFX_ScanlineCompositor.

Change-Id: I954dce307df55906bb7f0590ece55f5efd6e0526
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/102770
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fxge/dib/cfx_bitmapcomposer.cpp b/core/fxge/dib/cfx_bitmapcomposer.cpp
index fe31d4f..009a618 100644
--- a/core/fxge/dib/cfx_bitmapcomposer.cpp
+++ b/core/fxge/dib/cfx_bitmapcomposer.cpp
@@ -14,6 +14,7 @@
 #include "core/fxcrt/span_util.h"
 #include "core/fxge/cfx_cliprgn.h"
 #include "core/fxge/dib/cfx_dibitmap.h"
+#include "third_party/base/check_op.h"
 
 CFX_BitmapComposer::CFX_BitmapComposer() = default;
 
@@ -51,6 +52,8 @@
                                  int height,
                                  FXDIB_Format src_format,
                                  pdfium::span<const uint32_t> src_palette) {
+  DCHECK_NE(src_format, FXDIB_Format::k1bppMask);
+  DCHECK_NE(src_format, FXDIB_Format::k1bppRgb);
   m_SrcFormat = src_format;
   if (!m_Compositor.Init(m_pBitmap->GetFormat(), src_format, src_palette,
                          m_MaskColor, m_BlendMode,
diff --git a/core/fxge/dib/cfx_bitmapstorer.cpp b/core/fxge/dib/cfx_bitmapstorer.cpp
index 26ee268..607b0cb 100644
--- a/core/fxge/dib/cfx_bitmapstorer.cpp
+++ b/core/fxge/dib/cfx_bitmapstorer.cpp
@@ -12,6 +12,7 @@
 
 #include "core/fxcrt/span_util.h"
 #include "core/fxge/dib/cfx_dibitmap.h"
+#include "third_party/base/check_op.h"
 
 CFX_BitmapStorer::CFX_BitmapStorer() = default;
 
@@ -36,6 +37,8 @@
                                int height,
                                FXDIB_Format src_format,
                                pdfium::span<const uint32_t> src_palette) {
+  DCHECK_NE(src_format, FXDIB_Format::k1bppMask);
+  DCHECK_NE(src_format, FXDIB_Format::k1bppRgb);
   auto pBitmap = pdfium::MakeRetain<CFX_DIBitmap>();
   if (!pBitmap->Create(width, height, src_format))
     return false;
diff --git a/core/fxge/dib/scanlinecomposer_iface.h b/core/fxge/dib/scanlinecomposer_iface.h
index 0529859..57baf9b 100644
--- a/core/fxge/dib/scanlinecomposer_iface.h
+++ b/core/fxge/dib/scanlinecomposer_iface.h
@@ -17,6 +17,8 @@
   virtual void ComposeScanline(int line,
                                pdfium::span<const uint8_t> scanline) = 0;
 
+  // `src_format` cannot be `FXDIB_Format::k1bppMask` or
+  // `FXDIB_Format::k1bppRgb`.
   virtual bool SetInfo(int width,
                        int height,
                        FXDIB_Format src_format,