summaryrefslogtreecommitdiff
path: root/core/fpdfapi/page
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-02-15 11:07:32 -0500
committerChromium commit bot <commit-bot@chromium.org>2017-02-15 17:47:57 +0000
commite4602321f3175fa5addb6761d0e94f5c2fc93d0c (patch)
tree6671774659645fad6d9ce55a5910b4665a25094f /core/fpdfapi/page
parenteb55885e9a9eec670ed98cbd12dc96d63e6a6623 (diff)
downloadpdfium-e4602321f3175fa5addb6761d0e94f5c2fc93d0c.tar.xz
Cleanup CFX_PathData.
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 <npm@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fpdfapi/page')
-rw-r--r--core/fpdfapi/page/cpdf_path.cpp17
-rw-r--r--core/fpdfapi/page/cpdf_path.h8
-rw-r--r--core/fpdfapi/page/cpdf_streamcontentparser.cpp10
3 files changed, 15 insertions, 20 deletions
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<FX_PATHPOINT>& 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 <vector>
+
#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<FX_PATHPOINT>& 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) {