Pass span to IccTransform::TranslateScanline().
-- move some locals further down to show they are not
moved from original positions when spans are used in
their place.
Change-Id: I73d58437c1cb98faabb87fa30e59a9414267e3ca
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/86178
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fpdfapi/page/cpdf_colorspace.cpp b/core/fpdfapi/page/cpdf_colorspace.cpp
index 7648782..da5549e 100644
--- a/core/fpdfapi/page/cpdf_colorspace.cpp
+++ b/core/fpdfapi/page/cpdf_colorspace.cpp
@@ -985,10 +985,8 @@
int image_width,
int image_height,
bool bTransMask) const {
- uint8_t* pDestBuf = dest_span.data();
- const uint8_t* pSrcBuf = src_span.data();
if (m_pProfile->IsSRGB()) {
- fxcodec::ReverseRGB(pDestBuf, pSrcBuf, pixels);
+ fxcodec::ReverseRGB(dest_span.data(), src_span.data(), pixels);
return;
}
if (!m_pProfile->transform()) {
@@ -1014,7 +1012,7 @@
bTranslate = nPixelCount.ValueOrDie() < nMaxColors * 3 / 2;
}
if (bTranslate && m_pProfile->transform()) {
- m_pProfile->transform()->TranslateScanline(pDestBuf, pSrcBuf, pixels);
+ m_pProfile->transform()->TranslateScanline(dest_span, src_span, pixels);
return;
}
if (m_pCache.empty()) {
@@ -1033,10 +1031,12 @@
}
}
if (m_pProfile->transform()) {
- m_pProfile->transform()->TranslateScanline(m_pCache.data(),
- temp_src.data(), nMaxColors);
+ m_pProfile->transform()->TranslateScanline(m_pCache, temp_src,
+ nMaxColors);
}
}
+ uint8_t* pDestBuf = dest_span.data();
+ const uint8_t* pSrcBuf = src_span.data();
for (int i = 0; i < pixels; i++) {
int index = 0;
for (uint32_t c = 0; c < nComponents; c++) {
diff --git a/core/fxcodec/icc/icc_transform.cpp b/core/fxcodec/icc/icc_transform.cpp
index b8483ba..002a20d 100644
--- a/core/fxcodec/icc/icc_transform.cpp
+++ b/core/fxcodec/icc/icc_transform.cpp
@@ -138,10 +138,10 @@
pDestValues[2] = output[0] / 255.0f;
}
-void IccTransform::TranslateScanline(unsigned char* pDest,
- const unsigned char* pSrc,
+void IccTransform::TranslateScanline(pdfium::span<uint8_t> pDest,
+ pdfium::span<const uint8_t> pSrc,
int32_t pixels) {
- cmsDoTransform(m_hTransform, pSrc, pDest, pixels);
+ cmsDoTransform(m_hTransform, pSrc.data(), pDest.data(), pixels);
}
} // namespace fxcodec
diff --git a/core/fxcodec/icc/icc_transform.h b/core/fxcodec/icc/icc_transform.h
index 9ea0c34..d501c8b 100644
--- a/core/fxcodec/icc/icc_transform.h
+++ b/core/fxcodec/icc/icc_transform.h
@@ -31,7 +31,9 @@
void Translate(pdfium::span<const float> pSrcValues,
pdfium::span<float> pDestValues);
- void TranslateScanline(uint8_t* pDest, const uint8_t* pSrc, int pixels);
+ void TranslateScanline(pdfium::span<uint8_t> pDest,
+ pdfium::span<const uint8_t> pSrc,
+ int pixels);
int components() const { return m_nSrcComponents; }
bool IsNormal() const { return m_bNormal; }