summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-05-09 20:13:42 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-05-09 20:13:42 +0000
commit54ef2cb9eb5b145c6e973e95ccb488e121556ad7 (patch)
tree1cfd20ec575e8d825693256a17ca0f55b53f6b57
parenta44b288c4132711d0d9dbcc6885fc98525748ad7 (diff)
downloadpdfium-54ef2cb9eb5b145c6e973e95ccb488e121556ad7.tar.xz
Mark numerious pointers as const.
They are mostly CPDF_Object* and derived classes, but others that should be are marked const as well. Change-Id: Ib3344d7d8db90940df8edc97c0dd6c59da080541 Reviewed-on: https://pdfium-review.googlesource.com/32180 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
-rw-r--r--core/fpdfapi/page/cpdf_color.cpp2
-rw-r--r--core/fpdfapi/page/cpdf_colorspace.cpp122
-rw-r--r--core/fpdfapi/page/cpdf_colorspace.h12
-rw-r--r--core/fpdfapi/page/cpdf_devicecs.cpp4
-rw-r--r--core/fpdfapi/page/cpdf_devicecs.h4
-rw-r--r--core/fpdfapi/page/cpdf_docpagedata.cpp26
-rw-r--r--core/fpdfapi/page/cpdf_docpagedata.h16
-rw-r--r--core/fpdfapi/page/cpdf_expintfunc.cpp8
-rw-r--r--core/fpdfapi/page/cpdf_expintfunc.h3
-rw-r--r--core/fpdfapi/page/cpdf_function.cpp25
-rw-r--r--core/fpdfapi/page/cpdf_function.h12
-rw-r--r--core/fpdfapi/page/cpdf_image.cpp2
-rw-r--r--core/fpdfapi/page/cpdf_image.h2
-rw-r--r--core/fpdfapi/page/cpdf_meshstream.cpp8
-rw-r--r--core/fpdfapi/page/cpdf_meshstream.h8
-rw-r--r--core/fpdfapi/page/cpdf_pageobjectholder.h1
-rw-r--r--core/fpdfapi/page/cpdf_patterncs.cpp9
-rw-r--r--core/fpdfapi/page/cpdf_patterncs.h8
-rw-r--r--core/fpdfapi/page/cpdf_psfunc.cpp3
-rw-r--r--core/fpdfapi/page/cpdf_psfunc.h3
-rw-r--r--core/fpdfapi/page/cpdf_sampledfunc.cpp6
-rw-r--r--core/fpdfapi/page/cpdf_sampledfunc.h3
-rw-r--r--core/fpdfapi/page/cpdf_shadingpattern.cpp2
-rw-r--r--core/fpdfapi/page/cpdf_stitchfunc.cpp6
-rw-r--r--core/fpdfapi/page/cpdf_stitchfunc.h3
-rw-r--r--core/fpdfapi/page/cpdf_streamcontentparser.cpp4
-rw-r--r--core/fpdfapi/page/cpdf_streamparser.cpp2
-rw-r--r--core/fpdfapi/page/cpdf_streamparser.h2
-rw-r--r--core/fpdfapi/parser/cpdf_document.cpp5
-rw-r--r--core/fpdfapi/parser/cpdf_document.h4
-rw-r--r--core/fpdfapi/render/cpdf_dibsource.cpp4
-rw-r--r--core/fpdfapi/render/cpdf_dibsource.h2
-rw-r--r--core/fpdfapi/render/cpdf_docrenderdata.cpp6
-rw-r--r--core/fpdfapi/render/cpdf_docrenderdata.h6
-rw-r--r--core/fpdfapi/render/cpdf_imagecacheentry.cpp2
-rw-r--r--core/fpdfapi/render/cpdf_imagecacheentry.h2
-rw-r--r--core/fpdfapi/render/cpdf_renderstatus.cpp91
-rw-r--r--core/fpdfapi/render/cpdf_renderstatus.h13
38 files changed, 231 insertions, 210 deletions
diff --git a/core/fpdfapi/page/cpdf_color.cpp b/core/fpdfapi/page/cpdf_color.cpp
index b3dd141103..44b2e4023d 100644
--- a/core/fpdfapi/page/cpdf_color.cpp
+++ b/core/fpdfapi/page/cpdf_color.cpp
@@ -127,7 +127,7 @@ void CPDF_Color::Copy(const CPDF_Color& src) {
return;
CPDF_Document* pDoc = m_pCS->GetDocument();
- CPDF_Array* pArray = m_pCS->GetArray();
+ const CPDF_Array* pArray = m_pCS->GetArray();
if (pDoc && pArray) {
m_pCS = pDoc->GetPageData()->GetCopiedColorSpace(pArray);
if (!m_pCS)
diff --git a/core/fpdfapi/page/cpdf_colorspace.cpp b/core/fpdfapi/page/cpdf_colorspace.cpp
index d7fb18edd7..aa664d4e0f 100644
--- a/core/fpdfapi/page/cpdf_colorspace.cpp
+++ b/core/fpdfapi/page/cpdf_colorspace.cpp
@@ -112,8 +112,8 @@ class CPDF_CalGray : public CPDF_ColorSpace {
// CPDF_ColorSpace:
uint32_t v_Load(CPDF_Document* pDoc,
- CPDF_Array* pArray,
- std::set<CPDF_Object*>* pVisited) override;
+ const CPDF_Array* pArray,
+ std::set<const CPDF_Object*>* pVisited) override;
bool GetRGB(const float* pBuf, float* R, float* G, float* B) const override;
void TranslateImageLine(uint8_t* pDestBuf,
const uint8_t* pSrcBuf,
@@ -136,8 +136,8 @@ class CPDF_CalRGB : public CPDF_ColorSpace {
~CPDF_CalRGB() override {}
uint32_t v_Load(CPDF_Document* pDoc,
- CPDF_Array* pArray,
- std::set<CPDF_Object*>* pVisited) override;
+ const CPDF_Array* pArray,
+ std::set<const CPDF_Object*>* pVisited) override;
bool GetRGB(const float* pBuf, float* R, float* G, float* B) const override;
@@ -166,8 +166,8 @@ class CPDF_LabCS : public CPDF_ColorSpace {
~CPDF_LabCS() override {}
uint32_t v_Load(CPDF_Document* pDoc,
- CPDF_Array* pArray,
- std::set<CPDF_Object*>* pVisited) override;
+ const CPDF_Array* pArray,
+ std::set<const CPDF_Object*>* pVisited) override;
void GetDefaultValue(int iComponent,
float* value,
@@ -197,8 +197,8 @@ class CPDF_ICCBasedCS : public CPDF_ColorSpace {
// CPDF_ColorSpace:
uint32_t v_Load(CPDF_Document* pDoc,
- CPDF_Array* pArray,
- std::set<CPDF_Object*>* pVisited) override;
+ const CPDF_Array* pArray,
+ std::set<const CPDF_Object*>* pVisited) override;
bool GetRGB(const float* pBuf, float* R, float* G, float* B) const override;
void EnableStdConversion(bool bEnabled) override;
void TranslateImageLine(uint8_t* pDestBuf,
@@ -213,12 +213,12 @@ class CPDF_ICCBasedCS : public CPDF_ColorSpace {
private:
// If no valid ICC profile or using sRGB, try looking for an alternate.
bool FindAlternateProfile(CPDF_Document* pDoc,
- CPDF_Dictionary* pDict,
- std::set<CPDF_Object*>* pVisited,
+ const CPDF_Dictionary* pDict,
+ std::set<const CPDF_Object*>* pVisited,
uint32_t nExpectedComponents);
static CPDF_ColorSpace* GetStockAlternateProfile(uint32_t nComponents);
static bool IsValidComponents(int32_t nComps);
- static std::vector<float> GetRanges(CPDF_Dictionary* pDict,
+ static std::vector<float> GetRanges(const CPDF_Dictionary* pDict,
uint32_t nComponents);
MaybeOwned<CPDF_ColorSpace> m_pAlterCS;
@@ -233,8 +233,8 @@ class CPDF_IndexedCS : public CPDF_ColorSpace {
~CPDF_IndexedCS() override;
uint32_t v_Load(CPDF_Document* pDoc,
- CPDF_Array* pArray,
- std::set<CPDF_Object*>* pVisited) override;
+ const CPDF_Array* pArray,
+ std::set<const CPDF_Object*>* pVisited) override;
bool GetRGB(const float* pBuf, float* R, float* G, float* B) const override;
@@ -242,7 +242,7 @@ class CPDF_IndexedCS : public CPDF_ColorSpace {
private:
CPDF_ColorSpace* m_pBaseCS = nullptr;
- UnownedPtr<CPDF_CountedColorSpace> m_pCountedBaseCS;
+ UnownedPtr<const CPDF_CountedColorSpace> m_pCountedBaseCS;
uint32_t m_nBaseComponents = 0;
int m_MaxIndex = 0;
ByteString m_Table;
@@ -260,14 +260,14 @@ class CPDF_SeparationCS : public CPDF_ColorSpace {
float* min,
float* max) const override;
uint32_t v_Load(CPDF_Document* pDoc,
- CPDF_Array* pArray,
- std::set<CPDF_Object*>* pVisited) override;
+ const CPDF_Array* pArray,
+ std::set<const CPDF_Object*>* pVisited) override;
bool GetRGB(const float* pBuf, float* R, float* G, float* B) const override;
void EnableStdConversion(bool bEnabled) override;
private:
std::unique_ptr<CPDF_ColorSpace> m_pAltCS;
- std::unique_ptr<CPDF_Function> m_pFunc;
+ std::unique_ptr<const CPDF_Function> m_pFunc;
enum { None, All, Colorant } m_Type;
};
@@ -282,14 +282,14 @@ class CPDF_DeviceNCS : public CPDF_ColorSpace {
float* min,
float* max) const override;
uint32_t v_Load(CPDF_Document* pDoc,
- CPDF_Array* pArray,
- std::set<CPDF_Object*>* pVisited) override;
+ const CPDF_Array* pArray,
+ std::set<const CPDF_Object*>* pVisited) override;
bool GetRGB(const float* pBuf, float* R, float* G, float* B) const override;
void EnableStdConversion(bool bEnabled) override;
private:
std::unique_ptr<CPDF_ColorSpace> m_pAltCS;
- std::unique_ptr<CPDF_Function> m_pFunc;
+ std::unique_ptr<const CPDF_Function> m_pFunc;
};
class Vector_3by1 {
@@ -437,27 +437,27 @@ CPDF_ColorSpace* CPDF_ColorSpace::GetStockCS(int family) {
// static
std::unique_ptr<CPDF_ColorSpace> CPDF_ColorSpace::Load(CPDF_Document* pDoc,
CPDF_Object* pObj) {
- std::set<CPDF_Object*> visited;
+ std::set<const CPDF_Object*> visited;
return Load(pDoc, pObj, &visited);
}
// static
std::unique_ptr<CPDF_ColorSpace> CPDF_ColorSpace::Load(
CPDF_Document* pDoc,
- CPDF_Object* pObj,
- std::set<CPDF_Object*>* pVisited) {
+ const CPDF_Object* pObj,
+ std::set<const CPDF_Object*>* pVisited) {
if (!pObj)
return nullptr;
if (pdfium::ContainsKey(*pVisited, pObj))
return nullptr;
- pdfium::ScopedSetInsertion<CPDF_Object*> insertion(pVisited, pObj);
+ pdfium::ScopedSetInsertion<const CPDF_Object*> insertion(pVisited, pObj);
if (pObj->IsName())
return pdfium::WrapUnique(ColorspaceFromName(pObj->GetString()));
- if (CPDF_Stream* pStream = pObj->AsStream()) {
+ if (const CPDF_Stream* pStream = pObj->AsStream()) {
CPDF_Dictionary* pDict = pStream->GetDict();
if (!pDict)
return nullptr;
@@ -473,11 +473,11 @@ std::unique_ptr<CPDF_ColorSpace> CPDF_ColorSpace::Load(
return nullptr;
}
- CPDF_Array* pArray = pObj->AsArray();
+ const CPDF_Array* pArray = pObj->AsArray();
if (!pArray || pArray->IsEmpty())
return nullptr;
- CPDF_Object* pFamilyObj = pArray->GetDirectObjectAt(0);
+ const CPDF_Object* pFamilyObj = pArray->GetDirectObjectAt(0);
if (!pFamilyObj)
return nullptr;
@@ -627,9 +627,9 @@ CPDF_CalGray::CPDF_CalGray(CPDF_Document* pDoc)
: CPDF_ColorSpace(pDoc, PDFCS_CALGRAY) {}
uint32_t CPDF_CalGray::v_Load(CPDF_Document* pDoc,
- CPDF_Array* pArray,
- std::set<CPDF_Object*>* pVisited) {
- CPDF_Dictionary* pDict = pArray->GetDictAt(1);
+ const CPDF_Array* pArray,
+ std::set<const CPDF_Object*>* pVisited) {
+ const CPDF_Dictionary* pDict = pArray->GetDictAt(1);
if (!pDict)
return 0;
@@ -671,9 +671,9 @@ CPDF_CalRGB::CPDF_CalRGB(CPDF_Document* pDoc)
: CPDF_ColorSpace(pDoc, PDFCS_CALRGB) {}
uint32_t CPDF_CalRGB::v_Load(CPDF_Document* pDoc,
- CPDF_Array* pArray,
- std::set<CPDF_Object*>* pVisited) {
- CPDF_Dictionary* pDict = pArray->GetDictAt(1);
+ const CPDF_Array* pArray,
+ std::set<const CPDF_Object*>* pVisited) {
+ const CPDF_Dictionary* pDict = pArray->GetDictAt(1);
if (!pDict)
return 0;
@@ -682,7 +682,7 @@ uint32_t CPDF_CalRGB::v_Load(CPDF_Document* pDoc,
GetBlackPoint(pDict, m_BlackPoint);
- CPDF_Array* pParam = pDict->GetArrayFor("Gamma");
+ const CPDF_Array* pParam = pDict->GetArrayFor("Gamma");
if (pParam) {
m_bGamma = true;
for (size_t i = 0; i < FX_ArraySize(m_Gamma); ++i)
@@ -775,9 +775,9 @@ void CPDF_LabCS::GetDefaultValue(int iComponent,
}
uint32_t CPDF_LabCS::v_Load(CPDF_Document* pDoc,
- CPDF_Array* pArray,
- std::set<CPDF_Object*>* pVisited) {
- CPDF_Dictionary* pDict = pArray->GetDictAt(1);
+ const CPDF_Array* pArray,
+ std::set<const CPDF_Object*>* pVisited) {
+ const CPDF_Dictionary* pDict = pArray->GetDictAt(1);
if (!pDict)
return 0;
@@ -786,7 +786,7 @@ uint32_t CPDF_LabCS::v_Load(CPDF_Document* pDoc,
GetBlackPoint(pDict, m_BlackPoint);
- CPDF_Array* pParam = pDict->GetArrayFor("Range");
+ const CPDF_Array* pParam = pDict->GetArrayFor("Range");
static constexpr float kDefaultRanges[kRangesCount] = {-100.0f, 100.0f,
-100.0f, 100.0f};
static_assert(FX_ArraySize(kDefaultRanges) == FX_ArraySize(m_Ranges),
@@ -863,8 +863,8 @@ CPDF_ICCBasedCS::~CPDF_ICCBasedCS() {
}
uint32_t CPDF_ICCBasedCS::v_Load(CPDF_Document* pDoc,
- CPDF_Array* pArray,
- std::set<CPDF_Object*>* pVisited) {
+ const CPDF_Array* pArray,
+ std::set<const CPDF_Object*>* pVisited) {
CPDF_Stream* pStream = pArray->GetStreamAt(1);
if (!pStream)
return 0;
@@ -872,7 +872,7 @@ uint32_t CPDF_ICCBasedCS::v_Load(CPDF_Document* pDoc,
// The PDF 1.7 spec says the number of components must be valid. While some
// PDF viewers tolerate invalid values, Acrobat does not, so be consistent
// with Acrobat and reject bad values.
- CPDF_Dictionary* pDict = pStream->GetDict();
+ const CPDF_Dictionary* pDict = pStream->GetDict();
int32_t nDictComponents = pDict ? pDict->GetIntegerFor("N") : 0;
if (!IsValidComponents(nDictComponents))
return 0;
@@ -1010,11 +1010,12 @@ void CPDF_ICCBasedCS::TranslateImageLine(uint8_t* pDestBuf,
}
}
-bool CPDF_ICCBasedCS::FindAlternateProfile(CPDF_Document* pDoc,
- CPDF_Dictionary* pDict,
- std::set<CPDF_Object*>* pVisited,
- uint32_t nExpectedComponents) {
- CPDF_Object* pAlterCSObj = pDict->GetDirectObjectFor("Alternate");
+bool CPDF_ICCBasedCS::FindAlternateProfile(
+ CPDF_Document* pDoc,
+ const CPDF_Dictionary* pDict,
+ std::set<const CPDF_Object*>* pVisited,
+ uint32_t nExpectedComponents) {
+ const CPDF_Object* pAlterCSObj = pDict->GetDirectObjectFor("Alternate");
if (!pAlterCSObj)
return false;
@@ -1051,13 +1052,13 @@ bool CPDF_ICCBasedCS::IsValidComponents(int32_t nComps) {
}
// static
-std::vector<float> CPDF_ICCBasedCS::GetRanges(CPDF_Dictionary* pDict,
+std::vector<float> CPDF_ICCBasedCS::GetRanges(const CPDF_Dictionary* pDict,
uint32_t nComponents) {
ASSERT(IsValidComponents(nComponents));
std::vector<float> ranges;
ranges.reserve(nComponents * 2);
- CPDF_Array* pRanges = pDict->GetArrayFor("Range");
+ const CPDF_Array* pRanges = pDict->GetArrayFor("Range");
if (pRanges) {
for (uint32_t i = 0; i < nComponents * 2; i++) {
ranges.push_back(pRanges->GetNumberAt(i));
@@ -1076,7 +1077,8 @@ CPDF_IndexedCS::CPDF_IndexedCS(CPDF_Document* pDoc)
CPDF_IndexedCS::~CPDF_IndexedCS() {
FX_Free(m_pCompMinMax);
- CPDF_ColorSpace* pCS = m_pCountedBaseCS ? m_pCountedBaseCS->get() : nullptr;
+ const CPDF_ColorSpace* pCS =
+ m_pCountedBaseCS ? m_pCountedBaseCS->get() : nullptr;
if (pCS && m_pDocument) {
auto* pPageData = m_pDocument->GetPageData();
if (pPageData)
@@ -1085,12 +1087,12 @@ CPDF_IndexedCS::~CPDF_IndexedCS() {
}
uint32_t CPDF_IndexedCS::v_Load(CPDF_Document* pDoc,
- CPDF_Array* pArray,
- std::set<CPDF_Object*>* pVisited) {
+ const CPDF_Array* pArray,
+ std::set<const CPDF_Object*>* pVisited) {
if (pArray->GetCount() < 4)
return 0;
- CPDF_Object* pBaseObj = pArray->GetDirectObjectAt(1);
+ const CPDF_Object* pBaseObj = pArray->GetDirectObjectAt(1);
if (pBaseObj == m_pArray)
return 0;
@@ -1181,8 +1183,8 @@ void CPDF_SeparationCS::GetDefaultValue(int iComponent,
}
uint32_t CPDF_SeparationCS::v_Load(CPDF_Document* pDoc,
- CPDF_Array* pArray,
- std::set<CPDF_Object*>* pVisited) {
+ const CPDF_Array* pArray,
+ std::set<const CPDF_Object*>* pVisited) {
ByteString name = pArray->GetStringAt(1);
if (name == "None") {
m_Type = None;
@@ -1190,7 +1192,7 @@ uint32_t CPDF_SeparationCS::v_Load(CPDF_Document* pDoc,
}
m_Type = Colorant;
- CPDF_Object* pAltCS = pArray->GetDirectObjectAt(2);
+ const CPDF_Object* pAltCS = pArray->GetDirectObjectAt(2);
if (pAltCS == m_pArray)
return 0;
@@ -1201,7 +1203,7 @@ uint32_t CPDF_SeparationCS::v_Load(CPDF_Document* pDoc,
if (m_pAltCS->IsSpecial())
return 0;
- CPDF_Object* pFuncObj = pArray->GetDirectObjectAt(3);
+ const CPDF_Object* pFuncObj = pArray->GetDirectObjectAt(3);
if (pFuncObj && !pFuncObj->IsName()) {
auto pFunc = CPDF_Function::Load(pFuncObj);
if (pFunc && pFunc->CountOutputs() >= m_pAltCS->CountComponents())
@@ -1252,13 +1254,13 @@ void CPDF_DeviceNCS::GetDefaultValue(int iComponent,
}
uint32_t CPDF_DeviceNCS::v_Load(CPDF_Document* pDoc,
- CPDF_Array* pArray,
- std::set<CPDF_Object*>* pVisited) {
- CPDF_Array* pObj = ToArray(pArray->GetDirectObjectAt(1));
+ const CPDF_Array* pArray,
+ std::set<const CPDF_Object*>* pVisited) {
+ const CPDF_Array* pObj = ToArray(pArray->GetDirectObjectAt(1));
if (!pObj)
return 0;
- CPDF_Object* pAltCS = pArray->GetDirectObjectAt(2);
+ const CPDF_Object* pAltCS = pArray->GetDirectObjectAt(2);
if (!pAltCS || pAltCS == m_pArray)
return 0;
diff --git a/core/fpdfapi/page/cpdf_colorspace.h b/core/fpdfapi/page/cpdf_colorspace.h
index 71722224aa..fba63917f7 100644
--- a/core/fpdfapi/page/cpdf_colorspace.h
+++ b/core/fpdfapi/page/cpdf_colorspace.h
@@ -49,8 +49,8 @@ class CPDF_ColorSpace {
CPDF_Object* pCSObj);
static std::unique_ptr<CPDF_ColorSpace> Load(
CPDF_Document* pDoc,
- CPDF_Object* pCSObj,
- std::set<CPDF_Object*>* pVisited);
+ const CPDF_Object* pCSObj,
+ std::set<const CPDF_Object*>* pVisited);
void Release();
@@ -97,7 +97,7 @@ class CPDF_ColorSpace {
float* G,
float* B) const;
- CPDF_Array* GetArray() const { return m_pArray.Get(); }
+ const CPDF_Array* GetArray() const { return m_pArray.Get(); }
CPDF_Document* GetDocument() const { return m_pDocument.Get(); }
protected:
@@ -106,15 +106,15 @@ class CPDF_ColorSpace {
// Returns the number of components, or 0 on failure.
virtual uint32_t v_Load(CPDF_Document* pDoc,
- CPDF_Array* pArray,
- std::set<CPDF_Object*>* pVisited) = 0;
+ const CPDF_Array* pArray,
+ std::set<const CPDF_Object*>* pVisited) = 0;
// Stock colorspaces are not loaded normally. This initializes their
// components count.
void SetComponentsForStockCS(uint32_t nComponents);
UnownedPtr<CPDF_Document> const m_pDocument;
- UnownedPtr<CPDF_Array> m_pArray;
+ UnownedPtr<const CPDF_Array> m_pArray;
const int m_Family;
uint32_t m_dwStdConversion = 0;
diff --git a/core/fpdfapi/page/cpdf_devicecs.cpp b/core/fpdfapi/page/cpdf_devicecs.cpp
index bf9b3768e7..dd440f5398 100644
--- a/core/fpdfapi/page/cpdf_devicecs.cpp
+++ b/core/fpdfapi/page/cpdf_devicecs.cpp
@@ -63,8 +63,8 @@ CPDF_DeviceCS::CPDF_DeviceCS(int family) : CPDF_ColorSpace(nullptr, family) {
CPDF_DeviceCS::~CPDF_DeviceCS() {}
uint32_t CPDF_DeviceCS::v_Load(CPDF_Document* pDoc,
- CPDF_Array* pArray,
- std::set<CPDF_Object*>* pVisited) {
+ const CPDF_Array* pArray,
+ std::set<const CPDF_Object*>* pVisited) {
// Unlike other classes that inherit from CPDF_ColorSpace, CPDF_DeviceCS is
// never loaded by CPDF_ColorSpace.
NOTREACHED();
diff --git a/core/fpdfapi/page/cpdf_devicecs.h b/core/fpdfapi/page/cpdf_devicecs.h
index aecda71a41..bf668c359b 100644
--- a/core/fpdfapi/page/cpdf_devicecs.h
+++ b/core/fpdfapi/page/cpdf_devicecs.h
@@ -18,8 +18,8 @@ class CPDF_DeviceCS : public CPDF_ColorSpace {
// CPDF_ColorSpace:
uint32_t v_Load(CPDF_Document* pDoc,
- CPDF_Array* pArray,
- std::set<CPDF_Object*>* pVisited) override;
+ const CPDF_Array* pArray,
+ std::set<const CPDF_Object*>* pVisited) override;
bool GetRGB(const float* pBuf, float* R, float* G, float* B) const override;
void TranslateImageLine(uint8_t* pDestBuf,
const uint8_t* pSrcBuf,
diff --git a/core/fpdfapi/page/cpdf_docpagedata.cpp b/core/fpdfapi/page/cpdf_docpagedata.cpp
index 03db315912..9ac5c1e304 100644
--- a/core/fpdfapi/page/cpdf_docpagedata.cpp
+++ b/core/fpdfapi/page/cpdf_docpagedata.cpp
@@ -209,32 +209,33 @@ void CPDF_DocPageData::ReleaseFont(const CPDF_Dictionary* pFontDict) {
}
CPDF_ColorSpace* CPDF_DocPageData::GetColorSpace(
- CPDF_Object* pCSObj,
+ const CPDF_Object* pCSObj,
const CPDF_Dictionary* pResources) {
- std::set<CPDF_Object*> visited;
+ std::set<const CPDF_Object*> visited;
return GetColorSpaceGuarded(pCSObj, pResources, &visited);
}
CPDF_ColorSpace* CPDF_DocPageData::GetColorSpaceGuarded(
- CPDF_Object* pCSObj,
+ const CPDF_Object* pCSObj,
const CPDF_Dictionary* pResources,
- std::set<CPDF_Object*>* pVisited) {
- std::set<CPDF_Object*> visitedLocal;
+ std::set<const CPDF_Object*>* pVisited) {
+ std::set<const CPDF_Object*> visitedLocal;
return GetColorSpaceInternal(pCSObj, pResources, pVisited, &visitedLocal);
}
CPDF_ColorSpace* CPDF_DocPageData::GetColorSpaceInternal(
- CPDF_Object* pCSObj,
+ const CPDF_Object* pCSObj,
const CPDF_Dictionary* pResources,
- std::set<CPDF_Object*>* pVisited,
- std::set<CPDF_Object*>* pVisitedInternal) {
+ std::set<const CPDF_Object*>* pVisited,
+ std::set<const CPDF_Object*>* pVisitedInternal) {
if (!pCSObj)
return nullptr;
if (pdfium::ContainsKey(*pVisitedInternal, pCSObj))
return nullptr;
- pdfium::ScopedSetInsertion<CPDF_Object*> insertion(pVisitedInternal, pCSObj);
+ pdfium::ScopedSetInsertion<const CPDF_Object*> insertion(pVisitedInternal,
+ pCSObj);
if (pCSObj->IsName()) {
ByteString name = pCSObj->GetString();
@@ -272,7 +273,7 @@ CPDF_ColorSpace* CPDF_DocPageData::GetColorSpaceInternal(
pVisitedInternal);
}
- CPDF_Array* pArray = pCSObj->AsArray();
+ const CPDF_Array* pArray = pCSObj->AsArray();
if (!pArray || pArray->IsEmpty())
return nullptr;
@@ -304,7 +305,8 @@ CPDF_ColorSpace* CPDF_DocPageData::GetColorSpaceInternal(
return csData->AddRef();
}
-CPDF_ColorSpace* CPDF_DocPageData::GetCopiedColorSpace(CPDF_Object* pCSObj) {
+CPDF_ColorSpace* CPDF_DocPageData::GetCopiedColorSpace(
+ const CPDF_Object* pCSObj) {
if (!pCSObj)
return nullptr;
@@ -484,7 +486,7 @@ void CPDF_DocPageData::MaybePurgeFontFileStreamAcc(
}
CPDF_CountedColorSpace* CPDF_DocPageData::FindColorSpacePtr(
- CPDF_Object* pCSObj) const {
+ const CPDF_Object* pCSObj) const {
if (!pCSObj)
return nullptr;
diff --git a/core/fpdfapi/page/cpdf_docpagedata.h b/core/fpdfapi/page/cpdf_docpagedata.h
index 5508f568be..2d22ee991d 100644
--- a/core/fpdfapi/page/cpdf_docpagedata.h
+++ b/core/fpdfapi/page/cpdf_docpagedata.h
@@ -40,17 +40,17 @@ class CPDF_DocPageData {
void ReleaseFont(const CPDF_Dictionary* pFontDict);
// Loads a colorspace.
- CPDF_ColorSpace* GetColorSpace(CPDF_Object* pCSObj,
+ CPDF_ColorSpace* GetColorSpace(const CPDF_Object* pCSObj,
const CPDF_Dictionary* pResources);
// Loads a colorspace in a context that might be while loading another
// colorspace. |pVisited| is passed recursively to avoid circular calls
// involving CPDF_ColorSpace::Load().
- CPDF_ColorSpace* GetColorSpaceGuarded(CPDF_Object* pCSObj,
+ CPDF_ColorSpace* GetColorSpaceGuarded(const CPDF_Object* pCSObj,
const CPDF_Dictionary* pResources,
- std::set<CPDF_Object*>* pVisited);
+ std::set<const CPDF_Object*>* pVisited);
- CPDF_ColorSpace* GetCopiedColorSpace(CPDF_Object* pCSObj);
+ CPDF_ColorSpace* GetCopiedColorSpace(const CPDF_Object* pCSObj);
void ReleaseColorSpace(const CPDF_Object* pColorSpace);
CPDF_Pattern* GetPattern(CPDF_Object* pPatternObj,
@@ -67,7 +67,7 @@ class CPDF_DocPageData {
RetainPtr<CPDF_StreamAcc> GetFontFileStreamAcc(CPDF_Stream* pFontStream);
void MaybePurgeFontFileStreamAcc(const CPDF_Stream* pFontStream);
- CPDF_CountedColorSpace* FindColorSpacePtr(CPDF_Object* pCSObj) const;
+ CPDF_CountedColorSpace* FindColorSpacePtr(const CPDF_Object* pCSObj) const;
CPDF_CountedPattern* FindPatternPtr(CPDF_Object* pPatternObj) const;
private:
@@ -79,10 +79,10 @@ class CPDF_DocPageData {
// CPDF_ColorSpace::Load() and |pVisitedInternal| is also passed recursively
// to avoid circular calls with this method calling itself.
CPDF_ColorSpace* GetColorSpaceInternal(
- CPDF_Object* pCSObj,
+ const CPDF_Object* pCSObj,
const CPDF_Dictionary* pResources,
- std::set<CPDF_Object*>* pVisited,
- std::set<CPDF_Object*>* pVisitedInternal);
+ std::set<const CPDF_Object*>* pVisited,
+ std::set<const CPDF_Object*>* pVisitedInternal);
bool m_bForceClear;
UnownedPtr<CPDF_Document> const m_pPDFDoc;
diff --git a/core/fpdfapi/page/cpdf_expintfunc.cpp b/core/fpdfapi/page/cpdf_expintfunc.cpp
index 0b3dc24033..ac17b282a9 100644
--- a/core/fpdfapi/page/cpdf_expintfunc.cpp
+++ b/core/fpdfapi/page/cpdf_expintfunc.cpp
@@ -19,14 +19,14 @@ CPDF_ExpIntFunc::~CPDF_ExpIntFunc() {
FX_Free(m_pEndValues);
}
-bool CPDF_ExpIntFunc::v_Init(CPDF_Object* pObj,
- std::set<CPDF_Object*>* pVisited) {
- CPDF_Dictionary* pDict = pObj->GetDict();
+bool CPDF_ExpIntFunc::v_Init(const CPDF_Object* pObj,
+ std::set<const CPDF_Object*>* pVisited) {
+ const CPDF_Dictionary* pDict = pObj->GetDict();
if (!pDict)
return false;
{
- CPDF_Number* pExponent = ToNumber(pDict->GetObjectFor("N"));
+ const CPDF_Number* pExponent = ToNumber(pDict->GetObjectFor("N"));
if (!pExponent)
return false;
diff --git a/core/fpdfapi/page/cpdf_expintfunc.h b/core/fpdfapi/page/cpdf_expintfunc.h
index 3ff6a7eb22..9ea9f5ccb8 100644
--- a/core/fpdfapi/page/cpdf_expintfunc.h
+++ b/core/fpdfapi/page/cpdf_expintfunc.h
@@ -17,7 +17,8 @@ class CPDF_ExpIntFunc : public CPDF_Function {
~CPDF_ExpIntFunc() override;
// CPDF_Function
- bool v_Init(CPDF_Object* pObj, std::set<CPDF_Object*>* pVisited) override;
+ bool v_Init(const CPDF_Object* pObj,
+ std::set<const CPDF_Object*>* pVisited) override;
bool v_Call(const float* inputs, float* results) const override;
uint32_t m_nOrigOutputs = 0;
diff --git a/core/fpdfapi/page/cpdf_function.cpp b/core/fpdfapi/page/cpdf_function.cpp
index a43c887e71..ad3b666a1f 100644
--- a/core/fpdfapi/page/cpdf_function.cpp
+++ b/core/fpdfapi/page/cpdf_function.cpp
@@ -18,26 +18,27 @@
#include "third_party/base/ptr_util.h"
// static
-std::unique_ptr<CPDF_Function> CPDF_Function::Load(CPDF_Object* pFuncObj) {
- std::set<CPDF_Object*> visited;
+std::unique_ptr<CPDF_Function> CPDF_Function::Load(
+ const CPDF_Object* pFuncObj) {
+ std::set<const CPDF_Object*> visited;
return Load(pFuncObj, &visited);
}
// static
std::unique_ptr<CPDF_Function> CPDF_Function::Load(
- CPDF_Object* pFuncObj,
- std::set<CPDF_Object*>* pVisited) {
+ const CPDF_Object* pFuncObj,
+ std::set<const CPDF_Object*>* pVisited) {
if (!pFuncObj)
return nullptr;
if (pdfium::ContainsKey(*pVisited, pFuncObj))
return nullptr;
- pdfium::ScopedSetInsertion<CPDF_Object*> insertion(pVisited, pFuncObj);
+ pdfium::ScopedSetInsertion<const CPDF_Object*> insertion(pVisited, pFuncObj);
int iType = -1;
- if (CPDF_Stream* pStream = pFuncObj->AsStream())
+ if (const CPDF_Stream* pStream = pFuncObj->AsStream())
iType = pStream->GetDict()->GetIntegerFor("FunctionType");
- else if (CPDF_Dictionary* pDict = pFuncObj->AsDictionary())
+ else if (const CPDF_Dictionary* pDict = pFuncObj->AsDictionary())
iType = pDict->GetIntegerFor("FunctionType");
std::unique_ptr<CPDF_Function> pFunc;
@@ -78,11 +79,13 @@ CPDF_Function::~CPDF_Function() {
FX_Free(m_pRanges);
}
-bool CPDF_Function::Init(CPDF_Object* pObj, std::set<CPDF_Object*>* pVisited) {
- CPDF_Stream* pStream = pObj->AsStream();
- CPDF_Dictionary* pDict = pStream ? pStream->GetDict() : pObj->AsDictionary();
+bool CPDF_Function::Init(const CPDF_Object* pObj,
+ std::set<const CPDF_Object*>* pVisited) {
+ const CPDF_Stream* pStream = pObj->AsStream();
+ const CPDF_Dictionary* pDict =
+ pStream ? pStream->GetDict() : pObj->AsDictionary();
- CPDF_Array* pDomains = pDict->GetArrayFor("Domain");
+ const CPDF_Array* pDomains = pDict->GetArrayFor("Domain");
if (!pDomains)
return false;
diff --git a/core/fpdfapi/page/cpdf_function.h b/core/fpdfapi/page/cpdf_function.h
index 82a3a54327..c2f2a4bb4e 100644
--- a/core/fpdfapi/page/cpdf_function.h
+++ b/core/fpdfapi/page/cpdf_function.h
@@ -25,7 +25,7 @@ class CPDF_Function {
kType4PostScript = 4,
};
- static std::unique_ptr<CPDF_Function> Load(CPDF_Object* pFuncObj);
+ static std::unique_ptr<CPDF_Function> Load(const CPDF_Object* pFuncObj);
static Type IntegerToFunctionType(int iType);
virtual ~CPDF_Function();
@@ -51,10 +51,12 @@ class CPDF_Function {
protected:
explicit CPDF_Function(Type type);
- static std::unique_ptr<CPDF_Function> Load(CPDF_Object* pFuncObj,
- std::set<CPDF_Object*>* pVisited);
- bool Init(CPDF_Object* pObj, std::set<CPDF_Object*>* pVisited);
- virtual bool v_Init(CPDF_Object* pObj, std::set<CPDF_Object*>* pVisited) = 0;
+ static std::unique_ptr<CPDF_Function> Load(
+ const CPDF_Object* pFuncObj,
+ std::set<const CPDF_Object*>* pVisited);
+ bool Init(const CPDF_Object* pObj, std::set<const CPDF_Object*>* pVisited);
+ virtual bool v_Init(const CPDF_Object* pObj,
+ std::set<const CPDF_Object*>* pVisited) = 0;
virtual bool v_Call(const float* inputs, float* results) const = 0;
uint32_t m_nInputs;
diff --git a/core/fpdfapi/page/cpdf_image.cpp b/core/fpdfapi/page/cpdf_image.cpp
index 9ce4268a36..8720342d35 100644
--- a/core/fpdfapi/page/cpdf_image.cpp
+++ b/core/fpdfapi/page/cpdf_image.cpp
@@ -353,7 +353,7 @@ RetainPtr<CFX_DIBSource> CPDF_Image::DetachMask() {
return std::move(m_pMask);
}
-bool CPDF_Image::StartLoadDIBSource(CPDF_Dictionary* pFormResource,
+bool CPDF_Image::StartLoadDIBSource(const CPDF_Dictionary* pFormResource,
CPDF_Dictionary* pPageResource,
bool bStdCS,
uint32_t GroupFamily,
diff --git a/core/fpdfapi/page/cpdf_image.h b/core/fpdfapi/page/cpdf_image.h
index 73ea92c666..9281a2c77d 100644
--- a/core/fpdfapi/page/cpdf_image.h
+++ b/core/fpdfapi/page/cpdf_image.h
@@ -50,7 +50,7 @@ class CPDF_Image : public Retainable {
void ResetCache(CPDF_Page* pPage, const RetainPtr<CFX_DIBitmap>& pDIBitmap);
// Returns whether to Continue() or not.
- bool StartLoadDIBSource(CPDF_Dictionary* pFormResource,
+ bool StartLoadDIBSource(const CPDF_Dictionary* pFormResource,
CPDF_Dictionary* pPageResource,
bool bStdCS = false,
uint32_t GroupFamily = 0,
diff --git a/core/fpdfapi/page/cpdf_meshstream.cpp b/core/fpdfapi/page/cpdf_meshstream.cpp
index 579678af41..57a5dd1da1 100644
--- a/core/fpdfapi/page/cpdf_meshstream.cpp
+++ b/core/fpdfapi/page/cpdf_meshstream.cpp
@@ -93,8 +93,8 @@ CPDF_MeshVertex::~CPDF_MeshVertex() = default;
CPDF_MeshStream::CPDF_MeshStream(
ShadingType type,
const std::vector<std::unique_ptr<CPDF_Function>>& funcs,
- CPDF_Stream* pShadingStream,
- CPDF_ColorSpace* pCS)
+ const CPDF_Stream* pShadingStream,
+ const CPDF_ColorSpace* pCS)
: m_type(type),
m_funcs(funcs),
m_pShadingStream(pShadingStream),
@@ -120,7 +120,7 @@ bool CPDF_MeshStream::Load() {
m_pStream->LoadAllDataFiltered();
m_BitStream = pdfium::MakeUnique<CFX_BitStream>(
pdfium::make_span(m_pStream->GetData(), m_pStream->GetSize()));
- CPDF_Dictionary* pDict = m_pShadingStream->GetDict();
+ const CPDF_Dictionary* pDict = m_pShadingStream->GetDict();
m_nCoordBits = pDict->GetIntegerFor("BitsPerCoordinate");
m_nComponentBits = pDict->GetIntegerFor("BitsPerComponent");
if (ShouldCheckBPC(m_type)) {
@@ -139,7 +139,7 @@ bool CPDF_MeshStream::Load() {
return false;
m_nComponents = m_funcs.empty() ? nComponents : 1;
- CPDF_Array* pDecode = pDict->GetArrayFor("Decode");
+ const CPDF_Array* pDecode = pDict->GetArrayFor("Decode");
if (!pDecode || pDecode->GetCount() != 4 + m_nComponents * 2)
return false;
diff --git a/core/fpdfapi/page/cpdf_meshstream.h b/core/fpdfapi/page/cpdf_meshstream.h
index 9c97e09c15..1148494578 100644
--- a/core/fpdfapi/page/cpdf_meshstream.h
+++ b/core/fpdfapi/page/cpdf_meshstream.h
@@ -37,8 +37,8 @@ class CPDF_MeshStream {
public:
CPDF_MeshStream(ShadingType type,
const std::vector<std::unique_ptr<CPDF_Function>>& funcs,
- CPDF_Stream* pShadingStream,
- CPDF_ColorSpace* pCS);
+ const CPDF_Stream* pShadingStream,
+ const CPDF_ColorSpace* pCS);
~CPDF_MeshStream();
bool Load();
@@ -66,8 +66,8 @@ class CPDF_MeshStream {
const ShadingType m_type;
const std::vector<std::unique_ptr<CPDF_Function>>& m_funcs;
- UnownedPtr<CPDF_Stream> const m_pShadingStream;
- UnownedPtr<CPDF_ColorSpace> const m_pCS;
+ UnownedPtr<const CPDF_Stream> const m_pShadingStream;
+ UnownedPtr<const CPDF_ColorSpace> const m_pCS;
uint32_t m_nCoordBits;
uint32_t m_nComponentBits;
uint32_t m_nFlagBits;
diff --git a/core/fpdfapi/page/cpdf_pageobjectholder.h b/core/fpdfapi/page/cpdf_pageobjectholder.h
index 47c02fcf44..dc1a607cf0 100644
--- a/core/fpdfapi/page/cpdf_pageobjectholder.h
+++ b/core/fpdfapi/page/cpdf_pageobjectholder.h
@@ -86,6 +86,7 @@ class CPDF_PageObjectHolder {
void Transform(const CFX_Matrix& matrix);
CFX_FloatRect CalcBoundingBox() const;
+ // TODO(thestig): Move |m_pFormStream| into CPDF_Form.
UnownedPtr<CPDF_Stream> m_pFormStream;
UnownedPtr<CPDF_Dictionary> m_pPageResources;
UnownedPtr<CPDF_Dictionary> m_pResources;
diff --git a/core/fpdfapi/page/cpdf_patterncs.cpp b/core/fpdfapi/page/cpdf_patterncs.cpp
index 37e91aa4e0..69be3d2b82 100644
--- a/core/fpdfapi/page/cpdf_patterncs.cpp
+++ b/core/fpdfapi/page/cpdf_patterncs.cpp
@@ -16,7 +16,8 @@ CPDF_PatternCS::CPDF_PatternCS(CPDF_Document* pDoc)
m_pCountedBaseCS(nullptr) {}
CPDF_PatternCS::~CPDF_PatternCS() {
- CPDF_ColorSpace* pCS = m_pCountedBaseCS ? m_pCountedBaseCS->get() : nullptr;
+ const CPDF_ColorSpace* pCS =
+ m_pCountedBaseCS ? m_pCountedBaseCS->get() : nullptr;
if (pCS && m_pDocument) {
auto* pPageData = m_pDocument->GetPageData();
if (pPageData)
@@ -29,9 +30,9 @@ void CPDF_PatternCS::InitializeStockPattern() {
}
uint32_t CPDF_PatternCS::v_Load(CPDF_Document* pDoc,
- CPDF_Array* pArray,
- std::set<CPDF_Object*>* pVisited) {
- CPDF_Object* pBaseCS = pArray->GetDirectObjectAt(1);
+ const CPDF_Array* pArray,
+ std::set<const CPDF_Object*>* pVisited) {
+ const CPDF_Object* pBaseCS = pArray->GetDirectObjectAt(1);
if (pBaseCS == m_pArray)
return 0;
diff --git a/core/fpdfapi/page/cpdf_patterncs.h b/core/fpdfapi/page/cpdf_patterncs.h
index 45365cc738..23735fd8f2 100644
--- a/core/fpdfapi/page/cpdf_patterncs.h
+++ b/core/fpdfapi/page/cpdf_patterncs.h
@@ -24,8 +24,8 @@ class CPDF_PatternCS : public CPDF_ColorSpace {
// CPDF_ColorSpace:
uint32_t v_Load(CPDF_Document* pDoc,
- CPDF_Array* pArray,
- std::set<CPDF_Object*>* pVisited) override;
+ const CPDF_Array* pArray,
+ std::set<const CPDF_Object*>* pVisited) override;
bool GetRGB(const float* pBuf, float* R, float* G, float* B) const override;
CPDF_PatternCS* AsPatternCS() override;
const CPDF_PatternCS* AsPatternCS() const override;
@@ -35,8 +35,8 @@ class CPDF_PatternCS : public CPDF_ColorSpace {
float* B) const override;
private:
- CPDF_ColorSpace* m_pBaseCS;
- CPDF_CountedColorSpace* m_pCountedBaseCS;
+ const CPDF_ColorSpace* m_pBaseCS;
+ const CPDF_CountedColorSpace* m_pCountedBaseCS;
};
#endif // CORE_FPDFAPI_PAGE_CPDF_PATTERNCS_H_
diff --git a/core/fpdfapi/page/cpdf_psfunc.cpp b/core/fpdfapi/page/cpdf_psfunc.cpp
index 2230d4e241..be0afe9659 100644
--- a/core/fpdfapi/page/cpdf_psfunc.cpp
+++ b/core/fpdfapi/page/cpdf_psfunc.cpp
@@ -13,7 +13,8 @@ CPDF_PSFunc::CPDF_PSFunc() : CPDF_Function(Type::kType4PostScript) {}
CPDF_PSFunc::~CPDF_PSFunc() {}
-bool CPDF_PSFunc::v_Init(CPDF_Object* pObj, std::set<CPDF_Object*>* pVisited) {
+bool CPDF_PSFunc::v_Init(const CPDF_Object* pObj,
+ std::set<const CPDF_Object*>* pVisited) {
auto pAcc = pdfium::MakeRetain<CPDF_StreamAcc>(pObj->AsStream());
pAcc->LoadAllDataFiltered();
return m_PS.Parse(pAcc->GetSpan());
diff --git a/core/fpdfapi/page/cpdf_psfunc.h b/core/fpdfapi/page/cpdf_psfunc.h
index b4bc5bd2ef..459da5a599 100644
--- a/core/fpdfapi/page/cpdf_psfunc.h
+++ b/core/fpdfapi/page/cpdf_psfunc.h
@@ -20,7 +20,8 @@ class CPDF_PSFunc : public CPDF_Function {
~CPDF_PSFunc() override;
// CPDF_Function
- bool v_Init(CPDF_Object* pObj, std::set<CPDF_Object*>* pVisited) override;
+ bool v_Init(const CPDF_Object* pObj,
+ std::set<const CPDF_Object*>* pVisited) override;
bool v_Call(const float* inputs, float* results) const override;
private:
diff --git a/core/fpdfapi/page/cpdf_sampledfunc.cpp b/core/fpdfapi/page/cpdf_sampledfunc.cpp
index 3777254f34..9f19c1c468 100644
--- a/core/fpdfapi/page/cpdf_sampledfunc.cpp
+++ b/core/fpdfapi/page/cpdf_sampledfunc.cpp
@@ -36,9 +36,9 @@ CPDF_SampledFunc::CPDF_SampledFunc() : CPDF_Function(Type::kType0Sampled) {}
CPDF_SampledFunc::~CPDF_SampledFunc() {}
-bool CPDF_SampledFunc::v_Init(CPDF_Object* pObj,
- std::set<CPDF_Object*>* pVisited) {
- CPDF_Stream* pStream = pObj->AsStream();
+bool CPDF_SampledFunc::v_Init(const CPDF_Object* pObj,
+ std::set<const CPDF_Object*>* pVisited) {
+ const CPDF_Stream* pStream = pObj->AsStream();
if (!pStream)
return false;
diff --git a/core/fpdfapi/page/cpdf_sampledfunc.h b/core/fpdfapi/page/cpdf_sampledfunc.h
index cbf2dd3648..bd129662cf 100644
--- a/core/fpdfapi/page/cpdf_sampledfunc.h
+++ b/core/fpdfapi/page/cpdf_sampledfunc.h
@@ -31,7 +31,8 @@ class CPDF_SampledFunc : public CPDF_Function {
~CPDF_SampledFunc() override;
// CPDF_Function
- bool v_Init(CPDF_Object* pObj, std::set<CPDF_Object*>* pVisited) override;
+ bool v_Init(const CPDF_Object* pObj,
+ std::set<const CPDF_Object*>* pVisited) override;
bool v_Call(const float* inputs, float* results) const override;
const std::vector<SampleEncodeInfo>& GetEncodeInfo() const {
diff --git a/core/fpdfapi/page/cpdf_shadingpattern.cpp b/core/fpdfapi/page/cpdf_shadingpattern.cpp
index f1e75b726a..628155c575 100644
--- a/core/fpdfapi/page/cpdf_shadingpattern.cpp
+++ b/core/fpdfapi/page/cpdf_shadingpattern.cpp
@@ -83,7 +83,7 @@ bool CPDF_ShadingPattern::Load() {
m_pFunctions.push_back(CPDF_Function::Load(pFunc));
}
}
- CPDF_Object* pCSObj = pShadingDict->GetDirectObjectFor("ColorSpace");
+ const CPDF_Object* pCSObj = pShadingDict->GetDirectObjectFor("ColorSpace");
if (!pCSObj)
return false;
diff --git a/core/fpdfapi/page/cpdf_stitchfunc.cpp b/core/fpdfapi/page/cpdf_stitchfunc.cpp
index aed17828d9..2083a91623 100644
--- a/core/fpdfapi/page/cpdf_stitchfunc.cpp
+++ b/core/fpdfapi/page/cpdf_stitchfunc.cpp
@@ -22,8 +22,8 @@ CPDF_StitchFunc::CPDF_StitchFunc() : CPDF_Function(Type::kType3Stitching) {}
CPDF_StitchFunc::~CPDF_StitchFunc() {}
-bool CPDF_StitchFunc::v_Init(CPDF_Object* pObj,
- std::set<CPDF_Object*>* pVisited) {
+bool CPDF_StitchFunc::v_Init(const CPDF_Object* pObj,
+ std::set<const CPDF_Object*>* pVisited) {
if (m_nInputs != kRequiredNumInputs)
return false;
@@ -66,7 +66,7 @@ bool CPDF_StitchFunc::v_Init(CPDF_Object* pObj,
{
Optional<uint32_t> nOutputs;
for (uint32_t i = 0; i < nSubs; ++i) {
- CPDF_Object* pSub = pFunctionsArray->GetDirectObjectAt(i);
+ const CPDF_Object* pSub = pFunctionsArray->GetDirectObjectAt(i);
if (pSub == pObj)
return false;
diff --git a/core/fpdfapi/page/cpdf_stitchfunc.h b/core/fpdfapi/page/cpdf_stitchfunc.h
index d6dd63d2d5..20dac6cbc1 100644
--- a/core/fpdfapi/page/cpdf_stitchfunc.h
+++ b/core/fpdfapi/page/cpdf_stitchfunc.h
@@ -19,7 +19,8 @@ class CPDF_StitchFunc : public CPDF_Function {
~CPDF_StitchFunc() override;
// CPDF_Function
- bool v_Init(CPDF_Object* pObj, std::set<CPDF_Object*>* pVisited) override;
+ bool v_Init(const CPDF_Object* pObj,
+ std::set<const CPDF_Object*>* pVisited) override;
bool v_Call(const float* inputs, float* results) const override;
const std::vector<std::unique_ptr<CPDF_Function>>& GetSubFunctions() const {
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
index 736e91b3c8..df69aa43b9 100644
--- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp
+++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
@@ -1161,7 +1161,7 @@ CPDF_ColorSpace* CPDF_StreamContentParser::FindColorSpace(
if (name == "DeviceGray" || name == "DeviceCMYK" || name == "DeviceRGB") {
ByteString defname = "Default";
defname += name.Right(name.GetLength() - 7);
- CPDF_Object* pDefObj = FindResourceObj("ColorSpace", defname);
+ const CPDF_Object* pDefObj = FindResourceObj("ColorSpace", defname);
if (!pDefObj) {
if (name == "DeviceGray") {
return CPDF_ColorSpace::GetStockCS(PDFCS_DEVICEGRAY);
@@ -1173,7 +1173,7 @@ CPDF_ColorSpace* CPDF_StreamContentParser::FindColorSpace(
}
return m_pDocument->LoadColorSpace(pDefObj);
}
- CPDF_Object* pCSObj = FindResourceObj("ColorSpace", name);
+ const CPDF_Object* pCSObj = FindResourceObj("ColorSpace", name);
if (!pCSObj) {
m_bResourceMissing = true;
return nullptr;
diff --git a/core/fpdfapi/page/cpdf_streamparser.cpp b/core/fpdfapi/page/cpdf_streamparser.cpp
index b6658ee5fb..8652490a22 100644
--- a/core/fpdfapi/page/cpdf_streamparser.cpp
+++ b/core/fpdfapi/page/cpdf_streamparser.cpp
@@ -114,7 +114,7 @@ CPDF_StreamParser::~CPDF_StreamParser() {}
std::unique_ptr<CPDF_Stream> CPDF_StreamParser::ReadInlineStream(
CPDF_Document* pDoc,
std::unique_ptr<CPDF_Dictionary> pDict,
- CPDF_Object* pCSObj) {
+ const CPDF_Object* pCSObj) {
if (m_Pos < m_pBuf.size() && PDFCharIsWhitespace(m_pBuf[m_Pos]))
m_Pos++;
diff --git a/core/fpdfapi/page/cpdf_streamparser.h b/core/fpdfapi/page/cpdf_streamparser.h
index 78727da481..062527813c 100644
--- a/core/fpdfapi/page/cpdf_streamparser.h
+++ b/core/fpdfapi/page/cpdf_streamparser.h
@@ -40,7 +40,7 @@ class CPDF_StreamParser {
std::unique_ptr<CPDF_Stream> ReadInlineStream(
CPDF_Document* pDoc,
std::unique_ptr<CPDF_Dictionary> pDict,
- CPDF_Object* pCSObj);
+ const CPDF_Object* pCSObj);
private:
friend class cpdf_streamparser_ReadHexString_Test;
diff --git a/core/fpdfapi/parser/cpdf_document.cpp b/core/fpdfapi/parser/cpdf_document.cpp
index 13f5db244b..fea0bddb33 100644
--- a/core/fpdfapi/parser/cpdf_document.cpp
+++ b/core/fpdfapi/parser/cpdf_document.cpp
@@ -479,8 +479,9 @@ RetainPtr<CPDF_StreamAcc> CPDF_Document::LoadFontFile(CPDF_Stream* pStream) {
return m_pDocPage->GetFontFileStreamAcc(pStream);
}
-CPDF_ColorSpace* CPDF_Document::LoadColorSpace(CPDF_Object* pCSObj,
- CPDF_Dictionary* pResources) {
+CPDF_ColorSpace* CPDF_Document::LoadColorSpace(
+ const CPDF_Object* pCSObj,
+ const CPDF_Dictionary* pResources) {
return m_pDocPage->GetColorSpace(pCSObj, pResources);
}
diff --git a/core/fpdfapi/parser/cpdf_document.h b/core/fpdfapi/parser/cpdf_document.h
index 8690efed80..6357049777 100644
--- a/core/fpdfapi/parser/cpdf_document.h
+++ b/core/fpdfapi/parser/cpdf_document.h
@@ -83,8 +83,8 @@ class CPDF_Document : public CPDF_IndirectObjectHolder {
// |pFontDict| must not be null.
CPDF_Font* LoadFont(CPDF_Dictionary* pFontDict);
- CPDF_ColorSpace* LoadColorSpace(CPDF_Object* pCSObj,
- CPDF_Dictionary* pResources = nullptr);
+ CPDF_ColorSpace* LoadColorSpace(const CPDF_Object* pCSObj,
+ const CPDF_Dictionary* pResources = nullptr);
CPDF_Pattern* LoadPattern(CPDF_Object* pObj,
bool bShading,
diff --git a/core/fpdfapi/render/cpdf_dibsource.cpp b/core/fpdfapi/render/cpdf_dibsource.cpp
index b8b91d2fe6..bbf91da868 100644
--- a/core/fpdfapi/render/cpdf_dibsource.cpp
+++ b/core/fpdfapi/render/cpdf_dibsource.cpp
@@ -224,7 +224,7 @@ CPDF_DIBSource::LoadState CPDF_DIBSource::StartLoadDIBSource(
CPDF_Document* pDoc,
const CPDF_Stream* pStream,
bool bHasMask,
- CPDF_Dictionary* pFormResources,
+ const CPDF_Dictionary* pFormResources,
CPDF_Dictionary* pPageResources,
bool bStdCS,
uint32_t GroupFamily,
@@ -366,7 +366,7 @@ bool CPDF_DIBSource::LoadColorInfo(const CPDF_Dictionary* pFormResources,
return true;
}
- CPDF_Object* pCSObj = m_pDict->GetDirectObjectFor("ColorSpace");
+ const CPDF_Object* pCSObj = m_pDict->GetDirectObjectFor("ColorSpace");
if (!pCSObj)
return false;
diff --git a/core/fpdfapi/render/cpdf_dibsource.h b/core/fpdfapi/render/cpdf_dibsource.h
index 4cb79fa57c..a9f98e158d 100644
--- a/core/fpdfapi/render/cpdf_dibsource.h
+++ b/core/fpdfapi/render/cpdf_dibsource.h
@@ -68,7 +68,7 @@ class CPDF_DIBSource : public CFX_DIBSource {
LoadState StartLoadDIBSource(CPDF_Document* pDoc,
const CPDF_Stream* pStream,
bool bHasMask,
- CPDF_Dictionary* pFormResources,
+ const CPDF_Dictionary* pFormResources,
CPDF_Dictionary* pPageResources,
bool bStdCS = false,
uint32_t GroupFamily = 0,
diff --git a/core/fpdfapi/render/cpdf_docrenderdata.cpp b/core/fpdfapi/render/cpdf_docrenderdata.cpp
index 6480688f21..568bf76e97 100644
--- a/core/fpdfapi/render/cpdf_docrenderdata.cpp
+++ b/core/fpdfapi/render/cpdf_docrenderdata.cpp
@@ -62,7 +62,7 @@ void CPDF_DocRenderData::MaybePurgeCachedType3(CPDF_Type3Font* pFont) {
}
RetainPtr<CPDF_TransferFunc> CPDF_DocRenderData::GetTransferFunc(
- CPDF_Object* pObj) {
+ const CPDF_Object* pObj) {
if (!pObj)
return nullptr;
@@ -73,7 +73,7 @@ RetainPtr<CPDF_TransferFunc> CPDF_DocRenderData::GetTransferFunc(
std::unique_ptr<CPDF_Function> pFuncs[3];
bool bUniTransfer = true;
bool bIdentity = true;
- if (CPDF_Array* pArray = pObj->AsArray()) {
+ if (const CPDF_Array* pArray = pObj->AsArray()) {
bUniTransfer = false;
if (pArray->GetCount() < 3)
return nullptr;
@@ -124,7 +124,7 @@ RetainPtr<CPDF_TransferFunc> CPDF_DocRenderData::GetTransferFunc(
return pTransfer;
}
-void CPDF_DocRenderData::MaybePurgeTransferFunc(CPDF_Object* pObj) {
+void CPDF_DocRenderData::MaybePurgeTransferFunc(const CPDF_Object* pObj) {
auto it = m_TransferFuncMap.find(pObj);
if (it != m_TransferFuncMap.end() && it->second->HasOneRef())
m_TransferFuncMap.erase(it);
diff --git a/core/fpdfapi/render/cpdf_docrenderdata.h b/core/fpdfapi/render/cpdf_docrenderdata.h
index 7b3e0ed398..e4e3548c9f 100644
--- a/core/fpdfapi/render/cpdf_docrenderdata.h
+++ b/core/fpdfapi/render/cpdf_docrenderdata.h
@@ -28,15 +28,15 @@ class CPDF_DocRenderData {
RetainPtr<CPDF_Type3Cache> GetCachedType3(CPDF_Type3Font* pFont);
void MaybePurgeCachedType3(CPDF_Type3Font* pFont);
- RetainPtr<CPDF_TransferFunc> GetTransferFunc(CPDF_Object* pObj);
- void MaybePurgeTransferFunc(CPDF_Object* pOb);
+ RetainPtr<CPDF_TransferFunc> GetTransferFunc(const CPDF_Object* pObj);
+ void MaybePurgeTransferFunc(const CPDF_Object* pObj);
void Clear(bool bRelease);
private:
UnownedPtr<CPDF_Document> m_pPDFDoc;
std::map<CPDF_Font*, RetainPtr<CPDF_Type3Cache>> m_Type3FaceMap;
- std::map<CPDF_Object*, RetainPtr<CPDF_TransferFunc>> m_TransferFuncMap;
+ std::map<const CPDF_Object*, RetainPtr<CPDF_TransferFunc>> m_TransferFuncMap;
};
#endif // CORE_FPDFAPI_RENDER_CPDF_DOCRENDERDATA_H_
diff --git a/core/fpdfapi/render/cpdf_imagecacheentry.cpp b/core/fpdfapi/render/cpdf_imagecacheentry.cpp
index 65c9a6b9a4..615a44d869 100644
--- a/core/fpdfapi/render/cpdf_imagecacheentry.cpp
+++ b/core/fpdfapi/render/cpdf_imagecacheentry.cpp
@@ -53,7 +53,7 @@ RetainPtr<CFX_DIBSource> CPDF_ImageCacheEntry::DetachMask() {
}
CPDF_DIBSource::LoadState CPDF_ImageCacheEntry::StartGetCachedBitmap(
- CPDF_Dictionary* pFormResources,
+ const CPDF_Dictionary* pFormResources,
CPDF_Dictionary* pPageResources,
bool bStdCS,
uint32_t GroupFamily,
diff --git a/core/fpdfapi/render/cpdf_imagecacheentry.h b/core/fpdfapi/render/cpdf_imagecacheentry.h
index b397370eea..df13c4b3f8 100644
--- a/core/fpdfapi/render/cpdf_imagecacheentry.h
+++ b/core/fpdfapi/render/cpdf_imagecacheentry.h
@@ -33,7 +33,7 @@ class CPDF_ImageCacheEntry {
CPDF_Image* GetImage() const { return m_pImage.Get(); }
CPDF_DIBSource::LoadState StartGetCachedBitmap(
- CPDF_Dictionary* pFormResources,
+ const CPDF_Dictionary* pFormResources,
CPDF_Dictionary* pPageResources,
bool bStdCS,
uint32_t GroupFamily,
diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp
index 0f054ef578..565be85412 100644
--- a/core/fpdfapi/render/cpdf_renderstatus.cpp
+++ b/core/fpdfapi/render/cpdf_renderstatus.cpp
@@ -113,9 +113,9 @@ uint32_t GetValidatedOutputsCount(
void DrawAxialShading(const RetainPtr<CFX_DIBitmap>& pBitmap,
CFX_Matrix* pObject2Bitmap,
- CPDF_Dictionary* pDict,
+ const CPDF_Dictionary* pDict,
const std::vector<std::unique_ptr<CPDF_Function>>& funcs,
- CPDF_ColorSpace* pCS,
+ const CPDF_ColorSpace* pCS,
int alpha) {
ASSERT(pBitmap->GetFormat() == FXDIB_Argb);
@@ -123,7 +123,7 @@ void DrawAxialShading(const RetainPtr<CFX_DIBitmap>& pBitmap,
if (total_results == 0)
return;
- CPDF_Array* pCoords = pDict->GetArrayFor("Coords");
+ const CPDF_Array* pCoords = pDict->GetArrayFor("Coords");
if (!pCoords)
return;
@@ -133,7 +133,7 @@ void DrawAxialShading(const RetainPtr<CFX_DIBitmap>& pBitmap,
float end_y = pCoords->GetNumberAt(3);
float t_min = 0;
float t_max = 1.0f;
- CPDF_Array* pArray = pDict->GetArrayFor("Domain");
+ const CPDF_Array* pArray = pDict->GetArrayFor("Domain");
if (pArray) {
t_min = pArray->GetNumberAt(0);
t_max = pArray->GetNumberAt(1);
@@ -200,9 +200,9 @@ void DrawAxialShading(const RetainPtr<CFX_DIBitmap>& pBitmap,
void DrawRadialShading(const RetainPtr<CFX_DIBitmap>& pBitmap,
CFX_Matrix* pObject2Bitmap,
- CPDF_Dictionary* pDict,
+ const CPDF_Dictionary* pDict,
const std::vector<std::unique_ptr<CPDF_Function>>& funcs,
- CPDF_ColorSpace* pCS,
+ const CPDF_ColorSpace* pCS,
int alpha) {
ASSERT(pBitmap->GetFormat() == FXDIB_Argb);
@@ -210,7 +210,7 @@ void DrawRadialShading(const RetainPtr<CFX_DIBitmap>& pBitmap,
if (total_results == 0)
return;
- CPDF_Array* pCoords = pDict->GetArrayFor("Coords");
+ const CPDF_Array* pCoords = pDict->GetArrayFor("Coords");
if (!pCoords)
return;
@@ -222,7 +222,7 @@ void DrawRadialShading(const RetainPtr<CFX_DIBitmap>& pBitmap,
float end_r = pCoords->GetNumberAt(5);
float t_min = 0;
float t_max = 1.0f;
- CPDF_Array* pArray = pDict->GetArrayFor("Domain");
+ const CPDF_Array* pArray = pDict->GetArrayFor("Domain");
if (pArray) {
t_min = pArray->GetNumberAt(0);
t_max = pArray->GetNumberAt(1);
@@ -334,9 +334,9 @@ void DrawRadialShading(const RetainPtr<CFX_DIBitmap>& pBitmap,
void DrawFuncShading(const RetainPtr<CFX_DIBitmap>& pBitmap,
CFX_Matrix* pObject2Bitmap,
- CPDF_Dictionary* pDict,
+ const CPDF_Dictionary* pDict,
const std::vector<std::unique_ptr<CPDF_Function>>& funcs,
- CPDF_ColorSpace* pCS,
+ const CPDF_ColorSpace* pCS,
int alpha) {
ASSERT(pBitmap->GetFormat() == FXDIB_Argb);
@@ -344,7 +344,7 @@ void DrawFuncShading(const RetainPtr<CFX_DIBitmap>& pBitmap,
if (total_results == 0)
return;
- CPDF_Array* pDomain = pDict->GetArrayFor("Domain");
+ const CPDF_Array* pDomain = pDict->GetArrayFor("Domain");
float xmin = 0.0f;
float ymin = 0.0f;
float xmax = 1.0f;
@@ -492,9 +492,9 @@ void DrawGouraud(const RetainPtr<CFX_DIBitmap>& pBitmap,
void DrawFreeGouraudShading(
const RetainPtr<CFX_DIBitmap>& pBitmap,
CFX_Matrix* pObject2Bitmap,
- CPDF_Stream* pShadingStream,
+ const CPDF_Stream* pShadingStream,
const std::vector<std::unique_ptr<CPDF_Function>>& funcs,
- CPDF_ColorSpace* pCS,
+ const CPDF_ColorSpace* pCS,
int alpha) {
ASSERT(pBitmap->GetFormat() == FXDIB_Argb);
@@ -533,9 +533,9 @@ void DrawFreeGouraudShading(
void DrawLatticeGouraudShading(
const RetainPtr<CFX_DIBitmap>& pBitmap,
CFX_Matrix* pObject2Bitmap,
- CPDF_Stream* pShadingStream,
+ const CPDF_Stream* pShadingStream,
const std::vector<std::unique_ptr<CPDF_Function>>& funcs,
- CPDF_ColorSpace* pCS,
+ const CPDF_ColorSpace* pCS,
int alpha) {
ASSERT(pBitmap->GetFormat() == FXDIB_Argb);
@@ -851,9 +851,9 @@ void DrawCoonPatchMeshes(
ShadingType type,
const RetainPtr<CFX_DIBitmap>& pBitmap,
CFX_Matrix* pObject2Bitmap,
- CPDF_Stream* pShadingStream,
+ const CPDF_Stream* pShadingStream,
const std::vector<std::unique_ptr<CPDF_Function>>& funcs,
- CPDF_ColorSpace* pCS,
+ const CPDF_ColorSpace* pCS,
int fill_mode,
int alpha) {
ASSERT(pBitmap->GetFormat() == FXDIB_Argb);
@@ -1019,7 +1019,7 @@ bool CPDF_RenderStatus::Initialize(CPDF_RenderContext* pContext,
const CPDF_RenderOptions* pOptions,
int transparency,
bool bDropObjects,
- CPDF_Dictionary* pFormResource,
+ const CPDF_Dictionary* pFormResource,
bool bStdCS,
CPDF_Type3Char* pType3Char,
FX_ARGB fill_color,
@@ -1232,7 +1232,7 @@ void CPDF_RenderStatus::DrawObjWithBackground(CPDF_PageObject* pObj,
}
CFX_Matrix matrix = *pObj2Device;
matrix.Concat(*buffer.GetMatrix());
- CPDF_Dictionary* pFormResource = nullptr;
+ const CPDF_Dictionary* pFormResource = nullptr;
const CPDF_FormObject* pFormObj = pObj->AsForm();
if (pFormObj) {
const CPDF_Dictionary* pFormDict = pFormObj->form()->GetFormDict();
@@ -1252,7 +1252,8 @@ bool CPDF_RenderStatus::ProcessForm(const CPDF_FormObject* pFormObj,
#if defined _SKIA_SUPPORT_
DebugVerifyDeviceIsPreMultiplied();
#endif
- CPDF_Dictionary* pOC = pFormObj->form()->GetFormDict()->GetDictFor("OC");
+ const CPDF_Dictionary* pOC =
+ pFormObj->form()->GetFormDict()->GetDictFor("OC");
if (pOC && m_Options.GetOCContext() &&
!m_Options.GetOCContext()->CheckOCGVisible(pOC)) {
return true;
@@ -1260,7 +1261,7 @@ bool CPDF_RenderStatus::ProcessForm(const CPDF_FormObject* pFormObj,
CFX_Matrix matrix = pFormObj->form_matrix();
matrix.Concat(*pObj2Device);
const CPDF_Dictionary* pFormDict = pFormObj->form()->GetFormDict();
- CPDF_Dictionary* pResources =
+ const CPDF_Dictionary* pResources =
pFormDict ? pFormDict->GetDictFor("Resources") : nullptr;
CPDF_RenderStatus status;
status.Initialize(m_pContext.Get(), m_pDevice, nullptr, m_pStopObj, this,
@@ -1318,7 +1319,7 @@ bool CPDF_RenderStatus::ProcessPath(CPDF_PathObject* pPathObj,
}
RetainPtr<CPDF_TransferFunc> CPDF_RenderStatus::GetTransferFunc(
- CPDF_Object* pObj) const {
+ const CPDF_Object* pObj) const {
ASSERT(pObj);
CPDF_DocRenderData* pDocCache = m_pContext->GetDocument()->GetRenderData();
return pDocCache ? pDocCache->GetTransferFunc(pObj) : nullptr;
@@ -1466,7 +1467,7 @@ bool CPDF_RenderStatus::ProcessTransparency(CPDF_PageObject* pPageObj,
if (blend_type == FXDIB_BLEND_UNSUPPORTED)
return true;
- CPDF_Dictionary* pSMaskDict =
+ const CPDF_Dictionary* pSMaskDict =
ToDictionary(pPageObj->m_GeneralState.GetSoftMask());
if (pSMaskDict) {
if (pPageObj->IsImage() &&
@@ -1474,7 +1475,7 @@ bool CPDF_RenderStatus::ProcessTransparency(CPDF_PageObject* pPageObj,
pSMaskDict = nullptr;
}
}
- CPDF_Dictionary* pFormResource = nullptr;
+ const CPDF_Dictionary* pFormResource = nullptr;
float group_alpha = 1.0f;
int iTransparency = m_iTransparency;
bool bGroupTransparent = false;
@@ -1503,14 +1504,14 @@ bool CPDF_RenderStatus::ProcessTransparency(CPDF_PageObject* pPageObj,
} else {
pDocument = pPageObj->AsImage()->GetImage()->GetDocument();
}
- CPDF_Dictionary* pPageResources =
+ const CPDF_Dictionary* pPageResources =
pPage ? pPage->m_pPageResources.Get() : nullptr;
- CPDF_Object* pCSObj = pPageObj->AsImage()
- ->GetImage()
- ->GetStream()
- ->GetDict()
- ->GetDirectObjectFor("ColorSpace");
- CPDF_ColorSpace* pColorSpace =
+ const CPDF_Object* pCSObj = pPageObj->AsImage()
+ ->GetImage()
+ ->GetStream()
+ ->GetDict()
+ ->GetDirectObjectFor("ColorSpace");
+ const CPDF_ColorSpace* pColorSpace =
pDocument->LoadColorSpace(pCSObj, pPageResources);
if (pColorSpace) {
int format = pColorSpace->GetFamily();
@@ -1872,7 +1873,7 @@ bool CPDF_RenderStatus::ProcessType3Text(CPDF_TextObject* textobj,
option_flags &= ~RENDER_FORCE_DOWNSAMPLE;
options.SetFlags(option_flags);
- CPDF_Dictionary* pFormResource = nullptr;
+ const CPDF_Dictionary* pFormResource = nullptr;
if (pType3Char->form() && pType3Char->form()->GetFormDict()) {
pFormResource =
pType3Char->form()->GetFormDict()->GetDictFor("Resources");
@@ -2038,14 +2039,14 @@ void CPDF_RenderStatus::DrawShading(const CPDF_ShadingPattern* pPattern,
int alpha,
bool bAlphaMode) {
const auto& funcs = pPattern->GetFuncs();
- CPDF_Dictionary* pDict = pPattern->GetShadingObject()->GetDict();
- CPDF_ColorSpace* pColorSpace = pPattern->GetCS();
+ const CPDF_Dictionary* pDict = pPattern->GetShadingObject()->GetDict();
+ const CPDF_ColorSpace* pColorSpace = pPattern->GetCS();
if (!pColorSpace)
return;
FX_ARGB background = 0;
if (!pPattern->IsShadingObject() && pDict->KeyExist("Background")) {
- CPDF_Array* pBackColor = pDict->GetArrayFor("Background");
+ const CPDF_Array* pBackColor = pDict->GetArrayFor("Background");
if (pBackColor &&
pBackColor->GetCount() >= pColorSpace->CountComponents()) {
std::vector<float> comps;
@@ -2097,7 +2098,7 @@ void CPDF_RenderStatus::DrawShading(const CPDF_ShadingPattern* pPattern,
case kFreeFormGouraudTriangleMeshShading: {
// The shading object can be a stream or a dictionary. We do not handle
// the case of dictionary at the moment.
- if (CPDF_Stream* pStream = ToStream(pPattern->GetShadingObject())) {
+ if (const CPDF_Stream* pStream = ToStream(pPattern->GetShadingObject())) {
DrawFreeGouraudShading(pBitmap, &FinalMatrix, pStream, funcs,
pColorSpace, alpha);
}
@@ -2105,7 +2106,7 @@ void CPDF_RenderStatus::DrawShading(const CPDF_ShadingPattern* pPattern,
case kLatticeFormGouraudTriangleMeshShading: {
// The shading object can be a stream or a dictionary. We do not handle
// the case of dictionary at the moment.
- if (CPDF_Stream* pStream = ToStream(pPattern->GetShadingObject())) {
+ if (const CPDF_Stream* pStream = ToStream(pPattern->GetShadingObject())) {
DrawLatticeGouraudShading(pBitmap, &FinalMatrix, pStream, funcs,
pColorSpace, alpha);
}
@@ -2114,7 +2115,7 @@ void CPDF_RenderStatus::DrawShading(const CPDF_ShadingPattern* pPattern,
case kTensorProductPatchMeshShading: {
// The shading object can be a stream or a dictionary. We do not handle
// the case of dictionary at the moment.
- if (CPDF_Stream* pStream = ToStream(pPattern->GetShadingObject())) {
+ if (const CPDF_Stream* pStream = ToStream(pPattern->GetShadingObject())) {
DrawCoonPatchMeshes(pPattern->GetShadingType(), pBitmap, &FinalMatrix,
pStream, funcs, pColorSpace, m_Options.GetFlags(),
alpha);
@@ -2243,7 +2244,7 @@ void CPDF_RenderStatus::DrawTilingPattern(CPDF_TilingPattern* pPattern,
pStates = CloneObjStates(pPageObj, bStroke);
const CPDF_Dictionary* pFormDict = pPattern->form()->GetFormDict();
- CPDF_Dictionary* pFormResource =
+ const CPDF_Dictionary* pFormResource =
pFormDict ? pFormDict->GetDictFor("Resources") : nullptr;
for (int col = min_col; col <= max_col; col++) {
for (int row = min_row; row <= max_row; row++) {
@@ -2525,7 +2526,7 @@ void CPDF_RenderStatus::CompositeDIBitmap(
}
RetainPtr<CFX_DIBitmap> CPDF_RenderStatus::LoadSMask(
- CPDF_Dictionary* pSMaskDict,
+ const CPDF_Dictionary* pSMaskDict,
FX_RECT* pClipRect,
const CFX_Matrix* pMatrix) {
if (!pSMaskDict)
@@ -2536,7 +2537,7 @@ RetainPtr<CFX_DIBitmap> CPDF_RenderStatus::LoadSMask(
return nullptr;
std::unique_ptr<CPDF_Function> pFunc;
- CPDF_Object* pFuncObj =
+ const CPDF_Object* pFuncObj =
pSMaskDict->GetDirectObjectFor(pdfium::transparency::kTR);
if (pFuncObj && (pFuncObj->IsDictionary() || pFuncObj->IsStream()))
pFunc = CPDF_Function::Load(pFuncObj);
@@ -2573,10 +2574,10 @@ RetainPtr<CFX_DIBitmap> CPDF_RenderStatus::LoadSMask(
} else {
bitmap.Clear(0);
}
- CPDF_Dictionary* pFormResource = nullptr;
- if (form.GetFormDict()) {
+
+ const CPDF_Dictionary* pFormResource = nullptr;
+ if (form.GetFormDict())
pFormResource = form.GetFormDict()->GetDictFor("Resources");
- }
CPDF_RenderOptions options;
options.SetColorMode(bLuminosity ? CPDF_RenderOptions::kNormal
: CPDF_RenderOptions::kAlpha);
@@ -2637,7 +2638,7 @@ FX_ARGB CPDF_RenderStatus::GetBackColor(const CPDF_Dictionary* pSMaskDict,
if (!pBC)
return kDefaultColor;
- CPDF_Object* pCSObj = nullptr;
+ const CPDF_Object* pCSObj = nullptr;
const CPDF_Dictionary* pGroup =
pGroupDict ? pGroupDict->GetDictFor("Group") : nullptr;
if (pGroup) {
diff --git a/core/fpdfapi/render/cpdf_renderstatus.h b/core/fpdfapi/render/cpdf_renderstatus.h
index 7058c0f9b9..5618196ce6 100644
--- a/core/fpdfapi/render/cpdf_renderstatus.h
+++ b/core/fpdfapi/render/cpdf_renderstatus.h
@@ -50,7 +50,7 @@ class CPDF_RenderStatus {
const CPDF_RenderOptions* pOptions,
int transparency,
bool bDropObjects,
- CPDF_Dictionary* pFormResource = nullptr,
+ const CPDF_Dictionary* pFormResource = nullptr,
bool bStdCS = false,
CPDF_Type3Char* pType3Char = nullptr,
FX_ARGB fill_color = 0,
@@ -71,7 +71,9 @@ class CPDF_RenderStatus {
bool IsPrint() const { return m_bPrint; }
bool IsStopped() const { return m_bStopped; }
CPDF_RenderContext* GetContext() const { return m_pContext.Get(); }
- CPDF_Dictionary* GetFormResource() const { return m_pFormResource.Get(); }
+ const CPDF_Dictionary* GetFormResource() const {
+ return m_pFormResource.Get();
+ }
CPDF_Dictionary* GetPageResource() const { return m_pPageResource.Get(); }
CFX_RenderDevice* GetRenderDevice() const { return m_pDevice; }
const CPDF_RenderOptions* GetRenderOptions() const { return &m_Options; }
@@ -80,7 +82,8 @@ class CPDF_RenderStatus {
void DebugVerifyDeviceIsPreMultiplied() const;
#endif
- RetainPtr<CPDF_TransferFunc> GetTransferFunc(CPDF_Object* pObject) const;
+ RetainPtr<CPDF_TransferFunc> GetTransferFunc(
+ const CPDF_Object* pObject) const;
FX_ARGB GetFillArgb(CPDF_PageObject* pObj, bool bType3 = false) const;
void DrawTilingPattern(CPDF_TilingPattern* pPattern,
CPDF_PageObject* pPageObj,
@@ -145,7 +148,7 @@ class CPDF_RenderStatus {
bool bBackAlphaRequired,
int* left,
int* top);
- RetainPtr<CFX_DIBitmap> LoadSMask(CPDF_Dictionary* pSMaskDict,
+ RetainPtr<CFX_DIBitmap> LoadSMask(const CPDF_Dictionary* pSMaskDict,
FX_RECT* pClipRect,
const CFX_Matrix* pMatrix);
// Optionally write the colorspace family value into |pCSFamily|.
@@ -161,7 +164,7 @@ class CPDF_RenderStatus {
const CFX_Matrix* pObj2Device) const;
CPDF_RenderOptions m_Options;
- UnownedPtr<CPDF_Dictionary> m_pFormResource;
+ UnownedPtr<const CPDF_Dictionary> m_pFormResource;
UnownedPtr<CPDF_Dictionary> m_pPageResource;
std::vector<CPDF_Type3Font*> m_Type3FontCache;
UnownedPtr<CPDF_RenderContext> m_pContext;