OLD | NEW |
1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "core/fpdfapi/fpdf_page/include/cpdf_clippath.h" | 7 #include "core/fpdfapi/fpdf_page/include/cpdf_clippath.h" |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 } else { | 66 } else { |
67 layer_rect.Union(CFX_FloatRect(pTextObj->GetBBox(nullptr))); | 67 layer_rect.Union(CFX_FloatRect(pTextObj->GetBBox(nullptr))); |
68 } | 68 } |
69 } | 69 } |
70 } | 70 } |
71 } | 71 } |
72 return rect; | 72 return rect; |
73 } | 73 } |
74 | 74 |
75 void CPDF_ClipPath::AppendPath(CPDF_Path path, uint8_t type, bool bAutoMerge) { | 75 void CPDF_ClipPath::AppendPath(CPDF_Path path, uint8_t type, bool bAutoMerge) { |
76 CPDF_ClipPathData* pData = GetPrivateCopy(); | 76 MakePrivateCopy(); |
| 77 CPDF_ClipPathData* pData = GetObject(); |
77 if (!pData->m_PathAndTypeList.empty() && bAutoMerge) { | 78 if (!pData->m_PathAndTypeList.empty() && bAutoMerge) { |
78 const CPDF_Path& old_path = pData->m_PathAndTypeList.back().first; | 79 const CPDF_Path& old_path = pData->m_PathAndTypeList.back().first; |
79 if (old_path.IsRect()) { | 80 if (old_path.IsRect()) { |
80 CFX_FloatRect old_rect(old_path.GetPointX(0), old_path.GetPointY(0), | 81 CFX_FloatRect old_rect(old_path.GetPointX(0), old_path.GetPointY(0), |
81 old_path.GetPointX(2), old_path.GetPointY(2)); | 82 old_path.GetPointX(2), old_path.GetPointY(2)); |
82 CFX_FloatRect new_rect = path.GetBoundingBox(); | 83 CFX_FloatRect new_rect = path.GetBoundingBox(); |
83 if (old_rect.Contains(new_rect)) | 84 if (old_rect.Contains(new_rect)) |
84 pData->m_PathAndTypeList.pop_back(); | 85 pData->m_PathAndTypeList.pop_back(); |
85 } | 86 } |
86 } | 87 } |
87 pData->m_PathAndTypeList.push_back(std::make_pair(path, type)); | 88 pData->m_PathAndTypeList.push_back(std::make_pair(path, type)); |
88 } | 89 } |
89 | 90 |
90 void CPDF_ClipPath::AppendTexts( | 91 void CPDF_ClipPath::AppendTexts( |
91 std::vector<std::unique_ptr<CPDF_TextObject>>* pTexts) { | 92 std::vector<std::unique_ptr<CPDF_TextObject>>* pTexts) { |
92 CPDF_ClipPathData* pData = GetPrivateCopy(); | 93 MakePrivateCopy(); |
| 94 CPDF_ClipPathData* pData = GetObject(); |
93 if (pData->m_TextList.size() + pTexts->size() <= FPDF_CLIPPATH_MAX_TEXTS) { | 95 if (pData->m_TextList.size() + pTexts->size() <= FPDF_CLIPPATH_MAX_TEXTS) { |
94 for (size_t i = 0; i < pTexts->size(); i++) | 96 for (size_t i = 0; i < pTexts->size(); i++) |
95 pData->m_TextList.push_back(std::move((*pTexts)[i])); | 97 pData->m_TextList.push_back(std::move((*pTexts)[i])); |
96 pData->m_TextList.push_back(std::unique_ptr<CPDF_TextObject>()); | 98 pData->m_TextList.push_back(std::unique_ptr<CPDF_TextObject>()); |
97 } | 99 } |
98 pTexts->clear(); | 100 pTexts->clear(); |
99 } | 101 } |
100 | 102 |
101 void CPDF_ClipPath::Transform(const CFX_Matrix& matrix) { | 103 void CPDF_ClipPath::Transform(const CFX_Matrix& matrix) { |
102 CPDF_ClipPathData* pData = GetPrivateCopy(); | 104 MakePrivateCopy(); |
| 105 CPDF_ClipPathData* pData = GetObject(); |
103 for (auto& obj : pData->m_PathAndTypeList) | 106 for (auto& obj : pData->m_PathAndTypeList) |
104 obj.first.Transform(&matrix); | 107 obj.first.Transform(&matrix); |
105 for (auto& text : pData->m_TextList) { | 108 for (auto& text : pData->m_TextList) { |
106 if (text) | 109 if (text) |
107 text->Transform(matrix); | 110 text->Transform(matrix); |
108 } | 111 } |
109 } | 112 } |
OLD | NEW |