summaryrefslogtreecommitdiff
path: root/core/fxge/dib/cfx_dibitmap.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_dibitmap.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_dibitmap.cpp')
-rw-r--r--core/fxge/dib/cfx_dibitmap.cpp16
1 files changed, 7 insertions, 9 deletions
diff --git a/core/fxge/dib/cfx_dibitmap.cpp b/core/fxge/dib/cfx_dibitmap.cpp
index f17ca52095..3d642c2e76 100644
--- a/core/fxge/dib/cfx_dibitmap.cpp
+++ b/core/fxge/dib/cfx_dibitmap.cpp
@@ -372,7 +372,7 @@ bool CFX_DIBitmap::LoadChannel(FXDIB_Channel destChannel,
int srcBytes = pSrcClone->GetBPP() / 8;
int destBytes = pDst->GetBPP() / 8;
for (int row = 0; row < m_Height; row++) {
- uint8_t* dest_pos = (uint8_t*)pDst->GetScanline(row) + destOffset;
+ uint8_t* dest_pos = pDst->GetWritableScanline(row) + destOffset;
const uint8_t* src_pos = pSrcClone->GetScanline(row) + srcOffset;
for (int col = 0; col < m_Width; col++) {
*dest_pos = *src_pos;
@@ -923,7 +923,7 @@ bool CFX_DIBitmap::CompositeBitmap(int dest_left,
: nullptr;
uint8_t* dst_scan_extra_alpha =
m_pAlphaMask
- ? (uint8_t*)m_pAlphaMask->GetScanline(dest_top + row) + dest_left
+ ? m_pAlphaMask->GetWritableScanline(dest_top + row) + dest_left
: nullptr;
const uint8_t* clip_scan = nullptr;
if (pClipMask) {
@@ -995,7 +995,7 @@ bool CFX_DIBitmap::CompositeMask(int dest_left,
const uint8_t* src_scan = pMask->GetScanline(src_top + row);
uint8_t* dst_scan_extra_alpha =
m_pAlphaMask
- ? (uint8_t*)m_pAlphaMask->GetScanline(dest_top + row) + dest_left
+ ? m_pAlphaMask->GetWritableScanline(dest_top + row) + dest_left
: nullptr;
const uint8_t* clip_scan = nullptr;
if (pClipMask) {
@@ -1084,10 +1084,8 @@ bool CFX_DIBitmap::CompositeRect(int left,
index = (static_cast<uint8_t>(color) == 0xff) ? 1 : 0;
}
for (int row = rect.top; row < rect.bottom; row++) {
- uint8_t* dest_scan_top =
- const_cast<uint8_t*>(GetScanline(row)) + rect.left / 8;
- uint8_t* dest_scan_top_r =
- const_cast<uint8_t*>(GetScanline(row)) + rect.right / 8;
+ uint8_t* dest_scan_top = GetWritableScanline(row) + rect.left / 8;
+ uint8_t* dest_scan_top_r = GetWritableScanline(row) + rect.right / 8;
uint8_t left_flag = *dest_scan_top & (255 << (8 - left_shift));
uint8_t right_flag = *dest_scan_top_r & (255 >> right_shift);
if (new_width) {
@@ -1126,7 +1124,7 @@ bool CFX_DIBitmap::CompositeRect(int left,
for (int row = rect.top; row < rect.bottom; row++) {
uint8_t* dest_scan = m_pBuffer.Get() + row * m_Pitch + rect.left * Bpp;
uint8_t* dest_scan_alpha =
- m_pAlphaMask ? (uint8_t*)m_pAlphaMask->GetScanline(row) + rect.left
+ m_pAlphaMask ? m_pAlphaMask->GetWritableScanline(row) + rect.left
: nullptr;
if (dest_scan_alpha) {
memset(dest_scan_alpha, 0xff, width);
@@ -1171,7 +1169,7 @@ bool CFX_DIBitmap::CompositeRect(int left,
}
} else {
uint8_t* dest_scan_alpha =
- (uint8_t*)m_pAlphaMask->GetScanline(row) + rect.left;
+ m_pAlphaMask->GetWritableScanline(row) + rect.left;
for (int col = 0; col < width; col++) {
uint8_t back_alpha = *dest_scan_alpha;
if (back_alpha == 0) {