diff options
author | Lei Zhang <thestig@chromium.org> | 2018-09-22 06:03:28 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-09-22 06:03:28 +0000 |
commit | 4993f558f9df8f85404d4bca71808542d5a18266 (patch) | |
tree | 9a993a524b7bc642e63d367c34e490a084c6bf77 /fxbarcode/common | |
parent | 36f4841d67037ce640273ce357d2d33f3e8567c3 (diff) | |
download | pdfium-4993f558f9df8f85404d4bca71808542d5a18266.tar.xz |
Remove CBC_CommonByteArray and CBC_QRCoderBlockPair.
CBC_CommonByteArray is just a std::vector. CBC_QRCoderBlockPair is just
a struct with two vectors.
Change-Id: I9e5fdab18f07a1cff7ee486dfce619f9391c80dc
Reviewed-on: https://pdfium-review.googlesource.com/42454
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Wei Li <weili@chromium.org>
Diffstat (limited to 'fxbarcode/common')
-rw-r--r-- | fxbarcode/common/BC_CommonByteArray.cpp | 101 | ||||
-rw-r--r-- | fxbarcode/common/BC_CommonByteArray.h | 38 | ||||
-rw-r--r-- | fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp | 8 | ||||
-rw-r--r-- | fxbarcode/common/reedsolomon/BC_ReedSolomon.h | 1 |
4 files changed, 3 insertions, 145 deletions
diff --git a/fxbarcode/common/BC_CommonByteArray.cpp b/fxbarcode/common/BC_CommonByteArray.cpp deleted file mode 100644 index bb4fbf8af5..0000000000 --- a/fxbarcode/common/BC_CommonByteArray.cpp +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -// Original code is licensed as follows: -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "fxbarcode/common/BC_CommonByteArray.h" - -#include <algorithm> - -#include "core/fxcrt/fx_memory.h" - -CBC_CommonByteArray::CBC_CommonByteArray() { - m_bytes = nullptr; - m_size = 0; - m_index = 0; -} -CBC_CommonByteArray::CBC_CommonByteArray(int32_t size) { - m_size = size; - m_bytes = FX_Alloc(uint8_t, size); - memset(m_bytes, 0, size); - m_index = 0; -} -CBC_CommonByteArray::CBC_CommonByteArray(uint8_t* byteArray, int32_t size) { - m_size = size; - m_bytes = FX_Alloc(uint8_t, size); - memcpy(m_bytes, byteArray, size); - m_index = size; -} -CBC_CommonByteArray::~CBC_CommonByteArray() { - FX_Free(m_bytes); -} -int32_t CBC_CommonByteArray::At(int32_t index) const { - return m_bytes[index] & 0xff; -} -void CBC_CommonByteArray::Set(int32_t index, int32_t value) { - m_bytes[index] = (uint8_t)value; -} -int32_t CBC_CommonByteArray::Size() const { - return m_size; -} -bool CBC_CommonByteArray::IsEmpty() const { - return m_size == 0; -} -void CBC_CommonByteArray::AppendByte(int32_t value) { - if (m_size == 0 || m_index >= m_size) { - int32_t newSize = std::max(32, m_size << 1); - Reserve(newSize); - } - m_bytes[m_index] = (uint8_t)value; - m_index++; -} -void CBC_CommonByteArray::Reserve(int32_t capacity) { - if (!m_bytes || m_size < capacity) { - uint8_t* newArray = FX_Alloc(uint8_t, capacity); - if (m_bytes) { - memcpy(newArray, m_bytes, m_size); - memset(newArray + m_size, 0, capacity - m_size); - } else { - memset(newArray, 0, capacity); - } - FX_Free(m_bytes); - m_bytes = newArray; - m_size = capacity; - } -} -void CBC_CommonByteArray::Set(const uint8_t* source, - int32_t offset, - int32_t count) { - FX_Free(m_bytes); - m_bytes = FX_Alloc(uint8_t, count); - m_size = count; - memcpy(m_bytes, source + offset, count); - m_index = count; -} -void CBC_CommonByteArray::Set(std::vector<uint8_t>* source, - int32_t offset, - int32_t count) { - FX_Free(m_bytes); - m_bytes = FX_Alloc(uint8_t, count); - m_size = count; - int32_t i; - for (i = 0; i < count; i++) - m_bytes[i] = (*source)[i + offset]; - m_index = m_size; -} diff --git a/fxbarcode/common/BC_CommonByteArray.h b/fxbarcode/common/BC_CommonByteArray.h deleted file mode 100644 index 285a567c8e..0000000000 --- a/fxbarcode/common/BC_CommonByteArray.h +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef FXBARCODE_COMMON_BC_COMMONBYTEARRAY_H_ -#define FXBARCODE_COMMON_BC_COMMONBYTEARRAY_H_ - -#include <stdint.h> - -#include <vector> - -// TODO(weili): The usage of this class should be replaced by -// std::vector<uint8_t>. -class CBC_CommonByteArray { - public: - CBC_CommonByteArray(); - explicit CBC_CommonByteArray(int32_t size); - CBC_CommonByteArray(uint8_t* byteArray, int32_t size); - virtual ~CBC_CommonByteArray(); - - int32_t At(int32_t index) const; - int32_t Size() const; - bool IsEmpty() const; - void Set(int32_t index, int32_t value); - void AppendByte(int32_t value); - void Reserve(int32_t capacity); - void Set(const uint8_t* source, int32_t offset, int32_t count); - void Set(std::vector<uint8_t>* source, int32_t offset, int32_t count); - - private: - int32_t m_size; - int32_t m_index; - uint8_t* m_bytes; -}; - -#endif // FXBARCODE_COMMON_BC_COMMONBYTEARRAY_H_ diff --git a/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp b/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp index 2be74c7fa3..8ce4ebf97d 100644 --- a/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp +++ b/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp @@ -30,15 +30,13 @@ #include "third_party/base/ptr_util.h" CBC_ReedSolomonEncoder::CBC_ReedSolomonEncoder(CBC_ReedSolomonGF256* field) - : m_field(field) {} - -CBC_ReedSolomonEncoder::~CBC_ReedSolomonEncoder() {} - -void CBC_ReedSolomonEncoder::Init() { + : m_field(field) { m_cachedGenerators.push_back( pdfium::MakeUnique<CBC_ReedSolomonGF256Poly>(m_field.Get(), 1)); } +CBC_ReedSolomonEncoder::~CBC_ReedSolomonEncoder() {} + CBC_ReedSolomonGF256Poly* CBC_ReedSolomonEncoder::BuildGenerator( size_t degree) { if (degree >= m_cachedGenerators.size()) { diff --git a/fxbarcode/common/reedsolomon/BC_ReedSolomon.h b/fxbarcode/common/reedsolomon/BC_ReedSolomon.h index e45c8a4976..772ca3c041 100644 --- a/fxbarcode/common/reedsolomon/BC_ReedSolomon.h +++ b/fxbarcode/common/reedsolomon/BC_ReedSolomon.h @@ -20,7 +20,6 @@ class CBC_ReedSolomonEncoder { explicit CBC_ReedSolomonEncoder(CBC_ReedSolomonGF256* field); ~CBC_ReedSolomonEncoder(); - void Init(); bool Encode(std::vector<int32_t>* toEncode, size_t ecBytes); private: |