OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 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 "../../../include/fpdfapi/fpdf_page.h" | 7 #include "../../../include/fpdfapi/fpdf_page.h" |
8 #include "../../../include/fpdfapi/fpdf_pageobj.h" | 8 #include "../../../include/fpdfapi/fpdf_pageobj.h" |
9 #include "../../../include/fpdfapi/fpdf_module.h" | 9 #include "../../../include/fpdfapi/fpdf_module.h" |
10 #include "../../../include/fpdfapi/fpdf_render.h" | 10 #include "../../../include/fpdfapi/fpdf_render.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 { | 26 { |
27 m_PathCount = 0; | 27 m_PathCount = 0; |
28 m_pPathList = NULL; | 28 m_pPathList = NULL; |
29 m_pTypeList = NULL; | 29 m_pTypeList = NULL; |
30 m_TextCount = 0; | 30 m_TextCount = 0; |
31 m_pTextList = NULL; | 31 m_pTextList = NULL; |
32 } | 32 } |
33 CPDF_ClipPathData::~CPDF_ClipPathData() | 33 CPDF_ClipPathData::~CPDF_ClipPathData() |
34 { | 34 { |
35 int i; | 35 int i; |
36 if (m_pPathList) { | 36 delete[] m_pPathList; |
37 FX_DELETE_VECTOR(m_pPathList, CPDF_Path, m_PathCount); | |
38 } | |
39 if (m_pTypeList) { | 37 if (m_pTypeList) { |
40 FX_Free(m_pTypeList); | 38 FX_Free(m_pTypeList); |
41 } | 39 } |
42 for (i = m_TextCount - 1; i > -1; i --) | 40 for (i = m_TextCount - 1; i > -1; i --) |
43 if (m_pTextList[i]) { | 41 if (m_pTextList[i]) { |
44 delete m_pTextList[i]; | 42 delete m_pTextList[i]; |
45 } | 43 } |
46 if (m_pTextList) { | 44 if (m_pTextList) { |
47 FX_Free(m_pTextList); | 45 FX_Free(m_pTextList); |
48 } | 46 } |
49 } | 47 } |
50 CPDF_ClipPathData::CPDF_ClipPathData(const CPDF_ClipPathData& src) | 48 CPDF_ClipPathData::CPDF_ClipPathData(const CPDF_ClipPathData& src) |
51 { | 49 { |
52 m_pPathList = NULL; | 50 m_pPathList = NULL; |
53 m_pPathList = NULL; | 51 m_pPathList = NULL; |
54 m_pTextList = NULL; | 52 m_pTextList = NULL; |
55 m_PathCount = src.m_PathCount; | 53 m_PathCount = src.m_PathCount; |
56 if (m_PathCount) { | 54 if (m_PathCount) { |
57 int alloc_size = m_PathCount; | 55 int alloc_size = m_PathCount; |
58 if (alloc_size % 8) { | 56 if (alloc_size % 8) { |
59 alloc_size += 8 - (alloc_size % 8); | 57 alloc_size += 8 - (alloc_size % 8); |
60 } | 58 } |
61 FX_NEW_VECTOR(m_pPathList, CPDF_Path, alloc_size); | 59 m_pPathList = new CPDF_Path[alloc_size]; |
62 for (int i = 0; i < m_PathCount; i ++) { | 60 for (int i = 0; i < m_PathCount; i ++) { |
63 m_pPathList[i] = src.m_pPathList[i]; | 61 m_pPathList[i] = src.m_pPathList[i]; |
64 } | 62 } |
65 m_pTypeList = FX_Alloc(FX_BYTE, alloc_size); | 63 m_pTypeList = FX_Alloc(FX_BYTE, alloc_size); |
66 FXSYS_memcpy32(m_pTypeList, src.m_pTypeList, m_PathCount); | 64 FXSYS_memcpy32(m_pTypeList, src.m_pTypeList, m_PathCount); |
67 } else { | 65 } else { |
68 m_pPathList = NULL; | 66 m_pPathList = NULL; |
69 m_pTypeList = NULL; | 67 m_pTypeList = NULL; |
70 } | 68 } |
71 m_TextCount = src.m_TextCount; | 69 m_TextCount = src.m_TextCount; |
(...skipping 10 matching lines...) Expand all Loading... |
82 } else { | 80 } else { |
83 m_pTextList = NULL; | 81 m_pTextList = NULL; |
84 } | 82 } |
85 } | 83 } |
86 void CPDF_ClipPathData::SetCount(int path_count, int text_count) | 84 void CPDF_ClipPathData::SetCount(int path_count, int text_count) |
87 { | 85 { |
88 ASSERT(m_TextCount == 0 && m_PathCount == 0); | 86 ASSERT(m_TextCount == 0 && m_PathCount == 0); |
89 if (path_count) { | 87 if (path_count) { |
90 m_PathCount = path_count; | 88 m_PathCount = path_count; |
91 int alloc_size = (path_count + 7) / 8 * 8; | 89 int alloc_size = (path_count + 7) / 8 * 8; |
92 FX_NEW_VECTOR(m_pPathList, CPDF_Path, alloc_size); | 90 m_pPathList = new CPDF_Path[alloc_size]; |
93 m_pTypeList = FX_Alloc(FX_BYTE, alloc_size); | 91 m_pTypeList = FX_Alloc(FX_BYTE, alloc_size); |
94 } | 92 } |
95 if (text_count) { | 93 if (text_count) { |
96 m_TextCount = text_count; | 94 m_TextCount = text_count; |
97 m_pTextList = FX_Alloc(CPDF_TextObject*, text_count); | 95 m_pTextList = FX_Alloc(CPDF_TextObject*, text_count); |
98 } | 96 } |
99 } | 97 } |
100 CPDF_Rect CPDF_ClipPath::GetClipBox() const | 98 CPDF_Rect CPDF_ClipPath::GetClipBox() const |
101 { | 99 { |
102 CPDF_Rect rect; | 100 CPDF_Rect rect; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 CPDF_Rect old_rect(old_path.GetPointX(0), old_path.GetPointY(0), | 143 CPDF_Rect old_rect(old_path.GetPointX(0), old_path.GetPointY(0), |
146 old_path.GetPointX(2), old_path.GetPointY(2)); | 144 old_path.GetPointX(2), old_path.GetPointY(2)); |
147 CPDF_Rect new_rect = path.GetBoundingBox(); | 145 CPDF_Rect new_rect = path.GetBoundingBox(); |
148 if (old_rect.Contains(new_rect)) { | 146 if (old_rect.Contains(new_rect)) { |
149 pData->m_PathCount --; | 147 pData->m_PathCount --; |
150 pData->m_pPathList[pData->m_PathCount].SetNull(); | 148 pData->m_pPathList[pData->m_PathCount].SetNull(); |
151 } | 149 } |
152 } | 150 } |
153 } | 151 } |
154 if (pData->m_PathCount % 8 == 0) { | 152 if (pData->m_PathCount % 8 == 0) { |
155 CPDF_Path* pNewPath; | 153 CPDF_Path* pNewPath = new CPDF_Path[pData->m_PathCount + 8]; |
156 FX_NEW_VECTOR(pNewPath, CPDF_Path, pData->m_PathCount + 8); | |
157 for (int i = 0; i < pData->m_PathCount; i ++) { | 154 for (int i = 0; i < pData->m_PathCount; i ++) { |
158 pNewPath[i] = pData->m_pPathList[i]; | 155 pNewPath[i] = pData->m_pPathList[i]; |
159 } | 156 } |
160 if (pData->m_pPathList) { | 157 delete[] pData->m_pPathList; |
161 FX_DELETE_VECTOR(pData->m_pPathList, CPDF_Path, pData->m_PathCount); | |
162 } | |
163 FX_BYTE* pNewType = FX_Alloc(FX_BYTE, pData->m_PathCount + 8); | 158 FX_BYTE* pNewType = FX_Alloc(FX_BYTE, pData->m_PathCount + 8); |
164 FXSYS_memcpy32(pNewType, pData->m_pTypeList, pData->m_PathCount); | 159 FXSYS_memcpy32(pNewType, pData->m_pTypeList, pData->m_PathCount); |
165 if (pData->m_pTypeList) { | 160 if (pData->m_pTypeList) { |
166 FX_Free(pData->m_pTypeList); | 161 FX_Free(pData->m_pTypeList); |
167 } | 162 } |
168 pData->m_pPathList = pNewPath; | 163 pData->m_pPathList = pNewPath; |
169 pData->m_pTypeList = pNewType; | 164 pData->m_pTypeList = pNewType; |
170 } | 165 } |
171 pData->m_pPathList[pData->m_PathCount] = path; | 166 pData->m_pPathList[pData->m_PathCount] = path; |
172 pData->m_pTypeList[pData->m_PathCount] = (FX_BYTE)type; | 167 pData->m_pTypeList[pData->m_PathCount] = (FX_BYTE)type; |
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
706 pDict = NULL; | 701 pDict = NULL; |
707 if (item.GetParamType() == CPDF_ContentMarkItem::PropertiesDict || | 702 if (item.GetParamType() == CPDF_ContentMarkItem::PropertiesDict || |
708 item.GetParamType() == CPDF_ContentMarkItem::DirectDict) { | 703 item.GetParamType() == CPDF_ContentMarkItem::DirectDict) { |
709 pDict = (CPDF_Dictionary*)item.GetParam(); | 704 pDict = (CPDF_Dictionary*)item.GetParam(); |
710 } | 705 } |
711 return TRUE; | 706 return TRUE; |
712 } | 707 } |
713 } | 708 } |
714 return FALSE; | 709 return FALSE; |
715 } | 710 } |
OLD | NEW |