1 // Copyright 2016 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 
7 #include "core/fpdfapi/page/cpdf_path.h"
8 
9 CPDF_Path::CPDF_Path() = default;
10 
CPDF_Path(const CPDF_Path & that)11 CPDF_Path::CPDF_Path(const CPDF_Path& that) : m_Ref(that.m_Ref) {}
12 
13 CPDF_Path::~CPDF_Path() = default;
14 
GetPoints() const15 const std::vector<FX_PATHPOINT>& CPDF_Path::GetPoints() const {
16   return m_Ref.GetObject()->GetPoints();
17 }
18 
ClosePath()19 void CPDF_Path::ClosePath() {
20   m_Ref.GetPrivateCopy()->ClosePath();
21 }
22 
GetPoint(int index) const23 CFX_PointF CPDF_Path::GetPoint(int index) const {
24   return m_Ref.GetObject()->GetPoint(index);
25 }
26 
GetBoundingBox() const27 CFX_FloatRect CPDF_Path::GetBoundingBox() const {
28   return m_Ref.GetObject()->GetBoundingBox();
29 }
30 
GetBoundingBox(float line_width,float miter_limit) const31 CFX_FloatRect CPDF_Path::GetBoundingBox(float line_width,
32                                         float miter_limit) const {
33   return m_Ref.GetObject()->GetBoundingBox(line_width, miter_limit);
34 }
35 
IsRect() const36 bool CPDF_Path::IsRect() const {
37   return m_Ref.GetObject()->IsRect();
38 }
39 
Transform(const CFX_Matrix & matrix)40 void CPDF_Path::Transform(const CFX_Matrix& matrix) {
41   m_Ref.GetPrivateCopy()->Transform(matrix);
42 }
43 
Append(const CFX_PathData * pData,const CFX_Matrix * pMatrix)44 void CPDF_Path::Append(const CFX_PathData* pData, const CFX_Matrix* pMatrix) {
45   m_Ref.GetPrivateCopy()->Append(pData, pMatrix);
46 }
47 
AppendFloatRect(const CFX_FloatRect & rect)48 void CPDF_Path::AppendFloatRect(const CFX_FloatRect& rect) {
49   m_Ref.GetPrivateCopy()->AppendFloatRect(rect);
50 }
51 
AppendRect(float left,float bottom,float right,float top)52 void CPDF_Path::AppendRect(float left, float bottom, float right, float top) {
53   m_Ref.GetPrivateCopy()->AppendRect(left, bottom, right, top);
54 }
55 
AppendPoint(const CFX_PointF & point,FXPT_TYPE type)56 void CPDF_Path::AppendPoint(const CFX_PointF& point, FXPT_TYPE type) {
57   CFX_PathData data;
58   data.AppendPoint(point, type);
59   Append(&data, nullptr);
60 }
61 
AppendPointAndClose(const CFX_PointF & point,FXPT_TYPE type)62 void CPDF_Path::AppendPointAndClose(const CFX_PointF& point, FXPT_TYPE type) {
63   CFX_PathData data;
64   data.AppendPointAndClose(point, type);
65   Append(&data, nullptr);
66 }
67