summaryrefslogtreecommitdiff
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
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>
-rw-r--r--core/fpdfapi/render/cpdf_dibsource.cpp2
-rw-r--r--core/fpdfapi/render/cpdf_imagerenderer.cpp3
-rw-r--r--core/fxcodec/codec/ccodec_tiffmodule.cpp2
-rw-r--r--core/fxcodec/codec/fx_codec_progress.cpp43
-rw-r--r--core/fxge/agg/fx_agg_driver.cpp20
-rw-r--r--core/fxge/dib/cfx_bitmapcomposer.cpp8
-rw-r--r--core/fxge/dib/cfx_bitmapstorer.cpp4
-rw-r--r--core/fxge/dib/cfx_dibitmap.cpp16
-rw-r--r--core/fxge/dib/cfx_dibsource.cpp21
-rw-r--r--core/fxge/dib/cfx_dibsource.h3
-rw-r--r--core/fxge/dib/cfx_imagetransformer.cpp12
-rw-r--r--core/fxge/skia/fx_skia_device.cpp16
12 files changed, 72 insertions, 78 deletions
diff --git a/core/fpdfapi/render/cpdf_dibsource.cpp b/core/fpdfapi/render/cpdf_dibsource.cpp
index 72dec67438..fec439a689 100644
--- a/core/fpdfapi/render/cpdf_dibsource.cpp
+++ b/core/fpdfapi/render/cpdf_dibsource.cpp
@@ -640,7 +640,7 @@ RetainPtr<CFX_DIBitmap> CPDF_DIBSource::LoadJpxBitmap() {
m_bpc < 8) {
int scale = 8 - m_bpc;
for (uint32_t row = 0; row < height; ++row) {
- uint8_t* scanline = const_cast<uint8_t*>(pCachedBitmap->GetScanline(row));
+ uint8_t* scanline = pCachedBitmap->GetWritableScanline(row);
for (uint32_t col = 0; col < width; ++col) {
*scanline = (*scanline) >> scale;
++scanline;
diff --git a/core/fpdfapi/render/cpdf_imagerenderer.cpp b/core/fpdfapi/render/cpdf_imagerenderer.cpp
index d3e7075cc2..c7334f6ad3 100644
--- a/core/fpdfapi/render/cpdf_imagerenderer.cpp
+++ b/core/fpdfapi/render/cpdf_imagerenderer.cpp
@@ -247,8 +247,7 @@ void CPDF_ImageRenderer::CalculateDrawImage(
int matte_g = FXARGB_G(m_Loader.m_MatteColor);
int matte_b = FXARGB_B(m_Loader.m_MatteColor);
for (int row = 0; row < rect.Height(); row++) {
- uint8_t* dest_scan =
- const_cast<uint8_t*>(pBitmapDevice1->GetBitmap()->GetScanline(row));
+ uint8_t* dest_scan = pBitmapDevice1->GetBitmap()->GetWritableScanline(row);
const uint8_t* mask_scan = pBitmapDevice2->GetBitmap()->GetScanline(row);
for (int col = 0; col < rect.Width(); col++) {
int alpha = *mask_scan++;
diff --git a/core/fxcodec/codec/ccodec_tiffmodule.cpp b/core/fxcodec/codec/ccodec_tiffmodule.cpp
index 1a7a51af80..5f74b28cdc 100644
--- a/core/fxcodec/codec/ccodec_tiffmodule.cpp
+++ b/core/fxcodec/codec/ccodec_tiffmodule.cpp
@@ -463,7 +463,7 @@ bool CTiffContext::Decode(const RetainPtr<CFX_DIBitmap>& pDIBitmap) {
(uint32*)pDIBitmap->GetBuffer(), rotation,
1)) {
for (uint32_t row = 0; row < img_height; row++) {
- uint8_t* row_buf = (uint8_t*)pDIBitmap->GetScanline(row);
+ uint8_t* row_buf = pDIBitmap->GetWritableScanline(row);
TiffBGRA2RGBA(row_buf, img_width, 4);
}
return true;
diff --git a/core/fxcodec/codec/fx_codec_progress.cpp b/core/fxcodec/codec/fx_codec_progress.cpp
index 6b91e864ab..d1c04b9790 100644
--- a/core/fxcodec/codec/fx_codec_progress.cpp
+++ b/core/fxcodec/codec/fx_codec_progress.cpp
@@ -361,7 +361,7 @@ bool CCodec_ProgressiveDecoder::PngAskScanlineBuf(int line, uint8_t** pSrcBuf) {
if (line >= m_clipBox.top && line < m_clipBox.bottom) {
double scale_y = static_cast<double>(m_sizeY) / m_clipBox.Height();
int32_t row = (int32_t)((line - m_clipBox.top) * scale_y) + m_startY;
- uint8_t* src_scan = (uint8_t*)pDIBitmap->GetScanline(row);
+ const uint8_t* src_scan = pDIBitmap->GetScanline(row);
uint8_t* dest_scan = m_pDecodeBuf;
*pSrcBuf = m_pDecodeBuf;
int32_t src_Bpp = pDIBitmap->GetBPP() >> 3;
@@ -522,7 +522,7 @@ bool CCodec_ProgressiveDecoder::GifInputRecordPositionBuf(
FX_ARGB argb = m_pSrcPalette[pal_index];
for (int row = 0; row < sizeY; row++) {
uint8_t* pScanline =
- (uint8_t*)pDevice->GetScanline(row + startY) + startX * Bpp;
+ pDevice->GetWritableScanline(row + startY) + startX * Bpp;
switch (m_TransMethod) {
case 3: {
uint8_t gray =
@@ -600,12 +600,11 @@ void CCodec_ProgressiveDecoder::GifReadScanline(int32_t row_num,
int dest_Bpp = pDIBitmap->GetBPP() >> 3;
uint32_t dest_ScanOffet = m_startX * dest_Bpp;
if (dest_row + (int)scale_y >= dest_bottom - 1) {
- uint8_t* scan_src =
- (uint8_t*)pDIBitmap->GetScanline(dest_row) + dest_ScanOffet;
+ const uint8_t* scan_src = pDIBitmap->GetScanline(dest_row) + dest_ScanOffet;
int cur_row = dest_row;
while (++cur_row < dest_bottom) {
uint8_t* scan_des =
- (uint8_t*)pDIBitmap->GetScanline(cur_row) + dest_ScanOffet;
+ pDIBitmap->GetWritableScanline(cur_row) + dest_ScanOffet;
uint32_t size = m_sizeX * dest_Bpp;
memmove(scan_des, scan_src, size);
}
@@ -667,11 +666,11 @@ void CCodec_ProgressiveDecoder::ResampleVertBT(
check_dest_row_1 += pdfium::base::checked_cast<int>(scale_y);
int dest_row_1 = check_dest_row_1.ValueOrDie();
if (dest_row_1 >= dest_bottom - 1) {
- uint8_t* scan_src =
- (uint8_t*)pDeviceBitmap->GetScanline(dest_row) + dest_ScanOffet;
+ const uint8_t* scan_src =
+ pDeviceBitmap->GetScanline(dest_row) + dest_ScanOffet;
while (++dest_row < dest_bottom) {
uint8_t* scan_des =
- (uint8_t*)pDeviceBitmap->GetScanline(dest_row) + dest_ScanOffet;
+ pDeviceBitmap->GetWritableScanline(dest_row) + dest_ScanOffet;
uint32_t size = m_sizeX * dest_Bpp;
memmove(scan_des, scan_src, size);
}
@@ -679,7 +678,7 @@ void CCodec_ProgressiveDecoder::ResampleVertBT(
}
for (; dest_row_1 > dest_row; dest_row_1--) {
uint8_t* scan_des =
- (uint8_t*)pDeviceBitmap->GetScanline(dest_row_1) + dest_ScanOffet;
+ pDeviceBitmap->GetWritableScanline(dest_row_1) + dest_ScanOffet;
PixelWeight* pWeight = m_WeightVert.GetPixelWeight(dest_row_1 - dest_top);
const uint8_t* scan_src1 =
pDeviceBitmap->GetScanline(pWeight->m_SrcStart + dest_top) +
@@ -1089,7 +1088,7 @@ void CCodec_ProgressiveDecoder::GifDoubleLineResampleVert(
dest_row_1 = std::max(dest_row_1, dest_top);
for (; dest_row_1 < dest_row; dest_row_1++) {
uint8_t* scan_des =
- (uint8_t*)pDeviceBitmap->GetScanline(dest_row_1) + dest_ScanOffet;
+ pDeviceBitmap->GetWritableScanline(dest_row_1) + dest_ScanOffet;
PixelWeight* pWeight = m_WeightVert.GetPixelWeight(dest_row_1 - dest_top);
const uint8_t* scan_src1 =
pDeviceBitmap->GetScanline(pWeight->m_SrcStart + dest_top) +
@@ -1339,7 +1338,7 @@ void CCodec_ProgressiveDecoder::PngOneOneMapResampleHorz(
int32_t dest_line,
uint8_t* src_scan,
FXCodec_Format src_format) {
- uint8_t* dest_scan = (uint8_t*)pDeviceBitmap->GetScanline(dest_line);
+ uint8_t* dest_scan = pDeviceBitmap->GetWritableScanline(dest_line);
int32_t src_Bpp = (m_SrcFormat & 0xff) >> 3;
int32_t dest_Bpp = pDeviceBitmap->GetBPP() >> 3;
int32_t src_left = m_clipBox.left;
@@ -1667,8 +1666,8 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::TiffContinueDecode() {
case FXDIB_8bppRgb:
case FXDIB_8bppMask: {
for (int32_t row = 0; row < pClipBitmap->GetHeight(); row++) {
- uint8_t* src_line = (uint8_t*)pClipBitmap->GetScanline(row);
- uint8_t* dest_line = (uint8_t*)pFormatBitmap->GetScanline(row);
+ const uint8_t* src_line = pClipBitmap->GetScanline(row);
+ uint8_t* dest_line = pFormatBitmap->GetWritableScanline(row);
for (int32_t col = 0; col < pClipBitmap->GetWidth(); col++) {
uint8_t _a = 255 - src_line[3];
uint8_t b = (src_line[0] * src_line[3] + 0xFF * _a) / 255;
@@ -1683,8 +1682,8 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::TiffContinueDecode() {
case FXDIB_Rgb32: {
int32_t desBpp = (m_pDeviceBitmap->GetFormat() == FXDIB_Rgb) ? 3 : 4;
for (int32_t row = 0; row < pClipBitmap->GetHeight(); row++) {
- uint8_t* src_line = (uint8_t*)pClipBitmap->GetScanline(row);
- uint8_t* dest_line = (uint8_t*)pFormatBitmap->GetScanline(row);
+ const uint8_t* src_line = pClipBitmap->GetScanline(row);
+ uint8_t* dest_line = pFormatBitmap->GetWritableScanline(row);
for (int32_t col = 0; col < pClipBitmap->GetWidth(); col++) {
uint8_t _a = 255 - src_line[3];
uint8_t b = (src_line[0] * src_line[3] + 0xFF * _a) / 255;
@@ -2193,11 +2192,11 @@ void CCodec_ProgressiveDecoder::ResampleVert(
if (dest_row_1 < dest_top) {
int dest_bottom = dest_top + m_sizeY;
if (dest_row + (int)scale_y >= dest_bottom - 1) {
- uint8_t* scan_src =
- (uint8_t*)pDeviceBitmap->GetScanline(dest_row) + dest_ScanOffet;
+ const uint8_t* scan_src =
+ pDeviceBitmap->GetScanline(dest_row) + dest_ScanOffet;
while (++dest_row < dest_bottom) {
uint8_t* scan_des =
- (uint8_t*)pDeviceBitmap->GetScanline(dest_row) + dest_ScanOffet;
+ pDeviceBitmap->GetWritableScanline(dest_row) + dest_ScanOffet;
uint32_t size = m_sizeX * dest_Bpp;
memmove(scan_des, scan_src, size);
}
@@ -2206,7 +2205,7 @@ void CCodec_ProgressiveDecoder::ResampleVert(
}
for (; dest_row_1 < dest_row; dest_row_1++) {
uint8_t* scan_des =
- (uint8_t*)pDeviceBitmap->GetScanline(dest_row_1) + dest_ScanOffet;
+ pDeviceBitmap->GetWritableScanline(dest_row_1) + dest_ScanOffet;
PixelWeight* pWeight = m_WeightVert.GetPixelWeight(dest_row_1 - dest_top);
const uint8_t* scan_src1 =
pDeviceBitmap->GetScanline(pWeight->m_SrcStart + dest_top) +
@@ -2273,11 +2272,11 @@ void CCodec_ProgressiveDecoder::ResampleVert(
}
int dest_bottom = dest_top + m_sizeY;
if (dest_row + (int)scale_y >= dest_bottom - 1) {
- uint8_t* scan_src =
- (uint8_t*)pDeviceBitmap->GetScanline(dest_row) + dest_ScanOffet;
+ const uint8_t* scan_src =
+ pDeviceBitmap->GetScanline(dest_row) + dest_ScanOffet;
while (++dest_row < dest_bottom) {
uint8_t* scan_des =
- (uint8_t*)pDeviceBitmap->GetScanline(dest_row) + dest_ScanOffet;
+ pDeviceBitmap->GetWritableScanline(dest_row) + dest_ScanOffet;
uint32_t size = m_sizeX * dest_Bpp;
memmove(scan_des, scan_src, size);
}
diff --git a/core/fxge/agg/fx_agg_driver.cpp b/core/fxge/agg/fx_agg_driver.cpp
index affabba797..3d35e12e45 100644
--- a/core/fxge/agg/fx_agg_driver.cpp
+++ b/core/fxge/agg/fx_agg_driver.cpp
@@ -164,9 +164,8 @@ void RgbByteOrderTransferBitmap(const RetainPtr<CFX_DIBitmap>& pBitmap,
if (dest_format == src_format) {
for (int row = 0; row < height; row++) {
uint8_t* dest_scan = buffer + (dest_top + row) * pitch + dest_left * Bpp;
- uint8_t* src_scan =
- const_cast<uint8_t*>(pSrcBitmap->GetScanline(src_top + row)) +
- src_left * Bpp;
+ const uint8_t* src_scan =
+ pSrcBitmap->GetScanline(src_top + row) + src_left * Bpp;
if (Bpp == 4) {
for (int col = 0; col < width; col++) {
FXARGB_SETDIB(dest_scan, ArgbEncode(src_scan[3], src_scan[0],
@@ -191,9 +190,8 @@ void RgbByteOrderTransferBitmap(const RetainPtr<CFX_DIBitmap>& pBitmap,
ASSERT(src_format == FXDIB_Rgb32);
for (int row = 0; row < height; row++) {
uint8_t* dest_scan = dest_buf + row * pitch;
- uint8_t* src_scan =
- const_cast<uint8_t*>(pSrcBitmap->GetScanline(src_top + row)) +
- src_left * 4;
+ const uint8_t* src_scan =
+ pSrcBitmap->GetScanline(src_top + row) + src_left * 4;
for (int col = 0; col < width; col++) {
*dest_scan++ = src_scan[2];
*dest_scan++ = src_scan[1];
@@ -208,9 +206,8 @@ void RgbByteOrderTransferBitmap(const RetainPtr<CFX_DIBitmap>& pBitmap,
if (src_format == FXDIB_Rgb) {
for (int row = 0; row < height; row++) {
uint8_t* dest_scan = dest_buf + row * pitch;
- uint8_t* src_scan =
- const_cast<uint8_t*>(pSrcBitmap->GetScanline(src_top + row)) +
- src_left * 3;
+ const uint8_t* src_scan =
+ pSrcBitmap->GetScanline(src_top + row) + src_left * 3;
for (int col = 0; col < width; col++) {
FXARGB_SETDIB(dest_scan,
ArgbEncode(0xff, src_scan[0], src_scan[1], src_scan[2]));
@@ -225,9 +222,8 @@ void RgbByteOrderTransferBitmap(const RetainPtr<CFX_DIBitmap>& pBitmap,
ASSERT(dest_format == FXDIB_Argb);
for (int row = 0; row < height; row++) {
uint8_t* dest_scan = dest_buf + row * pitch;
- uint8_t* src_scan =
- const_cast<uint8_t*>(pSrcBitmap->GetScanline(src_top + row)) +
- src_left * 4;
+ const uint8_t* src_scan =
+ pSrcBitmap->GetScanline(src_top + row) + src_left * 4;
for (int col = 0; col < width; col++) {
FXARGB_SETDIB(dest_scan,
ArgbEncode(0xff, src_scan[0], src_scan[1], src_scan[2]));
diff --git a/core/fxge/dib/cfx_bitmapcomposer.cpp b/core/fxge/dib/cfx_bitmapcomposer.cpp
index 3854949207..22e1bc9b65 100644
--- a/core/fxge/dib/cfx_bitmapcomposer.cpp
+++ b/core/fxge/dib/cfx_bitmapcomposer.cpp
@@ -112,13 +112,11 @@ void CFX_BitmapComposer::ComposeScanline(int line,
m_pClipMask->GetPitch() +
(m_DestLeft - m_pClipRgn->GetBox().left);
}
- uint8_t* dest_scan =
- const_cast<uint8_t*>(m_pBitmap->GetScanline(line + m_DestTop)) +
- m_DestLeft * m_pBitmap->GetBPP() / 8;
+ uint8_t* dest_scan = m_pBitmap->GetWritableScanline(line + m_DestTop) +
+ m_DestLeft * m_pBitmap->GetBPP() / 8;
uint8_t* dest_alpha_scan =
m_pBitmap->m_pAlphaMask
- ? const_cast<uint8_t*>(
- m_pBitmap->m_pAlphaMask->GetScanline(line + m_DestTop)) +
+ ? m_pBitmap->m_pAlphaMask->GetWritableScanline(line + m_DestTop) +
m_DestLeft
: nullptr;
DoCompose(dest_scan, scanline, m_DestWidth, clip_scan, scan_extra_alpha,
diff --git a/core/fxge/dib/cfx_bitmapstorer.cpp b/core/fxge/dib/cfx_bitmapstorer.cpp
index f649e0caea..d5b26f28b7 100644
--- a/core/fxge/dib/cfx_bitmapstorer.cpp
+++ b/core/fxge/dib/cfx_bitmapstorer.cpp
@@ -25,10 +25,10 @@ void CFX_BitmapStorer::Replace(RetainPtr<CFX_DIBitmap>&& pBitmap) {
void CFX_BitmapStorer::ComposeScanline(int line,
const uint8_t* scanline,
const uint8_t* scan_extra_alpha) {
- uint8_t* dest_buf = const_cast<uint8_t*>(m_pBitmap->GetScanline(line));
+ uint8_t* dest_buf = m_pBitmap->GetWritableScanline(line);
uint8_t* dest_alpha_buf =
m_pBitmap->m_pAlphaMask
- ? const_cast<uint8_t*>(m_pBitmap->m_pAlphaMask->GetScanline(line))
+ ? m_pBitmap->m_pAlphaMask->GetWritableScanline(line)
: nullptr;
if (dest_buf)
memcpy(dest_buf, scanline, m_pBitmap->GetPitch());
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) {
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;
diff --git a/core/fxge/dib/cfx_dibsource.h b/core/fxge/dib/cfx_dibsource.h
index 0e7fb27dde..064dbe2055 100644
--- a/core/fxge/dib/cfx_dibsource.h
+++ b/core/fxge/dib/cfx_dibsource.h
@@ -44,6 +44,9 @@ class CFX_DIBSource : public Retainable {
int clip_left,
int clip_width) const = 0;
+ uint8_t* GetWritableScanline(int line) {
+ return const_cast<uint8_t*>(GetScanline(line));
+ }
int GetWidth() const { return m_Width; }
int GetHeight() const { return m_Height; }
diff --git a/core/fxge/dib/cfx_imagetransformer.cpp b/core/fxge/dib/cfx_imagetransformer.cpp
index 9cd5cea10e..37f56b57dc 100644
--- a/core/fxge/dib/cfx_imagetransformer.cpp
+++ b/core/fxge/dib/cfx_imagetransformer.cpp
@@ -480,7 +480,7 @@ void CFX_ImageTransformer::DoBilinearLoop(
std::function<void(const BilinearData&, uint8_t*)> func) {
CFX_BilinearMatrix matrix_fix(cdata.matrix);
for (int row = 0; row < m_result.Height(); row++) {
- uint8_t* dest = const_cast<uint8_t*>(cdata.bitmap->GetScanline(row));
+ const uint8_t* dest = cdata.bitmap->GetScanline(row);
for (int col = 0; col < m_result.Width(); col++) {
BilinearData d;
d.res_x = 0;
@@ -496,7 +496,7 @@ void CFX_ImageTransformer::DoBilinearLoop(
AdjustCoords(&d.src_col_r, &d.src_row_r);
d.row_offset_l = d.src_row_l * cdata.pitch;
d.row_offset_r = d.src_row_r * cdata.pitch;
- func(d, dest);
+ func(d, const_cast<uint8_t*>(dest));
}
dest += increment;
}
@@ -509,7 +509,7 @@ void CFX_ImageTransformer::DoBicubicLoop(
std::function<void(const BicubicData&, uint8_t*)> func) {
CFX_BilinearMatrix matrix_fix(cdata.matrix);
for (int row = 0; row < m_result.Height(); row++) {
- uint8_t* dest = const_cast<uint8_t*>(cdata.bitmap->GetScanline(row));
+ const uint8_t* dest = cdata.bitmap->GetScanline(row);
for (int col = 0; col < m_result.Width(); col++) {
BicubicData d;
d.res_x = 0;
@@ -523,7 +523,7 @@ void CFX_ImageTransformer::DoBicubicLoop(
bicubic_get_pos_weight(d.pos_pixel, d.u_w, d.v_w, d.src_col_l,
d.src_row_l, d.res_x, d.res_y, stretch_width(),
stretch_height());
- func(d, dest);
+ func(d, const_cast<uint8_t*>(dest));
}
dest += increment;
}
@@ -536,7 +536,7 @@ void CFX_ImageTransformer::DoDownSampleLoop(
std::function<void(const DownSampleData&, uint8_t*)> func) {
CPDF_FixedMatrix matrix_fix(cdata.matrix);
for (int row = 0; row < m_result.Height(); row++) {
- uint8_t* dest = const_cast<uint8_t*>(cdata.bitmap->GetScanline(row));
+ const uint8_t* dest = cdata.bitmap->GetScanline(row);
for (int col = 0; col < m_result.Width(); col++) {
DownSampleData d;
d.src_col = 0;
@@ -544,7 +544,7 @@ void CFX_ImageTransformer::DoDownSampleLoop(
matrix_fix.Transform(col, row, &d.src_col, &d.src_row);
if (LIKELY(InStretchBounds(d.src_col, d.src_row))) {
AdjustCoords(&d.src_col, &d.src_row);
- func(d, dest);
+ func(d, const_cast<uint8_t*>(dest));
}
dest += increment;
}
diff --git a/core/fxge/skia/fx_skia_device.cpp b/core/fxge/skia/fx_skia_device.cpp
index 4fa5a08d09..0b96cdca5f 100644
--- a/core/fxge/skia/fx_skia_device.cpp
+++ b/core/fxge/skia/fx_skia_device.cpp
@@ -80,8 +80,8 @@ void RgbByteOrderTransferBitmap(const RetainPtr<CFX_DIBitmap>& pBitmap,
if (dest_format == src_format) {
for (int row = 0; row < height; row++) {
uint8_t* dest_scan = buffer + (dest_top + row) * pitch + dest_left * Bpp;
- uint8_t* src_scan =
- (uint8_t*)pSrcBitmap->GetScanline(src_top + row) + src_left * Bpp;
+ const uint8_t* src_scan =
+ pSrcBitmap->GetScanline(src_top + row) + src_left * Bpp;
if (Bpp == 4) {
for (int col = 0; col < width; col++) {
FXARGB_SETDIB(dest_scan, ArgbEncode(src_scan[3], src_scan[0],
@@ -106,8 +106,8 @@ void RgbByteOrderTransferBitmap(const RetainPtr<CFX_DIBitmap>& pBitmap,
if (src_format == FXDIB_Rgb32) {
for (int row = 0; row < height; row++) {
uint8_t* dest_scan = dest_buf + row * pitch;
- uint8_t* src_scan =
- (uint8_t*)pSrcBitmap->GetScanline(src_top + row) + src_left * 4;
+ const uint8_t* src_scan =
+ pSrcBitmap->GetScanline(src_top + row) + src_left * 4;
for (int col = 0; col < width; col++) {
*dest_scan++ = src_scan[2];
*dest_scan++ = src_scan[1];
@@ -125,8 +125,8 @@ void RgbByteOrderTransferBitmap(const RetainPtr<CFX_DIBitmap>& pBitmap,
if (src_format == FXDIB_Rgb) {
for (int row = 0; row < height; row++) {
uint8_t* dest_scan = (uint8_t*)(dest_buf + row * pitch);
- uint8_t* src_scan =
- (uint8_t*)pSrcBitmap->GetScanline(src_top + row) + src_left * 3;
+ const uint8_t* src_scan =
+ pSrcBitmap->GetScanline(src_top + row) + src_left * 3;
for (int col = 0; col < width; col++) {
FXARGB_SETDIB(dest_scan, ArgbEncode(0xff, src_scan[0], src_scan[1],
src_scan[2]));
@@ -138,8 +138,8 @@ void RgbByteOrderTransferBitmap(const RetainPtr<CFX_DIBitmap>& pBitmap,
ASSERT(dest_format == FXDIB_Argb);
for (int row = 0; row < height; row++) {
uint8_t* dest_scan = dest_buf + row * pitch;
- uint8_t* src_scan =
- (uint8_t*)(pSrcBitmap->GetScanline(src_top + row) + src_left * 4);
+ const uint8_t* src_scan =
+ pSrcBitmap->GetScanline(src_top + row) + src_left * 4;
for (int col = 0; col < width; col++) {
FXARGB_SETDIB(dest_scan, ArgbEncode(0xff, src_scan[0], src_scan[1],
src_scan[2]));