Rewrite CFX_DIBBase::DebugVerifyBitmapIsPreMultiplied() using spans.
Use fewer direct raw pointer calculations.
Change-Id: I902848d6e5249218fe2cb542f6a38b247648c26d
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/103219
Reviewed-by: Nigi <nigi@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fxge/skia/fx_skia_device.cpp b/core/fxge/skia/fx_skia_device.cpp
index 7bd4306..5dd6239 100644
--- a/core/fxge/skia/fx_skia_device.cpp
+++ b/core/fxge/skia/fx_skia_device.cpp
@@ -2301,21 +2301,25 @@
void CFX_DIBBase::DebugVerifyBitmapIsPreMultiplied() const {
#if !defined(NDEBUG)
DCHECK_EQ(GetBPP(), 32);
- const uint32_t* buffer = reinterpret_cast<uint32_t*>(GetBuffer().data());
- int width = GetWidth();
- int height = GetHeight();
- // verify that input is really premultiplied
+ const int width = GetWidth();
+ const int height = GetHeight();
+ const size_t pitch = Fx2DSizeOrDie(width, 4);
for (int y = 0; y < height; ++y) {
- const uint32_t* srcRow = buffer + y * width;
+ pdfium::span<const uint8_t> line = GetScanline(y);
+ DCHECK_LE(pitch, line.size());
+
+ // Using `line` directly in the inner-loop is too slow under ASAN.
+ const uint8_t* line_ptr = line.data();
for (int x = 0; x < width; ++x) {
- uint8_t a = SkGetPackedA32(srcRow[x]);
- uint8_t r = SkGetPackedR32(srcRow[x]);
- uint8_t g = SkGetPackedG32(srcRow[x]);
- uint8_t b = SkGetPackedB32(srcRow[x]);
- DCHECK(static_cast<unsigned>(a) <= SK_A32_MASK);
- DCHECK(r <= a);
- DCHECK(g <= a);
- DCHECK(b <= a);
+ uint8_t a = line_ptr[3];
+ uint8_t r = line_ptr[2];
+ uint8_t g = line_ptr[1];
+ uint8_t b = line_ptr[0];
+ DCHECK_LE(a, SK_A32_MASK);
+ DCHECK_LE(r, a);
+ DCHECK_LE(g, a);
+ DCHECK_LE(b, a);
+ line_ptr += 4;
}
}
#endif