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/page/cpdf_clippath.h" | 7 #include "core/fpdfapi/page/cpdf_clippath.h" |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 } | 93 } |
94 pData->m_PathAndTypeList.push_back(std::make_pair(path, type)); | 94 pData->m_PathAndTypeList.push_back(std::make_pair(path, type)); |
95 } | 95 } |
96 | 96 |
97 void CPDF_ClipPath::AppendTexts( | 97 void CPDF_ClipPath::AppendTexts( |
98 std::vector<std::unique_ptr<CPDF_TextObject>>* pTexts) { | 98 std::vector<std::unique_ptr<CPDF_TextObject>>* pTexts) { |
99 PathData* pData = m_Ref.GetPrivateCopy(); | 99 PathData* pData = m_Ref.GetPrivateCopy(); |
100 if (pData->m_TextList.size() + pTexts->size() <= FPDF_CLIPPATH_MAX_TEXTS) { | 100 if (pData->m_TextList.size() + pTexts->size() <= FPDF_CLIPPATH_MAX_TEXTS) { |
101 for (size_t i = 0; i < pTexts->size(); i++) | 101 for (size_t i = 0; i < pTexts->size(); i++) |
102 pData->m_TextList.push_back(std::move((*pTexts)[i])); | 102 pData->m_TextList.push_back(std::move((*pTexts)[i])); |
103 pData->m_TextList.push_back(std::unique_ptr<CPDF_TextObject>()); | 103 pData->m_TextList.push_back(nullptr); |
104 } | 104 } |
105 pTexts->clear(); | 105 pTexts->clear(); |
106 } | 106 } |
107 | 107 |
108 void CPDF_ClipPath::Transform(const CFX_Matrix& matrix) { | 108 void CPDF_ClipPath::Transform(const CFX_Matrix& matrix) { |
109 PathData* pData = m_Ref.GetPrivateCopy(); | 109 PathData* pData = m_Ref.GetPrivateCopy(); |
110 for (auto& obj : pData->m_PathAndTypeList) | 110 for (auto& obj : pData->m_PathAndTypeList) |
111 obj.first.Transform(&matrix); | 111 obj.first.Transform(&matrix); |
112 for (auto& text : pData->m_TextList) { | 112 for (auto& text : pData->m_TextList) { |
113 if (text) | 113 if (text) |
114 text->Transform(matrix); | 114 text->Transform(matrix); |
115 } | 115 } |
116 } | 116 } |
117 | 117 |
118 CPDF_ClipPath::PathData::PathData() {} | 118 CPDF_ClipPath::PathData::PathData() {} |
119 | 119 |
120 CPDF_ClipPath::PathData::PathData(const PathData& that) { | 120 CPDF_ClipPath::PathData::PathData(const PathData& that) { |
121 m_PathAndTypeList = that.m_PathAndTypeList; | 121 m_PathAndTypeList = that.m_PathAndTypeList; |
122 | 122 |
123 m_TextList.resize(that.m_TextList.size()); | 123 m_TextList.resize(that.m_TextList.size()); |
124 for (size_t i = 0; i < that.m_TextList.size(); ++i) { | 124 for (size_t i = 0; i < that.m_TextList.size(); ++i) { |
125 if (that.m_TextList[i]) | 125 if (that.m_TextList[i]) |
126 m_TextList[i].reset(that.m_TextList[i]->Clone()); | 126 m_TextList[i].reset(that.m_TextList[i]->Clone()); |
127 } | 127 } |
128 } | 128 } |
129 | 129 |
130 CPDF_ClipPath::PathData::~PathData() {} | 130 CPDF_ClipPath::PathData::~PathData() {} |
OLD | NEW |