1 // Copyright 2016 The PDFium Authors 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/retain_ptr.h" 17 #include "core/fxcrt/shared_copy_on_write.h" 18 #include "core/fxge/cfx_fillrenderoptions.h" 19 20 class CPDF_TextObject; 21 22 class CPDF_ClipPath { 23 public: 24 CPDF_ClipPath(); 25 CPDF_ClipPath(const CPDF_ClipPath& that); 26 CPDF_ClipPath& operator=(const CPDF_ClipPath& that); 27 ~CPDF_ClipPath(); 28 Emplace()29 void Emplace() { m_Ref.Emplace(); } SetNull()30 void SetNull() { m_Ref.SetNull(); } 31 HasRef()32 bool HasRef() const { return !!m_Ref; } 33 bool operator==(const CPDF_ClipPath& that) const { 34 return m_Ref == that.m_Ref; 35 } 36 bool operator!=(const CPDF_ClipPath& that) const { return !(*this == that); } 37 38 size_t GetPathCount() const; 39 CPDF_Path GetPath(size_t i) const; 40 CFX_FillRenderOptions::FillType GetClipType(size_t i) const; 41 size_t GetTextCount() const; 42 CPDF_TextObject* GetText(size_t i) const; 43 CFX_FloatRect GetClipBox() const; 44 void AppendPath(CPDF_Path path, CFX_FillRenderOptions::FillType type); 45 void AppendPathWithAutoMerge(CPDF_Path path, 46 CFX_FillRenderOptions::FillType type); 47 void AppendTexts(std::vector<std::unique_ptr<CPDF_TextObject>>* pTexts); 48 void CopyClipPath(const CPDF_ClipPath& that); 49 void Transform(const CFX_Matrix& matrix); 50 51 private: 52 class PathData final : public Retainable { 53 public: 54 CONSTRUCT_VIA_MAKE_RETAIN; 55 56 RetainPtr<PathData> Clone() const; 57 58 using PathAndTypeData = 59 std::pair<CPDF_Path, CFX_FillRenderOptions::FillType>; 60 61 std::vector<PathAndTypeData> m_PathAndTypeList; 62 std::vector<std::unique_ptr<CPDF_TextObject>> m_TextList; 63 64 private: 65 PathData(); 66 PathData(const PathData& that); 67 ~PathData() override; 68 }; 69 70 SharedCopyOnWrite<PathData> m_Ref; 71 }; 72 73 #endif // CORE_FPDFAPI_PAGE_CPDF_CLIPPATH_H_ 74