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