Remove remaining CFX_DIBBase stub methods.
Remove more useless methods and their callers.
Change-Id: Iba7f47d0b8d9e4493d0a09f10ea2a3be7bc83d71
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/101852
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 f549729..1a3546c 100644
--- a/core/fxge/dib/cfx_bitmapcomposer.cpp
+++ b/core/fxge/dib/cfx_bitmapcomposer.cpp
@@ -69,12 +69,10 @@
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) {
+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) {
if (m_BitmapAlpha < 255) {
if (!clip_scan.empty()) {
for (int i = 0; i < dest_width; ++i)
@@ -90,19 +88,17 @@
clip_scan);
} else if (GetBppFromFormat(m_SrcFormat) == 8) {
m_Compositor.CompositePalBitmapLine(dest_scan, src_scan, 0, dest_width,
- clip_scan, src_extra_alpha);
+ clip_scan);
} else {
m_Compositor.CompositeRgbBitmapLine(dest_scan, src_scan, dest_width,
- clip_scan, src_extra_alpha);
+ clip_scan);
}
}
-void CFX_BitmapComposer::ComposeScanline(
- int line,
- pdfium::span<const uint8_t> scanline,
- pdfium::span<const uint8_t> scan_extra_alpha) {
+void CFX_BitmapComposer::ComposeScanline(int line,
+ pdfium::span<const uint8_t> scanline) {
if (m_bVertical) {
- ComposeScanlineV(line, scanline, scan_extra_alpha);
+ ComposeScanlineV(line, scanline);
return;
}
pdfium::span<const uint8_t> clip_scan;
@@ -123,13 +119,12 @@
dest_scan = dest_scan.subspan(offset.ValueOrDie());
}
- DoCompose(dest_scan, scanline, m_DestWidth, clip_scan, scan_extra_alpha);
+ DoCompose(dest_scan, scanline, m_DestWidth, clip_scan);
}
void CFX_BitmapComposer::ComposeScanlineV(
int line,
- pdfium::span<const uint8_t> scanline,
- pdfium::span<const uint8_t> scan_extra_alpha) {
+ pdfium::span<const uint8_t> scanline) {
int Bpp = m_pBitmap->GetBPP() / 8;
int dest_pitch = m_pBitmap->GetPitch();
int dest_x = m_DestLeft + (m_bFlipX ? (m_DestWidth - line - 1) : line);
@@ -170,7 +165,7 @@
src_clip += clip_pitch;
}
}
- DoCompose(m_pScanlineV, scanline, m_DestHeight, clip_scan, scan_extra_alpha);
+ DoCompose(m_pScanlineV, scanline, m_DestHeight, clip_scan);
src_scan = m_pScanlineV.data();
dest_scan = dest_buf;
for (int i = 0; i < m_DestHeight; ++i) {
diff --git a/core/fxge/dib/cfx_bitmapcomposer.h b/core/fxge/dib/cfx_bitmapcomposer.h
index 3f73c2f..c4cc07d 100644
--- a/core/fxge/dib/cfx_bitmapcomposer.h
+++ b/core/fxge/dib/cfx_bitmapcomposer.h
@@ -41,20 +41,14 @@
int height,
FXDIB_Format src_format,
pdfium::span<const uint32_t> src_palette) override;
-
- void ComposeScanline(int line,
- pdfium::span<const uint8_t> scanline,
- pdfium::span<const uint8_t> scan_extra_alpha) override;
+ void ComposeScanline(int line, pdfium::span<const uint8_t> scanline) override;
private:
void 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);
- void ComposeScanlineV(int line,
- pdfium::span<const uint8_t> scanline,
- pdfium::span<const uint8_t> scan_extra_alpha);
+ pdfium::span<const uint8_t> clip_scan);
+ void ComposeScanlineV(int line, pdfium::span<const uint8_t> scanline);
RetainPtr<CFX_DIBitmap> m_pBitmap;
UnownedPtr<const CFX_ClipRgn> m_pClipRgn;
diff --git a/core/fxge/dib/cfx_bitmapstorer.cpp b/core/fxge/dib/cfx_bitmapstorer.cpp
index 84629a7..26ee268 100644
--- a/core/fxge/dib/cfx_bitmapstorer.cpp
+++ b/core/fxge/dib/cfx_bitmapstorer.cpp
@@ -25,10 +25,8 @@
m_pBitmap = std::move(pBitmap);
}
-void CFX_BitmapStorer::ComposeScanline(
- int line,
- pdfium::span<const uint8_t> scanline,
- pdfium::span<const uint8_t> scan_extra_alpha) {
+void CFX_BitmapStorer::ComposeScanline(int line,
+ pdfium::span<const uint8_t> scanline) {
pdfium::span<uint8_t> dest_buf = m_pBitmap->GetWritableScanline(line);
if (!dest_buf.empty())
fxcrt::spancpy(dest_buf, scanline);
diff --git a/core/fxge/dib/cfx_bitmapstorer.h b/core/fxge/dib/cfx_bitmapstorer.h
index 822ff2e..de934e2 100644
--- a/core/fxge/dib/cfx_bitmapstorer.h
+++ b/core/fxge/dib/cfx_bitmapstorer.h
@@ -19,9 +19,7 @@
~CFX_BitmapStorer() override;
// ScanlineComposerIface:
- void ComposeScanline(int line,
- pdfium::span<const uint8_t> scanline,
- pdfium::span<const uint8_t> scan_extra_alpha) override;
+ void ComposeScanline(int line, pdfium::span<const uint8_t> scanline) override;
bool SetInfo(int width,
int height,
FXDIB_Format src_format,
diff --git a/core/fxge/dib/cfx_dibbase.cpp b/core/fxge/dib/cfx_dibbase.cpp
index 36b31b6..785d502 100644
--- a/core/fxge/dib/cfx_dibbase.cpp
+++ b/core/fxge/dib/cfx_dibbase.cpp
@@ -844,14 +844,6 @@
m_palette[i] = src_palette[i];
}
-pdfium::span<const uint8_t> CFX_DIBBase::GetAlphaMaskScanline(int line) const {
- return pdfium::span<const uint8_t>();
-}
-
-RetainPtr<CFX_DIBitmap> CFX_DIBBase::GetAlphaMask() {
- return nullptr;
-}
-
RetainPtr<CFX_DIBitmap> CFX_DIBBase::CloneAlphaMask() const {
DCHECK_EQ(GetFormat(), FXDIB_Format::kArgb);
FX_RECT rect(0, 0, m_Width, m_Height);
diff --git a/core/fxge/dib/cfx_dibbase.h b/core/fxge/dib/cfx_dibbase.h
index 11c2d42..27161a5 100644
--- a/core/fxge/dib/cfx_dibbase.h
+++ b/core/fxge/dib/cfx_dibbase.h
@@ -75,11 +75,6 @@
RetainPtr<CFX_DIBitmap> SwapXY(bool bXFlip, bool bYFlip) const;
RetainPtr<CFX_DIBitmap> FlipImage(bool bXFlip, bool bYFlip) const;
- // TODO(thestig): Remove these dummy methods.
- bool HasAlphaMask() const { return false; }
- pdfium::span<const uint8_t> GetAlphaMaskScanline(int line) const;
- RetainPtr<CFX_DIBitmap> GetAlphaMask();
-
RetainPtr<CFX_DIBitmap> CloneAlphaMask() const;
bool GetOverlapRect(int& dest_left,
diff --git a/core/fxge/dib/cfx_dibitmap.cpp b/core/fxge/dib/cfx_dibitmap.cpp
index 6e67244..4f06539 100644
--- a/core/fxge/dib/cfx_dibitmap.cpp
+++ b/core/fxge/dib/cfx_dibitmap.cpp
@@ -740,27 +740,21 @@
if (!bRgb && !pSrcBitmap->HasPalette())
return false;
- RetainPtr<CFX_DIBitmap> pSrcAlphaMask = pSrcBitmap->GetAlphaMask();
for (int row = 0; row < height; row++) {
pdfium::span<uint8_t> dest_scan =
GetWritableScanline(dest_top + row).subspan(dest_left * dest_Bpp);
pdfium::span<const uint8_t> src_scan =
pSrcBitmap->GetScanline(src_top + row).subspan(src_left * src_Bpp);
- pdfium::span<const uint8_t> src_scan_extra_alpha =
- pSrcAlphaMask
- ? pSrcAlphaMask->GetScanline(src_top + row).subspan(src_left)
- : pdfium::span<const uint8_t>();
pdfium::span<const uint8_t> clip_scan;
if (pClipMask) {
clip_scan = pClipMask->GetWritableScanline(dest_top + row - clip_box.top)
.subspan(dest_left - clip_box.left);
}
if (bRgb) {
- compositor.CompositeRgbBitmapLine(dest_scan, src_scan, width, clip_scan,
- src_scan_extra_alpha);
+ compositor.CompositeRgbBitmapLine(dest_scan, src_scan, width, clip_scan);
} else {
compositor.CompositePalBitmapLine(dest_scan, src_scan, src_left, width,
- clip_scan, src_scan_extra_alpha);
+ clip_scan);
}
}
return true;
diff --git a/core/fxge/dib/cfx_scanlinecompositor.cpp b/core/fxge/dib/cfx_scanlinecompositor.cpp
index b959e7e..af9e4ce 100644
--- a/core/fxge/dib/cfx_scanlinecompositor.cpp
+++ b/core/fxge/dib/cfx_scanlinecompositor.cpp
@@ -2975,8 +2975,7 @@
pdfium::span<uint8_t> dest_scan,
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<const uint8_t> clip_scan) {
int src_Bpp = GetCompsFromFormat(m_SrcFormat);
int dest_Bpp = GetCompsFromFormat(m_DestFormat);
if (m_bRgbByteOrder) {
@@ -3039,8 +3038,8 @@
if (m_SrcFormat == FXDIB_Format::kArgb) {
CompositeRow_AlphaToMask(dest_scan, src_scan, width, clip_scan, 4);
} else {
- CompositeRow_AlphaToMask(dest_scan, src_extra_alpha, width, clip_scan,
- 1);
+ // TODO(thestig): Check if empty span argument is always empty.
+ CompositeRow_AlphaToMask(dest_scan, {}, width, clip_scan, 1);
}
} else {
CompositeRow_Rgb2Mask(dest_scan, width, clip_scan);
@@ -3048,12 +3047,13 @@
} else if (GetBppFromFormat(m_DestFormat) == 8) {
if (GetIsAlphaFromFormat(m_SrcFormat)) {
if (GetIsAlphaFromFormat(m_DestFormat)) {
- // TODO(thestig): Check if empty span argument is always empty.
+ // TODO(thestig): Check if empty span arguments are always empty.
CompositeRow_Argb2Graya(dest_scan, src_scan, width, m_BlendType,
- clip_scan, src_extra_alpha, {});
+ clip_scan, {}, {});
} else {
+ // TODO(thestig): Check if empty span argument is always empty.
CompositeRow_Argb2Gray(dest_scan, src_scan, width, m_BlendType,
- clip_scan, src_extra_alpha);
+ clip_scan, {});
}
} else {
if (GetIsAlphaFromFormat(m_DestFormat)) {
@@ -3071,9 +3071,9 @@
case 4:
case 8:
case 4 + 8: {
- // TODO(thestig): Check if empty span argument is always empty.
+ // TODO(thestig): Check if empty span arguments are always empty.
CompositeRow_Argb2Argb(dest_scan, src_scan, width, m_BlendType,
- clip_scan, {}, src_extra_alpha);
+ clip_scan, {}, {});
} break;
case 1:
// TODO(thestig): Check if empty span argument is always empty.
@@ -3097,13 +3097,15 @@
break;
case 2:
case 2 + 8:
+ // TODO(thestig): Check if empty span argument is always empty.
CompositeRow_Argb2Rgb_Blend(dest_scan, src_scan, width, m_BlendType,
- dest_Bpp, clip_scan, src_extra_alpha);
+ dest_Bpp, clip_scan, {});
break;
case 2 + 4:
case 2 + 4 + 8:
+ // TODO(thestig): Check if empty span argument is always empty.
CompositeRow_Argb2Rgb_NoBlend(dest_scan, src_scan, width, dest_Bpp,
- clip_scan, src_extra_alpha);
+ clip_scan, {});
break;
case 1 + 2:
CompositeRow_Rgb2Rgb_Blend_NoClip(dest_scan, src_scan, width,
@@ -3130,8 +3132,7 @@
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<const uint8_t> clip_scan) {
if (m_bRgbByteOrder) {
if (m_SrcFormat == FXDIB_Format::k1bppRgb) {
if (m_DestFormat == FXDIB_Format::k8bppRgb) {
@@ -3180,22 +3181,24 @@
}
} else {
if (GetIsAlphaFromFormat(m_DestFormat)) {
- // TODO(thestig): Check if empty span argument is always empty.
+ // TODO(thestig): Check if empty span arguments are always empty.
CompositeRow_8bppPal2Graya(dest_scan, src_scan,
m_SrcPalette.Get8BitPalette(), width,
- m_BlendType, clip_scan, {}, src_extra_alpha);
+ m_BlendType, clip_scan, {}, {});
} else {
+ // TODO(thestig): Check if empty span argument is always empty.
CompositeRow_8bppPal2Gray(dest_scan, src_scan,
m_SrcPalette.Get8BitPalette(), width,
- m_BlendType, clip_scan, src_extra_alpha);
+ m_BlendType, clip_scan, {});
}
}
} else {
switch (m_iTransparency) {
case 1 + 2:
+ // TODO(thestig): Check if empty span argument is always empty.
CompositeRow_8bppRgb2Argb_NoBlend(dest_scan, src_scan, width,
m_SrcPalette.Get32BitPalette(),
- clip_scan, src_extra_alpha);
+ clip_scan, {});
break;
case 1 + 2 + 8:
CompositeRow_1bppRgb2Argb_NoBlend(dest_scan, src_scan, src_left, width,
@@ -3203,9 +3206,10 @@
clip_scan);
break;
case 0:
+ // TODO(thestig): Check if empty span argument is always empty.
CompositeRow_8bppRgb2Rgb_NoBlend(
dest_scan, src_scan, m_SrcPalette.Get32BitPalette(), width,
- GetCompsFromFormat(m_DestFormat), clip_scan, src_extra_alpha);
+ GetCompsFromFormat(m_DestFormat), clip_scan, {});
break;
case 0 + 8:
CompositeRow_1bppRgb2Rgb_NoBlend(
@@ -3213,9 +3217,10 @@
width, GetCompsFromFormat(m_DestFormat), clip_scan);
break;
case 0 + 2:
+ // TODO(thestig): Check if empty span argument is always empty.
CompositeRow_8bppRgb2Rgb_NoBlend(
dest_scan, src_scan, m_SrcPalette.Get32BitPalette(), width,
- GetCompsFromFormat(m_DestFormat), clip_scan, src_extra_alpha);
+ GetCompsFromFormat(m_DestFormat), clip_scan, {});
break;
case 0 + 2 + 8:
// TODO(thestig): Check if empty span argument is always empty.
diff --git a/core/fxge/dib/cfx_scanlinecompositor.h b/core/fxge/dib/cfx_scanlinecompositor.h
index 7827ad3..4e87f28 100644
--- a/core/fxge/dib/cfx_scanlinecompositor.h
+++ b/core/fxge/dib/cfx_scanlinecompositor.h
@@ -30,15 +30,13 @@
void CompositeRgbBitmapLine(pdfium::span<uint8_t> dest_scan,
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<const uint8_t> clip_scan);
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<const uint8_t> clip_scan);
void CompositeByteMaskLine(pdfium::span<uint8_t> dest_scan,
pdfium::span<const uint8_t> src_scan,
diff --git a/core/fxge/dib/cstretchengine.cpp b/core/fxge/dib/cstretchengine.cpp
index a7632b1..4a851f8 100644
--- a/core/fxge/dib/cstretchengine.cpp
+++ b/core/fxge/dib/cstretchengine.cpp
@@ -284,10 +284,6 @@
if (m_InterBuf.empty())
return false;
- if (m_pSource && m_bHasAlpha && m_pSource->HasAlphaMask()) {
- m_ExtraAlphaBuf.resize(m_SrcClip.Height(), m_ExtraMaskPitch);
- m_DestMaskScanline.resize(m_ExtraMaskPitch);
- }
if (!m_WeightTable.CalculateWeights(
m_DestWidth, m_DestClip.left, m_DestClip.right, m_SrcWidth,
m_SrcClip.left, m_SrcClip.right, m_ResampleOptions)) {
@@ -319,13 +315,9 @@
pdfium::span<uint8_t> dest_span = m_InterBuf.writable_span().subspan(
(m_CurRow - m_SrcClip.top) * m_InterPitch, m_InterPitch);
size_t dest_span_index = 0;
+ // TODO(thestig): Audit suspicious variable usage.
const uint8_t* src_scan_mask = nullptr;
uint8_t* dest_scan_mask = nullptr;
- if (!m_ExtraAlphaBuf.empty()) {
- src_scan_mask = m_pSource->GetAlphaMaskScanline(m_CurRow).data();
- dest_scan_mask = m_ExtraAlphaBuf.data() +
- (m_CurRow - m_SrcClip.top) * m_ExtraMaskPitch;
- }
// TODO(npm): reduce duplicated code here
switch (m_TransMethod) {
case TransformMethod::k1BppTo8Bpp:
@@ -489,7 +481,8 @@
const int DestBpp = m_DestBpp / 8;
for (int row = m_DestClip.top; row < m_DestClip.bottom; ++row) {
unsigned char* dest_scan = m_DestScanline.data();
- unsigned char* dest_scan_mask = m_DestMaskScanline.data();
+ // TODO(thestig): Audit suspicious variable usage.
+ unsigned char* dest_scan_mask = nullptr;
PixelWeight* pWeights = table.GetPixelWeight(row);
switch (m_TransMethod) {
case TransformMethod::k1BppTo8Bpp:
@@ -513,8 +506,9 @@
for (int col = m_DestClip.left; col < m_DestClip.right; ++col) {
pdfium::span<const uint8_t> src_span =
m_InterBuf.span().subspan((col - m_DestClip.left) * DestBpp);
+ // TODO(thestig): Audit suspicious variable usage.
unsigned char* src_scan_mask =
- m_ExtraAlphaBuf.data() + (col - m_DestClip.left);
+ reinterpret_cast<unsigned char*>(col - m_DestClip.left);
uint32_t dest_a = 0;
uint32_t dest_k = 0;
for (int j = pWeights->m_SrcStart; j <= pWeights->m_SrcEnd; ++j) {
@@ -558,9 +552,12 @@
for (int col = m_DestClip.left; col < m_DestClip.right; ++col) {
pdfium::span<const uint8_t> src_span =
m_InterBuf.span().subspan((col - m_DestClip.left) * DestBpp);
+ // TODO(thestig): Audit suspicious variable usage.
unsigned char* src_scan_mask = nullptr;
- if (m_DestFormat != FXDIB_Format::kArgb)
- src_scan_mask = m_ExtraAlphaBuf.data() + (col - m_DestClip.left);
+ if (m_DestFormat != FXDIB_Format::kArgb) {
+ src_scan_mask =
+ reinterpret_cast<unsigned char*>(col - m_DestClip.left);
+ }
uint32_t dest_a = 0;
uint32_t dest_r = 0;
uint32_t dest_g = 0;
@@ -601,7 +598,6 @@
break;
}
}
- m_pDestBitmap->ComposeScanline(row - m_DestClip.top, m_DestScanline,
- m_DestMaskScanline);
+ m_pDestBitmap->ComposeScanline(row - m_DestClip.top, m_DestScanline);
}
}
diff --git a/core/fxge/dib/cstretchengine.h b/core/fxge/dib/cstretchengine.h
index 50a344c..6dabcb1 100644
--- a/core/fxge/dib/cstretchengine.h
+++ b/core/fxge/dib/cstretchengine.h
@@ -152,9 +152,7 @@
const int m_DestHeight;
const FX_RECT m_DestClip;
DataVector<uint8_t> m_DestScanline;
- DataVector<uint8_t> m_DestMaskScanline;
FixedTryAllocZeroedDataVector<uint8_t> m_InterBuf;
- DataVector<uint8_t> m_ExtraAlphaBuf;
FX_RECT m_SrcClip;
int m_InterPitch;
int m_ExtraMaskPitch;
diff --git a/core/fxge/dib/scanlinecomposer_iface.h b/core/fxge/dib/scanlinecomposer_iface.h
index 4bb9ca8..0529859 100644
--- a/core/fxge/dib/scanlinecomposer_iface.h
+++ b/core/fxge/dib/scanlinecomposer_iface.h
@@ -14,11 +14,8 @@
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,
- pdfium::span<const uint8_t> scan_extra_alpha) = 0;
+ virtual void ComposeScanline(int line,
+ pdfium::span<const uint8_t> scanline) = 0;
virtual bool SetInfo(int width,
int height,