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

Side by Side Diff: xfa/src/fxbarcode/common/BC_CommonBitArray.cpp

Issue 1172793002: Merge to XFA: Use stdint.h types throughout PDFium. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years, 6 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 // Original code is licensed as follows: 6 // Original code is licensed as follows:
7 /* 7 /*
8 * Copyright 2007 ZXing authors 8 * Copyright 2007 ZXing authors
9 * 9 *
10 * Licensed under the Apache License, Version 2.0 (the "License"); 10 * Licensed under the Apache License, Version 2.0 (the "License");
(...skipping 14 matching lines...) Expand all
25 CBC_CommonBitArray::CBC_CommonBitArray(CBC_CommonBitArray* array) 25 CBC_CommonBitArray::CBC_CommonBitArray(CBC_CommonBitArray* array)
26 { 26 {
27 m_size = array->GetSize(); 27 m_size = array->GetSize();
28 m_bits.Copy(array->GetBits()); 28 m_bits.Copy(array->GetBits());
29 } 29 }
30 CBC_CommonBitArray::CBC_CommonBitArray() 30 CBC_CommonBitArray::CBC_CommonBitArray()
31 { 31 {
32 m_bits.SetSize(1); 32 m_bits.SetSize(1);
33 m_size = 0; 33 m_size = 0;
34 } 34 }
35 CBC_CommonBitArray::CBC_CommonBitArray(FX_INT32 size) 35 CBC_CommonBitArray::CBC_CommonBitArray(int32_t size)
36 { 36 {
37 m_bits.SetSize((size + 31) >> 5); 37 m_bits.SetSize((size + 31) >> 5);
38 m_size = size; 38 m_size = size;
39 } 39 }
40 CBC_CommonBitArray::~CBC_CommonBitArray() 40 CBC_CommonBitArray::~CBC_CommonBitArray()
41 { 41 {
42 m_size = 0; 42 m_size = 0;
43 } 43 }
44 FX_INT32 CBC_CommonBitArray::GetSize() 44 int32_t CBC_CommonBitArray::GetSize()
45 { 45 {
46 return m_size; 46 return m_size;
47 } 47 }
48 CFX_Int32Array& CBC_CommonBitArray::GetBits() 48 CFX_Int32Array& CBC_CommonBitArray::GetBits()
49 { 49 {
50 return m_bits; 50 return m_bits;
51 } 51 }
52 FX_INT32 CBC_CommonBitArray::GetSizeInBytes() 52 int32_t CBC_CommonBitArray::GetSizeInBytes()
53 { 53 {
54 return (m_size + 7) >> 3; 54 return (m_size + 7) >> 3;
55 } 55 }
56 FX_BOOL CBC_CommonBitArray::Get(FX_INT32 i) 56 FX_BOOL CBC_CommonBitArray::Get(int32_t i)
57 { 57 {
58 return (m_bits[i >> 5] & (1 << (i & 0x1f))) != 0; 58 return (m_bits[i >> 5] & (1 << (i & 0x1f))) != 0;
59 } 59 }
60 void CBC_CommonBitArray::Set(FX_INT32 i) 60 void CBC_CommonBitArray::Set(int32_t i)
61 { 61 {
62 m_bits[i >> 5] |= 1 << (i & 0x1F); 62 m_bits[i >> 5] |= 1 << (i & 0x1F);
63 } 63 }
64 void CBC_CommonBitArray::Flip(FX_INT32 i) 64 void CBC_CommonBitArray::Flip(int32_t i)
65 { 65 {
66 m_bits[i >> 5] ^= 1 << (i & 0x1F); 66 m_bits[i >> 5] ^= 1 << (i & 0x1F);
67 } 67 }
68 void CBC_CommonBitArray::SetBulk(FX_INT32 i, FX_INT32 newBits) 68 void CBC_CommonBitArray::SetBulk(int32_t i, int32_t newBits)
69 { 69 {
70 m_bits[i >> 5] = newBits; 70 m_bits[i >> 5] = newBits;
71 } 71 }
72 void CBC_CommonBitArray::Clear() 72 void CBC_CommonBitArray::Clear()
73 { 73 {
74 FXSYS_memset32(&m_bits[0], 0x00, m_bits.GetSize() * sizeof(FX_INT32)); 74 FXSYS_memset32(&m_bits[0], 0x00, m_bits.GetSize() * sizeof(int32_t));
75 } 75 }
76 FX_BOOL CBC_CommonBitArray::IsRange(FX_INT32 start, FX_INT32 end, FX_BOOL value, FX_INT32 &e) 76 FX_BOOL CBC_CommonBitArray::IsRange(int32_t start, int32_t end, FX_BOOL value, i nt32_t &e)
77 { 77 {
78 if (end < start) { 78 if (end < start) {
79 e = BCExceptionEndLessThanStart; 79 e = BCExceptionEndLessThanStart;
80 return FALSE; 80 return FALSE;
81 } 81 }
82 if (end == start) { 82 if (end == start) {
83 return TRUE; 83 return TRUE;
84 } 84 }
85 end--; 85 end--;
86 FX_INT32 firstInt = start >> 5; 86 int32_t firstInt = start >> 5;
87 FX_INT32 lastInt = end >> 5; 87 int32_t lastInt = end >> 5;
88 FX_INT32 i; 88 int32_t i;
89 for (i = firstInt; i <= lastInt; i++) { 89 for (i = firstInt; i <= lastInt; i++) {
90 FX_INT32 firstBit = i > firstInt ? 0 : start & 0x1F; 90 int32_t firstBit = i > firstInt ? 0 : start & 0x1F;
91 FX_INT32 lastBit = i < lastInt ? 31 : end & 0x1F; 91 int32_t lastBit = i < lastInt ? 31 : end & 0x1F;
92 FX_INT32 mask; 92 int32_t mask;
93 if (firstBit == 0 && lastBit == 31) { 93 if (firstBit == 0 && lastBit == 31) {
94 mask = -1; 94 mask = -1;
95 } else { 95 } else {
96 mask = 0; 96 mask = 0;
97 for (FX_INT32 j = firstBit; j <= lastBit; j++) { 97 for (int32_t j = firstBit; j <= lastBit; j++) {
98 mask |= 1 << j; 98 mask |= 1 << j;
99 } 99 }
100 } 100 }
101 if ((m_bits[i] & mask) != (value ? mask : 0)) { 101 if ((m_bits[i] & mask) != (value ? mask : 0)) {
102 return FALSE; 102 return FALSE;
103 } 103 }
104 } 104 }
105 return TRUE; 105 return TRUE;
106 } 106 }
107 FX_INT32* CBC_CommonBitArray::GetBitArray() 107 int32_t* CBC_CommonBitArray::GetBitArray()
108 { 108 {
109 return &m_bits[0]; 109 return &m_bits[0];
110 } 110 }
111 void CBC_CommonBitArray::Reverse() 111 void CBC_CommonBitArray::Reverse()
112 { 112 {
113 FX_INT32* newBits = FX_Alloc(FX_INT32, m_bits.GetSize()); 113 int32_t* newBits = FX_Alloc(int32_t, m_bits.GetSize());
114 FXSYS_memset32(newBits, 0x00, m_bits.GetSize() * sizeof(FX_INT32)); 114 FXSYS_memset32(newBits, 0x00, m_bits.GetSize() * sizeof(int32_t));
115 FX_INT32 size = m_size; 115 int32_t size = m_size;
116 FX_INT32 i; 116 int32_t i;
117 for (i = 0; i < size; i++) { 117 for (i = 0; i < size; i++) {
118 if (Get(size - i - 1)) { 118 if (Get(size - i - 1)) {
119 newBits[i >> 5] |= 1 << (i & 0x1F); 119 newBits[i >> 5] |= 1 << (i & 0x1F);
120 } 120 }
121 } 121 }
122 FXSYS_memcpy32(&m_bits[0], newBits, m_bits.GetSize() * sizeof(FX_INT32)); 122 FXSYS_memcpy32(&m_bits[0], newBits, m_bits.GetSize() * sizeof(int32_t));
123 FX_Free(newBits); 123 FX_Free(newBits);
124 } 124 }
OLDNEW
« no previous file with comments | « xfa/src/fxbarcode/common/BC_CommonBitArray.h ('k') | xfa/src/fxbarcode/common/BC_CommonBitMatrix.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698