• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 {
33  public:
34   CFX_PathData();
35   CFX_PathData(const CFX_PathData& src);
36   ~CFX_PathData();
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(FX_FLOAT line_width, FX_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(FX_FLOAT left, FX_FLOAT bottom, FX_FLOAT right, FX_FLOAT top);
63   void AppendPoint(const CFX_PointF& pos, FXPT_TYPE type, bool closeFigure);
64   void ClosePath();
65 
66  private:
67   std::vector<FX_PATHPOINT> m_Points;
68 };
69 
70 #endif  // CORE_FXGE_CFX_PATHDATA_H_
71