7#include "core/fpdfapi/page/cpdf_clippath.h"
11#include "core/fpdfapi/page/cpdf_textobject.h"
22 return m_Ref.GetObject()->m_PathAndTypeList.size();
26 return m_Ref.GetObject()->m_PathAndTypeList[i].first;
30 return m_Ref.GetObject()->m_PathAndTypeList[i].second;
34 return m_Ref.GetObject()->m_TextList.size();
38 return m_Ref.GetObject()->m_TextList[i].get();
43 bool bStarted =
false;
44 if (GetPathCount() > 0) {
45 rect = GetPath(0).GetBoundingBox();
46 for (size_t i = 1; i < GetPathCount(); ++i) {
54 bool bLayerStarted =
false;
55 for (size_t i = 0; i < GetTextCount(); ++i) {
56 CPDF_TextObject* pTextObj = GetText(i);
71 bLayerStarted =
false;
79 PathData* pData = m_Ref.GetPrivateCopy();
80 pData->m_PathAndTypeList.emplace_back(path, type);
86 PathData* pData = m_Ref.GetPrivateCopy();
87 if (!pData->m_PathAndTypeList.empty()) {
88 const CPDF_Path& old_path = pData->m_PathAndTypeList.back().first;
90 CFX_PointF point0 = old_path.GetPoint(0);
91 CFX_PointF point2 = old_path.GetPoint(2);
92 CFX_FloatRect old_rect(point0.x, point0.y, point2.x, point2.y);
95 pData->m_PathAndTypeList.pop_back();
102 std::vector<std::unique_ptr<CPDF_TextObject>>* pTexts) {
103 constexpr size_t kMaxTextObjects = 1024;
104 PathData* pData = m_Ref.GetPrivateCopy();
105 if (pData->m_TextList.size() + pTexts->size() <= kMaxTextObjects) {
106 for (size_t i = 0; i < pTexts->size(); i++)
107 pData->m_TextList.push_back(
std::move((*pTexts)[i]));
108 pData->m_TextList.push_back(
nullptr);
117 for (size_t i = 0; i < that.GetPathCount(); ++i)
122 PathData* pData = m_Ref.GetPrivateCopy();
123 for (
auto& obj : pData->m_PathAndTypeList)
124 obj.first.Transform(matrix);
126 for (
auto& text : pData->m_TextList) {
128 text->Transform(matrix);
135 : m_PathAndTypeList(that.m_PathAndTypeList),
136 m_TextList(that.m_TextList.size()) {
137 for (size_t i = 0; i < that.m_TextList.size(); ++i) {
138 if (that.m_TextList[i])
139 m_TextList[i] = that.m_TextList[i]->Clone();
void Intersect(const CFX_FloatRect &other_rect)
CFX_FloatRect & operator=(const CFX_FloatRect &that)=default
bool Contains(const CFX_FloatRect &other_rect) const
void Union(const CFX_FloatRect &other_rect)
CFX_FloatRect GetClipBox() const
CPDF_TextObject * GetText(size_t i) const
CPDF_ClipPath & operator=(const CPDF_ClipPath &that)
CPDF_ClipPath(const CPDF_ClipPath &that)
void CopyClipPath(const CPDF_ClipPath &that)
void AppendPathWithAutoMerge(CPDF_Path path, CFX_FillRenderOptions::FillType type)
CFX_FillRenderOptions::FillType GetClipType(size_t i) const
size_t GetTextCount() const
void Transform(const CFX_Matrix &matrix)
bool operator==(const CPDF_ClipPath &that) const
void AppendTexts(std::vector< std::unique_ptr< CPDF_TextObject > > *pTexts)
CPDF_Path GetPath(size_t i) const
size_t GetPathCount() const
void AppendPath(CPDF_Path path, CFX_FillRenderOptions::FillType type)
CFX_FloatRect GetBoundingBox() const