Convert some reinterpret_span<>() to GetScanlineAs<>().
Use the conversion methods to shorten the code.
Change-Id: I25e11c5bb9631374768c151ba136d022d65c3216
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/121550
Reviewed-by: Tom Sepez <tsepez@google.com>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/render/cpdf_rendershading.cpp b/core/fpdfapi/render/cpdf_rendershading.cpp
index 9cabf3f..b742215 100644
--- a/core/fpdfapi/render/cpdf_rendershading.cpp
+++ b/core/fpdfapi/render/cpdf_rendershading.cpp
@@ -134,9 +134,7 @@
CFX_Matrix matrix = mtObject2Bitmap.GetInverse();
for (int row = 0; row < height; row++) {
- auto dest_buf =
- fxcrt::reinterpret_span<uint32_t>(pBitmap->GetWritableScanline(row))
- .first(width);
+ auto dest_buf = pBitmap->GetWritableScanlineAs<uint32_t>(row).first(width);
size_t column_counter = 0;
for (auto& pix : dest_buf) {
const float column = static_cast<float>(column_counter++);
@@ -210,9 +208,7 @@
CFX_Matrix matrix = mtObject2Bitmap.GetInverse();
for (int row = 0; row < height; row++) {
- auto dest_buf =
- fxcrt::reinterpret_span<uint32_t>(pBitmap->GetWritableScanline(row))
- .first(width);
+ auto dest_buf = pBitmap->GetWritableScanlineAs<uint32_t>(row).first(width);
size_t column_counter = 0;
for (auto& pix : dest_buf) {
const float column = static_cast<float>(column_counter++);
@@ -296,8 +292,7 @@
CHECK_GE(total_results, pCS->ComponentCount());
std::vector<float> result_array(total_results);
for (int row = 0; row < height; ++row) {
- auto dib_buf =
- fxcrt::reinterpret_span<uint32_t>(pBitmap->GetWritableScanline(row));
+ auto dib_buf = pBitmap->GetWritableScanlineAs<uint32_t>(row);
for (int column = 0; column < width; column++) {
CFX_PointF pos = matrix.Transform(
CFX_PointF(static_cast<float>(column), static_cast<float>(row)));
diff --git a/core/fxge/dib/cfx_dibbase.cpp b/core/fxge/dib/cfx_dibbase.cpp
index 2d6715d..7bd6c2d 100644
--- a/core/fxge/dib/cfx_dibbase.cpp
+++ b/core/fxge/dib/cfx_dibbase.cpp
@@ -687,9 +687,9 @@
int right_shift = 32 - left_shift;
int dword_count = pNewBitmap->m_Pitch / 4;
for (int row = rect.top; row < rect.bottom; ++row) {
- auto src_span = fxcrt::reinterpret_span<const uint32_t>(GetScanline(row));
- auto dst_span = fxcrt::reinterpret_span<uint32_t>(
- pNewBitmap->GetWritableScanline(row - rect.top));
+ auto src_span = GetScanlineAs<const uint32_t>(row);
+ auto dst_span =
+ pNewBitmap->GetWritableScanlineAs<uint32_t>(row - rect.top);
// Bounds check for free with first/subspan.
const uint32_t* src_scan =
src_span.subspan(rect.left / 32, dword_count + 1).data();
@@ -1053,9 +1053,7 @@
uint8_t* dest_scan = dest_span.subspan(dest_offset).data();
if (nBytes == 4) {
const uint32_t* src_scan =
- fxcrt::reinterpret_span<const uint32_t>(GetScanline(row))
- .subspan(col_start)
- .data();
+ GetScanlineAs<const uint32_t>(row).subspan(col_start).data();
for (int col = col_start; col < col_end; ++col) {
uint32_t* dest_scan32 = reinterpret_cast<uint32_t*>(dest_scan);
*dest_scan32 = *src_scan++;
diff --git a/xfa/fgas/graphics/cfgas_gegraphics.cpp b/xfa/fgas/graphics/cfgas_gegraphics.cpp
index 616e5ff..ccda308 100644
--- a/xfa/fgas/graphics/cfgas_gegraphics.cpp
+++ b/xfa/fgas/graphics/cfgas_gegraphics.cpp
@@ -301,9 +301,7 @@
float y_span = end_y - start_y;
float axis_len_square = (x_span * x_span) + (y_span * y_span);
for (int32_t row = 0; row < height; row++) {
- uint32_t* dib_buf =
- fxcrt::reinterpret_span<uint32_t>(bmp->GetWritableScanline(row))
- .data();
+ uint32_t* dib_buf = bmp->GetWritableScanlineAs<uint32_t>(row).data();
for (int32_t column = 0; column < width; column++) {
float scale = 0.0f;
if (axis_len_square) {
@@ -335,9 +333,7 @@
((start_y - end_y) * (start_y - end_y)) -
((start_r - end_r) * (start_r - end_r));
for (int32_t row = 0; row < height; row++) {
- uint32_t* dib_buf =
- fxcrt::reinterpret_span<uint32_t>(bmp->GetWritableScanline(row))
- .data();
+ uint32_t* dib_buf = bmp->GetWritableScanlineAs<uint32_t>(row).data();
for (int32_t column = 0; column < width; column++) {
float x = (float)(column);
float y = (float)(row);