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 #ifndef CORE_FXGE_CFX_PATHDATA_H_ 8 #define CORE_FXGE_CFX_PATHDATA_H_ 9 10 #include <vector> 11 12 #include "core/fxcrt/fx_coordinates.h" 13 #include "core/fxcrt/fx_system.h" 14 #include "core/fxge/cfx_renderdevice.h" 15 16 class FX_PATHPOINT { 17 public: 18 FX_PATHPOINT(); 19 FX_PATHPOINT(const CFX_PointF& point, FXPT_TYPE type, bool close); 20 FX_PATHPOINT(const FX_PATHPOINT& other); 21 ~FX_PATHPOINT(); 22 IsTypeAndOpen(FXPT_TYPE type)23 bool IsTypeAndOpen(FXPT_TYPE type) const { 24 return m_Type == type && !m_CloseFigure; 25 } 26 27 CFX_PointF m_Point; 28 FXPT_TYPE m_Type; 29 bool m_CloseFigure; 30 }; 31 32 class CFX_PathData : public Retainable { 33 public: 34 CFX_PathData(); 35 CFX_PathData(const CFX_PathData& src); 36 ~CFX_PathData() override; 37 38 void Clear(); 39 GetType(int index)40 FXPT_TYPE GetType(int index) const { return m_Points[index].m_Type; } IsClosingFigure(int index)41 bool IsClosingFigure(int index) const { 42 return m_Points[index].m_CloseFigure; 43 } 44 GetPoint(int index)45 CFX_PointF GetPoint(int index) const { return m_Points[index].m_Point; } GetPoints()46 const std::vector<FX_PATHPOINT>& GetPoints() const { return m_Points; } GetPoints()47 std::vector<FX_PATHPOINT>& GetPoints() { return m_Points; } 48 49 CFX_FloatRect GetBoundingBox() const; 50 CFX_FloatRect GetBoundingBox(float line_width, float miter_limit) const; 51 52 void Transform(const CFX_Matrix* pMatrix); 53 bool IsRect() const; 54 bool GetZeroAreaPath(const CFX_Matrix* pMatrix, 55 bool bAdjust, 56 CFX_PathData* NewPath, 57 bool* bThin, 58 bool* setIdentity) const; 59 bool IsRect(const CFX_Matrix* pMatrix, CFX_FloatRect* rect) const; 60 61 void Append(const CFX_PathData* pSrc, const CFX_Matrix* pMatrix); 62 void AppendRect(float left, float bottom, float right, float top); 63 void AppendLine(const CFX_PointF& pt1, const CFX_PointF& pt2); 64 void AppendPoint(const CFX_PointF& pos, FXPT_TYPE type, bool closeFigure); 65 void ClosePath(); 66 67 private: 68 std::vector<FX_PATHPOINT> m_Points; 69 }; 70 71 #endif // CORE_FXGE_CFX_PATHDATA_H_ 72