diff options
author | tsepez <tsepez@chromium.org> | 2016-08-29 14:42:36 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-08-29 14:42:36 -0700 |
commit | d24c3a60d0e6e5badef57d3baf55e5c3b6d4882e (patch) | |
tree | 56abe4fe5e26d4aa18b1921d1f8208065aae0bbd /core/fpdfapi/fpdf_page | |
parent | 596014357f7cd9ee3245ba8ed52cbc5761151727 (diff) | |
download | pdfium-d24c3a60d0e6e5badef57d3baf55e5c3b6d4882e.tar.xz |
Revert "Add -> operators to CFX_CountRef."
This reverts commit c10c23a2b1999b1cb0354fd4db9837dc63a3d833.
TBR=dsinclair@chromium.org
Review-Url: https://codereview.chromium.org/2285283003
Diffstat (limited to 'core/fpdfapi/fpdf_page')
-rw-r--r-- | core/fpdfapi/fpdf_page/cpdf_allstates.cpp | 71 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_page/cpdf_clippath.cpp | 9 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_page/cpdf_colorstate.cpp | 12 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_page/cpdf_generalstate.cpp | 3 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_page/cpdf_pageobject.cpp | 6 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_page/cpdf_pathobject.cpp | 4 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_page/cpdf_shadingobject.cpp | 2 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_page/cpdf_textobject.cpp | 10 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_page/cpdf_textstate.cpp | 19 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_page/fpdf_page_parser.cpp | 100 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp | 11 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_page/include/cpdf_path.h | 3 |
12 files changed, 113 insertions, 137 deletions
diff --git a/core/fpdfapi/fpdf_page/cpdf_allstates.cpp b/core/fpdfapi/fpdf_page/cpdf_allstates.cpp index fb0c2445e7..e4b6e328b9 100644 --- a/core/fpdfapi/fpdf_page/cpdf_allstates.cpp +++ b/core/fpdfapi/fpdf_page/cpdf_allstates.cpp @@ -45,16 +45,16 @@ void CPDF_AllStates::Copy(const CPDF_AllStates& src) { void CPDF_AllStates::SetLineDash(CPDF_Array* pArray, FX_FLOAT phase, FX_FLOAT scale) { - m_GraphState.MakePrivateCopy(); - m_GraphState->m_DashPhase = phase * scale; - m_GraphState->SetDashCount(static_cast<int>(pArray->GetCount())); + 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++) - m_GraphState->m_DashArray[i] = pArray->GetNumberAt(i) * scale; + pData->m_DashArray[i] = pArray->GetNumberAt(i) * scale; } void CPDF_AllStates::ProcessExtGS(CPDF_Dictionary* pGS, CPDF_StreamContentParser* pParser) { - m_GeneralState.MakePrivateCopy(); + CPDF_GeneralStateData* pGeneralState = m_GeneralState.GetPrivateCopy(); for (const auto& it : *pGS) { const CFX_ByteString& key_str = it.first; CPDF_Object* pElement = it.second; @@ -65,22 +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.MakePrivateCopy(); - m_GraphState->m_LineWidth = pObject->GetNumber(); + m_GraphState.GetPrivateCopy()->m_LineWidth = pObject->GetNumber(); break; case FXBSTR_ID('L', 'C', 0, 0): - m_GraphState.MakePrivateCopy(); - m_GraphState->m_LineCap = - static_cast<CFX_GraphStateData::LineCap>(pObject->GetInteger()); + m_GraphState.GetPrivateCopy()->m_LineCap = + (CFX_GraphStateData::LineCap)pObject->GetInteger(); break; case FXBSTR_ID('L', 'J', 0, 0): - m_GraphState.MakePrivateCopy(); - m_GraphState->m_LineJoin = - static_cast<CFX_GraphStateData::LineJoin>(pObject->GetInteger()); + m_GraphState.GetPrivateCopy()->m_LineJoin = + (CFX_GraphStateData::LineJoin)pObject->GetInteger(); break; case FXBSTR_ID('M', 'L', 0, 0): - m_GraphState.MakePrivateCopy(); - m_GraphState->m_MiterLimit = pObject->GetNumber(); + m_GraphState.GetPrivateCopy()->m_MiterLimit = pObject->GetNumber(); break; case FXBSTR_ID('D', 0, 0, 0): { CPDF_Array* pDash = pObject->AsArray(); @@ -102,8 +98,7 @@ void CPDF_AllStates::ProcessExtGS(CPDF_Dictionary* pGS, if (!pFont) break; - m_TextState.MakePrivateCopy(); - m_TextState->m_FontSize = pFont->GetNumberAt(1); + m_TextState.GetPrivateCopy()->m_FontSize = pFont->GetNumberAt(1); m_TextState.SetFont(pParser->FindFont(pFont->GetStringAt(0))); break; } @@ -112,7 +107,7 @@ void CPDF_AllStates::ProcessExtGS(CPDF_Dictionary* pGS, continue; } case FXBSTR_ID('T', 'R', '2', 0): - m_GeneralState->m_pTR = + pGeneralState->m_pTR = (pObject && !pObject->IsName()) ? pObject : nullptr; break; case FXBSTR_ID('B', 'M', 0, 0): { @@ -120,72 +115,72 @@ void CPDF_AllStates::ProcessExtGS(CPDF_Dictionary* pGS, CFX_ByteString mode = pArray ? pArray->GetStringAt(0) : pObject->GetString(); - m_GeneralState->SetBlendMode(mode.AsStringC()); - if (m_GeneralState->m_BlendType > FXDIB_BLEND_MULTIPLY) { + pGeneralState->SetBlendMode(mode.AsStringC()); + if (pGeneralState->m_BlendType > FXDIB_BLEND_MULTIPLY) { pParser->GetPageObjectHolder()->SetBackgroundAlphaNeeded(TRUE); } break; } case FXBSTR_ID('S', 'M', 'a', 's'): if (ToDictionary(pObject)) { - m_GeneralState->m_pSoftMask = pObject; - FXSYS_memcpy(m_GeneralState->m_SMaskMatrix, + pGeneralState->m_pSoftMask = pObject; + FXSYS_memcpy(pGeneralState->m_SMaskMatrix, &pParser->GetCurStates()->m_CTM, sizeof(CFX_Matrix)); } else { - m_GeneralState->m_pSoftMask = nullptr; + pGeneralState->m_pSoftMask = nullptr; } break; case FXBSTR_ID('C', 'A', 0, 0): - m_GeneralState->m_StrokeAlpha = ClipFloat(pObject->GetNumber()); + pGeneralState->m_StrokeAlpha = ClipFloat(pObject->GetNumber()); break; case FXBSTR_ID('c', 'a', 0, 0): - m_GeneralState->m_FillAlpha = ClipFloat(pObject->GetNumber()); + pGeneralState->m_FillAlpha = ClipFloat(pObject->GetNumber()); break; case FXBSTR_ID('O', 'P', 0, 0): - m_GeneralState->m_StrokeOP = pObject->GetInteger(); + pGeneralState->m_StrokeOP = pObject->GetInteger(); if (!pGS->KeyExist("op")) { - m_GeneralState->m_FillOP = pObject->GetInteger(); + pGeneralState->m_FillOP = pObject->GetInteger(); } break; case FXBSTR_ID('o', 'p', 0, 0): - m_GeneralState->m_FillOP = pObject->GetInteger(); + pGeneralState->m_FillOP = pObject->GetInteger(); break; case FXBSTR_ID('O', 'P', 'M', 0): - m_GeneralState->m_OPMode = pObject->GetInteger(); + pGeneralState->m_OPMode = pObject->GetInteger(); break; case FXBSTR_ID('B', 'G', 0, 0): if (pGS->KeyExist("BG2")) { continue; } case FXBSTR_ID('B', 'G', '2', 0): - m_GeneralState->m_pBG = pObject; + pGeneralState->m_pBG = pObject; break; case FXBSTR_ID('U', 'C', 'R', 0): if (pGS->KeyExist("UCR2")) { continue; } case FXBSTR_ID('U', 'C', 'R', '2'): - m_GeneralState->m_pUCR = pObject; + pGeneralState->m_pUCR = pObject; break; case FXBSTR_ID('H', 'T', 0, 0): - m_GeneralState->m_pHT = pObject; + pGeneralState->m_pHT = pObject; break; case FXBSTR_ID('F', 'L', 0, 0): - m_GeneralState->m_Flatness = pObject->GetNumber(); + pGeneralState->m_Flatness = pObject->GetNumber(); break; case FXBSTR_ID('S', 'M', 0, 0): - m_GeneralState->m_Smoothness = pObject->GetNumber(); + pGeneralState->m_Smoothness = pObject->GetNumber(); break; case FXBSTR_ID('S', 'A', 0, 0): - m_GeneralState->m_StrokeAdjust = pObject->GetInteger(); + pGeneralState->m_StrokeAdjust = pObject->GetInteger(); break; case FXBSTR_ID('A', 'I', 'S', 0): - m_GeneralState->m_AlphaSource = pObject->GetInteger(); + pGeneralState->m_AlphaSource = pObject->GetInteger(); break; case FXBSTR_ID('T', 'K', 0, 0): - m_GeneralState->m_TextKnockout = pObject->GetInteger(); + pGeneralState->m_TextKnockout = pObject->GetInteger(); break; } } - m_GeneralState->m_Matrix = m_CTM; + pGeneralState->m_Matrix = m_CTM; } diff --git a/core/fpdfapi/fpdf_page/cpdf_clippath.cpp b/core/fpdfapi/fpdf_page/cpdf_clippath.cpp index 2c05df0d19..e820260131 100644 --- a/core/fpdfapi/fpdf_page/cpdf_clippath.cpp +++ b/core/fpdfapi/fpdf_page/cpdf_clippath.cpp @@ -73,8 +73,7 @@ CFX_FloatRect CPDF_ClipPath::GetClipBox() const { } void CPDF_ClipPath::AppendPath(CPDF_Path path, uint8_t type, bool bAutoMerge) { - MakePrivateCopy(); - CPDF_ClipPathData* pData = GetObject(); + CPDF_ClipPathData* pData = GetPrivateCopy(); if (!pData->m_PathAndTypeList.empty() && bAutoMerge) { const CPDF_Path& old_path = pData->m_PathAndTypeList.back().first; if (old_path.IsRect()) { @@ -90,8 +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) { - MakePrivateCopy(); - CPDF_ClipPathData* pData = GetObject(); + 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])); @@ -101,8 +99,7 @@ void CPDF_ClipPath::AppendTexts( } void CPDF_ClipPath::Transform(const CFX_Matrix& matrix) { - MakePrivateCopy(); - CPDF_ClipPathData* pData = GetObject(); + 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 a46dea3bb8..a2234378eb 100644 --- a/core/fpdfapi/fpdf_page/cpdf_colorstate.cpp +++ b/core/fpdfapi/fpdf_page/cpdf_colorstate.cpp @@ -13,16 +13,14 @@ void CPDF_ColorState::SetFillColor(CPDF_ColorSpace* pCS, FX_FLOAT* pValue, uint32_t nValues) { - MakePrivateCopy(); - CPDF_ColorStateData* pData = GetObject(); + 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) { - MakePrivateCopy(); - CPDF_ColorStateData* pData = GetObject(); + CPDF_ColorStateData* pData = GetPrivateCopy(); SetColor(pData->m_StrokeColor, pData->m_StrokeRGB, pCS, pValue, nValues); } @@ -47,8 +45,7 @@ void CPDF_ColorState::SetColor(CPDF_Color& color, void CPDF_ColorState::SetFillPattern(CPDF_Pattern* pPattern, FX_FLOAT* pValue, uint32_t nValues) { - MakePrivateCopy(); - CPDF_ColorStateData* pData = GetObject(); + 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); @@ -64,8 +61,7 @@ void CPDF_ColorState::SetFillPattern(CPDF_Pattern* pPattern, void CPDF_ColorState::SetStrokePattern(CPDF_Pattern* pPattern, FX_FLOAT* pValue, uint32_t nValues) { - MakePrivateCopy(); - CPDF_ColorStateData* pData = GetObject(); + 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_generalstate.cpp b/core/fpdfapi/fpdf_page/cpdf_generalstate.cpp index ff22d4d74b..0f6cce6e29 100644 --- a/core/fpdfapi/fpdf_page/cpdf_generalstate.cpp +++ b/core/fpdfapi/fpdf_page/cpdf_generalstate.cpp @@ -25,6 +25,5 @@ int RI_StringToId(const CFX_ByteString& ri) { } // namespace void CPDF_GeneralState::SetRenderIntent(const CFX_ByteString& ri) { - MakePrivateCopy(); - GetObject()->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 df777dfb92..17014c4883 100644 --- a/core/fpdfapi/fpdf_page/cpdf_pageobject.cpp +++ b/core/fpdfapi/fpdf_page/cpdf_pageobject.cpp @@ -81,15 +81,15 @@ void CPDF_PageObject::CopyData(const CPDF_PageObject* pSrc) { void CPDF_PageObject::TransformClipPath(CFX_Matrix& matrix) { if (!m_ClipPath) return; - m_ClipPath.MakePrivateCopy(); + m_ClipPath.GetPrivateCopy(); m_ClipPath.Transform(matrix); } void CPDF_PageObject::TransformGeneralState(CFX_Matrix& matrix) { if (!m_GeneralState) return; - m_GeneralState.MakePrivateCopy(); - m_GeneralState->m_Matrix.Concat(matrix); + CPDF_GeneralStateData* pGS = m_GeneralState.GetPrivateCopy(); + pGS->m_Matrix.Concat(matrix); } FX_RECT CPDF_PageObject::GetBBox(const CFX_Matrix* pMatrix) const { diff --git a/core/fpdfapi/fpdf_page/cpdf_pathobject.cpp b/core/fpdfapi/fpdf_page/cpdf_pathobject.cpp index ceb3dd43cc..0055d6a133 100644 --- a/core/fpdfapi/fpdf_page/cpdf_pathobject.cpp +++ b/core/fpdfapi/fpdf_page/cpdf_pathobject.cpp @@ -46,9 +46,9 @@ void CPDF_PathObject::CalcBoundingBox() { if (!m_Path) return; CFX_FloatRect rect; - FX_FLOAT width = m_GraphState->m_LineWidth; + FX_FLOAT width = m_GraphState.GetObject()->m_LineWidth; if (m_bStroke && width != 0) { - rect = m_Path.GetBoundingBox(width, m_GraphState->m_MiterLimit); + rect = m_Path.GetBoundingBox(width, m_GraphState.GetObject()->m_MiterLimit); } else { rect = m_Path.GetBoundingBox(); } diff --git a/core/fpdfapi/fpdf_page/cpdf_shadingobject.cpp b/core/fpdfapi/fpdf_page/cpdf_shadingobject.cpp index 383fd154e5..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.MakePrivateCopy(); + 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 a3653359de..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.MakePrivateCopy(); + m_TextState.GetPrivateCopy(); CFX_Matrix text_matrix; GetTextMatrix(&text_matrix); text_matrix.Concat(matrix); @@ -334,9 +334,9 @@ void CPDF_TextObject::CalcPositionData(FX_FLOAT* pTextAdvanceX, } curpos += charwidth; if (charcode == ' ' && (!pCIDFont || pCIDFont->GetCharSize(32) == 1)) { - curpos += m_TextState->m_WordSpace; + curpos += m_TextState.GetObject()->m_WordSpace; } - curpos += m_TextState->m_CharSpace; + curpos += m_TextState.GetObject()->m_CharSpace; } if (bVertWriting) { if (pTextAdvanceX) { @@ -364,8 +364,8 @@ void CPDF_TextObject::CalcPositionData(FX_FLOAT* pTextAdvanceX, m_Bottom = min_y; m_Top = max_y; matrix.TransformRect(m_Left, m_Right, m_Top, m_Bottom); - if (TextRenderingModeIsStrokeMode(m_TextState->m_TextMode)) { - FX_FLOAT half_width = m_GraphState->m_LineWidth / 2; + if (TextRenderingModeIsStrokeMode(m_TextState.GetObject()->m_TextMode)) { + FX_FLOAT half_width = m_GraphState.GetObject()->m_LineWidth / 2; m_Left -= half_width; m_Right += half_width; m_Top += half_width; diff --git a/core/fpdfapi/fpdf_page/cpdf_textstate.cpp b/core/fpdfapi/fpdf_page/cpdf_textstate.cpp index 47e2116836..ae75876664 100644 --- a/core/fpdfapi/fpdf_page/cpdf_textstate.cpp +++ b/core/fpdfapi/fpdf_page/cpdf_textstate.cpp @@ -10,15 +10,16 @@ #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" void CPDF_TextState::SetFont(CPDF_Font* pFont) { - MakePrivateCopy(); - CPDF_TextStateData* pStateData = GetObject(); - CPDF_Document* pDoc = pStateData->m_pDocument; - CPDF_DocPageData* pPageData = pDoc ? pDoc->GetPageData() : nullptr; - if (pPageData && pStateData->m_pFont && !pPageData->IsForceClear()) - pPageData->ReleaseFont(pStateData->m_pFont->GetFontDict()); - - pStateData->m_pDocument = pFont ? pFont->m_pDocument : nullptr; - pStateData->m_pFont = pFont; + CPDF_TextStateData* pStateData = GetPrivateCopy(); + if (pStateData) { + CPDF_Document* pDoc = pStateData->m_pDocument; + CPDF_DocPageData* pPageData = pDoc ? pDoc->GetPageData() : nullptr; + if (pPageData && pStateData->m_pFont && !pPageData->IsForceClear()) { + pPageData->ReleaseFont(pStateData->m_pFont->GetFontDict()); + } + pStateData->m_pDocument = pFont ? pFont->m_pDocument : nullptr; + pStateData->m_pFont = pFont; + } } FX_FLOAT CPDF_TextState::GetFontSizeV() const { diff --git a/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp b/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp index 3afcf4b7d1..f1101034ae 100644 --- a/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp +++ b/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp @@ -583,8 +583,7 @@ void CPDF_StreamContentParser::Handle_BeginMarkedContent_Dictionary() { bDirect = FALSE; } if (CPDF_Dictionary* pDict = pProperty->AsDictionary()) { - m_CurContentMark.MakePrivateCopy(); - m_CurContentMark->AddMark(tag, pDict, bDirect); + m_CurContentMark.GetPrivateCopy()->AddMark(tag, pDict, bDirect); } } @@ -659,8 +658,8 @@ void CPDF_StreamContentParser::Handle_BeginImage() { } void CPDF_StreamContentParser::Handle_BeginMarkedContent() { - m_CurContentMark.MakePrivateCopy(); - m_CurContentMark->AddMark(GetString(0), nullptr, FALSE); + CFX_ByteString tag = GetString(0); + m_CurContentMark.GetPrivateCopy()->AddMark(tag, nullptr, FALSE); } void CPDF_StreamContentParser::Handle_BeginText() { @@ -687,21 +686,21 @@ void CPDF_StreamContentParser::Handle_ConcatMatrix() { } void CPDF_StreamContentParser::Handle_SetColorSpace_Fill() { - CPDF_ColorSpace* pCS = FindColorSpace(GetString(0)); - if (!pCS) + CFX_ByteString csname = GetString(0); + CPDF_ColorSpace* pCS = FindColorSpace(csname); + if (!pCS) { return; - - m_pCurStates->m_ColorState.MakePrivateCopy(); - m_pCurStates->m_ColorState->m_FillColor.SetColorSpace(pCS); + } + m_pCurStates->m_ColorState.GetPrivateCopy()->m_FillColor.SetColorSpace(pCS); } void CPDF_StreamContentParser::Handle_SetColorSpace_Stroke() { - CPDF_ColorSpace* pCS = FindColorSpace(GetString(0)); - if (!pCS) + CFX_ByteString csname = GetString(0); + CPDF_ColorSpace* pCS = FindColorSpace(csname); + if (!pCS) { return; - - m_pCurStates->m_ColorState.MakePrivateCopy(); - m_pCurStates->m_ColorState->m_StrokeColor.SetColorSpace(pCS); + } + m_pCurStates->m_ColorState.GetPrivateCopy()->m_StrokeColor.SetColorSpace(pCS); } void CPDF_StreamContentParser::Handle_SetDash() { @@ -812,22 +811,22 @@ void CPDF_StreamContentParser::Handle_EndMarkedContent() { if (!m_CurContentMark) return; - if (m_CurContentMark->CountItems() == 1) { - m_CurContentMark.Clear(); + int count = m_CurContentMark.GetObject()->CountItems(); + if (count == 1) { + m_CurContentMark.SetNull(); return; } - - m_CurContentMark.MakePrivateCopy(); - m_CurContentMark->DeleteLastMark(); + m_CurContentMark.GetPrivateCopy()->DeleteLastMark(); } void CPDF_StreamContentParser::Handle_EndText() { if (m_ClipTextList.empty()) return; - if (TextRenderingModeIsClipMode(m_pCurStates->m_TextState->m_TextMode)) + if (TextRenderingModeIsClipMode( + m_pCurStates->m_TextState.GetObject()->m_TextMode)) { m_pCurStates->m_ClipPath.AppendTexts(&m_ClipTextList); - + } m_ClipTextList.clear(); } @@ -877,22 +876,19 @@ void CPDF_StreamContentParser::Handle_ClosePath() { } void CPDF_StreamContentParser::Handle_SetFlat() { - m_pCurStates->m_GeneralState.MakePrivateCopy(); - m_pCurStates->m_GeneralState->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.MakePrivateCopy(); - m_pCurStates->m_GraphState->m_LineJoin = - static_cast<CFX_GraphStateData::LineJoin>(GetInteger(0)); + m_pCurStates->m_GraphState.GetPrivateCopy()->m_LineJoin = + (CFX_GraphStateData::LineJoin)GetInteger(0); } void CPDF_StreamContentParser::Handle_SetLineCap() { - m_pCurStates->m_GraphState.MakePrivateCopy(); - m_pCurStates->m_GraphState->m_LineCap = - static_cast<CFX_GraphStateData::LineCap>(GetInteger(0)); + m_pCurStates->m_GraphState.GetPrivateCopy()->m_LineCap = + (CFX_GraphStateData::LineCap)GetInteger(0); } void CPDF_StreamContentParser::Handle_SetCMYKColor_Fill() { @@ -935,8 +931,7 @@ void CPDF_StreamContentParser::Handle_MoveTo() { } void CPDF_StreamContentParser::Handle_SetMiterLimit() { - m_pCurStates->m_GraphState.MakePrivateCopy(); - m_pCurStates->m_GraphState->m_MiterLimit = GetNumber(0); + m_pCurStates->m_GraphState.GetPrivateCopy()->m_MiterLimit = GetNumber(0); } void CPDF_StreamContentParser::Handle_MarkPlace() {} @@ -1119,8 +1114,7 @@ void CPDF_StreamContentParser::Handle_ShadeFill() { } void CPDF_StreamContentParser::Handle_SetCharSpace() { - m_pCurStates->m_TextState.MakePrivateCopy(); - m_pCurStates->m_TextState->m_CharSpace = GetNumber(0); + m_pCurStates->m_TextState.GetPrivateCopy()->m_CharSpace = GetNumber(0); } void CPDF_StreamContentParser::Handle_MoveTextPoint() { @@ -1137,14 +1131,14 @@ void CPDF_StreamContentParser::Handle_MoveTextPoint_SetLeading() { void CPDF_StreamContentParser::Handle_SetFont() { FX_FLOAT fs = GetNumber(0); - if (fs == 0) + if (fs == 0) { fs = m_DefFontSize; - - m_pCurStates->m_TextState.MakePrivateCopy(); - m_pCurStates->m_TextState->m_FontSize = fs; + } + m_pCurStates->m_TextState.GetPrivateCopy()->m_FontSize = fs; CPDF_Font* pFont = FindFont(GetString(1)); - if (pFont) + if (pFont) { m_pCurStates->m_TextState.SetFont(pFont); + } } CPDF_Object* CPDF_StreamContentParser::FindResourceObj( @@ -1249,14 +1243,13 @@ void CPDF_StreamContentParser::AddTextObject(CFX_ByteString* pStrs, } const TextRenderingMode text_mode = pFont->IsType3Font() ? TextRenderingMode::MODE_FILL - : m_pCurStates->m_TextState->m_TextMode; + : m_pCurStates->m_TextState.GetObject()->m_TextMode; { std::unique_ptr<CPDF_TextObject> pText(new CPDF_TextObject); m_pLastTextObject = pText.get(); SetGraphicStates(m_pLastTextObject, TRUE, TRUE, TRUE); if (TextRenderingModeIsStrokeMode(text_mode)) { - pText->m_TextState.MakePrivateCopy(); - FX_FLOAT* pCTM = pText->m_TextState->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; @@ -1365,8 +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); - m_pCurStates->m_TextState.MakePrivateCopy(); - FX_FLOAT* pTextMatrix = m_pCurStates->m_TextState->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; @@ -1374,9 +1366,9 @@ void CPDF_StreamContentParser::OnChangeTextMatrix() { } void CPDF_StreamContentParser::Handle_SetTextRenderMode() { - m_pCurStates->m_TextState.MakePrivateCopy(); - SetTextRenderingModeFromInt(GetInteger(0), - &m_pCurStates->m_TextState->m_TextMode); + int mode = GetInteger(0); + SetTextRenderingModeFromInt( + mode, &m_pCurStates->m_TextState.GetPrivateCopy()->m_TextMode); } void CPDF_StreamContentParser::Handle_SetTextRise() { @@ -1384,14 +1376,13 @@ void CPDF_StreamContentParser::Handle_SetTextRise() { } void CPDF_StreamContentParser::Handle_SetWordSpace() { - m_pCurStates->m_TextState.MakePrivateCopy(); - m_pCurStates->m_TextState->m_WordSpace = GetNumber(0); + m_pCurStates->m_TextState.GetPrivateCopy()->m_WordSpace = GetNumber(0); } void CPDF_StreamContentParser::Handle_SetHorzScale() { - if (m_ParamCount != 1) + if (m_ParamCount != 1) { return; - + } m_pCurStates->m_TextHorzScale = GetNumber(0) / 100; OnChangeTextMatrix(); } @@ -1409,8 +1400,8 @@ void CPDF_StreamContentParser::Handle_CurveTo_23() { } void CPDF_StreamContentParser::Handle_SetLineWidth() { - m_pCurStates->m_GraphState.MakePrivateCopy(); - m_pCurStates->m_GraphState->m_LineWidth = GetNumber(0); + FX_FLOAT width = GetNumber(0); + m_pCurStates->m_GraphState.GetPrivateCopy()->m_LineWidth = width; } void CPDF_StreamContentParser::Handle_Clip() { @@ -1433,9 +1424,8 @@ void CPDF_StreamContentParser::Handle_NextLineShowText() { } void CPDF_StreamContentParser::Handle_NextLineShowText_Space() { - m_pCurStates->m_TextState.MakePrivateCopy(); - m_pCurStates->m_TextState->m_WordSpace = GetNumber(2); - m_pCurStates->m_TextState->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 1b37862e99..6fa1df26cd 100644 --- a/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp +++ b/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp @@ -711,9 +711,8 @@ void CPDF_ContentParser::Start(CPDF_Form* pForm, TRUE); } if (pForm->m_Transparency & PDFTRANS_GROUP) { - m_pParser->GetCurStates()->m_GeneralState.MakePrivateCopy(); CPDF_GeneralStateData* pData = - m_pParser->GetCurStates()->m_GeneralState.GetObject(); + m_pParser->GetCurStates()->m_GeneralState.GetPrivateCopy(); pData->m_BlendType = FXDIB_BLEND_NORMAL; pData->m_StrokeAlpha = 1.0f; pData->m_FillAlpha = 1.0f; @@ -775,8 +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.MakePrivateCopy(); - m_pParser->GetCurStates()->m_ColorState->Default(); + m_pParser->GetCurStates()->m_ColorState.GetPrivateCopy()->Default(); } if (m_CurrentOffset >= m_Size) { m_InternalStage = STAGE_CHECKCLIP; @@ -814,8 +812,9 @@ void CPDF_ContentParser::Continue(IFX_Pause* pPause) { ClipPath.GetPointX(2), ClipPath.GetPointY(2)); CFX_FloatRect obj_rect(pObj->m_Left, pObj->m_Bottom, pObj->m_Right, pObj->m_Top); - if (old_rect.Contains(obj_rect)) - pObj->m_ClipPath.Clear(); + if (old_rect.Contains(obj_rect)) { + pObj->m_ClipPath.SetNull(); + } } m_Status = Done; return; diff --git a/core/fpdfapi/fpdf_page/include/cpdf_path.h b/core/fpdfapi/fpdf_page/include/cpdf_path.h index 33db4d755a..98de696004 100644 --- a/core/fpdfapi/fpdf_page/include/cpdf_path.h +++ b/core/fpdfapi/fpdf_page/include/cpdf_path.h @@ -27,8 +27,7 @@ class CPDF_Path : public CFX_CountRef<CFX_PathData> { FX_BOOL IsRect() const { return GetObject()->IsRect(); } void Transform(const CFX_Matrix* pMatrix) { - MakePrivateCopy(); - GetObject()->Transform(pMatrix); + GetPrivateCopy()->Transform(pMatrix); } void Append(const CPDF_Path& other, const CFX_Matrix* pMatrix) { GetObject()->Append(other.GetObject(), pMatrix); |