diff options
author | Tom Sepez <tsepez@chromium.org> | 2018-10-09 19:44:11 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-10-09 19:44:11 +0000 |
commit | 3e838a75ae5c0bb0e524f745df69e54a021fc5ec (patch) | |
tree | 92d389fbba456469c14e75d7723493dc85603b81 /core/fxcodec/codec/ccodec_progressivedecoder.cpp | |
parent | 78606af0550f34a41d262e0a01381f48b7dfe197 (diff) | |
download | pdfium-3e838a75ae5c0bb0e524f745df69e54a021fc5ec.tar.xz |
Pass CFX_CodecMemory in place of spans to codecs.
Next step towards making CFX_CodecMemory own the memory it is
ref-counting.
Change-Id: I5922d80d13032c3ea028447c47d34a10234109a3
Reviewed-on: https://pdfium-review.googlesource.com/c/43630
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fxcodec/codec/ccodec_progressivedecoder.cpp')
-rw-r--r-- | core/fxcodec/codec/ccodec_progressivedecoder.cpp | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/core/fxcodec/codec/ccodec_progressivedecoder.cpp b/core/fxcodec/codec/ccodec_progressivedecoder.cpp index 0e6014595e..07665c1d4a 100644 --- a/core/fxcodec/codec/ccodec_progressivedecoder.cpp +++ b/core/fxcodec/codec/ccodec_progressivedecoder.cpp @@ -718,7 +718,10 @@ bool CCodec_ProgressiveDecoder::BmpDetectImageTypeInBuffer( std::unique_ptr<CodecModuleIface::Context> pBmpContext = pBmpModule->Start(this); - pBmpModule->Input(pBmpContext.get(), {m_pSrcBuf.get(), m_SrcSize}, nullptr); + pBmpModule->Input(pBmpContext.get(), + pdfium::MakeRetain<CFX_CodecMemory>( + pdfium::make_span(m_pSrcBuf.get(), m_SrcSize)), + nullptr); std::vector<uint32_t> palette; int32_t readResult = pBmpModule->ReadHeader( @@ -863,7 +866,10 @@ bool CCodec_ProgressiveDecoder::GifDetectImageTypeInBuffer( return false; } m_pGifContext = pGifModule->Start(this); - pGifModule->Input(m_pGifContext.get(), {m_pSrcBuf.get(), m_SrcSize}, nullptr); + pGifModule->Input(m_pGifContext.get(), + pdfium::MakeRetain<CFX_CodecMemory>( + pdfium::make_span(m_pSrcBuf.get(), m_SrcSize)), + nullptr); m_SrcComponents = 1; CFX_GifDecodeStatus readResult = pGifModule->ReadHeader( m_pGifContext.get(), &m_SrcWidth, &m_SrcHeight, &m_GifPltNumber, @@ -1046,7 +1052,9 @@ bool CCodec_ProgressiveDecoder::JpegDetectImageTypeInBuffer( m_status = FXCODEC_STATUS_ERR_MEMORY; return false; } - pJpegModule->Input(m_pJpegContext.get(), {m_pSrcBuf.get(), m_SrcSize}, + pJpegModule->Input(m_pJpegContext.get(), + pdfium::MakeRetain<CFX_CodecMemory>( + pdfium::make_span(m_pSrcBuf.get(), m_SrcSize)), nullptr); // Setting jump marker before calling ReadHeader, since a longjmp to // the marker indicates a fatal error. @@ -1256,8 +1264,11 @@ bool CCodec_ProgressiveDecoder::PngDetectImageTypeInBuffer( m_status = FXCODEC_STATUS_ERR_MEMORY; return false; } - bool bResult = pPngModule->Input(m_pPngContext.get(), - {m_pSrcBuf.get(), m_SrcSize}, pAttribute); + bool bResult = + pPngModule->Input(m_pPngContext.get(), + pdfium::MakeRetain<CFX_CodecMemory>( + pdfium::make_span(m_pSrcBuf.get(), m_SrcSize)), + pAttribute); while (bResult) { uint32_t remain_size = static_cast<uint32_t>(m_pFile->GetSize()) - m_offSet; uint32_t input_size = @@ -1277,8 +1288,11 @@ bool CCodec_ProgressiveDecoder::PngDetectImageTypeInBuffer( return false; } m_offSet += input_size; - bResult = pPngModule->Input(m_pPngContext.get(), - {m_pSrcBuf.get(), input_size}, pAttribute); + bResult = + pPngModule->Input(m_pPngContext.get(), + pdfium::MakeRetain<CFX_CodecMemory>( + pdfium::make_span(m_pSrcBuf.get(), input_size)), + pAttribute); } m_pPngContext.reset(); if (m_SrcPassNumber == 0) { @@ -1365,8 +1379,11 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::PngContinueDecode() { return m_status; } m_offSet += input_size; - bResult = pPngModule->Input(m_pPngContext.get(), - {m_pSrcBuf.get(), input_size}, nullptr); + bResult = + pPngModule->Input(m_pPngContext.get(), + pdfium::MakeRetain<CFX_CodecMemory>( + pdfium::make_span(m_pSrcBuf.get(), input_size)), + nullptr); if (!bResult) { m_pDeviceBitmap = nullptr; m_pFile = nullptr; @@ -1633,7 +1650,10 @@ bool CCodec_ProgressiveDecoder::ReadMoreData( return false; } m_offSet += dwBytesToFetchFromFile; - return pModule->Input(pContext, {m_pSrcBuf.get(), m_SrcSize}, nullptr); + return pModule->Input(pContext, + pdfium::MakeRetain<CFX_CodecMemory>( + pdfium::make_span(m_pSrcBuf.get(), m_SrcSize)), + nullptr); } FXCODEC_STATUS CCodec_ProgressiveDecoder::LoadImageInfo( |