summaryrefslogtreecommitdiff
path: root/core/fpdfapi/fpdf_page
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-08-26 15:17:12 -0700
committerCommit bot <commit-bot@chromium.org>2016-08-26 15:17:13 -0700
commit987f3ee94c3cb8e4a6113ad05453a2948469386c (patch)
treefbd1fdc800c2510c89ae043331a799a42c3251af /core/fpdfapi/fpdf_page
parent83d2351fd64128156c9abfb70266133d58a5e525 (diff)
downloadpdfium-987f3ee94c3cb8e4a6113ad05453a2948469386c.tar.xz
Make CFX_CountRef<>::m_pObject private, add accessors, fix const-ness.
Hide the CountedObj class from the rest of the code. Rename GetModify() to GetPrivateCopy(), since it turns out there are places where we modify a potentially-shared copy. Add non-const version of GetObject() to permit these. Review-Url: https://codereview.chromium.org/2287633002
Diffstat (limited to 'core/fpdfapi/fpdf_page')
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_allstates.cpp14
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_clippath.cpp16
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_colorstate.cpp8
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_colorstate.h10
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_contentmark.cpp33
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_contentmark.h11
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_generalstate.cpp2
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_pageobject.cpp4
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_shadingobject.cpp2
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_textobject.cpp4
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_textstate.cpp10
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_textstate.h8
-rw-r--r--core/fpdfapi/fpdf_page/fpdf_page_parser.cpp36
-rw-r--r--core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp4
-rw-r--r--core/fpdfapi/fpdf_page/include/cpdf_generalstate.h10
-rw-r--r--core/fpdfapi/fpdf_page/include/cpdf_path.h24
16 files changed, 103 insertions, 93 deletions
diff --git a/core/fpdfapi/fpdf_page/cpdf_allstates.cpp b/core/fpdfapi/fpdf_page/cpdf_allstates.cpp
index ab69eb7488..e4b6e328b9 100644
--- a/core/fpdfapi/fpdf_page/cpdf_allstates.cpp
+++ b/core/fpdfapi/fpdf_page/cpdf_allstates.cpp
@@ -45,7 +45,7 @@ void CPDF_AllStates::Copy(const CPDF_AllStates& src) {
void CPDF_AllStates::SetLineDash(CPDF_Array* pArray,
FX_FLOAT phase,
FX_FLOAT scale) {
- CFX_GraphStateData* pData = m_GraphState.GetModify();
+ CFX_GraphStateData* pData = m_GraphState.GetPrivateCopy();
pData->m_DashPhase = phase * scale;
pData->SetDashCount(static_cast<int>(pArray->GetCount()));
for (size_t i = 0; i < pArray->GetCount(); i++)
@@ -54,7 +54,7 @@ void CPDF_AllStates::SetLineDash(CPDF_Array* pArray,
void CPDF_AllStates::ProcessExtGS(CPDF_Dictionary* pGS,
CPDF_StreamContentParser* pParser) {
- CPDF_GeneralStateData* pGeneralState = m_GeneralState.GetModify();
+ CPDF_GeneralStateData* pGeneralState = m_GeneralState.GetPrivateCopy();
for (const auto& it : *pGS) {
const CFX_ByteString& key_str = it.first;
CPDF_Object* pElement = it.second;
@@ -65,18 +65,18 @@ void CPDF_AllStates::ProcessExtGS(CPDF_Dictionary* pGS,
uint32_t key = key_str.GetID();
switch (key) {
case FXBSTR_ID('L', 'W', 0, 0):
- m_GraphState.GetModify()->m_LineWidth = pObject->GetNumber();
+ m_GraphState.GetPrivateCopy()->m_LineWidth = pObject->GetNumber();
break;
case FXBSTR_ID('L', 'C', 0, 0):
- m_GraphState.GetModify()->m_LineCap =
+ m_GraphState.GetPrivateCopy()->m_LineCap =
(CFX_GraphStateData::LineCap)pObject->GetInteger();
break;
case FXBSTR_ID('L', 'J', 0, 0):
- m_GraphState.GetModify()->m_LineJoin =
+ m_GraphState.GetPrivateCopy()->m_LineJoin =
(CFX_GraphStateData::LineJoin)pObject->GetInteger();
break;
case FXBSTR_ID('M', 'L', 0, 0):
- m_GraphState.GetModify()->m_MiterLimit = pObject->GetNumber();
+ m_GraphState.GetPrivateCopy()->m_MiterLimit = pObject->GetNumber();
break;
case FXBSTR_ID('D', 0, 0, 0): {
CPDF_Array* pDash = pObject->AsArray();
@@ -98,7 +98,7 @@ void CPDF_AllStates::ProcessExtGS(CPDF_Dictionary* pGS,
if (!pFont)
break;
- m_TextState.GetModify()->m_FontSize = pFont->GetNumberAt(1);
+ m_TextState.GetPrivateCopy()->m_FontSize = pFont->GetNumberAt(1);
m_TextState.SetFont(pParser->FindFont(pFont->GetStringAt(0)));
break;
}
diff --git a/core/fpdfapi/fpdf_page/cpdf_clippath.cpp b/core/fpdfapi/fpdf_page/cpdf_clippath.cpp
index ea854d1b29..e820260131 100644
--- a/core/fpdfapi/fpdf_page/cpdf_clippath.cpp
+++ b/core/fpdfapi/fpdf_page/cpdf_clippath.cpp
@@ -14,23 +14,23 @@
#define FPDF_CLIPPATH_MAX_TEXTS 1024
uint32_t CPDF_ClipPath::GetPathCount() const {
- return pdfium::CollectionSize<uint32_t>(m_pObject->m_PathAndTypeList);
+ return pdfium::CollectionSize<uint32_t>(GetObject()->m_PathAndTypeList);
}
CPDF_Path CPDF_ClipPath::GetPath(size_t i) const {
- return m_pObject->m_PathAndTypeList[i].first;
+ return GetObject()->m_PathAndTypeList[i].first;
}
uint8_t CPDF_ClipPath::GetClipType(size_t i) const {
- return m_pObject->m_PathAndTypeList[i].second;
+ return GetObject()->m_PathAndTypeList[i].second;
}
uint32_t CPDF_ClipPath::GetTextCount() const {
- return pdfium::CollectionSize<uint32_t>(m_pObject->m_TextList);
+ return pdfium::CollectionSize<uint32_t>(GetObject()->m_TextList);
}
CPDF_TextObject* CPDF_ClipPath::GetText(size_t i) const {
- return m_pObject->m_TextList[i].get();
+ return GetObject()->m_TextList[i].get();
}
CFX_FloatRect CPDF_ClipPath::GetClipBox() const {
@@ -73,7 +73,7 @@ CFX_FloatRect CPDF_ClipPath::GetClipBox() const {
}
void CPDF_ClipPath::AppendPath(CPDF_Path path, uint8_t type, bool bAutoMerge) {
- CPDF_ClipPathData* pData = GetModify();
+ CPDF_ClipPathData* pData = GetPrivateCopy();
if (!pData->m_PathAndTypeList.empty() && bAutoMerge) {
const CPDF_Path& old_path = pData->m_PathAndTypeList.back().first;
if (old_path.IsRect()) {
@@ -89,7 +89,7 @@ void CPDF_ClipPath::AppendPath(CPDF_Path path, uint8_t type, bool bAutoMerge) {
void CPDF_ClipPath::AppendTexts(
std::vector<std::unique_ptr<CPDF_TextObject>>* pTexts) {
- CPDF_ClipPathData* pData = GetModify();
+ CPDF_ClipPathData* pData = GetPrivateCopy();
if (pData->m_TextList.size() + pTexts->size() <= FPDF_CLIPPATH_MAX_TEXTS) {
for (size_t i = 0; i < pTexts->size(); i++)
pData->m_TextList.push_back(std::move((*pTexts)[i]));
@@ -99,7 +99,7 @@ void CPDF_ClipPath::AppendTexts(
}
void CPDF_ClipPath::Transform(const CFX_Matrix& matrix) {
- CPDF_ClipPathData* pData = GetModify();
+ CPDF_ClipPathData* pData = GetPrivateCopy();
for (auto& obj : pData->m_PathAndTypeList)
obj.first.Transform(&matrix);
for (auto& text : pData->m_TextList) {
diff --git a/core/fpdfapi/fpdf_page/cpdf_colorstate.cpp b/core/fpdfapi/fpdf_page/cpdf_colorstate.cpp
index 1d422cb061..a2234378eb 100644
--- a/core/fpdfapi/fpdf_page/cpdf_colorstate.cpp
+++ b/core/fpdfapi/fpdf_page/cpdf_colorstate.cpp
@@ -13,14 +13,14 @@
void CPDF_ColorState::SetFillColor(CPDF_ColorSpace* pCS,
FX_FLOAT* pValue,
uint32_t nValues) {
- CPDF_ColorStateData* pData = GetModify();
+ CPDF_ColorStateData* pData = GetPrivateCopy();
SetColor(pData->m_FillColor, pData->m_FillRGB, pCS, pValue, nValues);
}
void CPDF_ColorState::SetStrokeColor(CPDF_ColorSpace* pCS,
FX_FLOAT* pValue,
uint32_t nValues) {
- CPDF_ColorStateData* pData = GetModify();
+ CPDF_ColorStateData* pData = GetPrivateCopy();
SetColor(pData->m_StrokeColor, pData->m_StrokeRGB, pCS, pValue, nValues);
}
@@ -45,7 +45,7 @@ void CPDF_ColorState::SetColor(CPDF_Color& color,
void CPDF_ColorState::SetFillPattern(CPDF_Pattern* pPattern,
FX_FLOAT* pValue,
uint32_t nValues) {
- CPDF_ColorStateData* pData = GetModify();
+ CPDF_ColorStateData* pData = GetPrivateCopy();
pData->m_FillColor.SetValue(pPattern, pValue, nValues);
int R, G, B;
FX_BOOL ret = pData->m_FillColor.GetRGB(R, G, B);
@@ -61,7 +61,7 @@ void CPDF_ColorState::SetFillPattern(CPDF_Pattern* pPattern,
void CPDF_ColorState::SetStrokePattern(CPDF_Pattern* pPattern,
FX_FLOAT* pValue,
uint32_t nValues) {
- CPDF_ColorStateData* pData = GetModify();
+ CPDF_ColorStateData* pData = GetPrivateCopy();
pData->m_StrokeColor.SetValue(pPattern, pValue, nValues);
int R, G, B;
FX_BOOL ret = pData->m_StrokeColor.GetRGB(R, G, B);
diff --git a/core/fpdfapi/fpdf_page/cpdf_colorstate.h b/core/fpdfapi/fpdf_page/cpdf_colorstate.h
index c7b8854be4..128d67558d 100644
--- a/core/fpdfapi/fpdf_page/cpdf_colorstate.h
+++ b/core/fpdfapi/fpdf_page/cpdf_colorstate.h
@@ -18,12 +18,14 @@ class CPDF_Pattern;
class CPDF_ColorState : public CFX_CountRef<CPDF_ColorStateData> {
public:
- CPDF_Color* GetFillColor() const {
- return m_pObject ? &m_pObject->m_FillColor : nullptr;
+ const CPDF_Color* GetFillColor() const {
+ const CPDF_ColorStateData* pData = GetObject();
+ return pData ? &pData->m_FillColor : nullptr;
}
- CPDF_Color* GetStrokeColor() const {
- return m_pObject ? &m_pObject->m_StrokeColor : nullptr;
+ const CPDF_Color* GetStrokeColor() const {
+ const CPDF_ColorStateData* pData = GetObject();
+ return pData ? &pData->m_StrokeColor : nullptr;
}
void SetFillColor(CPDF_ColorSpace* pCS, FX_FLOAT* pValue, uint32_t nValues);
diff --git a/core/fpdfapi/fpdf_page/cpdf_contentmark.cpp b/core/fpdfapi/fpdf_page/cpdf_contentmark.cpp
index 6e85d2940f..06a6a50443 100644
--- a/core/fpdfapi/fpdf_page/cpdf_contentmark.cpp
+++ b/core/fpdfapi/fpdf_page/cpdf_contentmark.cpp
@@ -6,33 +6,34 @@
#include "core/fpdfapi/fpdf_page/cpdf_contentmark.h"
-FX_BOOL CPDF_ContentMark::HasMark(const CFX_ByteStringC& mark) const {
- if (!m_pObject)
- return FALSE;
+bool CPDF_ContentMark::HasMark(const CFX_ByteStringC& mark) const {
+ const CPDF_ContentMarkData* pData = GetObject();
+ if (!pData)
+ return false;
- for (int i = 0; i < m_pObject->CountItems(); i++) {
- CPDF_ContentMarkItem& item = m_pObject->GetItem(i);
- if (item.GetName() == mark)
- return TRUE;
+ for (int i = 0; i < pData->CountItems(); i++) {
+ if (pData->GetItem(i).GetName() == mark)
+ return true;
}
- return FALSE;
+ return false;
}
-FX_BOOL CPDF_ContentMark::LookupMark(const CFX_ByteStringC& mark,
- CPDF_Dictionary*& pDict) const {
- if (!m_pObject)
- return FALSE;
+bool CPDF_ContentMark::LookupMark(const CFX_ByteStringC& mark,
+ CPDF_Dictionary*& pDict) const {
+ const CPDF_ContentMarkData* pData = GetObject();
+ if (!pData)
+ return false;
- for (int i = 0; i < m_pObject->CountItems(); i++) {
- CPDF_ContentMarkItem& item = m_pObject->GetItem(i);
+ for (int i = 0; i < pData->CountItems(); i++) {
+ const CPDF_ContentMarkItem& item = pData->GetItem(i);
if (item.GetName() == mark) {
pDict = nullptr;
if (item.GetParamType() == CPDF_ContentMarkItem::PropertiesDict ||
item.GetParamType() == CPDF_ContentMarkItem::DirectDict) {
pDict = item.GetParam();
}
- return TRUE;
+ return true;
}
}
- return FALSE;
+ return false;
}
diff --git a/core/fpdfapi/fpdf_page/cpdf_contentmark.h b/core/fpdfapi/fpdf_page/cpdf_contentmark.h
index 680aed4b99..2f8c5cdbc7 100644
--- a/core/fpdfapi/fpdf_page/cpdf_contentmark.h
+++ b/core/fpdfapi/fpdf_page/cpdf_contentmark.h
@@ -13,12 +13,13 @@
class CPDF_ContentMark : public CFX_CountRef<CPDF_ContentMarkData> {
public:
- int GetMCID() const { return m_pObject ? m_pObject->GetMCID() : -1; }
+ int GetMCID() const {
+ const CPDF_ContentMarkData* pData = GetObject();
+ return pData ? pData->GetMCID() : -1;
+ }
- FX_BOOL HasMark(const CFX_ByteStringC& mark) const;
-
- FX_BOOL LookupMark(const CFX_ByteStringC& mark,
- CPDF_Dictionary*& pDict) const;
+ bool HasMark(const CFX_ByteStringC& mark) const;
+ bool LookupMark(const CFX_ByteStringC& mark, CPDF_Dictionary*& pDict) const;
};
#endif // CORE_FPDFAPI_FPDF_PAGE_CPDF_CONTENTMARK_H_
diff --git a/core/fpdfapi/fpdf_page/cpdf_generalstate.cpp b/core/fpdfapi/fpdf_page/cpdf_generalstate.cpp
index 45a40cc85c..0f6cce6e29 100644
--- a/core/fpdfapi/fpdf_page/cpdf_generalstate.cpp
+++ b/core/fpdfapi/fpdf_page/cpdf_generalstate.cpp
@@ -25,5 +25,5 @@ int RI_StringToId(const CFX_ByteString& ri) {
} // namespace
void CPDF_GeneralState::SetRenderIntent(const CFX_ByteString& ri) {
- GetModify()->m_RenderIntent = RI_StringToId(ri);
+ GetPrivateCopy()->m_RenderIntent = RI_StringToId(ri);
}
diff --git a/core/fpdfapi/fpdf_page/cpdf_pageobject.cpp b/core/fpdfapi/fpdf_page/cpdf_pageobject.cpp
index 238675cb1c..17014c4883 100644
--- a/core/fpdfapi/fpdf_page/cpdf_pageobject.cpp
+++ b/core/fpdfapi/fpdf_page/cpdf_pageobject.cpp
@@ -81,14 +81,14 @@ void CPDF_PageObject::CopyData(const CPDF_PageObject* pSrc) {
void CPDF_PageObject::TransformClipPath(CFX_Matrix& matrix) {
if (!m_ClipPath)
return;
- m_ClipPath.GetModify();
+ m_ClipPath.GetPrivateCopy();
m_ClipPath.Transform(matrix);
}
void CPDF_PageObject::TransformGeneralState(CFX_Matrix& matrix) {
if (!m_GeneralState)
return;
- CPDF_GeneralStateData* pGS = m_GeneralState.GetModify();
+ CPDF_GeneralStateData* pGS = m_GeneralState.GetPrivateCopy();
pGS->m_Matrix.Concat(matrix);
}
diff --git a/core/fpdfapi/fpdf_page/cpdf_shadingobject.cpp b/core/fpdfapi/fpdf_page/cpdf_shadingobject.cpp
index 968c53bc07..d869bc20b3 100644
--- a/core/fpdfapi/fpdf_page/cpdf_shadingobject.cpp
+++ b/core/fpdfapi/fpdf_page/cpdf_shadingobject.cpp
@@ -36,7 +36,7 @@ CPDF_PageObject::Type CPDF_ShadingObject::GetType() const {
void CPDF_ShadingObject::Transform(const CFX_Matrix& matrix) {
if (m_ClipPath) {
- m_ClipPath.GetModify();
+ m_ClipPath.GetPrivateCopy();
m_ClipPath.Transform(matrix);
}
m_Matrix.Concat(matrix);
diff --git a/core/fpdfapi/fpdf_page/cpdf_textobject.cpp b/core/fpdfapi/fpdf_page/cpdf_textobject.cpp
index caa7d0df56..bd17dea86e 100644
--- a/core/fpdfapi/fpdf_page/cpdf_textobject.cpp
+++ b/core/fpdfapi/fpdf_page/cpdf_textobject.cpp
@@ -133,7 +133,7 @@ CPDF_PageObject::Type CPDF_TextObject::GetType() const {
}
void CPDF_TextObject::Transform(const CFX_Matrix& matrix) {
- m_TextState.GetModify();
+ m_TextState.GetPrivateCopy();
CFX_Matrix text_matrix;
GetTextMatrix(&text_matrix);
text_matrix.Concat(matrix);
@@ -160,7 +160,7 @@ const CPDF_TextObject* CPDF_TextObject::AsText() const {
}
void CPDF_TextObject::GetTextMatrix(CFX_Matrix* pMatrix) const {
- FX_FLOAT* pTextMatrix = m_TextState.GetMatrix();
+ const FX_FLOAT* pTextMatrix = m_TextState.GetMatrix();
pMatrix->Set(pTextMatrix[0], pTextMatrix[2], pTextMatrix[1], pTextMatrix[3],
m_PosX, m_PosY);
}
diff --git a/core/fpdfapi/fpdf_page/cpdf_textstate.cpp b/core/fpdfapi/fpdf_page/cpdf_textstate.cpp
index 50fc7789fe..ae75876664 100644
--- a/core/fpdfapi/fpdf_page/cpdf_textstate.cpp
+++ b/core/fpdfapi/fpdf_page/cpdf_textstate.cpp
@@ -10,7 +10,7 @@
#include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
void CPDF_TextState::SetFont(CPDF_Font* pFont) {
- CPDF_TextStateData* pStateData = GetModify();
+ CPDF_TextStateData* pStateData = GetPrivateCopy();
if (pStateData) {
CPDF_Document* pDoc = pStateData->m_pDocument;
CPDF_DocPageData* pPageData = pDoc ? pDoc->GetPageData() : nullptr;
@@ -23,26 +23,26 @@ void CPDF_TextState::SetFont(CPDF_Font* pFont) {
}
FX_FLOAT CPDF_TextState::GetFontSizeV() const {
- FX_FLOAT* pMatrix = GetMatrix();
+ const FX_FLOAT* pMatrix = GetMatrix();
FX_FLOAT unit = FXSYS_sqrt2(pMatrix[1], pMatrix[3]);
FX_FLOAT size = unit * GetFontSize();
return (FX_FLOAT)FXSYS_fabs(size);
}
FX_FLOAT CPDF_TextState::GetFontSizeH() const {
- FX_FLOAT* pMatrix = GetMatrix();
+ const FX_FLOAT* pMatrix = GetMatrix();
FX_FLOAT unit = FXSYS_sqrt2(pMatrix[0], pMatrix[2]);
FX_FLOAT size = unit * GetFontSize();
return (FX_FLOAT)FXSYS_fabs(size);
}
FX_FLOAT CPDF_TextState::GetBaselineAngle() const {
- FX_FLOAT* m_Matrix = GetMatrix();
+ const FX_FLOAT* m_Matrix = GetMatrix();
return FXSYS_atan2(m_Matrix[2], m_Matrix[0]);
}
FX_FLOAT CPDF_TextState::GetShearAngle() const {
- FX_FLOAT* m_Matrix = GetMatrix();
+ const FX_FLOAT* m_Matrix = GetMatrix();
FX_FLOAT shear_angle = FXSYS_atan2(m_Matrix[1], m_Matrix[3]);
return GetBaselineAngle() + shear_angle;
}
diff --git a/core/fpdfapi/fpdf_page/cpdf_textstate.h b/core/fpdfapi/fpdf_page/cpdf_textstate.h
index cfb4b28a21..59c988de06 100644
--- a/core/fpdfapi/fpdf_page/cpdf_textstate.h
+++ b/core/fpdfapi/fpdf_page/cpdf_textstate.h
@@ -14,11 +14,13 @@ class CPDF_Font;
class CPDF_TextState : public CFX_CountRef<CPDF_TextStateData> {
public:
- CPDF_Font* GetFont() const { return m_pObject->m_pFont; }
+ CPDF_Font* GetFont() const { return GetObject()->m_pFont; }
void SetFont(CPDF_Font* pFont);
- FX_FLOAT GetFontSize() const { return m_pObject->m_FontSize; }
- FX_FLOAT* GetMatrix() const { return m_pObject->m_Matrix; }
+ FX_FLOAT GetFontSize() const { return GetObject()->m_FontSize; }
+ FX_FLOAT* GetMatrix() { return GetObject()->m_Matrix; }
+ const FX_FLOAT* GetMatrix() const { return GetObject()->m_Matrix; }
+
FX_FLOAT GetFontSizeV() const;
FX_FLOAT GetFontSizeH() const;
FX_FLOAT GetBaselineAngle() const;
diff --git a/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp b/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp
index 8d3f5b8859..f1101034ae 100644
--- a/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp
+++ b/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp
@@ -583,7 +583,7 @@ void CPDF_StreamContentParser::Handle_BeginMarkedContent_Dictionary() {
bDirect = FALSE;
}
if (CPDF_Dictionary* pDict = pProperty->AsDictionary()) {
- m_CurContentMark.GetModify()->AddMark(tag, pDict, bDirect);
+ m_CurContentMark.GetPrivateCopy()->AddMark(tag, pDict, bDirect);
}
}
@@ -659,7 +659,7 @@ void CPDF_StreamContentParser::Handle_BeginImage() {
void CPDF_StreamContentParser::Handle_BeginMarkedContent() {
CFX_ByteString tag = GetString(0);
- m_CurContentMark.GetModify()->AddMark(tag, nullptr, FALSE);
+ m_CurContentMark.GetPrivateCopy()->AddMark(tag, nullptr, FALSE);
}
void CPDF_StreamContentParser::Handle_BeginText() {
@@ -691,7 +691,7 @@ void CPDF_StreamContentParser::Handle_SetColorSpace_Fill() {
if (!pCS) {
return;
}
- m_pCurStates->m_ColorState.GetModify()->m_FillColor.SetColorSpace(pCS);
+ m_pCurStates->m_ColorState.GetPrivateCopy()->m_FillColor.SetColorSpace(pCS);
}
void CPDF_StreamContentParser::Handle_SetColorSpace_Stroke() {
@@ -700,7 +700,7 @@ void CPDF_StreamContentParser::Handle_SetColorSpace_Stroke() {
if (!pCS) {
return;
}
- m_pCurStates->m_ColorState.GetModify()->m_StrokeColor.SetColorSpace(pCS);
+ m_pCurStates->m_ColorState.GetPrivateCopy()->m_StrokeColor.SetColorSpace(pCS);
}
void CPDF_StreamContentParser::Handle_SetDash() {
@@ -816,7 +816,7 @@ void CPDF_StreamContentParser::Handle_EndMarkedContent() {
m_CurContentMark.SetNull();
return;
}
- m_CurContentMark.GetModify()->DeleteLastMark();
+ m_CurContentMark.GetPrivateCopy()->DeleteLastMark();
}
void CPDF_StreamContentParser::Handle_EndText() {
@@ -876,18 +876,18 @@ void CPDF_StreamContentParser::Handle_ClosePath() {
}
void CPDF_StreamContentParser::Handle_SetFlat() {
- m_pCurStates->m_GeneralState.GetModify()->m_Flatness = GetNumber(0);
+ m_pCurStates->m_GeneralState.GetPrivateCopy()->m_Flatness = GetNumber(0);
}
void CPDF_StreamContentParser::Handle_BeginImageData() {}
void CPDF_StreamContentParser::Handle_SetLineJoin() {
- m_pCurStates->m_GraphState.GetModify()->m_LineJoin =
+ m_pCurStates->m_GraphState.GetPrivateCopy()->m_LineJoin =
(CFX_GraphStateData::LineJoin)GetInteger(0);
}
void CPDF_StreamContentParser::Handle_SetLineCap() {
- m_pCurStates->m_GraphState.GetModify()->m_LineCap =
+ m_pCurStates->m_GraphState.GetPrivateCopy()->m_LineCap =
(CFX_GraphStateData::LineCap)GetInteger(0);
}
@@ -931,7 +931,7 @@ void CPDF_StreamContentParser::Handle_MoveTo() {
}
void CPDF_StreamContentParser::Handle_SetMiterLimit() {
- m_pCurStates->m_GraphState.GetModify()->m_MiterLimit = GetNumber(0);
+ m_pCurStates->m_GraphState.GetPrivateCopy()->m_MiterLimit = GetNumber(0);
}
void CPDF_StreamContentParser::Handle_MarkPlace() {}
@@ -1114,7 +1114,7 @@ void CPDF_StreamContentParser::Handle_ShadeFill() {
}
void CPDF_StreamContentParser::Handle_SetCharSpace() {
- m_pCurStates->m_TextState.GetModify()->m_CharSpace = GetNumber(0);
+ m_pCurStates->m_TextState.GetPrivateCopy()->m_CharSpace = GetNumber(0);
}
void CPDF_StreamContentParser::Handle_MoveTextPoint() {
@@ -1134,7 +1134,7 @@ void CPDF_StreamContentParser::Handle_SetFont() {
if (fs == 0) {
fs = m_DefFontSize;
}
- m_pCurStates->m_TextState.GetModify()->m_FontSize = fs;
+ m_pCurStates->m_TextState.GetPrivateCopy()->m_FontSize = fs;
CPDF_Font* pFont = FindFont(GetString(1));
if (pFont) {
m_pCurStates->m_TextState.SetFont(pFont);
@@ -1249,7 +1249,7 @@ void CPDF_StreamContentParser::AddTextObject(CFX_ByteString* pStrs,
m_pLastTextObject = pText.get();
SetGraphicStates(m_pLastTextObject, TRUE, TRUE, TRUE);
if (TextRenderingModeIsStrokeMode(text_mode)) {
- FX_FLOAT* pCTM = pText->m_TextState.GetModify()->m_CTM;
+ FX_FLOAT* pCTM = pText->m_TextState.GetPrivateCopy()->m_CTM;
pCTM[0] = m_pCurStates->m_CTM.a;
pCTM[1] = m_pCurStates->m_CTM.c;
pCTM[2] = m_pCurStates->m_CTM.b;
@@ -1358,7 +1358,7 @@ void CPDF_StreamContentParser::OnChangeTextMatrix() {
text_matrix.Concat(m_pCurStates->m_TextMatrix);
text_matrix.Concat(m_pCurStates->m_CTM);
text_matrix.Concat(m_mtContentToUser);
- FX_FLOAT* pTextMatrix = m_pCurStates->m_TextState.GetModify()->m_Matrix;
+ FX_FLOAT* pTextMatrix = m_pCurStates->m_TextState.GetPrivateCopy()->m_Matrix;
pTextMatrix[0] = text_matrix.a;
pTextMatrix[1] = text_matrix.c;
pTextMatrix[2] = text_matrix.b;
@@ -1368,7 +1368,7 @@ void CPDF_StreamContentParser::OnChangeTextMatrix() {
void CPDF_StreamContentParser::Handle_SetTextRenderMode() {
int mode = GetInteger(0);
SetTextRenderingModeFromInt(
- mode, &m_pCurStates->m_TextState.GetModify()->m_TextMode);
+ mode, &m_pCurStates->m_TextState.GetPrivateCopy()->m_TextMode);
}
void CPDF_StreamContentParser::Handle_SetTextRise() {
@@ -1376,7 +1376,7 @@ void CPDF_StreamContentParser::Handle_SetTextRise() {
}
void CPDF_StreamContentParser::Handle_SetWordSpace() {
- m_pCurStates->m_TextState.GetModify()->m_WordSpace = GetNumber(0);
+ m_pCurStates->m_TextState.GetPrivateCopy()->m_WordSpace = GetNumber(0);
}
void CPDF_StreamContentParser::Handle_SetHorzScale() {
@@ -1401,7 +1401,7 @@ void CPDF_StreamContentParser::Handle_CurveTo_23() {
void CPDF_StreamContentParser::Handle_SetLineWidth() {
FX_FLOAT width = GetNumber(0);
- m_pCurStates->m_GraphState.GetModify()->m_LineWidth = width;
+ m_pCurStates->m_GraphState.GetPrivateCopy()->m_LineWidth = width;
}
void CPDF_StreamContentParser::Handle_Clip() {
@@ -1424,8 +1424,8 @@ void CPDF_StreamContentParser::Handle_NextLineShowText() {
}
void CPDF_StreamContentParser::Handle_NextLineShowText_Space() {
- m_pCurStates->m_TextState.GetModify()->m_WordSpace = GetNumber(2);
- m_pCurStates->m_TextState.GetModify()->m_CharSpace = GetNumber(1);
+ m_pCurStates->m_TextState.GetPrivateCopy()->m_WordSpace = GetNumber(2);
+ m_pCurStates->m_TextState.GetPrivateCopy()->m_CharSpace = GetNumber(1);
Handle_NextLineShowText();
}
diff --git a/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp b/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
index dbfd741887..6fa1df26cd 100644
--- a/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
+++ b/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
@@ -712,7 +712,7 @@ void CPDF_ContentParser::Start(CPDF_Form* pForm,
}
if (pForm->m_Transparency & PDFTRANS_GROUP) {
CPDF_GeneralStateData* pData =
- m_pParser->GetCurStates()->m_GeneralState.GetModify();
+ m_pParser->GetCurStates()->m_GeneralState.GetPrivateCopy();
pData->m_BlendType = FXDIB_BLEND_NORMAL;
pData->m_StrokeAlpha = 1.0f;
pData->m_FillAlpha = 1.0f;
@@ -774,7 +774,7 @@ void CPDF_ContentParser::Continue(IFX_Pause* pPause) {
m_pObjectHolder->m_pDocument, m_pObjectHolder->m_pPageResources,
nullptr, nullptr, m_pObjectHolder, m_pObjectHolder->m_pResources,
&m_pObjectHolder->m_BBox, nullptr, 0));
- m_pParser->GetCurStates()->m_ColorState.GetModify()->Default();
+ m_pParser->GetCurStates()->m_ColorState.GetPrivateCopy()->Default();
}
if (m_CurrentOffset >= m_Size) {
m_InternalStage = STAGE_CHECKCLIP;
diff --git a/core/fpdfapi/fpdf_page/include/cpdf_generalstate.h b/core/fpdfapi/fpdf_page/include/cpdf_generalstate.h
index ab1e940089..dff8371119 100644
--- a/core/fpdfapi/fpdf_page/include/cpdf_generalstate.h
+++ b/core/fpdfapi/fpdf_page/include/cpdf_generalstate.h
@@ -15,14 +15,16 @@ class CPDF_GeneralState : public CFX_CountRef<CPDF_GeneralStateData> {
void SetRenderIntent(const CFX_ByteString& ri);
int GetBlendType() const {
- return m_pObject ? m_pObject->m_BlendType : FXDIB_BLEND_NORMAL;
+ const CPDF_GeneralStateData* pData = GetObject();
+ return pData ? pData->m_BlendType : FXDIB_BLEND_NORMAL;
}
int GetAlpha(FX_BOOL bStroke) const {
- if (!m_pObject)
+ const CPDF_GeneralStateData* pData = GetObject();
+ if (!pData)
return 255;
- return FXSYS_round(
- (bStroke ? m_pObject->m_StrokeAlpha : m_pObject->m_FillAlpha) * 255);
+ return FXSYS_round((bStroke ? pData->m_StrokeAlpha : pData->m_FillAlpha) *
+ 255);
}
};
diff --git a/core/fpdfapi/fpdf_page/include/cpdf_path.h b/core/fpdfapi/fpdf_page/include/cpdf_path.h
index 0e8c491f9e..98de696004 100644
--- a/core/fpdfapi/fpdf_page/include/cpdf_path.h
+++ b/core/fpdfapi/fpdf_page/include/cpdf_path.h
@@ -14,28 +14,30 @@
class CPDF_Path : public CFX_CountRef<CFX_PathData> {
public:
- int GetPointCount() const { return m_pObject->GetPointCount(); }
- int GetFlag(int index) const { return m_pObject->GetFlag(index); }
- FX_FLOAT GetPointX(int index) const { return m_pObject->GetPointX(index); }
- FX_FLOAT GetPointY(int index) const { return m_pObject->GetPointY(index); }
- FX_PATHPOINT* GetPoints() const { return m_pObject->GetPoints(); }
- CFX_FloatRect GetBoundingBox() const { return m_pObject->GetBoundingBox(); }
+ int GetPointCount() const { return GetObject()->GetPointCount(); }
+ int GetFlag(int index) const { return GetObject()->GetFlag(index); }
+ FX_FLOAT GetPointX(int index) const { return GetObject()->GetPointX(index); }
+ FX_FLOAT GetPointY(int index) const { return GetObject()->GetPointY(index); }
+ FX_PATHPOINT* GetPoints() const { return GetObject()->GetPoints(); }
+ CFX_FloatRect GetBoundingBox() const { return GetObject()->GetBoundingBox(); }
CFX_FloatRect GetBoundingBox(FX_FLOAT line_width,
FX_FLOAT miter_limit) const {
- return m_pObject->GetBoundingBox(line_width, miter_limit);
+ return GetObject()->GetBoundingBox(line_width, miter_limit);
}
- FX_BOOL IsRect() const { return m_pObject->IsRect(); }
- void Transform(const CFX_Matrix* pMatrix) { GetModify()->Transform(pMatrix); }
+ FX_BOOL IsRect() const { return GetObject()->IsRect(); }
+ void Transform(const CFX_Matrix* pMatrix) {
+ GetPrivateCopy()->Transform(pMatrix);
+ }
void Append(const CPDF_Path& other, const CFX_Matrix* pMatrix) {
- m_pObject->Append(other.GetObject(), pMatrix);
+ GetObject()->Append(other.GetObject(), pMatrix);
}
void AppendRect(FX_FLOAT left,
FX_FLOAT bottom,
FX_FLOAT right,
FX_FLOAT top) {
- m_pObject->AppendRect(left, bottom, right, top);
+ GetObject()->AppendRect(left, bottom, right, top);
}
};