• 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_FPDFAPI_PAGE_CPDF_CLIPPATH_H_
8 #define CORE_FPDFAPI_PAGE_CPDF_CLIPPATH_H_
9 
10 #include <memory>
11 #include <utility>
12 #include <vector>
13 
14 #include "core/fpdfapi/page/cpdf_path.h"
15 #include "core/fxcrt/fx_coordinates.h"
16 #include "core/fxcrt/shared_copy_on_write.h"
17 
18 class CPDF_TextObject;
19 
20 class CPDF_ClipPath {
21  public:
22   CPDF_ClipPath();
23   CPDF_ClipPath(const CPDF_ClipPath& that);
24   CPDF_ClipPath& operator=(const CPDF_ClipPath& that);
25   ~CPDF_ClipPath();
26 
Emplace()27   void Emplace() { m_Ref.Emplace(); }
SetNull()28   void SetNull() { m_Ref.SetNull(); }
29 
HasRef()30   bool HasRef() const { return !!m_Ref; }
31   bool operator==(const CPDF_ClipPath& that) const {
32     return m_Ref == that.m_Ref;
33   }
34   bool operator!=(const CPDF_ClipPath& that) const { return !(*this == that); }
35 
36   size_t GetPathCount() const;
37   CPDF_Path GetPath(size_t i) const;
38   uint8_t GetClipType(size_t i) const;
39   size_t GetTextCount() const;
40   CPDF_TextObject* GetText(size_t i) const;
41   CFX_FloatRect GetClipBox() const;
42   void AppendPath(CPDF_Path path, uint8_t type, bool bAutoMerge);
43   void AppendTexts(std::vector<std::unique_ptr<CPDF_TextObject>>* pTexts);
44   void CopyClipPath(const CPDF_ClipPath& that);
45   void Transform(const CFX_Matrix& matrix);
46 
47  private:
48   class PathData final : public Retainable {
49    public:
50     template <typename T, typename... Args>
51     friend RetainPtr<T> pdfium::MakeRetain(Args&&... args);
52 
53     RetainPtr<PathData> Clone() const;
54 
55     using PathAndTypeData = std::pair<CPDF_Path, uint8_t>;
56 
57     std::vector<PathAndTypeData> m_PathAndTypeList;
58     std::vector<std::unique_ptr<CPDF_TextObject>> m_TextList;
59 
60    private:
61     PathData();
62     PathData(const PathData& that);
63     ~PathData() override;
64   };
65 
66   SharedCopyOnWrite<PathData> m_Ref;
67 };
68 
69 #endif  // CORE_FPDFAPI_PAGE_CPDF_CLIPPATH_H_
70