1 // Copyright 2014 PDFium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 6 7 #ifndef XFA_FXBARCODE_QRCODE_BC_QRCODERMATRIXUTIL_H_ 8 #define XFA_FXBARCODE_QRCODE_BC_QRCODERMATRIXUTIL_H_ 9 10 class CBC_CommonByteMatrix; 11 class CBC_QRCoderErrorCorrectionLevel; 12 class CBC_QRCoderBitVector; 13 class CBC_QRCoderMatrixUtil { 14 private: 15 static const int32_t POSITION_DETECTION_PATTERN[7][7]; 16 static const int32_t VERTICAL_SEPARATION_PATTERN[7][1]; 17 static const int32_t HORIZONTAL_SEPARATION_PATTERN[1][8]; 18 static const int32_t POSITION_ADJUSTMENT_PATTERN[5][5]; 19 static const int32_t POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[40][7]; 20 static const int32_t TYPE_INFO_COORDINATES[15][2]; 21 static const int32_t VERSION_INFO_POLY; 22 static const int32_t TYPE_INFO_POLY; 23 static const int32_t TYPE_INFO_MASK_PATTERN; 24 25 public: 26 CBC_QRCoderMatrixUtil(); 27 virtual ~CBC_QRCoderMatrixUtil(); 28 static void ClearMatrix(CBC_CommonByteMatrix* matrix, int32_t& e); 29 static void BuildMatrix(CBC_QRCoderBitVector* dataBits, 30 CBC_QRCoderErrorCorrectionLevel* ecLevel, 31 int32_t version, 32 int32_t maskPattern, 33 CBC_CommonByteMatrix* matrix, 34 int32_t& e); 35 static void EmbedBasicPatterns(int32_t version, 36 CBC_CommonByteMatrix* matrix, 37 int32_t& e); 38 static void EmbedTypeInfo(CBC_QRCoderErrorCorrectionLevel* ecLevel, 39 int32_t maskPattern, 40 CBC_CommonByteMatrix* matrix, 41 int32_t& e); 42 static void EmbedDataBits(CBC_QRCoderBitVector* dataBits, 43 int32_t maskPattern, 44 CBC_CommonByteMatrix* matrix, 45 int32_t& e); 46 static void MaybeEmbedVersionInfo(int32_t version, 47 CBC_CommonByteMatrix* matrix, 48 int32_t& e); 49 static int32_t FindMSBSet(int32_t value); 50 static int32_t CalculateBCHCode(int32_t code, int32_t poly); 51 static void MakeTypeInfoBits(CBC_QRCoderErrorCorrectionLevel* ecLevel, 52 int32_t maskPattern, 53 CBC_QRCoderBitVector* bits, 54 int32_t& e); 55 static void MakeVersionInfoBits(int32_t version, 56 CBC_QRCoderBitVector* bits, 57 int32_t& e); 58 static bool IsEmpty(int32_t value); 59 static bool IsValidValue(int32_t value); 60 static void EmbedTimingPatterns(CBC_CommonByteMatrix* matrix, int32_t& e); 61 static void EmbedDarkDotAtLeftBottomCorner(CBC_CommonByteMatrix* matrix, 62 int32_t& e); 63 static void EmbedHorizontalSeparationPattern(int32_t xStart, 64 int32_t yStart, 65 CBC_CommonByteMatrix* matrix, 66 int32_t& e); 67 static void EmbedVerticalSeparationPattern(int32_t xStart, 68 int32_t yStart, 69 CBC_CommonByteMatrix* matrix, 70 int32_t& e); 71 static void EmbedPositionAdjustmentPattern(int32_t xStart, 72 int32_t yStart, 73 CBC_CommonByteMatrix* matrix, 74 int32_t& e); 75 static void EmbedPositionDetectionPattern(int32_t xStart, 76 int32_t yStart, 77 CBC_CommonByteMatrix* matrix, 78 int32_t& e); 79 static void EmbedPositionDetectionPatternsAndSeparators( 80 CBC_CommonByteMatrix* matrix, 81 int32_t& e); 82 static void MaybeEmbedPositionAdjustmentPatterns(int32_t version, 83 CBC_CommonByteMatrix* matrix, 84 int32_t& e); 85 }; 86 87 #endif // XFA_FXBARCODE_QRCODE_BC_QRCODERMATRIXUTIL_H_ 88