diff options
author | Tom Sepez <tsepez@chromium.org> | 2018-08-28 22:25:49 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-08-28 22:25:49 +0000 |
commit | 126927eaec336153e3be43086deee672829395f1 (patch) | |
tree | 1d00d1ad571fcc412fac54433b4061d36b570beb /core/fpdfapi/page | |
parent | 4d92af5ace491a2e87a6c73e5afa9ed53ac86bd0 (diff) | |
download | pdfium-126927eaec336153e3be43086deee672829395f1.tar.xz |
Use std::span<> in CCodec_JPEGModule
Also rename .cpp file to match class name and .h file.
Modify some helper functions to operate on spans.
Move some initializations to member declarations.
Change-Id: Ie0889bda91daaef80fae6f5681f8ce068e92453b
Reviewed-on: https://pdfium-review.googlesource.com/41534
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'core/fpdfapi/page')
-rw-r--r-- | core/fpdfapi/page/cpdf_image.cpp | 13 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_image.h | 3 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_streamparser.cpp | 2 |
3 files changed, 9 insertions, 9 deletions
diff --git a/core/fpdfapi/page/cpdf_image.cpp b/core/fpdfapi/page/cpdf_image.cpp index b1c2fc9e82..9fdfa76710 100644 --- a/core/fpdfapi/page/cpdf_image.cpp +++ b/core/fpdfapi/page/cpdf_image.cpp @@ -71,15 +71,15 @@ CPDF_Dictionary* CPDF_Image::GetDict() const { return m_pStream ? m_pStream->GetDict() : nullptr; } -std::unique_ptr<CPDF_Dictionary> CPDF_Image::InitJPEG(uint8_t* pData, - uint32_t size) { +std::unique_ptr<CPDF_Dictionary> CPDF_Image::InitJPEG( + pdfium::span<uint8_t> src_span) { int32_t width; int32_t height; int32_t num_comps; int32_t bits; bool color_trans; if (!CPDF_ModuleMgr::Get()->GetJpegModule()->LoadInfo( - pData, size, &width, &height, &num_comps, &bits, &color_trans)) { + src_span, &width, &height, &num_comps, &bits, &color_trans)) { return nullptr; } @@ -128,12 +128,11 @@ void CPDF_Image::SetJpegImage(const RetainPtr<IFX_SeekableReadStream>& pFile) { if (!pFile->ReadBlock(data.data(), 0, dwEstimateSize)) return; - std::unique_ptr<CPDF_Dictionary> pDict = - InitJPEG(data.data(), dwEstimateSize); + std::unique_ptr<CPDF_Dictionary> pDict = InitJPEG(data); if (!pDict && size > dwEstimateSize) { data.resize(size); pFile->ReadBlock(data.data(), 0, size); - pDict = InitJPEG(data.data(), size); + pDict = InitJPEG(data); } if (!pDict) return; @@ -151,7 +150,7 @@ void CPDF_Image::SetJpegImageInline( if (!pFile->ReadBlock(data.data(), 0, size)) return; - std::unique_ptr<CPDF_Dictionary> pDict = InitJPEG(data.data(), size); + std::unique_ptr<CPDF_Dictionary> pDict = InitJPEG(data); if (!pDict) return; diff --git a/core/fpdfapi/page/cpdf_image.h b/core/fpdfapi/page/cpdf_image.h index 1be9b4d47f..f7752213f1 100644 --- a/core/fpdfapi/page/cpdf_image.h +++ b/core/fpdfapi/page/cpdf_image.h @@ -14,6 +14,7 @@ #include "core/fxcrt/maybe_owned.h" #include "core/fxcrt/retain_ptr.h" #include "core/fxcrt/unowned_ptr.h" +#include "third_party/base/span.h" class CFX_DIBBase; class CFX_DIBitmap; @@ -73,7 +74,7 @@ class CPDF_Image final : public Retainable { ~CPDF_Image() override; void FinishInitialization(CPDF_Dictionary* pStreamDict); - std::unique_ptr<CPDF_Dictionary> InitJPEG(uint8_t* pData, uint32_t size); + std::unique_ptr<CPDF_Dictionary> InitJPEG(pdfium::span<uint8_t> src_span); int32_t m_Height = 0; int32_t m_Width = 0; diff --git a/core/fpdfapi/page/cpdf_streamparser.cpp b/core/fpdfapi/page/cpdf_streamparser.cpp index 4b27cb32f3..bafb5820ff 100644 --- a/core/fpdfapi/page/cpdf_streamparser.cpp +++ b/core/fpdfapi/page/cpdf_streamparser.cpp @@ -89,7 +89,7 @@ uint32_t DecodeInlineStream(const uint8_t* src_buf, if (decoder == "DCTDecode" || decoder == "DCT") { std::unique_ptr<CCodec_ScanlineDecoder> pDecoder = CPDF_ModuleMgr::Get()->GetJpegModule()->CreateDecoder( - src_buf, limit, width, height, 0, + {src_buf, limit}, width, height, 0, !pParam || pParam->GetIntegerFor("ColorTransform", 1)); return DecodeAllScanlines(std::move(pDecoder), dest_buf, dest_size); } |