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 // Original code is licensed as follows: | 6 // Original code is licensed as follows: |
7 /* | 7 /* |
8 * Copyright 2008 ZXing authors | 8 * Copyright 2008 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 20 matching lines...) Expand all Loading... |
31 m_version = -1; | 31 m_version = -1; |
32 m_matrixWidth = -1; | 32 m_matrixWidth = -1; |
33 m_maskPattern = -1; | 33 m_maskPattern = -1; |
34 m_numTotalBytes = -1; | 34 m_numTotalBytes = -1; |
35 m_numDataBytes = -1; | 35 m_numDataBytes = -1; |
36 m_numECBytes = -1; | 36 m_numECBytes = -1; |
37 m_numRSBlocks = -1; | 37 m_numRSBlocks = -1; |
38 m_matrix = NULL; | 38 m_matrix = NULL; |
39 } | 39 } |
40 CBC_QRCoder::~CBC_QRCoder() { | 40 CBC_QRCoder::~CBC_QRCoder() { |
41 if (m_matrix != NULL) { | 41 delete m_matrix; |
42 delete m_matrix; | |
43 m_matrix = NULL; | |
44 } | |
45 m_mode = NULL; | |
46 m_ecLevel = NULL; | |
47 m_version = -1; | |
48 m_matrixWidth = -1; | |
49 m_maskPattern = -1; | |
50 m_numTotalBytes = -1; | |
51 m_numDataBytes = -1; | |
52 m_numECBytes = -1; | |
53 m_numRSBlocks = -1; | |
54 } | 42 } |
55 CBC_QRCoderMode* CBC_QRCoder::GetMode() { | 43 CBC_QRCoderMode* CBC_QRCoder::GetMode() { |
56 return m_mode; | 44 return m_mode; |
57 } | 45 } |
58 CBC_QRCoderErrorCorrectionLevel* CBC_QRCoder::GetECLevel() { | 46 CBC_QRCoderErrorCorrectionLevel* CBC_QRCoder::GetECLevel() { |
59 return m_ecLevel; | 47 return m_ecLevel; |
60 } | 48 } |
61 int32_t CBC_QRCoder::GetVersion() { | 49 int32_t CBC_QRCoder::GetVersion() { |
62 return m_version; | 50 return m_version; |
63 } | 51 } |
(...skipping 20 matching lines...) Expand all Loading... |
84 } | 72 } |
85 int32_t CBC_QRCoder::At(int32_t x, int32_t y, int32_t& e) { | 73 int32_t CBC_QRCoder::At(int32_t x, int32_t y, int32_t& e) { |
86 int32_t value = m_matrix->Get(x, y); | 74 int32_t value = m_matrix->Get(x, y); |
87 if (!(value == 0 || value == 1)) { | 75 if (!(value == 0 || value == 1)) { |
88 e = BCExceptionValueMustBeEither0or1; | 76 e = BCExceptionValueMustBeEither0or1; |
89 BC_EXCEPTION_CHECK_ReturnValue(e, 0); | 77 BC_EXCEPTION_CHECK_ReturnValue(e, 0); |
90 } | 78 } |
91 return value; | 79 return value; |
92 } | 80 } |
93 FX_BOOL CBC_QRCoder::IsValid() { | 81 FX_BOOL CBC_QRCoder::IsValid() { |
94 return m_mode != NULL && m_ecLevel != NULL && m_version != -1 && | 82 return m_mode && m_ecLevel && m_version != -1 && m_matrixWidth != -1 && |
95 m_matrixWidth != -1 && m_maskPattern != -1 && m_numTotalBytes != -1 && | 83 m_maskPattern != -1 && m_numTotalBytes != -1 && m_numDataBytes != -1 && |
96 m_numDataBytes != -1 && m_numECBytes != -1 && m_numRSBlocks != -1 && | 84 m_numECBytes != -1 && m_numRSBlocks != -1 && |
97 IsValidMaskPattern(m_maskPattern) && | 85 IsValidMaskPattern(m_maskPattern) && |
98 m_numTotalBytes == m_numDataBytes + m_numECBytes && m_matrix != NULL && | 86 m_numTotalBytes == m_numDataBytes + m_numECBytes && m_matrix && |
99 m_matrixWidth == m_matrix->GetWidth() && | 87 m_matrixWidth == m_matrix->GetWidth() && |
100 m_matrix->GetWidth() == m_matrix->GetHeight(); | 88 m_matrix->GetWidth() == m_matrix->GetHeight(); |
101 } | 89 } |
102 void CBC_QRCoder::SetMode(CBC_QRCoderMode* value) { | 90 void CBC_QRCoder::SetMode(CBC_QRCoderMode* value) { |
103 m_mode = value; | 91 m_mode = value; |
104 } | 92 } |
105 void CBC_QRCoder::SetECLevel(CBC_QRCoderErrorCorrectionLevel* ecLevel) { | 93 void CBC_QRCoder::SetECLevel(CBC_QRCoderErrorCorrectionLevel* ecLevel) { |
106 m_ecLevel = ecLevel; | 94 m_ecLevel = ecLevel; |
107 } | 95 } |
108 void CBC_QRCoder::SetVersion(int32_t version) { | 96 void CBC_QRCoder::SetVersion(int32_t version) { |
(...skipping 17 matching lines...) Expand all Loading... |
126 void CBC_QRCoder::SetNumECBytes(int32_t value) { | 114 void CBC_QRCoder::SetNumECBytes(int32_t value) { |
127 m_numECBytes = value; | 115 m_numECBytes = value; |
128 } | 116 } |
129 FX_BOOL CBC_QRCoder::IsValidMaskPattern(int32_t maskPattern) { | 117 FX_BOOL CBC_QRCoder::IsValidMaskPattern(int32_t maskPattern) { |
130 return maskPattern >= 0 && maskPattern < NUM_MASK_PATTERNS; | 118 return maskPattern >= 0 && maskPattern < NUM_MASK_PATTERNS; |
131 } | 119 } |
132 void CBC_QRCoder::SetMatrix(CBC_CommonByteMatrix* value) { | 120 void CBC_QRCoder::SetMatrix(CBC_CommonByteMatrix* value) { |
133 m_matrix = value; | 121 m_matrix = value; |
134 } | 122 } |
135 const int32_t CBC_QRCoder::NUM_MASK_PATTERNS = 8; | 123 const int32_t CBC_QRCoder::NUM_MASK_PATTERNS = 8; |
OLD | NEW |