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

Side by Side Diff: xfa/fgas/crt/fgas_algorithm.cpp

Issue 1830323006: Remove FX_DWORD from XFA. (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
« no previous file with comments | « xfa/fee/fx_wordbreak/fx_wordbreak_impl.cpp ('k') | xfa/fgas/crt/fgas_encode.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "xfa/fgas/crt/fgas_algorithm.h" 7 #include "xfa/fgas/crt/fgas_algorithm.h"
8 8
9 #include "core/fxcrt/include/fx_basic.h" 9 #include "core/fxcrt/include/fx_basic.h"
10 10
11 #ifdef __cplusplus 11 #ifdef __cplusplus
12 extern "C" { 12 extern "C" {
13 #endif 13 #endif
14 14
15 static const FX_CHAR g_FXBase64EncoderMap[64] = { 15 static const FX_CHAR g_FXBase64EncoderMap[64] = {
16 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 16 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
17 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 17 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
18 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 18 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
19 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 19 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
20 '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/', 20 '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/',
21 }; 21 };
22 22
23 struct FX_BASE64DATA { 23 struct FX_BASE64DATA {
24 FX_DWORD data1 : 2; 24 uint32_t data1 : 2;
25 FX_DWORD data2 : 6; 25 uint32_t data2 : 6;
26 FX_DWORD data3 : 4; 26 uint32_t data3 : 4;
27 FX_DWORD data4 : 4; 27 uint32_t data4 : 4;
28 FX_DWORD data5 : 6; 28 uint32_t data5 : 6;
29 FX_DWORD data6 : 2; 29 uint32_t data6 : 2;
30 FX_DWORD data7 : 8; 30 uint32_t data7 : 8;
31 }; 31 };
32 32
33 static void FX_Base64EncodePiece(const FX_BASE64DATA& src, 33 static void FX_Base64EncodePiece(const FX_BASE64DATA& src,
34 int32_t iBytes, 34 int32_t iBytes,
35 FX_CHAR dst[4]) { 35 FX_CHAR dst[4]) {
36 dst[0] = g_FXBase64EncoderMap[src.data2]; 36 dst[0] = g_FXBase64EncoderMap[src.data2];
37 FX_DWORD b = src.data1 << 4; 37 uint32_t b = src.data1 << 4;
38 if (iBytes > 1) { 38 if (iBytes > 1) {
39 b |= src.data4; 39 b |= src.data4;
40 } 40 }
41 dst[1] = g_FXBase64EncoderMap[b]; 41 dst[1] = g_FXBase64EncoderMap[b];
42 if (iBytes > 1) { 42 if (iBytes > 1) {
43 b = src.data3 << 2; 43 b = src.data3 << 2;
44 if (iBytes > 2) { 44 if (iBytes > 2) {
45 b |= src.data6; 45 b |= src.data6;
46 } 46 }
47 dst[2] = g_FXBase64EncoderMap[b]; 47 dst[2] = g_FXBase64EncoderMap[b];
(...skipping 21 matching lines...) Expand all
69 FX_BASE64DATA srcData; 69 FX_BASE64DATA srcData;
70 int32_t iBytes = 3; 70 int32_t iBytes = 3;
71 FX_CHAR* pDstEnd = pDst; 71 FX_CHAR* pDstEnd = pDst;
72 while (iSrcLen > 0) { 72 while (iSrcLen > 0) {
73 if (iSrcLen > 2) { 73 if (iSrcLen > 2) {
74 ((uint8_t*)&srcData)[0] = *pSrc++; 74 ((uint8_t*)&srcData)[0] = *pSrc++;
75 ((uint8_t*)&srcData)[1] = *pSrc++; 75 ((uint8_t*)&srcData)[1] = *pSrc++;
76 ((uint8_t*)&srcData)[2] = *pSrc++; 76 ((uint8_t*)&srcData)[2] = *pSrc++;
77 iSrcLen -= 3; 77 iSrcLen -= 3;
78 } else { 78 } else {
79 *((FX_DWORD*)&srcData) = 0; 79 *((uint32_t*)&srcData) = 0;
80 ((uint8_t*)&srcData)[0] = *pSrc++; 80 ((uint8_t*)&srcData)[0] = *pSrc++;
81 if (iSrcLen > 1) { 81 if (iSrcLen > 1) {
82 ((uint8_t*)&srcData)[1] = *pSrc++; 82 ((uint8_t*)&srcData)[1] = *pSrc++;
83 } 83 }
84 iBytes = iSrcLen; 84 iBytes = iSrcLen;
85 iSrcLen = 0; 85 iSrcLen = 0;
86 } 86 }
87 FX_Base64EncodePiece(srcData, iBytes, pDstEnd); 87 FX_Base64EncodePiece(srcData, iBytes, pDstEnd);
88 pDstEnd += 4; 88 pDstEnd += 4;
89 } 89 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 iDstLen += 2; 165 iDstLen += 2;
166 } 166 }
167 return iDstLen; 167 return iDstLen;
168 } 168 }
169 FX_CHAR srcData[4]; 169 FX_CHAR srcData[4];
170 FX_BASE64DATA dstData; 170 FX_BASE64DATA dstData;
171 int32_t iChars = 4, iBytes; 171 int32_t iChars = 4, iBytes;
172 uint8_t* pDstEnd = pDst; 172 uint8_t* pDstEnd = pDst;
173 while (iSrcLen > 0) { 173 while (iSrcLen > 0) {
174 if (iSrcLen > 3) { 174 if (iSrcLen > 3) {
175 *((FX_DWORD*)srcData) = *((FX_DWORD*)pSrc); 175 *((uint32_t*)srcData) = *((uint32_t*)pSrc);
176 pSrc += 4; 176 pSrc += 4;
177 iSrcLen -= 4; 177 iSrcLen -= 4;
178 } else { 178 } else {
179 *((FX_DWORD*)&dstData) = 0; 179 *((uint32_t*)&dstData) = 0;
180 *((FX_DWORD*)srcData) = 0; 180 *((uint32_t*)srcData) = 0;
181 srcData[0] = *pSrc++; 181 srcData[0] = *pSrc++;
182 if (iSrcLen > 1) { 182 if (iSrcLen > 1) {
183 srcData[1] = *pSrc++; 183 srcData[1] = *pSrc++;
184 } 184 }
185 if (iSrcLen > 2) { 185 if (iSrcLen > 2) {
186 srcData[2] = *pSrc++; 186 srcData[2] = *pSrc++;
187 } 187 }
188 iChars = iSrcLen; 188 iChars = iSrcLen;
189 iSrcLen = 0; 189 iSrcLen = 0;
190 } 190 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 int32_t iChars = 4, iBytes; 227 int32_t iChars = 4, iBytes;
228 uint8_t* pDstEnd = pDst; 228 uint8_t* pDstEnd = pDst;
229 while (iSrcLen > 0) { 229 while (iSrcLen > 0) {
230 if (iSrcLen > 3) { 230 if (iSrcLen > 3) {
231 srcData[0] = (FX_CHAR)*pSrc++; 231 srcData[0] = (FX_CHAR)*pSrc++;
232 srcData[1] = (FX_CHAR)*pSrc++; 232 srcData[1] = (FX_CHAR)*pSrc++;
233 srcData[2] = (FX_CHAR)*pSrc++; 233 srcData[2] = (FX_CHAR)*pSrc++;
234 srcData[3] = (FX_CHAR)*pSrc++; 234 srcData[3] = (FX_CHAR)*pSrc++;
235 iSrcLen -= 4; 235 iSrcLen -= 4;
236 } else { 236 } else {
237 *((FX_DWORD*)&dstData) = 0; 237 *((uint32_t*)&dstData) = 0;
238 *((FX_DWORD*)srcData) = 0; 238 *((uint32_t*)srcData) = 0;
239 srcData[0] = (FX_CHAR)*pSrc++; 239 srcData[0] = (FX_CHAR)*pSrc++;
240 if (iSrcLen > 1) { 240 if (iSrcLen > 1) {
241 srcData[1] = (FX_CHAR)*pSrc++; 241 srcData[1] = (FX_CHAR)*pSrc++;
242 } 242 }
243 if (iSrcLen > 2) { 243 if (iSrcLen > 2) {
244 srcData[2] = (FX_CHAR)*pSrc++; 244 srcData[2] = (FX_CHAR)*pSrc++;
245 } 245 }
246 iChars = iSrcLen; 246 iChars = iSrcLen;
247 iSrcLen = 0; 247 iSrcLen = 0;
248 } 248 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 break; 297 break;
298 } 298 }
299 } 299 }
300 pStr++; 300 pStr++;
301 } 301 }
302 return pieces.GetSize(); 302 return pieces.GetSize();
303 } 303 }
304 #ifdef __cplusplus 304 #ifdef __cplusplus
305 } 305 }
306 #endif 306 #endif
OLDNEW
« no previous file with comments | « xfa/fee/fx_wordbreak/fx_wordbreak_impl.cpp ('k') | xfa/fgas/crt/fgas_encode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698