From 4174b5ab6ac9024acb9b42acbb61d628a2a679e3 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Fri, 10 Aug 2018 00:13:37 +0000 Subject: Add CFX_DIBSource::GetWritableScanline(). Remove a bunch of const_cast 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 Reviewed-by: Lei Zhang --- core/fpdfapi/render/cpdf_dibsource.cpp | 2 +- core/fpdfapi/render/cpdf_imagerenderer.cpp | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'core/fpdfapi/render') 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 CPDF_DIBSource::LoadJpxBitmap() { m_bpc < 8) { int scale = 8 - m_bpc; for (uint32_t row = 0; row < height; ++row) { - uint8_t* scanline = const_cast(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(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++; -- cgit v1.2.3