| 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 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 29 matching lines...) Expand all Loading... |
| 40 } | 40 } |
| 41 void CBC_CommonBitMatrix::Init(int32_t width, int32_t height) { | 41 void CBC_CommonBitMatrix::Init(int32_t width, int32_t height) { |
| 42 m_width = width; | 42 m_width = width; |
| 43 m_height = height; | 43 m_height = height; |
| 44 int32_t rowSize = (width + 31) >> 5; | 44 int32_t rowSize = (width + 31) >> 5; |
| 45 m_rowSize = rowSize; | 45 m_rowSize = rowSize; |
| 46 m_bits = FX_Alloc2D(int32_t, m_rowSize, m_height); | 46 m_bits = FX_Alloc2D(int32_t, m_rowSize, m_height); |
| 47 FXSYS_memset(m_bits, 0, m_rowSize * m_height * sizeof(int32_t)); | 47 FXSYS_memset(m_bits, 0, m_rowSize * m_height * sizeof(int32_t)); |
| 48 } | 48 } |
| 49 CBC_CommonBitMatrix::~CBC_CommonBitMatrix() { | 49 CBC_CommonBitMatrix::~CBC_CommonBitMatrix() { |
| 50 if (m_bits != NULL) { | 50 FX_Free(m_bits); |
| 51 FX_Free(m_bits); | |
| 52 } | |
| 53 m_bits = NULL; | |
| 54 m_height = m_width = m_rowSize = 0; | |
| 55 } | 51 } |
| 56 FX_BOOL CBC_CommonBitMatrix::Get(int32_t x, int32_t y) { | 52 FX_BOOL CBC_CommonBitMatrix::Get(int32_t x, int32_t y) { |
| 57 int32_t offset = y * m_rowSize + (x >> 5); | 53 int32_t offset = y * m_rowSize + (x >> 5); |
| 58 if (offset >= m_rowSize * m_height || offset < 0) { | 54 if (offset >= m_rowSize * m_height || offset < 0) { |
| 59 return false; | 55 return false; |
| 60 } | 56 } |
| 61 return ((((FX_DWORD)m_bits[offset]) >> (x & 0x1f)) & 1) != 0; | 57 return ((((FX_DWORD)m_bits[offset]) >> (x & 0x1f)) & 1) != 0; |
| 62 } | 58 } |
| 63 int32_t* CBC_CommonBitMatrix::GetBits() { | 59 int32_t* CBC_CommonBitMatrix::GetBits() { |
| 64 return m_bits; | 60 return m_bits; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 int32_t CBC_CommonBitMatrix::GetRowSize() { | 137 int32_t CBC_CommonBitMatrix::GetRowSize() { |
| 142 return m_rowSize; | 138 return m_rowSize; |
| 143 } | 139 } |
| 144 int32_t CBC_CommonBitMatrix::GetDimension(int32_t& e) { | 140 int32_t CBC_CommonBitMatrix::GetDimension(int32_t& e) { |
| 145 if (m_width != m_height) { | 141 if (m_width != m_height) { |
| 146 e = BCExceptionCanNotCallGetDimensionOnNonSquareMatrix; | 142 e = BCExceptionCanNotCallGetDimensionOnNonSquareMatrix; |
| 147 return 0; | 143 return 0; |
| 148 } | 144 } |
| 149 return m_width; | 145 return m_width; |
| 150 } | 146 } |
| OLD | NEW |