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_Path; 19 class CPDF_TextObject; 20 21 class CPDF_ClipPath { 22 public: 23 CPDF_ClipPath(); 24 CPDF_ClipPath(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 Transform(const CFX_Matrix& matrix); 45 46 private: 47 class PathData : public Retainable { 48 public: 49 using PathAndTypeData = std::pair<CPDF_Path, uint8_t>; 50 51 PathData(); 52 PathData(const PathData& that); 53 ~PathData() override; 54 55 std::vector<PathAndTypeData> m_PathAndTypeList; 56 std::vector<std::unique_ptr<CPDF_TextObject>> m_TextList; 57 }; 58 59 SharedCopyOnWrite<PathData> m_Ref; 60 }; 61 62 #endif // CORE_FPDFAPI_PAGE_CPDF_CLIPPATH_H_ 63