From 126927eaec336153e3be43086deee672829395f1 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Tue, 28 Aug 2018 22:25:49 +0000 Subject: 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 Reviewed-by: Lei Zhang --- core/fpdfapi/render/cpdf_dibbase.cpp | 17 ++++++++--------- core/fpdfapi/render/cpdf_dibbase.h | 4 ++-- 2 files changed, 10 insertions(+), 11 deletions(-) (limited to 'core/fpdfapi/render') diff --git a/core/fpdfapi/render/cpdf_dibbase.cpp b/core/fpdfapi/render/cpdf_dibbase.cpp index a1fae05bda..dd710f6e75 100644 --- a/core/fpdfapi/render/cpdf_dibbase.cpp +++ b/core/fpdfapi/render/cpdf_dibbase.cpp @@ -484,7 +484,7 @@ CPDF_DIBBase::LoadState CPDF_DIBBase::CreateDecoder() { m_pDecoder = pEncoders->GetBasicModule()->CreateRunLengthDecoder( {src_data, src_size}, m_Width, m_Height, m_nComponents, m_bpc); } else if (decoder == "DCTDecode") { - if (!CreateDCTDecoder(src_data, src_size, pParams)) + if (!CreateDCTDecoder({src_data, src_size}, pParams)) return LoadState::kFail; } if (!m_pDecoder) @@ -503,12 +503,11 @@ CPDF_DIBBase::LoadState CPDF_DIBBase::CreateDecoder() { return LoadState::kSuccess; } -bool CPDF_DIBBase::CreateDCTDecoder(const uint8_t* src_data, - uint32_t src_size, +bool CPDF_DIBBase::CreateDCTDecoder(pdfium::span src_span, const CPDF_Dictionary* pParams) { CCodec_JpegModule* pJpegModule = CPDF_ModuleMgr::Get()->GetJpegModule(); m_pDecoder = pJpegModule->CreateDecoder( - src_data, src_size, m_Width, m_Height, m_nComponents, + src_span, m_Width, m_Height, m_nComponents, !pParams || pParams->GetIntegerFor("ColorTransform", 1)); if (m_pDecoder) return true; @@ -516,15 +515,15 @@ bool CPDF_DIBBase::CreateDCTDecoder(const uint8_t* src_data, bool bTransform = false; int comps; int bpc; - if (!pJpegModule->LoadInfo(src_data, src_size, &m_Width, &m_Height, &comps, - &bpc, &bTransform)) { + if (!pJpegModule->LoadInfo(src_span, &m_Width, &m_Height, &comps, &bpc, + &bTransform)) { return false; } if (m_nComponents == static_cast(comps)) { m_bpc = bpc; - m_pDecoder = pJpegModule->CreateDecoder( - src_data, src_size, m_Width, m_Height, m_nComponents, bTransform); + m_pDecoder = pJpegModule->CreateDecoder(src_span, m_Width, m_Height, + m_nComponents, bTransform); return true; } @@ -569,7 +568,7 @@ bool CPDF_DIBBase::CreateDCTDecoder(const uint8_t* src_data, return false; m_bpc = bpc; - m_pDecoder = pJpegModule->CreateDecoder(src_data, src_size, m_Width, m_Height, + m_pDecoder = pJpegModule->CreateDecoder(src_span, m_Width, m_Height, m_nComponents, bTransform); return true; } diff --git a/core/fpdfapi/render/cpdf_dibbase.h b/core/fpdfapi/render/cpdf_dibbase.h index 423069db25..be48c3182d 100644 --- a/core/fpdfapi/render/cpdf_dibbase.h +++ b/core/fpdfapi/render/cpdf_dibbase.h @@ -22,6 +22,7 @@ #include "core/fxcrt/unowned_ptr.h" #include "core/fxge/cfx_defaultrenderdevice.h" #include "core/fxge/dib/cfx_dibbase.h" +#include "third_party/base/span.h" class CCodec_Jbig2Context; class CCodec_ScanlineDecoder; @@ -90,8 +91,7 @@ class CPDF_DIBBase final : public CFX_DIBBase { RetainPtr LoadJpxBitmap(); void LoadPalette(); LoadState CreateDecoder(); - bool CreateDCTDecoder(const uint8_t* src_data, - uint32_t src_size, + bool CreateDCTDecoder(pdfium::span src_data, const CPDF_Dictionary* pParams); void TranslateScanline24bpp(uint8_t* dest_scan, const uint8_t* src_scan) const; -- cgit v1.2.3