summaryrefslogtreecommitdiff
path: root/core/fxge/dib/cfx_dibsource.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-08-10 00:13:37 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-08-10 00:13:37 +0000
commit4174b5ab6ac9024acb9b42acbb61d628a2a679e3 (patch)
tree0d73f6ad6d85fd7fead7fdc6ddfc647479511bcd /core/fxge/dib/cfx_dibsource.cpp
parentfd7cede17e027a83de2aff3bc0f5ee875271e444 (diff)
downloadpdfium-4174b5ab6ac9024acb9b42acbb61d628a2a679e3.tar.xz
Add CFX_DIBSource::GetWritableScanline().
Remove a bunch of const_cast<uint8_t*> or equivalent. This will also help when we convert to span<>, since casting spans is a nuisance. Change-Id: I330e5041cbaf33a84425fc4242a3dfacf5ca8011 Reviewed-on: https://pdfium-review.googlesource.com/39831 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'core/fxge/dib/cfx_dibsource.cpp')
-rw-r--r--core/fxge/dib/cfx_dibsource.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/core/fxge/dib/cfx_dibsource.cpp b/core/fxge/dib/cfx_dibsource.cpp
index 757547783d..4608b51802 100644
--- a/core/fxge/dib/cfx_dibsource.cpp
+++ b/core/fxge/dib/cfx_dibsource.cpp
@@ -349,11 +349,10 @@ void ConvertBuffer_Rgb2PltRgb8(uint8_t* dest_buf,
}
int32_t lut_1 = lut - 1;
for (int row = 0; row < height; ++row) {
- uint8_t* src_scan =
- const_cast<uint8_t*>(pSrcBitmap->GetScanline(src_top + row)) + src_left;
+ const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row) + src_left;
uint8_t* dest_scan = dest_buf + row * dest_pitch;
for (int col = 0; col < width; ++col) {
- uint8_t* src_port = src_scan + col * bpp;
+ const uint8_t* src_port = src_scan + col * bpp;
int r = src_port[2] & 0xf0;
int g = src_port[1] & 0xf0;
int b = src_port[0] & 0xf0;
@@ -748,8 +747,10 @@ RetainPtr<CFX_DIBitmap> CFX_DIBSource::Clone(const FX_RECT* pClip) const {
int right_shift = 32 - left_shift;
int dword_count = pNewBitmap->m_Pitch / 4;
for (int row = rect.top; row < rect.bottom; ++row) {
- uint32_t* src_scan = (uint32_t*)GetScanline(row) + rect.left / 32;
- uint32_t* dest_scan = (uint32_t*)pNewBitmap->GetScanline(row - rect.top);
+ const uint32_t* src_scan =
+ reinterpret_cast<const uint32_t*>(GetScanline(row)) + rect.left / 32;
+ uint32_t* dest_scan = reinterpret_cast<uint32_t*>(
+ pNewBitmap->GetWritableScanline(row - rect.top));
for (int i = 0; i < dword_count; ++i) {
dest_scan[i] =
(src_scan[i] << left_shift) | (src_scan[i + 1] >> right_shift);
@@ -762,7 +763,7 @@ RetainPtr<CFX_DIBitmap> CFX_DIBSource::Clone(const FX_RECT* pClip) const {
for (int row = rect.top; row < rect.bottom; ++row) {
const uint8_t* src_scan = GetScanline(row) + rect.left * m_bpp / 8;
- uint8_t* dest_scan = (uint8_t*)pNewBitmap->GetScanline(row - rect.top);
+ uint8_t* dest_scan = pNewBitmap->GetWritableScanline(row - rect.top);
memcpy(dest_scan, src_scan, copy_len);
}
}
@@ -932,8 +933,7 @@ RetainPtr<CFX_DIBitmap> CFX_DIBSource::CloneAlphaMask() const {
for (int row = rect.top; row < rect.bottom; ++row) {
const uint8_t* src_scan = GetScanline(row) + rect.left * 4 + 3;
- uint8_t* dest_scan =
- const_cast<uint8_t*>(pMask->GetScanline(row - rect.top));
+ uint8_t* dest_scan = pMask->GetWritableScanline(row - rect.top);
for (int col = rect.left; col < rect.right; ++col) {
*dest_scan++ = *src_scan;
src_scan += 4;
@@ -963,7 +963,7 @@ bool CFX_DIBSource::SetAlphaMask(const RetainPtr<CFX_DIBSource>& pAlphaMask,
return false;
}
for (int row = 0; row < m_Height; ++row) {
- memcpy(const_cast<uint8_t*>(m_pAlphaMask->GetScanline(row)),
+ memcpy(m_pAlphaMask->GetWritableScanline(row),
pAlphaMask->GetScanline(row + rect.top) + rect.left,
m_pAlphaMask->m_Pitch);
}
@@ -1126,7 +1126,8 @@ RetainPtr<CFX_DIBitmap> CFX_DIBSource::SwapXY(bool bXFlip, bool bYFlip) const {
if (bYFlip)
dest_scan += (result_height - 1) * dest_pitch;
if (nBytes == 4) {
- uint32_t* src_scan = (uint32_t*)GetScanline(row) + col_start;
+ const uint32_t* src_scan =
+ reinterpret_cast<const uint32_t*>(GetScanline(row)) + col_start;
for (int col = col_start; col < col_end; ++col) {
*(uint32_t*)dest_scan = *src_scan++;
dest_scan += dest_step;