Get rid of CompositeRowArgb2RgbNoBlend()
Merge with CompositeRowArgb2RgbBlend() to form CompositeRowArgb2Rgb(),
which now looks like CompositeRowArgb2Argb().
Change-Id: I3084879d4abd15b9d97f02cd1d60170ba53f4810
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/123130
Reviewed-by: Tom Sepez <tsepez@google.com>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fxge/dib/cfx_scanlinecompositor.cpp b/core/fxge/dib/cfx_scanlinecompositor.cpp
index d6b12ef..9473107 100644
--- a/core/fxge/dib/cfx_scanlinecompositor.cpp
+++ b/core/fxge/dib/cfx_scanlinecompositor.cpp
@@ -474,11 +474,10 @@
}
template <typename DestPixelStruct>
-void CompositeRowArgb2RgbBlend(
- pdfium::span<const FX_BGRA_STRUCT<uint8_t>> src_span,
- pdfium::span<const uint8_t> clip_span,
- pdfium::span<DestPixelStruct> dest_span,
- BlendMode blend_type) {
+void CompositeRowArgb2Rgb(pdfium::span<const FX_BGRA_STRUCT<uint8_t>> src_span,
+ pdfium::span<const uint8_t> clip_span,
+ pdfium::span<DestPixelStruct> dest_span,
+ BlendMode blend_type) {
const bool non_separable_blend = IsNonSeparableBlendMode(blend_type);
if (clip_span.empty()) {
if (non_separable_blend) {
@@ -488,8 +487,14 @@
}
return;
}
+ if (blend_type != BlendMode::kNormal) {
+ for (auto [input, output] : fxcrt::Zip(src_span, dest_span)) {
+ CompositePixelArgb2RgbBlend(input, /*clip=*/255, output, blend_type);
+ }
+ return;
+ }
for (auto [input, output] : fxcrt::Zip(src_span, dest_span)) {
- CompositePixelArgb2RgbBlend(input, /*clip=*/255, output, blend_type);
+ CompositePixelArgb2RgbNoBlend(input, /*clip=*/255, output);
}
return;
}
@@ -501,24 +506,13 @@
}
return;
}
- for (auto [input, clip, output] :
- fxcrt::Zip(src_span, clip_span, dest_span)) {
- CompositePixelArgb2RgbBlend(input, clip, output, blend_type);
- }
-}
-
-template <typename DestPixelStruct>
-void CompositeRowArgb2RgbNoBlend(
- pdfium::span<const FX_BGRA_STRUCT<uint8_t>> src_span,
- pdfium::span<const uint8_t> clip_span,
- pdfium::span<DestPixelStruct> dest_span) {
- if (clip_span.empty()) {
- for (auto [input, output] : fxcrt::Zip(src_span, dest_span)) {
- CompositePixelArgb2RgbNoBlend(input, /*clip=*/255, output);
+ if (blend_type != BlendMode::kNormal) {
+ for (auto [input, clip, output] :
+ fxcrt::Zip(src_span, clip_span, dest_span)) {
+ CompositePixelArgb2RgbBlend(input, clip, output, blend_type);
}
return;
}
-
for (auto [input, clip, output] :
fxcrt::Zip(src_span, clip_span, dest_span)) {
CompositePixelArgb2RgbNoBlend(input, clip, output);
@@ -2431,21 +2425,13 @@
if (m_bRgbByteOrder) {
auto dest_span =
fxcrt::reinterpret_span<FX_RGB_STRUCT<uint8_t>>(dest_scan);
- if (m_BlendType == BlendMode::kNormal) {
- CompositeRowArgb2RgbNoBlend(src_span, clip_scan, dest_span);
- return;
- }
- CompositeRowArgb2RgbBlend(src_span, clip_scan, dest_span, m_BlendType);
+ CompositeRowArgb2Rgb(src_span, clip_scan, dest_span, m_BlendType);
return;
}
auto dest_span =
fxcrt::reinterpret_span<FX_BGR_STRUCT<uint8_t>>(dest_scan);
- if (m_BlendType == BlendMode::kNormal) {
- CompositeRowArgb2RgbNoBlend(src_span, clip_scan, dest_span);
- return;
- }
- CompositeRowArgb2RgbBlend(src_span, clip_scan, dest_span, m_BlendType);
+ CompositeRowArgb2Rgb(src_span, clip_scan, dest_span, m_BlendType);
return;
}
case FXDIB_Format::kRgb32: {
@@ -2455,21 +2441,13 @@
if (m_bRgbByteOrder) {
auto dest_span =
fxcrt::reinterpret_span<FX_RGBA_STRUCT<uint8_t>>(dest_scan);
- if (m_BlendType == BlendMode::kNormal) {
- CompositeRowArgb2RgbNoBlend(src_span, clip_scan, dest_span);
- return;
- }
- CompositeRowArgb2RgbBlend(src_span, clip_scan, dest_span, m_BlendType);
+ CompositeRowArgb2Rgb(src_span, clip_scan, dest_span, m_BlendType);
return;
}
auto dest_span =
fxcrt::reinterpret_span<FX_BGRA_STRUCT<uint8_t>>(dest_scan);
- if (m_BlendType == BlendMode::kNormal) {
- CompositeRowArgb2RgbNoBlend(src_span, clip_scan, dest_span);
- return;
- }
- CompositeRowArgb2RgbBlend(src_span, clip_scan, dest_span, m_BlendType);
+ CompositeRowArgb2Rgb(src_span, clip_scan, dest_span, m_BlendType);
return;
}
case FXDIB_Format::kArgb: {