summaryrefslogtreecommitdiff
path: root/fxbarcode
diff options
context:
space:
mode:
authorHenrique Nakashima <hnakashima@chromium.org>2018-08-22 21:28:36 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-08-22 21:28:36 +0000
commit81e0830e67344ffd7c7eb98055c892fb748db5c4 (patch)
tree2034618459e800ac65b42f182fd319d89c013499 /fxbarcode
parentbd6db24c0b78831542656ce8c3268fc55394df01 (diff)
downloadpdfium-81e0830e67344ffd7c7eb98055c892fb748db5c4.tar.xz
Simplify internal state of CBC_BarcodeMatrix.
Change-Id: Icd66f42c240984df6821c2bae640bbfacfa62ad2 Reviewed-on: https://pdfium-review.googlesource.com/41010 Commit-Queue: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'fxbarcode')
-rw-r--r--fxbarcode/pdf417/BC_PDF417BarcodeMatrix.cpp33
-rw-r--r--fxbarcode/pdf417/BC_PDF417BarcodeMatrix.h15
2 files changed, 16 insertions, 32 deletions
diff --git a/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.cpp b/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.cpp
index 4fc55a2d10..7fb1259154 100644
--- a/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.cpp
+++ b/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.cpp
@@ -24,16 +24,11 @@
#include "fxbarcode/pdf417/BC_PDF417BarcodeRow.h"
#include "third_party/base/ptr_util.h"
-CBC_BarcodeMatrix::CBC_BarcodeMatrix(int32_t height, int32_t width) {
- m_matrix.resize(height);
- for (size_t i = 0; i < m_matrix.size(); ++i)
- m_matrix[i] = pdfium::MakeUnique<CBC_BarcodeRow>((width + 4) * 17 + 1);
-
- m_width = width * 17;
- m_height = height;
- m_currentRow = 0;
- m_outHeight = 0;
- m_outWidth = 0;
+CBC_BarcodeMatrix::CBC_BarcodeMatrix(size_t height, size_t width)
+ : m_width((width + 4) * 17 + 1), m_height(height) {
+ m_matrix.resize(m_height);
+ for (size_t i = 0; i < m_height; ++i)
+ m_matrix[i] = pdfium::MakeUnique<CBC_BarcodeRow>(m_width);
}
CBC_BarcodeMatrix::~CBC_BarcodeMatrix() {}
@@ -43,19 +38,11 @@ void CBC_BarcodeMatrix::nextRow() {
}
std::vector<uint8_t>& CBC_BarcodeMatrix::getMatrix() {
- std::vector<uint8_t> bytearray = m_matrix[0]->getRow();
- size_t xMax = bytearray.size();
- size_t yMax = m_height;
- m_matrixOut.resize(xMax * yMax);
- m_outWidth = xMax;
- m_outHeight = yMax;
- int32_t k = 0;
- for (size_t i = 0; i < yMax; i++) {
- if (i != 0)
- bytearray = m_matrix[i]->getRow();
- k = i * xMax;
- for (size_t l = 0; l < xMax; l++)
- m_matrixOut[k + l] = bytearray[l];
+ m_matrixOut.resize(m_width * m_height);
+ for (size_t i = 0; i < m_height; ++i) {
+ std::vector<uint8_t>& bytearray = m_matrix[i]->getRow();
+ for (size_t j = 0; j < m_width; ++j)
+ m_matrixOut[i * m_width + j] = bytearray[j];
}
return m_matrixOut;
}
diff --git a/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.h b/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.h
index 43906d8821..badb0ce3cd 100644
--- a/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.h
+++ b/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.h
@@ -14,24 +14,21 @@ class CBC_BarcodeRow;
class CBC_BarcodeMatrix {
public:
- CBC_BarcodeMatrix();
- CBC_BarcodeMatrix(int32_t height, int32_t width);
+ CBC_BarcodeMatrix(size_t height, size_t width);
virtual ~CBC_BarcodeMatrix();
CBC_BarcodeRow* getCurrentRow() const { return m_matrix[m_currentRow].get(); }
- int32_t getWidth() const { return m_outWidth; }
- int32_t getHeight() const { return m_outHeight; }
+ size_t getWidth() const { return m_width; }
+ size_t getHeight() const { return m_height; }
void nextRow();
std::vector<uint8_t>& getMatrix();
private:
std::vector<std::unique_ptr<CBC_BarcodeRow>> m_matrix;
std::vector<uint8_t> m_matrixOut;
- int32_t m_currentRow;
- int32_t m_height;
- int32_t m_width;
- int32_t m_outWidth;
- int32_t m_outHeight;
+ size_t m_currentRow = 0;
+ size_t m_width;
+ size_t m_height;
};
#endif // FXBARCODE_PDF417_BC_PDF417BARCODEMATRIX_H_