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

Side by Side Diff: xfa/src/fxbarcode/qrcode/BC_QRDataMask.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");
11 * you may not use this file except in compliance with the License. 11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at 12 * You may obtain a copy of the License at
13 * 13 *
14 * http://www.apache.org/licenses/LICENSE-2.0 14 * http://www.apache.org/licenses/LICENSE-2.0
15 * 15 *
16 * Unless required by applicable law or agreed to in writing, software 16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS, 17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and 19 * See the License for the specific language governing permissions and
20 * limitations under the License. 20 * limitations under the License.
21 */ 21 */
22 22
23 #include "../barcode.h" 23 #include "../barcode.h"
24 #include "../common/BC_CommonBitMatrix.h" 24 #include "../common/BC_CommonBitMatrix.h"
25 #include "BC_QRDataMask.h" 25 #include "BC_QRDataMask.h"
26 static FX_INT32 N_DATA_MASKS = 0; 26 static int32_t N_DATA_MASKS = 0;
27 CFX_PtrArray* CBC_QRDataMask::DATA_MASKS = NULL; 27 CFX_PtrArray* CBC_QRDataMask::DATA_MASKS = NULL;
28 void CBC_QRDataMask::Initialize() 28 void CBC_QRDataMask::Initialize()
29 { 29 {
30 DATA_MASKS = FX_NEW CFX_PtrArray(); 30 DATA_MASKS = FX_NEW CFX_PtrArray();
31 N_DATA_MASKS = BuildDataMasks(); 31 N_DATA_MASKS = BuildDataMasks();
32 } 32 }
33 void CBC_QRDataMask::Finalize() 33 void CBC_QRDataMask::Finalize()
34 { 34 {
35 Destroy(); 35 Destroy();
36 delete DATA_MASKS; 36 delete DATA_MASKS;
37 } 37 }
38 void CBC_QRDataMask::Destroy() 38 void CBC_QRDataMask::Destroy()
39 { 39 {
40 FX_INT32 i; 40 int32_t i;
41 for(i = 0; i < N_DATA_MASKS; i++) { 41 for(i = 0; i < N_DATA_MASKS; i++) {
42 CBC_QRDataMask* p = (CBC_QRDataMask*)(*DATA_MASKS)[i]; 42 CBC_QRDataMask* p = (CBC_QRDataMask*)(*DATA_MASKS)[i];
43 if (p) { 43 if (p) {
44 delete p; 44 delete p;
45 } 45 }
46 } 46 }
47 } 47 }
48 void CBC_QRDataMask::UnmaskBitMatirx(CBC_CommonBitMatrix *bits, FX_INT32 dimensi on) 48 void CBC_QRDataMask::UnmaskBitMatirx(CBC_CommonBitMatrix *bits, int32_t dimensio n)
49 { 49 {
50 for(FX_INT32 i = 0; i < dimension; i++) { 50 for(int32_t i = 0; i < dimension; i++) {
51 for(FX_INT32 j = 0; j < dimension; j++) { 51 for(int32_t j = 0; j < dimension; j++) {
52 if(IsMasked(i, j)) { 52 if(IsMasked(i, j)) {
53 bits->Flip(j, i); 53 bits->Flip(j, i);
54 } 54 }
55 } 55 }
56 } 56 }
57 } 57 }
58 CBC_QRDataMask* CBC_QRDataMask::ForReference(FX_INT32 reference, FX_INT32 &e) 58 CBC_QRDataMask* CBC_QRDataMask::ForReference(int32_t reference, int32_t &e)
59 { 59 {
60 if(reference < 0 || reference > 7) { 60 if(reference < 0 || reference > 7) {
61 e = BCExceptionReferenceMustBeBetween0And7; 61 e = BCExceptionReferenceMustBeBetween0And7;
62 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 62 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
63 } 63 }
64 return (CBC_QRDataMask*)(*DATA_MASKS)[reference]; 64 return (CBC_QRDataMask*)(*DATA_MASKS)[reference];
65 } 65 }
66 class DataMask000 : public CBC_QRDataMask 66 class DataMask000 : public CBC_QRDataMask
67 { 67 {
68 public: 68 public:
69 FX_BOOL IsMasked(FX_INT32 x, FX_INT32 y) 69 FX_BOOL IsMasked(int32_t x, int32_t y)
70 { 70 {
71 return ((x + y) % 2) == 0; 71 return ((x + y) % 2) == 0;
72 } 72 }
73 }; 73 };
74 class DataMask001 : public CBC_QRDataMask 74 class DataMask001 : public CBC_QRDataMask
75 { 75 {
76 public: 76 public:
77 FX_BOOL IsMasked(FX_INT32 x, FX_INT32 y) 77 FX_BOOL IsMasked(int32_t x, int32_t y)
78 { 78 {
79 return (x % 2) == 0; 79 return (x % 2) == 0;
80 } 80 }
81 }; 81 };
82 class DataMask010 : public CBC_QRDataMask 82 class DataMask010 : public CBC_QRDataMask
83 { 83 {
84 public: 84 public:
85 FX_BOOL IsMasked(FX_INT32 x, FX_INT32 y) 85 FX_BOOL IsMasked(int32_t x, int32_t y)
86 { 86 {
87 return y % 3 == 0; 87 return y % 3 == 0;
88 } 88 }
89 }; 89 };
90 class DataMask011 : public CBC_QRDataMask 90 class DataMask011 : public CBC_QRDataMask
91 { 91 {
92 public: 92 public:
93 FX_BOOL IsMasked(FX_INT32 x, FX_INT32 y) 93 FX_BOOL IsMasked(int32_t x, int32_t y)
94 { 94 {
95 return (x + y) % 3 == 0; 95 return (x + y) % 3 == 0;
96 } 96 }
97 }; 97 };
98 class DataMask100 : public CBC_QRDataMask 98 class DataMask100 : public CBC_QRDataMask
99 { 99 {
100 public: 100 public:
101 FX_BOOL IsMasked(FX_INT32 x, FX_INT32 y) 101 FX_BOOL IsMasked(int32_t x, int32_t y)
102 { 102 {
103 return (((x >> 1) + (y / 3)) % 2) == 0; 103 return (((x >> 1) + (y / 3)) % 2) == 0;
104 } 104 }
105 }; 105 };
106 class DataMask101 : public CBC_QRDataMask 106 class DataMask101 : public CBC_QRDataMask
107 { 107 {
108 public: 108 public:
109 FX_BOOL IsMasked(FX_INT32 x, FX_INT32 y) 109 FX_BOOL IsMasked(int32_t x, int32_t y)
110 { 110 {
111 size_t temp = x * y; 111 size_t temp = x * y;
112 return (temp % 2) + (temp % 3) == 0; 112 return (temp % 2) + (temp % 3) == 0;
113 } 113 }
114 }; 114 };
115 class DataMask110 : public CBC_QRDataMask 115 class DataMask110 : public CBC_QRDataMask
116 { 116 {
117 public: 117 public:
118 FX_BOOL IsMasked(FX_INT32 x, FX_INT32 y) 118 FX_BOOL IsMasked(int32_t x, int32_t y)
119 { 119 {
120 size_t temp = x * y; 120 size_t temp = x * y;
121 return (((temp % 2) + (temp % 3)) % 2) == 0; 121 return (((temp % 2) + (temp % 3)) % 2) == 0;
122 } 122 }
123 }; 123 };
124 class DataMask111 : public CBC_QRDataMask 124 class DataMask111 : public CBC_QRDataMask
125 { 125 {
126 public: 126 public:
127 FX_BOOL IsMasked(FX_INT32 x, FX_INT32 y) 127 FX_BOOL IsMasked(int32_t x, int32_t y)
128 { 128 {
129 return ((((x + y) % 2) + ((x * y) % 3)) % 2) == 0; 129 return ((((x + y) % 2) + ((x * y) % 3)) % 2) == 0;
130 } 130 }
131 }; 131 };
132 FX_INT32 CBC_QRDataMask::BuildDataMasks() 132 int32_t CBC_QRDataMask::BuildDataMasks()
133 { 133 {
134 DATA_MASKS->Add(FX_NEW DataMask000); 134 DATA_MASKS->Add(FX_NEW DataMask000);
135 DATA_MASKS->Add(FX_NEW DataMask001); 135 DATA_MASKS->Add(FX_NEW DataMask001);
136 DATA_MASKS->Add(FX_NEW DataMask010); 136 DATA_MASKS->Add(FX_NEW DataMask010);
137 DATA_MASKS->Add(FX_NEW DataMask011); 137 DATA_MASKS->Add(FX_NEW DataMask011);
138 DATA_MASKS->Add(FX_NEW DataMask100); 138 DATA_MASKS->Add(FX_NEW DataMask100);
139 DATA_MASKS->Add(FX_NEW DataMask101); 139 DATA_MASKS->Add(FX_NEW DataMask101);
140 DATA_MASKS->Add(FX_NEW DataMask110); 140 DATA_MASKS->Add(FX_NEW DataMask110);
141 DATA_MASKS->Add(FX_NEW DataMask111); 141 DATA_MASKS->Add(FX_NEW DataMask111);
142 return DATA_MASKS->GetSize(); 142 return DATA_MASKS->GetSize();
143 } 143 }
144 CBC_QRDataMask::CBC_QRDataMask() 144 CBC_QRDataMask::CBC_QRDataMask()
145 { 145 {
146 } 146 }
147 CBC_QRDataMask::~CBC_QRDataMask() 147 CBC_QRDataMask::~CBC_QRDataMask()
148 { 148 {
149 } 149 }
OLDNEW
« no previous file with comments | « xfa/src/fxbarcode/qrcode/BC_QRDataMask.h ('k') | xfa/src/fxbarcode/qrcode/BC_QRDecodedBitStreamParser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698