1 // Copyright 2016 The PDFium Authors
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<CFX_Path::Point>& 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
GetBoundingBoxForStrokePath(float line_width,float miter_limit) const31 CFX_FloatRect CPDF_Path::GetBoundingBoxForStrokePath(float line_width,
32 float miter_limit) const {
33 return m_Ref.GetObject()->GetBoundingBoxForStrokePath(line_width,
34 miter_limit);
35 }
36
IsRect() const37 bool CPDF_Path::IsRect() const {
38 return m_Ref.GetObject()->IsRect();
39 }
40
Transform(const CFX_Matrix & matrix)41 void CPDF_Path::Transform(const CFX_Matrix& matrix) {
42 m_Ref.GetPrivateCopy()->Transform(matrix);
43 }
44
Append(const CFX_Path & path,const CFX_Matrix * pMatrix)45 void CPDF_Path::Append(const CFX_Path& path, const CFX_Matrix* pMatrix) {
46 m_Ref.GetPrivateCopy()->Append(path, pMatrix);
47 }
48
AppendFloatRect(const CFX_FloatRect & rect)49 void CPDF_Path::AppendFloatRect(const CFX_FloatRect& rect) {
50 m_Ref.GetPrivateCopy()->AppendFloatRect(rect);
51 }
52
AppendRect(float left,float bottom,float right,float top)53 void CPDF_Path::AppendRect(float left, float bottom, float right, float top) {
54 m_Ref.GetPrivateCopy()->AppendRect(left, bottom, right, top);
55 }
56
AppendPoint(const CFX_PointF & point,CFX_Path::Point::Type type)57 void CPDF_Path::AppendPoint(const CFX_PointF& point,
58 CFX_Path::Point::Type type) {
59 CFX_Path data;
60 data.AppendPoint(point, type);
61 Append(data, nullptr);
62 }
63
AppendPointAndClose(const CFX_PointF & point,CFX_Path::Point::Type type)64 void CPDF_Path::AppendPointAndClose(const CFX_PointF& point,
65 CFX_Path::Point::Type type) {
66 CFX_Path data;
67 data.AppendPointAndClose(point, type);
68 Append(data, nullptr);
69 }
70