Simplify CFX_DIBBase::CloneAlphaMask().
The calculations in this method involves a rectangle variable whose top
and left values are always 0. Get rid of the rectangle and simplify the
calculations.
Change-Id: I9a82154bae26937cc6ed05eec82d68033337c0a3
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/103077
Reviewed-by: Nigi <nigi@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fxge/dib/cfx_dibbase.cpp b/core/fxge/dib/cfx_dibbase.cpp
index 4da06ae..4a62575 100644
--- a/core/fxge/dib/cfx_dibbase.cpp
+++ b/core/fxge/dib/cfx_dibbase.cpp
@@ -859,16 +859,14 @@
RetainPtr<CFX_DIBitmap> CFX_DIBBase::CloneAlphaMask() const {
DCHECK_EQ(GetFormat(), FXDIB_Format::kArgb);
- FX_RECT rect(0, 0, m_Width, m_Height);
auto pMask = pdfium::MakeRetain<CFX_DIBitmap>();
- if (!pMask->Create(rect.Width(), rect.Height(), FXDIB_Format::k8bppMask))
+ if (!pMask->Create(m_Width, m_Height, FXDIB_Format::k8bppMask))
return nullptr;
- for (int row = rect.top; row < rect.bottom; ++row) {
- const uint8_t* src_scan =
- GetScanline(row).subspan(rect.left * 4 + 3).data();
- uint8_t* dest_scan = pMask->GetWritableScanline(row - rect.top).data();
- for (int col = rect.left; col < rect.right; ++col) {
+ for (int row = 0; row < m_Height; ++row) {
+ const uint8_t* src_scan = GetScanline(row).subspan(3).data();
+ uint8_t* dest_scan = pMask->GetWritableScanline(row).data();
+ for (int col = 0; col < m_Width; ++col) {
*dest_scan++ = *src_scan;
src_scan += 4;
}