From 4d9df422c340b3bc33e044d3d94e1ff9582e1260 Mon Sep 17 00:00:00 2001 From: tsepez Date: Wed, 31 Aug 2016 10:26:38 -0700 Subject: Make CPDF_GraphState have a CPDF_GraphStateData instead of inheriting. Get callers out of the copy-before-write business, and let the class manage it instead. Review-Url: https://codereview.chromium.org/2292363002 --- core/fpdfapi/fpdf_page/cpdf_allstates.cpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'core/fpdfapi/fpdf_page/cpdf_allstates.cpp') diff --git a/core/fpdfapi/fpdf_page/cpdf_allstates.cpp b/core/fpdfapi/fpdf_page/cpdf_allstates.cpp index e01b379bed..acecafd01e 100644 --- a/core/fpdfapi/fpdf_page/cpdf_allstates.cpp +++ b/core/fpdfapi/fpdf_page/cpdf_allstates.cpp @@ -45,11 +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.GetPrivateCopy(); - pData->m_DashPhase = phase * scale; - pData->SetDashCount(static_cast(pArray->GetCount())); - for (size_t i = 0; i < pArray->GetCount(); i++) - pData->m_DashArray[i] = pArray->GetNumberAt(i) * scale; + m_GraphState.SetLineDash(pArray, phase, scale); } void CPDF_AllStates::ProcessExtGS(CPDF_Dictionary* pGS, @@ -65,18 +61,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.GetPrivateCopy()->m_LineWidth = pObject->GetNumber(); + m_GraphState.SetLineWidth(pObject->GetNumber()); break; case FXBSTR_ID('L', 'C', 0, 0): - m_GraphState.GetPrivateCopy()->m_LineCap = - (CFX_GraphStateData::LineCap)pObject->GetInteger(); + m_GraphState.SetLineCap( + static_cast(pObject->GetInteger())); break; case FXBSTR_ID('L', 'J', 0, 0): - m_GraphState.GetPrivateCopy()->m_LineJoin = - (CFX_GraphStateData::LineJoin)pObject->GetInteger(); + m_GraphState.SetLineJoin( + static_cast(pObject->GetInteger())); break; case FXBSTR_ID('M', 'L', 0, 0): - m_GraphState.GetPrivateCopy()->m_MiterLimit = pObject->GetNumber(); + m_GraphState.SetMiterLimit(pObject->GetNumber()); break; case FXBSTR_ID('D', 0, 0, 0): { CPDF_Array* pDash = pObject->AsArray(); -- cgit v1.2.3