Dan Sinclair | 584b1e6 | 2016-03-21 09:15:45 -0400 | [diff] [blame] | 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 | |
dsinclair | 41872fa | 2016-10-04 11:29:35 -0700 | [diff] [blame] | 7 | #ifndef CORE_FPDFAPI_PAGE_CPDF_PATH_H_ |
| 8 | #define CORE_FPDFAPI_PAGE_CPDF_PATH_H_ |
Dan Sinclair | 584b1e6 | 2016-03-21 09:15:45 -0400 | [diff] [blame] | 9 | |
Dan Sinclair | e460232 | 2017-02-15 11:07:32 -0500 | [diff] [blame] | 10 | #include <vector> |
| 11 | |
dsinclair | a52ab74 | 2016-09-29 13:59:29 -0700 | [diff] [blame] | 12 | #include "core/fxcrt/fx_system.h" |
Dan Sinclair | 9317f8f | 2017-09-21 16:19:19 -0400 | [diff] [blame] | 13 | #include "core/fxcrt/shared_copy_on_write.h" |
Dan Sinclair | a5085d4 | 2017-05-11 16:26:50 -0400 | [diff] [blame] | 14 | #include "core/fxge/cfx_defaultrenderdevice.h" |
dsinclair | 74a34fc | 2016-09-29 16:41:42 -0700 | [diff] [blame] | 15 | #include "core/fxge/cfx_pathdata.h" |
| 16 | #include "core/fxge/cfx_renderdevice.h" |
Dan Sinclair | 584b1e6 | 2016-03-21 09:15:45 -0400 | [diff] [blame] | 17 | |
tsepez | fc1d16f | 2016-09-02 15:45:22 -0700 | [diff] [blame] | 18 | class CPDF_Path { |
Dan Sinclair | 584b1e6 | 2016-03-21 09:15:45 -0400 | [diff] [blame] | 19 | public: |
tsepez | fc1d16f | 2016-09-02 15:45:22 -0700 | [diff] [blame] | 20 | CPDF_Path(); |
| 21 | CPDF_Path(const CPDF_Path& that); |
| 22 | ~CPDF_Path(); |
tsepez | 5960143 | 2016-08-29 14:26:57 -0700 | [diff] [blame] | 23 | |
tsepez | fc1d16f | 2016-09-02 15:45:22 -0700 | [diff] [blame] | 24 | void Emplace() { m_Ref.Emplace(); } |
Lei Zhang | 0a08926 | 2017-05-10 14:00:53 -0700 | [diff] [blame] | 25 | bool HasRef() const { return !!m_Ref; } |
tsepez | 5960143 | 2016-08-29 14:26:57 -0700 | [diff] [blame] | 26 | |
Dan Sinclair | e460232 | 2017-02-15 11:07:32 -0500 | [diff] [blame] | 27 | const std::vector<FX_PATHPOINT>& GetPoints() const; |
| 28 | void ClosePath(); |
tsepez | fc1d16f | 2016-09-02 15:45:22 -0700 | [diff] [blame] | 29 | |
dan sinclair | b147e07 | 2017-02-22 19:56:15 -0500 | [diff] [blame] | 30 | CFX_PointF GetPoint(int index) const; |
tsepez | fc1d16f | 2016-09-02 15:45:22 -0700 | [diff] [blame] | 31 | CFX_FloatRect GetBoundingBox() const; |
Dan Sinclair | 05df075 | 2017-03-14 14:43:42 -0400 | [diff] [blame] | 32 | CFX_FloatRect GetBoundingBox(float line_width, float miter_limit) const; |
tsepez | fc1d16f | 2016-09-02 15:45:22 -0700 | [diff] [blame] | 33 | |
tsepez | 12f3e4a | 2016-11-02 15:17:29 -0700 | [diff] [blame] | 34 | bool IsRect() const; |
tsepez | fc1d16f | 2016-09-02 15:45:22 -0700 | [diff] [blame] | 35 | void Transform(const CFX_Matrix* pMatrix); |
| 36 | |
| 37 | void Append(const CPDF_Path& other, const CFX_Matrix* pMatrix); |
| 38 | void Append(const CFX_PathData* pData, const CFX_Matrix* pMatrix); |
Dan Sinclair | 05df075 | 2017-03-14 14:43:42 -0400 | [diff] [blame] | 39 | void AppendRect(float left, float bottom, float right, float top); |
dan sinclair | b147e07 | 2017-02-22 19:56:15 -0500 | [diff] [blame] | 40 | void AppendPoint(const CFX_PointF& point, FXPT_TYPE type, bool close); |
tsepez | fc1d16f | 2016-09-02 15:45:22 -0700 | [diff] [blame] | 41 | |
| 42 | // TODO(tsepez): Remove when all access thru this class. |
| 43 | const CFX_PathData* GetObject() const { return m_Ref.GetObject(); } |
| 44 | |
| 45 | private: |
Dan Sinclair | 9317f8f | 2017-09-21 16:19:19 -0400 | [diff] [blame] | 46 | SharedCopyOnWrite<CFX_PathData> m_Ref; |
Dan Sinclair | 584b1e6 | 2016-03-21 09:15:45 -0400 | [diff] [blame] | 47 | }; |
| 48 | |
dsinclair | 41872fa | 2016-10-04 11:29:35 -0700 | [diff] [blame] | 49 | #endif // CORE_FPDFAPI_PAGE_CPDF_PATH_H_ |