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 _BC_QRCODERMATRIXUTIL_H_ 8 #define _BC_QRCODERMATRIXUTIL_H_ 9 class CBC_CommonByteMatrix; 10 class CBC_QRCoderErrorCorrectionLevel; 11 class CBC_QRCoderBitVector; 12 class CBC_QRCoderMatrixUtil { 13 private: 14 const static int32_t POSITION_DETECTION_PATTERN[7][7]; 15 const static int32_t VERTICAL_SEPARATION_PATTERN[7][1]; 16 const static int32_t HORIZONTAL_SEPARATION_PATTERN[1][8]; 17 const static int32_t POSITION_ADJUSTMENT_PATTERN[5][5]; 18 const static int32_t POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[40][7]; 19 const static int32_t TYPE_INFO_COORDINATES[15][2]; 20 const static int32_t VERSION_INFO_POLY; 21 const static int32_t TYPE_INFO_POLY; 22 const static int32_t TYPE_INFO_MASK_PATTERN; 23 24 public: 25 CBC_QRCoderMatrixUtil(); 26 virtual ~CBC_QRCoderMatrixUtil(); 27 static void ClearMatrix(CBC_CommonByteMatrix* matrix, int32_t& e); 28 static void BuildMatrix(CBC_QRCoderBitVector* dataBits, 29 CBC_QRCoderErrorCorrectionLevel* ecLevel, 30 int32_t version, 31 int32_t maskPattern, 32 CBC_CommonByteMatrix* matrix, 33 int32_t& e); 34 static void EmbedBasicPatterns(int32_t version, 35 CBC_CommonByteMatrix* matrix, 36 int32_t& e); 37 static void EmbedTypeInfo(CBC_QRCoderErrorCorrectionLevel* ecLevel, 38 int32_t maskPattern, 39 CBC_CommonByteMatrix* matrix, 40 int32_t& e); 41 static void EmbedDataBits(CBC_QRCoderBitVector* dataBits, 42 int32_t maskPattern, 43 CBC_CommonByteMatrix* matrix, 44 int32_t& e); 45 static void MaybeEmbedVersionInfo(int32_t version, 46 CBC_CommonByteMatrix* matrix, 47 int32_t& e); 48 static int32_t FindMSBSet(int32_t value); 49 static int32_t CalculateBCHCode(int32_t code, int32_t poly); 50 static void MakeTypeInfoBits(CBC_QRCoderErrorCorrectionLevel* ecLevel, 51 int32_t maskPattern, 52 CBC_QRCoderBitVector* bits, 53 int32_t& e); 54 static void MakeVersionInfoBits(int32_t version, 55 CBC_QRCoderBitVector* bits, 56 int32_t& e); 57 static FX_BOOL IsEmpty(int32_t value); 58 static FX_BOOL IsValidValue(int32_t value); 59 static void EmbedTimingPatterns(CBC_CommonByteMatrix* matrix, int32_t& e); 60 static void EmbedDarkDotAtLeftBottomCorner(CBC_CommonByteMatrix* matrix, 61 int32_t& e); 62 static void EmbedHorizontalSeparationPattern(int32_t xStart, 63 int32_t yStart, 64 CBC_CommonByteMatrix* matrix, 65 int32_t& e); 66 static void EmbedVerticalSeparationPattern(int32_t xStart, 67 int32_t yStart, 68 CBC_CommonByteMatrix* matrix, 69 int32_t& e); 70 static void EmbedPositionAdjustmentPattern(int32_t xStart, 71 int32_t yStart, 72 CBC_CommonByteMatrix* matrix, 73 int32_t& e); 74 static void EmbedPositionDetectionPattern(int32_t xStart, 75 int32_t yStart, 76 CBC_CommonByteMatrix* matrix, 77 int32_t& e); 78 static void EmbedPositionDetectionPatternsAndSeparators( 79 CBC_CommonByteMatrix* matrix, 80 int32_t& e); 81 static void MaybeEmbedPositionAdjustmentPatterns(int32_t version, 82 CBC_CommonByteMatrix* matrix, 83 int32_t& e); 84 }; 85 #endif 86