diff options
author | Tom Sepez <tsepez@chromium.org> | 2018-07-03 15:57:03 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-07-03 15:57:03 +0000 |
commit | 1c14ae2fbe1ae95dac3a7f5e60d049d9630aef02 (patch) | |
tree | 2d121ae2a0436adce5c54379d1824b427dd03359 /fxbarcode/qrcode | |
parent | d77e0ed72f73fb63305d04953ef03e2edab82d34 (diff) | |
download | pdfium-1c14ae2fbe1ae95dac3a7f5e60d049d9630aef02.tar.xz |
Avoid explicit allocs in fxbarcode matrix classes.
Other cleanups:
Remove unused method.
Fold Init() into constructor.
Return span<> where possible.
Change-Id: Ie38d32efb6e63d86ae24e93684903a6dd900810f
Reviewed-on: https://pdfium-review.googlesource.com/36810
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'fxbarcode/qrcode')
-rw-r--r-- | fxbarcode/qrcode/BC_QRCodeWriter.cpp | 2 | ||||
-rw-r--r-- | fxbarcode/qrcode/BC_QRCoderEncoder.cpp | 1 | ||||
-rw-r--r-- | fxbarcode/qrcode/BC_QRCoderMaskUtil.cpp | 11 |
3 files changed, 6 insertions, 8 deletions
diff --git a/fxbarcode/qrcode/BC_QRCodeWriter.cpp b/fxbarcode/qrcode/BC_QRCodeWriter.cpp index eb35af3867..8e4a57311a 100644 --- a/fxbarcode/qrcode/BC_QRCodeWriter.cpp +++ b/fxbarcode/qrcode/BC_QRCodeWriter.cpp @@ -83,6 +83,6 @@ uint8_t* CBC_QRCodeWriter::Encode(const WideString& contents, outWidth = qr.GetMatrixWidth(); outHeight = qr.GetMatrixWidth(); uint8_t* result = FX_Alloc2D(uint8_t, outWidth, outHeight); - memcpy(result, qr.GetMatrix()->GetArray(), outWidth * outHeight); + memcpy(result, qr.GetMatrix()->GetArray().data(), outWidth * outHeight); return result; } diff --git a/fxbarcode/qrcode/BC_QRCoderEncoder.cpp b/fxbarcode/qrcode/BC_QRCoderEncoder.cpp index 8da2d48e34..9c600b01b0 100644 --- a/fxbarcode/qrcode/BC_QRCoderEncoder.cpp +++ b/fxbarcode/qrcode/BC_QRCoderEncoder.cpp @@ -599,7 +599,6 @@ bool CBC_QRCoderEncoder::Encode(const WideString& content, auto matrix = pdfium::MakeUnique<CBC_CommonByteMatrix>( qrCode->GetMatrixWidth(), qrCode->GetMatrixWidth()); - matrix->Init(); int32_t maskPattern = ChooseMaskPattern( &finalBits, qrCode->GetECLevel(), qrCode->GetVersion(), matrix.get(), e); if (e != BCExceptionNO) diff --git a/fxbarcode/qrcode/BC_QRCoderMaskUtil.cpp b/fxbarcode/qrcode/BC_QRCoderMaskUtil.cpp index cdf1e4caf9..582da85078 100644 --- a/fxbarcode/qrcode/BC_QRCoderMaskUtil.cpp +++ b/fxbarcode/qrcode/BC_QRCoderMaskUtil.cpp @@ -37,7 +37,7 @@ int32_t CBC_QRCoderMaskUtil::ApplyMaskPenaltyRule1( int32_t CBC_QRCoderMaskUtil::ApplyMaskPenaltyRule2( CBC_CommonByteMatrix* matrix) { int32_t penalty = 0; - uint8_t* array = matrix->GetArray(); + pdfium::span<const uint8_t> array = matrix->GetArray(); int32_t width = matrix->GetWidth(); int32_t height = matrix->GetHeight(); for (int32_t y = 0; y < height - 1; y++) { @@ -56,7 +56,7 @@ int32_t CBC_QRCoderMaskUtil::ApplyMaskPenaltyRule2( int32_t CBC_QRCoderMaskUtil::ApplyMaskPenaltyRule3( CBC_CommonByteMatrix* matrix) { int32_t penalty = 0; - uint8_t* array = matrix->GetArray(); + pdfium::span<const uint8_t> array = matrix->GetArray(); int32_t width = matrix->GetWidth(); int32_t height = matrix->GetHeight(); for (int32_t y = 0; y < height; ++y) { @@ -108,14 +108,13 @@ int32_t CBC_QRCoderMaskUtil::ApplyMaskPenaltyRule3( int32_t CBC_QRCoderMaskUtil::ApplyMaskPenaltyRule4( CBC_CommonByteMatrix* matrix) { int32_t numDarkCells = 0; - uint8_t* array = matrix->GetArray(); + pdfium::span<const uint8_t> array = matrix->GetArray(); int32_t width = matrix->GetWidth(); int32_t height = matrix->GetHeight(); for (int32_t y = 0; y < height; ++y) { for (int32_t x = 0; x < width; ++x) { - if (array[y * width + x] == 1) { + if (array[y * width + x] == 1) numDarkCells += 1; - } } } int32_t numTotalCells = matrix->GetHeight() * matrix->GetWidth(); @@ -176,7 +175,7 @@ int32_t CBC_QRCoderMaskUtil::ApplyMaskPenaltyRule1Internal( int32_t height = matrix->GetHeight(); int32_t iLimit = isHorizontal ? height : width; int32_t jLimit = isHorizontal ? width : height; - uint8_t* array = matrix->GetArray(); + pdfium::span<const uint8_t> array = matrix->GetArray(); for (int32_t i = 0; i < iLimit; ++i) { for (int32_t j = 0; j < jLimit; ++j) { int32_t bit = isHorizontal ? array[i * width + j] : array[j * width + i]; |