summaryrefslogtreecommitdiff
path: root/core/fpdfapi
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfapi')
-rw-r--r--core/fpdfapi/page/cpdf_image.cpp13
-rw-r--r--core/fpdfapi/page/cpdf_image.h3
-rw-r--r--core/fpdfapi/page/cpdf_streamparser.cpp2
-rw-r--r--core/fpdfapi/render/cpdf_dibbase.cpp17
-rw-r--r--core/fpdfapi/render/cpdf_dibbase.h4
5 files changed, 19 insertions, 20 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);
}
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<const uint8_t> 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<uint32_t>(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<CFX_DIBitmap> LoadJpxBitmap();
void LoadPalette();
LoadState CreateDecoder();
- bool CreateDCTDecoder(const uint8_t* src_data,
- uint32_t src_size,
+ bool CreateDCTDecoder(pdfium::span<const uint8_t> src_data,
const CPDF_Dictionary* pParams);
void TranslateScanline24bpp(uint8_t* dest_scan,
const uint8_t* src_scan) const;