summaryrefslogtreecommitdiff
path: root/xfa/fxbarcode/qrcode/BC_QRCoderMatrixUtil.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2017-02-06 09:34:23 -0800
committerChromium commit bot <commit-bot@chromium.org>2017-02-06 17:56:54 +0000
commit3c056ae5599be463216fb1883c710157f019acc2 (patch)
tree69910ca9c32e06600adbe28bb0cdb0dc50245a64 /xfa/fxbarcode/qrcode/BC_QRCoderMatrixUtil.cpp
parente5f4f22e4c67f40123bca91c2213223cc5a12ebd (diff)
downloadpdfium-3c056ae5599be463216fb1883c710157f019acc2.tar.xz
Remove redundant tests exposed by inlining macros in fxbarcode
Remove some unused #defines as well. Change-Id: Ie7dc1ae85100eae24f18a3ecd456e3c8d8043a43 Reviewed-on: https://pdfium-review.googlesource.com/2490 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fxbarcode/qrcode/BC_QRCoderMatrixUtil.cpp')
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRCoderMatrixUtil.cpp84
1 files changed, 30 insertions, 54 deletions
diff --git a/xfa/fxbarcode/qrcode/BC_QRCoderMatrixUtil.cpp b/xfa/fxbarcode/qrcode/BC_QRCoderMatrixUtil.cpp
index 757f4ef7f4..d48d81c091 100644
--- a/xfa/fxbarcode/qrcode/BC_QRCoderMatrixUtil.cpp
+++ b/xfa/fxbarcode/qrcode/BC_QRCoderMatrixUtil.cpp
@@ -79,8 +79,7 @@ void CBC_QRCoderMatrixUtil::ClearMatrix(CBC_CommonByteMatrix* matrix,
int32_t& e) {
if (!matrix) {
e = BCExceptionNullPointer;
- if (e != BCExceptionNO)
- return;
+ return;
}
matrix->clear((uint8_t)-1);
}
@@ -93,8 +92,7 @@ void CBC_QRCoderMatrixUtil::BuildMatrix(
int32_t& e) {
if (!matrix) {
e = BCExceptionNullPointer;
- if (e != BCExceptionNO)
- return;
+ return;
}
ClearMatrix(matrix, e);
if (e != BCExceptionNO)
@@ -117,8 +115,7 @@ void CBC_QRCoderMatrixUtil::EmbedBasicPatterns(int32_t version,
int32_t& e) {
if (!matrix) {
e = BCExceptionNullPointer;
- if (e != BCExceptionNO)
- return;
+ return;
}
EmbedPositionDetectionPatternsAndSeparators(matrix, e);
if (e != BCExceptionNO)
@@ -140,8 +137,7 @@ void CBC_QRCoderMatrixUtil::EmbedTypeInfo(
int32_t& e) {
if (!matrix) {
e = BCExceptionNullPointer;
- if (e != BCExceptionNO)
- return;
+ return;
}
CBC_QRCoderBitVector typeInfoBits;
typeInfoBits.Init();
@@ -171,8 +167,7 @@ void CBC_QRCoderMatrixUtil::MaybeEmbedVersionInfo(int32_t version,
int32_t& e) {
if (!matrix) {
e = BCExceptionNullPointer;
- if (e != BCExceptionNO)
- return;
+ return;
}
if (version < 7) {
return;
@@ -200,8 +195,7 @@ void CBC_QRCoderMatrixUtil::EmbedDataBits(CBC_QRCoderBitVector* dataBits,
int32_t& e) {
if (!matrix || !dataBits) {
e = BCExceptionNullPointer;
- if (e != BCExceptionNO)
- return;
+ return;
}
int32_t bitIndex = 0;
int32_t direction = -1;
@@ -265,13 +259,11 @@ void CBC_QRCoderMatrixUtil::MakeTypeInfoBits(
int32_t& e) {
if (!bits) {
e = BCExceptionNullPointer;
- if (e != BCExceptionNO)
- return;
+ return;
}
if (!CBC_QRCoder::IsValidMaskPattern(maskPattern)) {
e = BCExceptionBadMask;
- if (e != BCExceptionNO)
- return;
+ return;
}
int32_t typeInfo = (ecLevel->GetBits() << 3) | maskPattern;
if (e != BCExceptionNO)
@@ -289,33 +281,30 @@ void CBC_QRCoderMatrixUtil::MakeTypeInfoBits(
bits->XOR(&maskBits, e);
if (e != BCExceptionNO)
return;
- if (bits->Size() != 15) {
+ if (bits->Size() != 15)
e = BCExceptionBitSizeNot15;
- if (e != BCExceptionNO)
- return;
- }
}
+
void CBC_QRCoderMatrixUtil::MakeVersionInfoBits(int32_t version,
CBC_QRCoderBitVector* bits,
int32_t& e) {
if (!bits) {
e = BCExceptionNullPointer;
- if (e != BCExceptionNO)
- return;
+ return;
}
bits->AppendBits(version, 6, e);
if (e != BCExceptionNO)
return;
+
int32_t bchCode = CalculateBCHCode(version, VERSION_INFO_POLY);
bits->AppendBits(bchCode, 12, e);
if (e != BCExceptionNO)
return;
- if (bits->Size() != 18) {
+
+ if (bits->Size() != 18)
e = BCExceptionBitSizeNot18;
- if (e != BCExceptionNO)
- return;
- }
}
+
bool CBC_QRCoderMatrixUtil::IsEmpty(int32_t value) {
return (uint8_t)value == 0xff;
}
@@ -323,27 +312,25 @@ bool CBC_QRCoderMatrixUtil::IsValidValue(int32_t value) {
return ((uint8_t)value == 0xff || (uint8_t)value == 0x00 ||
(uint8_t)value == 0x01);
}
+
void CBC_QRCoderMatrixUtil::EmbedTimingPatterns(CBC_CommonByteMatrix* matrix,
int32_t& e) {
if (!matrix) {
e = BCExceptionNullPointer;
- if (e != BCExceptionNO)
- return;
+ return;
}
for (int32_t i = 8; i < matrix->GetWidth() - 8; i++) {
int32_t bit = (i + 1) % 2;
if (!IsValidValue(matrix->Get(i, 6))) {
e = BCExceptionInvalidateImageData;
- if (e != BCExceptionNO)
- return;
+ return;
}
if (IsEmpty(matrix->Get(i, 6))) {
matrix->Set(i, 6, bit);
}
if (!IsValidValue(matrix->Get(6, i))) {
e = BCExceptionInvalidateImageData;
- if (e != BCExceptionNO)
- return;
+ return;
}
if (IsEmpty(matrix->Get(6, i))) {
matrix->Set(6, i, bit);
@@ -355,13 +342,11 @@ void CBC_QRCoderMatrixUtil::EmbedDarkDotAtLeftBottomCorner(
int32_t& e) {
if (!matrix) {
e = BCExceptionNullPointer;
- if (e != BCExceptionNO)
- return;
+ return;
}
if (matrix->Get(8, matrix->GetHeight() - 8) == 0) {
e = BCExceptionHeight_8BeZero;
- if (e != BCExceptionNO)
- return;
+ return;
}
matrix->Set(8, matrix->GetHeight() - 8, 1);
}
@@ -372,14 +357,12 @@ void CBC_QRCoderMatrixUtil::EmbedHorizontalSeparationPattern(
int32_t& e) {
if (!matrix) {
e = BCExceptionNullPointer;
- if (e != BCExceptionNO)
- return;
+ return;
}
for (int32_t x = 0; x < 8; x++) {
if (!IsEmpty(matrix->Get(xStart + x, yStart))) {
e = BCExceptionInvalidateData;
- if (e != BCExceptionNO)
- return;
+ return;
}
matrix->Set(xStart + x, yStart, HORIZONTAL_SEPARATION_PATTERN[0][x]);
}
@@ -391,14 +374,12 @@ void CBC_QRCoderMatrixUtil::EmbedVerticalSeparationPattern(
int32_t& e) {
if (!matrix) {
e = BCExceptionNullPointer;
- if (e != BCExceptionNO)
- return;
+ return;
}
for (int32_t y = 0; y < 7; y++) {
if (!IsEmpty(matrix->Get(xStart, yStart + y))) {
e = BCExceptionInvalidateData;
- if (e != BCExceptionNO)
- return;
+ return;
}
matrix->Set(xStart, yStart + y, VERTICAL_SEPARATION_PATTERN[y][0]);
}
@@ -417,8 +398,7 @@ void CBC_QRCoderMatrixUtil::EmbedPositionAdjustmentPattern(
for (int32_t x = 0; x < 5; x++) {
if (!IsEmpty(matrix->Get(xStart + x, y + yStart))) {
e = BCExceptionInvalidateData;
- if (e != BCExceptionNO)
- return;
+ return;
}
matrix->Set(xStart + x, yStart + y, POSITION_ADJUSTMENT_PATTERN[y][x]);
}
@@ -431,15 +411,13 @@ void CBC_QRCoderMatrixUtil::EmbedPositionDetectionPattern(
int32_t& e) {
if (!matrix) {
e = BCExceptionNullPointer;
- if (e != BCExceptionNO)
- return;
+ return;
}
for (int32_t y = 0; y < 7; y++) {
for (int32_t x = 0; x < 7; x++) {
if (!IsEmpty(matrix->Get(xStart + x, yStart + y))) {
e = BCExceptionInvalidateData;
- if (e != BCExceptionNO)
- return;
+ return;
}
matrix->Set(xStart + x, yStart + y, POSITION_DETECTION_PATTERN[y][x]);
}
@@ -450,8 +428,7 @@ void CBC_QRCoderMatrixUtil::EmbedPositionDetectionPatternsAndSeparators(
int32_t& e) {
if (!matrix) {
e = BCExceptionNullPointer;
- if (e != BCExceptionNO)
- return;
+ return;
}
int32_t pdpWidth = 7;
EmbedPositionDetectionPattern(0, 0, matrix, e);
@@ -493,8 +470,7 @@ void CBC_QRCoderMatrixUtil::MaybeEmbedPositionAdjustmentPatterns(
int32_t& e) {
if (!matrix) {
e = BCExceptionNullPointer;
- if (e != BCExceptionNO)
- return;
+ return;
}
if (version < 2) {
return;