From e4602321f3175fa5addb6761d0e94f5c2fc93d0c Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Wed, 15 Feb 2017 11:07:32 -0500 Subject: Cleanup CFX_PathData. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This CL replaces the array of path points with a vector. Cleaning up the usage as required. Change-Id: Ifa386a2c847005fef68af748ebe99c4e08961238 Reviewed-on: https://pdfium-review.googlesource.com/2710 Reviewed-by: Nicolás Peña Reviewed-by: Tom Sepez Commit-Queue: dsinclair --- core/fpdfapi/page/cpdf_path.cpp | 17 ++++------------- core/fpdfapi/page/cpdf_path.h | 8 ++++---- core/fpdfapi/page/cpdf_streamcontentparser.cpp | 10 +++++++--- 3 files changed, 15 insertions(+), 20 deletions(-) (limited to 'core/fpdfapi/page') diff --git a/core/fpdfapi/page/cpdf_path.cpp b/core/fpdfapi/page/cpdf_path.cpp index 96d6b72abb..a95ce1e5bc 100644 --- a/core/fpdfapi/page/cpdf_path.cpp +++ b/core/fpdfapi/page/cpdf_path.cpp @@ -12,20 +12,12 @@ CPDF_Path::CPDF_Path(const CPDF_Path& that) : m_Ref(that.m_Ref) {} CPDF_Path::~CPDF_Path() {} -int CPDF_Path::GetPointCount() const { - return m_Ref.GetObject()->GetPointCount(); -} - -void CPDF_Path::SetPointCount(int count) { - m_Ref.GetPrivateCopy()->SetPointCount(count); -} - -const FX_PATHPOINT* CPDF_Path::GetPoints() const { +const std::vector& CPDF_Path::GetPoints() const { return m_Ref.GetObject()->GetPoints(); } -FX_PATHPOINT* CPDF_Path::GetMutablePoints() { - return m_Ref.GetPrivateCopy()->GetPoints(); +void CPDF_Path::ClosePath() { + m_Ref.GetPrivateCopy()->ClosePath(); } FX_FLOAT CPDF_Path::GetPointX(int index) const { @@ -73,7 +65,6 @@ void CPDF_Path::AppendPoint(FX_FLOAT x, FXPT_TYPE type, bool close) { CFX_PathData data; - data.SetPointCount(1); - data.SetPoint(0, x, y, type, close); + data.AppendPoint(x, y, type, close); Append(&data, nullptr); } diff --git a/core/fpdfapi/page/cpdf_path.h b/core/fpdfapi/page/cpdf_path.h index 21a94becac..97dd8fd8a9 100644 --- a/core/fpdfapi/page/cpdf_path.h +++ b/core/fpdfapi/page/cpdf_path.h @@ -7,6 +7,8 @@ #ifndef CORE_FPDFAPI_PAGE_CPDF_PATH_H_ #define CORE_FPDFAPI_PAGE_CPDF_PATH_H_ +#include + #include "core/fxcrt/cfx_shared_copy_on_write.h" #include "core/fxcrt/fx_system.h" #include "core/fxge/cfx_fxgedevice.h" @@ -22,10 +24,8 @@ class CPDF_Path { void Emplace() { m_Ref.Emplace(); } explicit operator bool() const { return !!m_Ref; } - int GetPointCount() const; - void SetPointCount(int count); - const FX_PATHPOINT* GetPoints() const; - FX_PATHPOINT* GetMutablePoints(); + const std::vector& GetPoints() const; + void ClosePath(); FX_FLOAT GetPointX(int index) const; FX_FLOAT GetPointY(int index) const; diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp index 0af43d08b2..e991e456b7 100644 --- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp +++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp @@ -1506,10 +1506,14 @@ void CPDF_StreamContentParser::AddPathObject(int FillType, bool bStroke) { m_pPathPoints[PathPointCount - 1].IsTypeAndOpen(FXPT_TYPE::MoveTo)) { PathPointCount--; } + CPDF_Path Path; - Path.SetPointCount(PathPointCount); - FXSYS_memcpy(Path.GetMutablePoints(), m_pPathPoints, - sizeof(FX_PATHPOINT) * PathPointCount); + for (int i = 0; i < PathPointCount; i++) { + FX_PATHPOINT& point = m_pPathPoints[i]; + Path.AppendPoint(point.m_PointX, point.m_PointY, point.m_Type, + point.m_CloseFigure); + } + CFX_Matrix matrix = m_pCurStates->m_CTM; matrix.Concat(m_mtContentToUser); if (bStroke || FillType) { -- cgit v1.2.3