diff options
author | Tom Sepez <tsepez@chromium.org> | 2018-08-28 23:15:02 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-08-28 23:15:02 +0000 |
commit | b719bc4a6f219483059f66c33e4a3a7667d75ed5 (patch) | |
tree | bb1f512fd303b46dab323e849e56d21779d32488 /core/fpdfapi | |
parent | da379c7af512aa7baa221d38b04c8aa9912b4e02 (diff) | |
download | pdfium-b719bc4a6f219483059f66c33e4a3a7667d75ed5.tar.xz |
Use pdfium::span<> in more image modules
Change-Id: Ie344bb37abf7dde158d03cc2897dca3588f1a5e3
Reviewed-on: https://pdfium-review.googlesource.com/41550
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fpdfapi')
-rw-r--r-- | core/fpdfapi/page/cpdf_streamparser.cpp | 2 | ||||
-rw-r--r-- | core/fpdfapi/parser/fpdf_parser_decode.cpp | 14 | ||||
-rw-r--r-- | core/fpdfapi/parser/fpdf_parser_decode.h | 6 | ||||
-rw-r--r-- | core/fpdfapi/render/cpdf_dibbase.cpp | 18 |
4 files changed, 17 insertions, 23 deletions
diff --git a/core/fpdfapi/page/cpdf_streamparser.cpp b/core/fpdfapi/page/cpdf_streamparser.cpp index bafb5820ff..266f7db832 100644 --- a/core/fpdfapi/page/cpdf_streamparser.cpp +++ b/core/fpdfapi/page/cpdf_streamparser.cpp @@ -71,7 +71,7 @@ uint32_t DecodeInlineStream(const uint8_t* src_buf, uint32_t* dest_size) { if (decoder == "CCITTFaxDecode" || decoder == "CCF") { std::unique_ptr<CCodec_ScanlineDecoder> pDecoder = - FPDFAPI_CreateFaxDecoder(src_buf, limit, width, height, pParam); + FPDFAPI_CreateFaxDecoder({src_buf, limit}, width, height, pParam); return DecodeAllScanlines(std::move(pDecoder), dest_buf, dest_size); } if (decoder == "ASCII85Decode" || decoder == "A85") diff --git a/core/fpdfapi/parser/fpdf_parser_decode.cpp b/core/fpdfapi/parser/fpdf_parser_decode.cpp index 063d21ae5f..ff4f63f0cb 100644 --- a/core/fpdfapi/parser/fpdf_parser_decode.cpp +++ b/core/fpdfapi/parser/fpdf_parser_decode.cpp @@ -258,8 +258,7 @@ uint32_t RunLengthDecode(const uint8_t* src_buf, } std::unique_ptr<CCodec_ScanlineDecoder> FPDFAPI_CreateFaxDecoder( - const uint8_t* src_buf, - uint32_t src_size, + pdfium::span<const uint8_t> src_span, int width, int height, const CPDF_Dictionary* pParams) { @@ -280,13 +279,12 @@ std::unique_ptr<CCodec_ScanlineDecoder> FPDFAPI_CreateFaxDecoder( Rows = 0; } return CPDF_ModuleMgr::Get()->GetFaxModule()->CreateDecoder( - src_buf, src_size, width, height, K, EndOfLine, ByteAlign, BlackIs1, - Columns, Rows); + src_span, width, height, K, EndOfLine, ByteAlign, BlackIs1, Columns, + Rows); } std::unique_ptr<CCodec_ScanlineDecoder> FPDFAPI_CreateFlateDecoder( - const uint8_t* src_buf, - uint32_t src_size, + pdfium::span<const uint8_t> src_span, int width, int height, int nComps, @@ -305,8 +303,8 @@ std::unique_ptr<CCodec_ScanlineDecoder> FPDFAPI_CreateFlateDecoder( return nullptr; } return CPDF_ModuleMgr::Get()->GetFlateModule()->CreateDecoder( - src_buf, src_size, width, height, nComps, bpc, predictor, Colors, - BitsPerComponent, Columns); + src_span, width, height, nComps, bpc, predictor, Colors, BitsPerComponent, + Columns); } uint32_t FPDFAPI_FlateOrLZWDecode(bool bLZW, diff --git a/core/fpdfapi/parser/fpdf_parser_decode.h b/core/fpdfapi/parser/fpdf_parser_decode.h index 652299992a..bf70997397 100644 --- a/core/fpdfapi/parser/fpdf_parser_decode.h +++ b/core/fpdfapi/parser/fpdf_parser_decode.h @@ -39,15 +39,13 @@ uint32_t RunLengthDecode(const uint8_t* src_buf, uint32_t* dest_size); std::unique_ptr<CCodec_ScanlineDecoder> FPDFAPI_CreateFaxDecoder( - const uint8_t* src_buf, - uint32_t src_size, + pdfium::span<const uint8_t> src_span, int width, int height, const CPDF_Dictionary* pParams); std::unique_ptr<CCodec_ScanlineDecoder> FPDFAPI_CreateFlateDecoder( - const uint8_t* src_buf, - uint32_t src_size, + pdfium::span<const uint8_t> src_span, int width, int height, int nComps, diff --git a/core/fpdfapi/render/cpdf_dibbase.cpp b/core/fpdfapi/render/cpdf_dibbase.cpp index dd710f6e75..70aea8e45b 100644 --- a/core/fpdfapi/render/cpdf_dibbase.cpp +++ b/core/fpdfapi/render/cpdf_dibbase.cpp @@ -470,21 +470,19 @@ CPDF_DIBBase::LoadState CPDF_DIBBase::CreateDecoder() { return LoadState::kContinue; } - const uint8_t* src_data = m_pStreamAcc->GetData(); - uint32_t src_size = m_pStreamAcc->GetSize(); + pdfium::span<const uint8_t> src_span = m_pStreamAcc->GetSpan(); const CPDF_Dictionary* pParams = m_pStreamAcc->GetImageParam(); if (decoder == "CCITTFaxDecode") { - m_pDecoder = FPDFAPI_CreateFaxDecoder(src_data, src_size, m_Width, m_Height, - pParams); + m_pDecoder = FPDFAPI_CreateFaxDecoder(src_span, m_Width, m_Height, pParams); } else if (decoder == "FlateDecode") { - m_pDecoder = FPDFAPI_CreateFlateDecoder( - src_data, src_size, m_Width, m_Height, m_nComponents, m_bpc, pParams); + m_pDecoder = FPDFAPI_CreateFlateDecoder(src_span, m_Width, m_Height, + m_nComponents, m_bpc, pParams); } else if (decoder == "RunLengthDecode") { CCodec_ModuleMgr* pEncoders = CPDF_ModuleMgr::Get()->GetCodecModule(); m_pDecoder = pEncoders->GetBasicModule()->CreateRunLengthDecoder( - {src_data, src_size}, m_Width, m_Height, m_nComponents, m_bpc); + src_span, m_Width, m_Height, m_nComponents, m_bpc); } else if (decoder == "DCTDecode") { - if (!CreateDCTDecoder({src_data, src_size}, pParams)) + if (!CreateDCTDecoder(src_span, pParams)) return LoadState::kFail; } if (!m_pDecoder) @@ -576,8 +574,8 @@ bool CPDF_DIBBase::CreateDCTDecoder(pdfium::span<const uint8_t> src_span, RetainPtr<CFX_DIBitmap> CPDF_DIBBase::LoadJpxBitmap() { CCodec_JpxModule* pJpxModule = CPDF_ModuleMgr::Get()->GetJpxModule(); auto context = pdfium::MakeUnique<JpxBitMapContext>(pJpxModule); - context->set_decoder(pJpxModule->CreateDecoder( - m_pStreamAcc->GetData(), m_pStreamAcc->GetSize(), m_pColorSpace.Get())); + context->set_decoder( + pJpxModule->CreateDecoder(m_pStreamAcc->GetSpan(), m_pColorSpace.Get())); if (!context->decoder()) return nullptr; |