Chromium Code Reviews| 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/cpdf_clippathdata.h" | 7 #include "core/fpdfapi/fpdf_page/cpdf_clippathdata.h" |
| 8 | 8 |
| 9 #include "core/fpdfapi/fpdf_page/include/cpdf_path.h" | 9 #include "core/fpdfapi/fpdf_page/include/cpdf_path.h" |
| 10 #include "core/fpdfapi/fpdf_page/include/cpdf_textobject.h" | 10 #include "core/fpdfapi/fpdf_page/include/cpdf_textobject.h" |
| 11 | 11 |
| 12 CPDF_ClipPathData::CPDF_ClipPathData() | 12 CPDF_ClipPathData::CPDF_ClipPathData() {} |
| 13 : m_PathCount(0), | |
| 14 m_pPathList(nullptr), | |
| 15 m_pTypeList(nullptr), | |
| 16 m_TextCount(0), | |
| 17 m_pTextList(nullptr) {} | |
| 18 | 13 |
| 19 CPDF_ClipPathData::~CPDF_ClipPathData() { | 14 CPDF_ClipPathData::~CPDF_ClipPathData() {} |
| 20 delete[] m_pPathList; | |
| 21 FX_Free(m_pTypeList); | |
| 22 | |
| 23 for (int i = m_TextCount - 1; i > -1; i--) | |
| 24 delete m_pTextList[i]; | |
| 25 FX_Free(m_pTextList); | |
| 26 } | |
| 27 | 15 |
| 28 CPDF_ClipPathData::CPDF_ClipPathData(const CPDF_ClipPathData& src) { | 16 CPDF_ClipPathData::CPDF_ClipPathData(const CPDF_ClipPathData& src) { |
| 29 m_pPathList = nullptr; | 17 m_PathList = src.m_PathList; |
| 30 m_pPathList = nullptr; | 18 m_TypeList = src.m_TypeList; |
| 31 m_pTextList = nullptr; | |
| 32 | 19 |
| 33 m_PathCount = src.m_PathCount; | 20 m_TextList.resize(src.m_TextList.size()); |
| 34 if (m_PathCount) { | 21 for (size_t i = 0; i < src.m_TextList.size(); ++i) { |
| 35 int alloc_size = m_PathCount; | 22 if (src.m_TextList[i]) |
| 36 if (alloc_size % 8) | 23 m_TextList[i].reset(src.m_TextList[i]->Clone()); |
| 37 alloc_size += 8 - (alloc_size % 8); | |
| 38 | |
| 39 m_pPathList = new CPDF_Path[alloc_size]; | |
| 40 for (int i = 0; i < m_PathCount; i++) | |
| 41 m_pPathList[i] = src.m_pPathList[i]; | |
| 42 | |
| 43 m_pTypeList = FX_Alloc(uint8_t, alloc_size); | |
| 44 FXSYS_memcpy(m_pTypeList, src.m_pTypeList, m_PathCount); | |
| 45 } else { | |
| 46 m_pPathList = nullptr; | |
| 47 m_pTypeList = nullptr; | |
| 48 } | |
| 49 | |
| 50 m_TextCount = src.m_TextCount; | |
| 51 if (m_TextCount) { | |
| 52 m_pTextList = FX_Alloc(CPDF_TextObject*, m_TextCount); | |
| 53 for (int i = 0; i < m_TextCount; i++) { | |
| 54 if (src.m_pTextList[i]) | |
| 55 m_pTextList[i] = src.m_pTextList[i]->Clone(); | |
| 56 else | |
| 57 m_pTextList[i] = nullptr; | |
| 58 } | |
| 59 } else { | |
| 60 m_pTextList = nullptr; | |
| 61 } | 24 } |
| 62 } | 25 } |
| 63 | |
| 64 void CPDF_ClipPathData::SetCount(int path_count, int text_count) { | |
|
Lei Zhang
2016/05/19 17:28:45
Dead code.
| |
| 65 ASSERT(m_TextCount == 0 && m_PathCount == 0); | |
| 66 if (path_count) { | |
| 67 m_PathCount = path_count; | |
| 68 int alloc_size = (path_count + 7) / 8 * 8; | |
| 69 m_pPathList = new CPDF_Path[alloc_size]; | |
| 70 m_pTypeList = FX_Alloc(uint8_t, alloc_size); | |
| 71 } | |
| 72 | |
| 73 if (text_count) { | |
| 74 m_TextCount = text_count; | |
| 75 m_pTextList = FX_Alloc(CPDF_TextObject*, text_count); | |
| 76 } | |
| 77 } | |
| OLD | NEW |