Remove some dead code from CFX_BitmapComposer.
Remove CFX_BitmapComposer code that calls into CFX_DIBBase stub methods.
In turn, remove some parameters from CFX_ScanlineCompositor methods that
are always empty spans.
Change-Id: I6eb3951aceefc775f060daf60f179db35ae2a22f
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/101851
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 6cd3051..f549729 100644
--- a/core/fxge/dib/cfx_bitmapcomposer.cpp
+++ b/core/fxge/dib/cfx_bitmapcomposer.cpp
@@ -61,8 +61,6 @@
if (m_bVertical) {
m_pScanlineV.resize(m_pBitmap->GetBPP() / 8 * width + 4);
m_pClipScanV.resize(m_pBitmap->GetHeight());
- if (m_pBitmap->HasAlphaMask())
- m_pScanlineAlphaV.resize(width + 4);
}
if (m_BitmapAlpha < 255) {
m_pAddClipScan.resize(m_bVertical ? m_pBitmap->GetHeight()
@@ -71,12 +69,12 @@
return true;
}
-void CFX_BitmapComposer::DoCompose(pdfium::span<uint8_t> dest_scan,
- pdfium::span<const uint8_t> src_scan,
- int dest_width,
- pdfium::span<const uint8_t> clip_scan,
- pdfium::span<const uint8_t> src_extra_alpha,
- pdfium::span<uint8_t> dst_extra_alpha) {
+void CFX_BitmapComposer::DoCompose(
+ pdfium::span<uint8_t> dest_scan,
+ pdfium::span<const uint8_t> src_scan,
+ int dest_width,
+ pdfium::span<const uint8_t> clip_scan,
+ pdfium::span<const uint8_t> src_extra_alpha) {
if (m_BitmapAlpha < 255) {
if (!clip_scan.empty()) {
for (int i = 0; i < dest_width; ++i)
@@ -89,15 +87,13 @@
}
if (m_SrcFormat == FXDIB_Format::k8bppMask) {
m_Compositor.CompositeByteMaskLine(dest_scan, src_scan, dest_width,
- clip_scan, dst_extra_alpha);
+ clip_scan);
} else if (GetBppFromFormat(m_SrcFormat) == 8) {
m_Compositor.CompositePalBitmapLine(dest_scan, src_scan, 0, dest_width,
- clip_scan, src_extra_alpha,
- dst_extra_alpha);
+ clip_scan, src_extra_alpha);
} else {
m_Compositor.CompositeRgbBitmapLine(dest_scan, src_scan, dest_width,
- clip_scan, src_extra_alpha,
- dst_extra_alpha);
+ clip_scan, src_extra_alpha);
}
}
@@ -127,13 +123,7 @@
dest_scan = dest_scan.subspan(offset.ValueOrDie());
}
- pdfium::span<uint8_t> dest_alpha_scan =
- m_pBitmap->GetWritableAlphaMaskScanline(line + m_DestTop);
- if (!dest_alpha_scan.empty())
- dest_alpha_scan = dest_alpha_scan.subspan(m_DestLeft);
-
- DoCompose(dest_scan, scanline, m_DestWidth, clip_scan, scan_extra_alpha,
- dest_alpha_scan);
+ DoCompose(dest_scan, scanline, m_DestWidth, clip_scan, scan_extra_alpha);
}
void CFX_BitmapComposer::ComposeScanlineV(
@@ -142,7 +132,6 @@
pdfium::span<const uint8_t> scan_extra_alpha) {
int Bpp = m_pBitmap->GetBPP() / 8;
int dest_pitch = m_pBitmap->GetPitch();
- int dest_alpha_pitch = m_pBitmap->GetAlphaMaskPitch();
int dest_x = m_DestLeft + (m_bFlipX ? (m_DestWidth - line - 1) : line);
pdfium::span<uint8_t> dest_span = m_pBitmap->GetBuffer();
if (!dest_span.empty()) {
@@ -156,23 +145,7 @@
}
}
uint8_t* dest_buf = dest_span.data();
- pdfium::span<uint8_t> dest_alpha_span = m_pBitmap->GetAlphaMaskBuffer();
- if (!dest_alpha_span.empty()) {
- size_t dest_y_offset = Fx2DSizeOrDie(m_DestTop, dest_alpha_pitch);
- dest_alpha_span = dest_alpha_span.subspan(dest_x).subspan(dest_y_offset);
- if (m_bFlipY) {
- size_t dest_flip_offset =
- Fx2DSizeOrDie(dest_alpha_pitch, m_DestHeight - 1);
- dest_alpha_span = dest_alpha_span.subspan(dest_flip_offset);
- }
- }
- uint8_t* dest_alpha_buf = dest_alpha_span.data();
- int y_step = dest_pitch;
- int y_alpha_step = dest_alpha_pitch;
- if (m_bFlipY) {
- y_step = -y_step;
- y_alpha_step = -y_alpha_step;
- }
+ const int y_step = m_bFlipY ? -dest_pitch : dest_pitch;
uint8_t* src_scan = m_pScanlineV.data();
uint8_t* dest_scan = dest_buf;
for (int i = 0; i < m_DestHeight; ++i) {
@@ -180,14 +153,6 @@
*src_scan++ = dest_scan[j];
dest_scan += y_step;
}
- uint8_t* src_alpha_scan = m_pScanlineAlphaV.data();
- uint8_t* dest_alpha_scan = dest_alpha_buf;
- if (dest_alpha_scan) {
- for (int i = 0; i < m_DestHeight; ++i) {
- *src_alpha_scan++ = *dest_alpha_scan;
- dest_alpha_scan += y_alpha_step;
- }
- }
pdfium::span<uint8_t> clip_scan;
if (m_pClipMask) {
clip_scan = m_pClipScanV;
@@ -205,8 +170,7 @@
src_clip += clip_pitch;
}
}
- DoCompose(m_pScanlineV, scanline, m_DestHeight, clip_scan, scan_extra_alpha,
- m_pScanlineAlphaV);
+ DoCompose(m_pScanlineV, scanline, m_DestHeight, clip_scan, scan_extra_alpha);
src_scan = m_pScanlineV.data();
dest_scan = dest_buf;
for (int i = 0; i < m_DestHeight; ++i) {
@@ -214,12 +178,4 @@
dest_scan[j] = *src_scan++;
dest_scan += y_step;
}
- src_alpha_scan = m_pScanlineAlphaV.data();
- dest_alpha_scan = dest_alpha_buf;
- if (!dest_alpha_scan)
- return;
- for (int i = 0; i < m_DestHeight; ++i) {
- *dest_alpha_scan = *src_alpha_scan++;
- dest_alpha_scan += y_alpha_step;
- }
}
diff --git a/core/fxge/dib/cfx_bitmapcomposer.h b/core/fxge/dib/cfx_bitmapcomposer.h
index 8a0499a..3f73c2f 100644
--- a/core/fxge/dib/cfx_bitmapcomposer.h
+++ b/core/fxge/dib/cfx_bitmapcomposer.h
@@ -51,8 +51,7 @@
pdfium::span<const uint8_t> src_scan,
int dest_width,
pdfium::span<const uint8_t> clip_scan,
- pdfium::span<const uint8_t> src_extra_alpha,
- pdfium::span<uint8_t> dst_extra_alpha);
+ pdfium::span<const uint8_t> src_extra_alpha);
void ComposeScanlineV(int line,
pdfium::span<const uint8_t> scanline,
pdfium::span<const uint8_t> scan_extra_alpha);
@@ -76,7 +75,6 @@
DataVector<uint8_t> m_pScanlineV;
DataVector<uint8_t> m_pClipScanV;
DataVector<uint8_t> m_pAddClipScan;
- DataVector<uint8_t> m_pScanlineAlphaV;
};
#endif // CORE_FXGE_DIB_CFX_BITMAPCOMPOSER_H_
diff --git a/core/fxge/dib/cfx_dibitmap.cpp b/core/fxge/dib/cfx_dibitmap.cpp
index 03ca143..4b70361 100644
--- a/core/fxge/dib/cfx_dibitmap.cpp
+++ b/core/fxge/dib/cfx_dibitmap.cpp
@@ -764,8 +764,6 @@
pSrcAlphaMask
? pSrcAlphaMask->GetScanline(src_top + row).subspan(src_left)
: pdfium::span<const uint8_t>();
- // TODO(thestig): This span is always empty. Check for more dead code.
- pdfium::span<uint8_t> dst_scan_extra_alpha;
pdfium::span<const uint8_t> clip_scan;
if (pClipMask) {
clip_scan = pClipMask->GetWritableScanline(dest_top + row - clip_box.top)
@@ -773,12 +771,10 @@
}
if (bRgb) {
compositor.CompositeRgbBitmapLine(dest_scan, src_scan, width, clip_scan,
- src_scan_extra_alpha,
- dst_scan_extra_alpha);
+ src_scan_extra_alpha);
} else {
compositor.CompositePalBitmapLine(dest_scan, src_scan, src_left, width,
- clip_scan, src_scan_extra_alpha,
- dst_scan_extra_alpha);
+ clip_scan, src_scan_extra_alpha);
}
}
return true;
@@ -833,8 +829,6 @@
pdfium::span<uint8_t> dest_scan =
GetWritableScanline(dest_top + row).subspan(dest_left * Bpp);
pdfium::span<const uint8_t> src_scan = pMask->GetScanline(src_top + row);
- // TODO(thestig): This span is always empty. Check for more dead code.
- pdfium::span<uint8_t> dst_scan_extra_alpha;
pdfium::span<const uint8_t> clip_scan;
if (pClipMask) {
clip_scan = pClipMask->GetScanline(dest_top + row - clip_box.top)
@@ -842,10 +836,10 @@
}
if (src_bpp == 1) {
compositor.CompositeBitMaskLine(dest_scan, src_scan, src_left, width,
- clip_scan, dst_scan_extra_alpha);
+ clip_scan);
} else {
compositor.CompositeByteMaskLine(dest_scan, src_scan.subspan(src_left),
- width, clip_scan, dst_scan_extra_alpha);
+ width, clip_scan);
}
}
return true;
diff --git a/core/fxge/dib/cfx_scanlinecompositor.cpp b/core/fxge/dib/cfx_scanlinecompositor.cpp
index 4f178f5..b959e7e 100644
--- a/core/fxge/dib/cfx_scanlinecompositor.cpp
+++ b/core/fxge/dib/cfx_scanlinecompositor.cpp
@@ -2976,8 +2976,7 @@
pdfium::span<const uint8_t> src_scan,
int width,
pdfium::span<const uint8_t> clip_scan,
- pdfium::span<const uint8_t> src_extra_alpha,
- pdfium::span<uint8_t> dst_extra_alpha) {
+ pdfium::span<const uint8_t> src_extra_alpha) {
int src_Bpp = GetCompsFromFormat(m_SrcFormat);
int dest_Bpp = GetCompsFromFormat(m_DestFormat);
if (m_bRgbByteOrder) {
@@ -3049,16 +3048,18 @@
} else if (GetBppFromFormat(m_DestFormat) == 8) {
if (GetIsAlphaFromFormat(m_SrcFormat)) {
if (GetIsAlphaFromFormat(m_DestFormat)) {
+ // TODO(thestig): Check if empty span argument is always empty.
CompositeRow_Argb2Graya(dest_scan, src_scan, width, m_BlendType,
- clip_scan, src_extra_alpha, dst_extra_alpha);
+ clip_scan, src_extra_alpha, {});
} else {
CompositeRow_Argb2Gray(dest_scan, src_scan, width, m_BlendType,
clip_scan, src_extra_alpha);
}
} else {
if (GetIsAlphaFromFormat(m_DestFormat)) {
+ // TODO(thestig): Check if empty span argument is always empty.
CompositeRow_Rgb2Graya(dest_scan, src_scan, src_Bpp, width, m_BlendType,
- clip_scan, dst_extra_alpha);
+ clip_scan, {});
} else {
CompositeRow_Rgb2Gray(dest_scan, src_scan, src_Bpp, width, m_BlendType,
clip_scan);
@@ -3070,25 +3071,29 @@
case 4:
case 8:
case 4 + 8: {
+ // TODO(thestig): Check if empty span argument is always empty.
CompositeRow_Argb2Argb(dest_scan, src_scan, width, m_BlendType,
- clip_scan, dst_extra_alpha, src_extra_alpha);
+ clip_scan, {}, src_extra_alpha);
} break;
case 1:
- CompositeRow_Rgb2Argb_Blend_NoClip(
- dest_scan, src_scan, width, m_BlendType, src_Bpp, dst_extra_alpha);
+ // TODO(thestig): Check if empty span argument is always empty.
+ CompositeRow_Rgb2Argb_Blend_NoClip(dest_scan, src_scan, width,
+ m_BlendType, src_Bpp, {});
break;
case 1 + 8:
+ // TODO(thestig): Check if empty span argument is always empty.
CompositeRow_Rgb2Argb_Blend_Clip(dest_scan, src_scan, width,
- m_BlendType, src_Bpp, clip_scan,
- dst_extra_alpha);
+ m_BlendType, src_Bpp, clip_scan, {});
break;
case 1 + 4:
+ // TODO(thestig): Check if empty span argument is always empty.
CompositeRow_Rgb2Argb_NoBlend_NoClip(dest_scan, src_scan, width,
- src_Bpp, dst_extra_alpha);
+ src_Bpp, {});
break;
case 1 + 4 + 8:
+ // TODO(thestig): Check if empty span argument is always empty.
CompositeRow_Rgb2Argb_NoBlend_Clip(dest_scan, src_scan, width, src_Bpp,
- clip_scan, dst_extra_alpha);
+ clip_scan, {});
break;
case 2:
case 2 + 8:
@@ -3126,8 +3131,7 @@
int src_left,
int width,
pdfium::span<const uint8_t> clip_scan,
- pdfium::span<const uint8_t> src_extra_alpha,
- pdfium::span<uint8_t> dst_extra_alpha) {
+ pdfium::span<const uint8_t> src_extra_alpha) {
if (m_bRgbByteOrder) {
if (m_SrcFormat == FXDIB_Format::k1bppRgb) {
if (m_DestFormat == FXDIB_Format::k8bppRgb) {
@@ -3165,9 +3169,10 @@
if (GetBppFromFormat(m_DestFormat) == 8) {
if (m_iTransparency & 8) {
if (GetIsAlphaFromFormat(m_DestFormat)) {
+ // TODO(thestig): Check if empty span argument is always empty.
CompositeRow_1bppPal2Graya(dest_scan, src_scan, src_left,
m_SrcPalette.Get8BitPalette(), width,
- m_BlendType, clip_scan, dst_extra_alpha);
+ m_BlendType, clip_scan, {});
} else {
CompositeRow_1bppPal2Gray(dest_scan, src_scan, src_left,
m_SrcPalette.Get8BitPalette(), width,
@@ -3175,9 +3180,10 @@
}
} else {
if (GetIsAlphaFromFormat(m_DestFormat)) {
- CompositeRow_8bppPal2Graya(
- dest_scan, src_scan, m_SrcPalette.Get8BitPalette(), width,
- m_BlendType, clip_scan, dst_extra_alpha, src_extra_alpha);
+ // TODO(thestig): Check if empty span argument is always empty.
+ CompositeRow_8bppPal2Graya(dest_scan, src_scan,
+ m_SrcPalette.Get8BitPalette(), width,
+ m_BlendType, clip_scan, {}, src_extra_alpha);
} else {
CompositeRow_8bppPal2Gray(dest_scan, src_scan,
m_SrcPalette.Get8BitPalette(), width,
@@ -3212,9 +3218,10 @@
GetCompsFromFormat(m_DestFormat), clip_scan, src_extra_alpha);
break;
case 0 + 2 + 8:
+ // TODO(thestig): Check if empty span argument is always empty.
CompositeRow_1bppRgb2Rgba_NoBlend(dest_scan, src_scan, src_left, width,
m_SrcPalette.Get32BitPalette(),
- clip_scan, dst_extra_alpha);
+ clip_scan, {});
break;
}
}
@@ -3224,15 +3231,15 @@
pdfium::span<uint8_t> dest_scan,
pdfium::span<const uint8_t> src_scan,
int width,
- pdfium::span<const uint8_t> clip_scan,
- pdfium::span<uint8_t> dst_extra_alpha) {
+ pdfium::span<const uint8_t> clip_scan) {
if (m_DestFormat == FXDIB_Format::k8bppMask) {
CompositeRow_ByteMask2Mask(dest_scan, src_scan, m_MaskAlpha, width,
clip_scan);
} else if (GetBppFromFormat(m_DestFormat) == 8) {
if (GetIsAlphaFromFormat(m_DestFormat)) {
+ // TODO(thestig): Check if empty span argument is always empty.
CompositeRow_ByteMask2Graya(dest_scan, src_scan, m_MaskAlpha, m_MaskRed,
- width, clip_scan, dst_extra_alpha);
+ width, clip_scan, {});
} else {
CompositeRow_ByteMask2Gray(dest_scan, src_scan, m_MaskAlpha, m_MaskRed,
width, clip_scan);
@@ -3264,15 +3271,15 @@
pdfium::span<const uint8_t> src_scan,
int src_left,
int width,
- pdfium::span<const uint8_t> clip_scan,
- pdfium::span<uint8_t> dst_extra_alpha) {
+ pdfium::span<const uint8_t> clip_scan) {
if (m_DestFormat == FXDIB_Format::k8bppMask) {
CompositeRow_BitMask2Mask(dest_scan, src_scan, m_MaskAlpha, src_left, width,
clip_scan);
} else if (GetBppFromFormat(m_DestFormat) == 8) {
if (GetIsAlphaFromFormat(m_DestFormat)) {
+ // TODO(thestig): Check if empty span argument is always empty.
CompositeRow_BitMask2Graya(dest_scan, src_scan, m_MaskAlpha, m_MaskRed,
- src_left, width, clip_scan, dst_extra_alpha);
+ src_left, width, clip_scan, {});
} else {
CompositeRow_BitMask2Gray(dest_scan, src_scan, m_MaskAlpha, m_MaskRed,
src_left, width, clip_scan);
diff --git a/core/fxge/dib/cfx_scanlinecompositor.h b/core/fxge/dib/cfx_scanlinecompositor.h
index 6b0079b..7827ad3 100644
--- a/core/fxge/dib/cfx_scanlinecompositor.h
+++ b/core/fxge/dib/cfx_scanlinecompositor.h
@@ -31,29 +31,25 @@
pdfium::span<const uint8_t> src_scan,
int width,
pdfium::span<const uint8_t> clip_scan,
- pdfium::span<const uint8_t> src_extra_alpha,
- pdfium::span<uint8_t> dst_extra_alpha);
+ pdfium::span<const uint8_t> src_extra_alpha);
void CompositePalBitmapLine(pdfium::span<uint8_t> dest_scan,
pdfium::span<const uint8_t> src_scan,
int src_left,
int width,
pdfium::span<const uint8_t> clip_scan,
- pdfium::span<const uint8_t> src_extra_alpha,
- pdfium::span<uint8_t> dst_extra_alpha);
+ pdfium::span<const uint8_t> src_extra_alpha);
void CompositeByteMaskLine(pdfium::span<uint8_t> dest_scan,
pdfium::span<const uint8_t> src_scan,
int width,
- pdfium::span<const uint8_t> clip_scan,
- pdfium::span<uint8_t> dst_extra_alpha);
+ pdfium::span<const uint8_t> clip_scan);
void CompositeBitMaskLine(pdfium::span<uint8_t> dest_scan,
pdfium::span<const uint8_t> src_scan,
int src_left,
int width,
- pdfium::span<const uint8_t> clip_scan,
- pdfium::span<uint8_t> dst_extra_alpha);
+ pdfium::span<const uint8_t> clip_scan);
private:
class Palette {
diff --git a/core/fxge/dib/scanlinecomposer_iface.h b/core/fxge/dib/scanlinecomposer_iface.h
index d0461ca..4bb9ca8 100644
--- a/core/fxge/dib/scanlinecomposer_iface.h
+++ b/core/fxge/dib/scanlinecomposer_iface.h
@@ -14,6 +14,7 @@
public:
virtual ~ScanlineComposerIface() = default;
+ // TODO(thestig): Check if `scan_extra_alpha` is actually needed.
virtual void ComposeScanline(
int line,
pdfium::span<const uint8_t> scanline,