xref: /aosp_15_r20/external/pdfium/fxbarcode/datamatrix/BC_SymbolInfo.h (revision 3ac0a46f773bac49fa9476ec2b1cf3f8da5ec3a4)
1*3ac0a46fSAndroid Build Coastguard Worker // Copyright 2014 The PDFium Authors
2*3ac0a46fSAndroid Build Coastguard Worker // Use of this source code is governed by a BSD-style license that can be
3*3ac0a46fSAndroid Build Coastguard Worker // found in the LICENSE file.
4*3ac0a46fSAndroid Build Coastguard Worker 
5*3ac0a46fSAndroid Build Coastguard Worker // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6*3ac0a46fSAndroid Build Coastguard Worker 
7*3ac0a46fSAndroid Build Coastguard Worker #ifndef FXBARCODE_DATAMATRIX_BC_SYMBOLINFO_H_
8*3ac0a46fSAndroid Build Coastguard Worker #define FXBARCODE_DATAMATRIX_BC_SYMBOLINFO_H_
9*3ac0a46fSAndroid Build Coastguard Worker 
10*3ac0a46fSAndroid Build Coastguard Worker #include <stddef.h>
11*3ac0a46fSAndroid Build Coastguard Worker #include <stdint.h>
12*3ac0a46fSAndroid Build Coastguard Worker 
13*3ac0a46fSAndroid Build Coastguard Worker #include "core/fxcrt/unowned_ptr.h"
14*3ac0a46fSAndroid Build Coastguard Worker 
15*3ac0a46fSAndroid Build Coastguard Worker class CBC_SymbolInfo {
16*3ac0a46fSAndroid Build Coastguard Worker  public:
17*3ac0a46fSAndroid Build Coastguard Worker   struct Data {
18*3ac0a46fSAndroid Build Coastguard Worker     int16_t data_capacity;
19*3ac0a46fSAndroid Build Coastguard Worker     int16_t error_codewords;
20*3ac0a46fSAndroid Build Coastguard Worker     int16_t rs_block_data;
21*3ac0a46fSAndroid Build Coastguard Worker     int8_t rs_block_error;
22*3ac0a46fSAndroid Build Coastguard Worker     int8_t matrix_width;
23*3ac0a46fSAndroid Build Coastguard Worker     int8_t matrix_height;
24*3ac0a46fSAndroid Build Coastguard Worker     int8_t data_regions;
25*3ac0a46fSAndroid Build Coastguard Worker   };
26*3ac0a46fSAndroid Build Coastguard Worker 
27*3ac0a46fSAndroid Build Coastguard Worker   virtual ~CBC_SymbolInfo();
28*3ac0a46fSAndroid Build Coastguard Worker 
29*3ac0a46fSAndroid Build Coastguard Worker   static void Initialize();
30*3ac0a46fSAndroid Build Coastguard Worker   static void Finalize();
31*3ac0a46fSAndroid Build Coastguard Worker   static const CBC_SymbolInfo* Lookup(size_t data_codewords,
32*3ac0a46fSAndroid Build Coastguard Worker                                       bool allow_rectangular);
33*3ac0a46fSAndroid Build Coastguard Worker 
34*3ac0a46fSAndroid Build Coastguard Worker   int32_t GetSymbolDataWidth() const;
35*3ac0a46fSAndroid Build Coastguard Worker   int32_t GetSymbolDataHeight() const;
36*3ac0a46fSAndroid Build Coastguard Worker   int32_t GetSymbolWidth() const;
37*3ac0a46fSAndroid Build Coastguard Worker   int32_t GetSymbolHeight() const;
38*3ac0a46fSAndroid Build Coastguard Worker   virtual size_t GetInterleavedBlockCount() const;
39*3ac0a46fSAndroid Build Coastguard Worker   size_t GetDataLengthForInterleavedBlock() const;
40*3ac0a46fSAndroid Build Coastguard Worker   size_t GetErrorLengthForInterleavedBlock() const;
41*3ac0a46fSAndroid Build Coastguard Worker 
data_capacity()42*3ac0a46fSAndroid Build Coastguard Worker   size_t data_capacity() const { return data_->data_capacity; }
error_codewords()43*3ac0a46fSAndroid Build Coastguard Worker   size_t error_codewords() const { return data_->error_codewords; }
matrix_width()44*3ac0a46fSAndroid Build Coastguard Worker   int32_t matrix_width() const { return data_->matrix_width; }
matrix_height()45*3ac0a46fSAndroid Build Coastguard Worker   int32_t matrix_height() const { return data_->matrix_height; }
46*3ac0a46fSAndroid Build Coastguard Worker 
47*3ac0a46fSAndroid Build Coastguard Worker  protected:
48*3ac0a46fSAndroid Build Coastguard Worker   explicit CBC_SymbolInfo(const Data* data);
49*3ac0a46fSAndroid Build Coastguard Worker 
50*3ac0a46fSAndroid Build Coastguard Worker  private:
51*3ac0a46fSAndroid Build Coastguard Worker   int32_t GetHorizontalDataRegions() const;
52*3ac0a46fSAndroid Build Coastguard Worker   int32_t GetVerticalDataRegions() const;
is_rectangular()53*3ac0a46fSAndroid Build Coastguard Worker   bool is_rectangular() const {
54*3ac0a46fSAndroid Build Coastguard Worker     return data_->matrix_width != data_->matrix_height;
55*3ac0a46fSAndroid Build Coastguard Worker   }
56*3ac0a46fSAndroid Build Coastguard Worker 
57*3ac0a46fSAndroid Build Coastguard Worker   UnownedPtr<const Data> const data_;
58*3ac0a46fSAndroid Build Coastguard Worker };
59*3ac0a46fSAndroid Build Coastguard Worker 
60*3ac0a46fSAndroid Build Coastguard Worker #endif  // FXBARCODE_DATAMATRIX_BC_SYMBOLINFO_H_
61