blob: 613d715b033371df24f4c787de1ac3a5f39c1f1c [file] [log] [blame]
Dan Sinclair584b1e62016-03-21 09:15:45 -04001// 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
dsinclair41872fa2016-10-04 11:29:35 -07007#ifndef CORE_FPDFAPI_PAGE_CPDF_PATH_H_
8#define CORE_FPDFAPI_PAGE_CPDF_PATH_H_
Dan Sinclair584b1e62016-03-21 09:15:45 -04009
Dan Sinclaire4602322017-02-15 11:07:32 -050010#include <vector>
11
dsinclaira52ab742016-09-29 13:59:29 -070012#include "core/fxcrt/fx_system.h"
Dan Sinclair9317f8f2017-09-21 16:19:19 -040013#include "core/fxcrt/shared_copy_on_write.h"
Dan Sinclaira5085d42017-05-11 16:26:50 -040014#include "core/fxge/cfx_defaultrenderdevice.h"
dsinclair74a34fc2016-09-29 16:41:42 -070015#include "core/fxge/cfx_pathdata.h"
16#include "core/fxge/cfx_renderdevice.h"
Dan Sinclair584b1e62016-03-21 09:15:45 -040017
tsepezfc1d16f2016-09-02 15:45:22 -070018class CPDF_Path {
Dan Sinclair584b1e62016-03-21 09:15:45 -040019 public:
tsepezfc1d16f2016-09-02 15:45:22 -070020 CPDF_Path();
21 CPDF_Path(const CPDF_Path& that);
22 ~CPDF_Path();
tsepez59601432016-08-29 14:26:57 -070023
tsepezfc1d16f2016-09-02 15:45:22 -070024 void Emplace() { m_Ref.Emplace(); }
Lei Zhang0a089262017-05-10 14:00:53 -070025 bool HasRef() const { return !!m_Ref; }
tsepez59601432016-08-29 14:26:57 -070026
Dan Sinclaire4602322017-02-15 11:07:32 -050027 const std::vector<FX_PATHPOINT>& GetPoints() const;
28 void ClosePath();
tsepezfc1d16f2016-09-02 15:45:22 -070029
dan sinclairb147e072017-02-22 19:56:15 -050030 CFX_PointF GetPoint(int index) const;
tsepezfc1d16f2016-09-02 15:45:22 -070031 CFX_FloatRect GetBoundingBox() const;
Dan Sinclair05df0752017-03-14 14:43:42 -040032 CFX_FloatRect GetBoundingBox(float line_width, float miter_limit) const;
tsepezfc1d16f2016-09-02 15:45:22 -070033
tsepez12f3e4a2016-11-02 15:17:29 -070034 bool IsRect() const;
tsepezfc1d16f2016-09-02 15:45:22 -070035 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 Sinclair05df0752017-03-14 14:43:42 -040039 void AppendRect(float left, float bottom, float right, float top);
dan sinclairb147e072017-02-22 19:56:15 -050040 void AppendPoint(const CFX_PointF& point, FXPT_TYPE type, bool close);
tsepezfc1d16f2016-09-02 15:45:22 -070041
42 // TODO(tsepez): Remove when all access thru this class.
43 const CFX_PathData* GetObject() const { return m_Ref.GetObject(); }
44
45 private:
Dan Sinclair9317f8f2017-09-21 16:19:19 -040046 SharedCopyOnWrite<CFX_PathData> m_Ref;
Dan Sinclair584b1e62016-03-21 09:15:45 -040047};
48
dsinclair41872fa2016-10-04 11:29:35 -070049#endif // CORE_FPDFAPI_PAGE_CPDF_PATH_H_