Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(723)

Side by Side Diff: core/fpdfapi/fpdf_cmaps/fpdf_cmaps.cpp

Issue 1832173003: Remove FX_DWORD from core/ and delete definition (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "core/fpdfapi/fpdf_cmaps/cmap_int.h" 7 #include "core/fpdfapi/fpdf_cmaps/cmap_int.h"
8 8
9 #include "core/fpdfapi/fpdf_font/font_int.h" 9 #include "core/fpdfapi/fpdf_font/font_int.h"
10 #include "core/fpdfapi/include/cpdf_modulemgr.h" 10 #include "core/fpdfapi/include/cpdf_modulemgr.h"
(...skipping 27 matching lines...) Expand all
38 return -1; 38 return -1;
39 } 39 }
40 if (*(uint16_t*)key > ((uint16_t*)element)[1]) { 40 if (*(uint16_t*)key > ((uint16_t*)element)[1]) {
41 return 1; 41 return 1;
42 } 42 }
43 return 0; 43 return 0;
44 } 44 }
45 }; 45 };
46 extern "C" { 46 extern "C" {
47 static int compareDWordRange(const void* p1, const void* p2) { 47 static int compareDWordRange(const void* p1, const void* p2) {
48 FX_DWORD key = *(FX_DWORD*)p1; 48 uint32_t key = *(uint32_t*)p1;
49 uint16_t hiword = (uint16_t)(key >> 16); 49 uint16_t hiword = (uint16_t)(key >> 16);
50 uint16_t* element = (uint16_t*)p2; 50 uint16_t* element = (uint16_t*)p2;
51 if (hiword < element[0]) { 51 if (hiword < element[0]) {
52 return -1; 52 return -1;
53 } 53 }
54 if (hiword > element[0]) { 54 if (hiword > element[0]) {
55 return 1; 55 return 1;
56 } 56 }
57 uint16_t loword = (uint16_t)key; 57 uint16_t loword = (uint16_t)key;
58 if (loword < element[1]) { 58 if (loword < element[1]) {
59 return -1; 59 return -1;
60 } 60 }
61 if (loword > element[2]) { 61 if (loword > element[2]) {
62 return 1; 62 return 1;
63 } 63 }
64 return 0; 64 return 0;
65 } 65 }
66 }; 66 };
67 extern "C" { 67 extern "C" {
68 static int compareDWordSingle(const void* p1, const void* p2) { 68 static int compareDWordSingle(const void* p1, const void* p2) {
69 FX_DWORD key = *(FX_DWORD*)p1; 69 uint32_t key = *(uint32_t*)p1;
70 FX_DWORD value = ((*(uint16_t*)p2) << 16) | ((uint16_t*)p2)[1]; 70 uint32_t value = ((*(uint16_t*)p2) << 16) | ((uint16_t*)p2)[1];
71 if (key < value) { 71 if (key < value) {
72 return -1; 72 return -1;
73 } 73 }
74 if (key > value) { 74 if (key > value) {
75 return 1; 75 return 1;
76 } 76 }
77 return 0; 77 return 0;
78 } 78 }
79 }; 79 };
80 uint16_t FPDFAPI_CIDFromCharCode(const FXCMAP_CMap* pMap, FX_DWORD charcode) { 80 uint16_t FPDFAPI_CIDFromCharCode(const FXCMAP_CMap* pMap, uint32_t charcode) {
81 if (charcode >> 16) { 81 if (charcode >> 16) {
82 while (1) { 82 while (1) {
83 if (pMap->m_DWordMapType == FXCMAP_CMap::Range) { 83 if (pMap->m_DWordMapType == FXCMAP_CMap::Range) {
84 uint16_t* found = 84 uint16_t* found =
85 (uint16_t*)FXSYS_bsearch(&charcode, pMap->m_pDWordMap, 85 (uint16_t*)FXSYS_bsearch(&charcode, pMap->m_pDWordMap,
86 pMap->m_DWordCount, 8, compareDWordRange); 86 pMap->m_DWordCount, 8, compareDWordRange);
87 if (found) { 87 if (found) {
88 return found[3] + (uint16_t)charcode - found[1]; 88 return found[3] + (uint16_t)charcode - found[1];
89 } 89 }
90 } else if (pMap->m_DWordMapType == FXCMAP_CMap::Single) { 90 } else if (pMap->m_DWordMapType == FXCMAP_CMap::Single) {
(...skipping 29 matching lines...) Expand all
120 return found[2] + code - found[0]; 120 return found[2] + code - found[0];
121 } 121 }
122 } 122 }
123 if (pMap->m_UseOffset == 0) { 123 if (pMap->m_UseOffset == 0) {
124 return 0; 124 return 0;
125 } 125 }
126 pMap = pMap + pMap->m_UseOffset; 126 pMap = pMap + pMap->m_UseOffset;
127 } 127 }
128 return 0; 128 return 0;
129 } 129 }
130 FX_DWORD FPDFAPI_CharCodeFromCID(const FXCMAP_CMap* pMap, uint16_t cid) { 130 uint32_t FPDFAPI_CharCodeFromCID(const FXCMAP_CMap* pMap, uint16_t cid) {
131 while (1) { 131 while (1) {
132 if (pMap->m_WordMapType == FXCMAP_CMap::Single) { 132 if (pMap->m_WordMapType == FXCMAP_CMap::Single) {
133 const uint16_t* pCur = pMap->m_pWordMap; 133 const uint16_t* pCur = pMap->m_pWordMap;
134 const uint16_t* pEnd = pMap->m_pWordMap + pMap->m_WordCount * 2; 134 const uint16_t* pEnd = pMap->m_pWordMap + pMap->m_WordCount * 2;
135 while (pCur < pEnd) { 135 while (pCur < pEnd) {
136 if (pCur[1] == cid) { 136 if (pCur[1] == cid) {
137 return pCur[0]; 137 return pCur[0];
138 } 138 }
139 pCur += 2; 139 pCur += 2;
140 } 140 }
(...skipping 11 matching lines...) Expand all
152 return 0; 152 return 0;
153 } 153 }
154 pMap = pMap + pMap->m_UseOffset; 154 pMap = pMap + pMap->m_UseOffset;
155 } 155 }
156 while (1) { 156 while (1) {
157 if (pMap->m_DWordMapType == FXCMAP_CMap::Range) { 157 if (pMap->m_DWordMapType == FXCMAP_CMap::Range) {
158 const uint16_t* pCur = pMap->m_pDWordMap; 158 const uint16_t* pCur = pMap->m_pDWordMap;
159 const uint16_t* pEnd = pMap->m_pDWordMap + pMap->m_DWordCount * 4; 159 const uint16_t* pEnd = pMap->m_pDWordMap + pMap->m_DWordCount * 4;
160 while (pCur < pEnd) { 160 while (pCur < pEnd) {
161 if (cid >= pCur[3] && cid <= pCur[3] + pCur[2] - pCur[1]) { 161 if (cid >= pCur[3] && cid <= pCur[3] + pCur[2] - pCur[1]) {
162 return (((FX_DWORD)pCur[0] << 16) | pCur[1]) + cid - pCur[3]; 162 return (((uint32_t)pCur[0] << 16) | pCur[1]) + cid - pCur[3];
163 } 163 }
164 pCur += 4; 164 pCur += 4;
165 } 165 }
166 } else if (pMap->m_DWordMapType == FXCMAP_CMap::Single) { 166 } else if (pMap->m_DWordMapType == FXCMAP_CMap::Single) {
167 const uint16_t* pCur = pMap->m_pDWordMap; 167 const uint16_t* pCur = pMap->m_pDWordMap;
168 const uint16_t* pEnd = pMap->m_pDWordMap + pMap->m_DWordCount * 3; 168 const uint16_t* pEnd = pMap->m_pDWordMap + pMap->m_DWordCount * 3;
169 while (pCur < pEnd) { 169 while (pCur < pEnd) {
170 if (pCur[2] == cid) { 170 if (pCur[2] == cid) {
171 return ((FX_DWORD)pCur[0] << 16) | pCur[1]; 171 return ((uint32_t)pCur[0] << 16) | pCur[1];
172 } 172 }
173 pCur += 3; 173 pCur += 3;
174 } 174 }
175 } 175 }
176 if (pMap->m_UseOffset == 0) { 176 if (pMap->m_UseOffset == 0) {
177 return 0; 177 return 0;
178 } 178 }
179 pMap = pMap + pMap->m_UseOffset; 179 pMap = pMap + pMap->m_UseOffset;
180 } 180 }
181 return 0; 181 return 0;
182 } 182 }
183 183
184 void FPDFAPI_LoadCID2UnicodeMap(CIDSet charset, 184 void FPDFAPI_LoadCID2UnicodeMap(CIDSet charset,
185 const uint16_t*& pMap, 185 const uint16_t*& pMap,
186 FX_DWORD& count) { 186 uint32_t& count) {
187 CPDF_FontGlobals* pFontGlobals = 187 CPDF_FontGlobals* pFontGlobals =
188 CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGlobals(); 188 CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGlobals();
189 pMap = pFontGlobals->m_EmbeddedToUnicodes[charset].m_pMap; 189 pMap = pFontGlobals->m_EmbeddedToUnicodes[charset].m_pMap;
190 count = pFontGlobals->m_EmbeddedToUnicodes[charset].m_Count; 190 count = pFontGlobals->m_EmbeddedToUnicodes[charset].m_Count;
191 } 191 }
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_cmaps/cmap_int.h ('k') | core/fpdfapi/fpdf_edit/cpdf_pagecontentgenerator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698