diff options
author | tsepez <tsepez@chromium.org> | 2016-05-02 09:34:35 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-05-02 09:34:35 -0700 |
commit | 8f0d0da1b12e29133fb48a778603c03bf0056124 (patch) | |
tree | eacee99738a238d488c74723fef01a6b5c2f485d /xfa/fxbarcode/qrcode/BC_QRDataMask.cpp | |
parent | a86d113be692153d7707da377d11d4f09cb12c9b (diff) | |
download | pdfium-8f0d0da1b12e29133fb48a778603c03bf0056124.tar.xz |
Replace CFX_PtrArray with typesafe CFX_ArrayTemplate, part 10
Review-Url: https://codereview.chromium.org/1936733002
Diffstat (limited to 'xfa/fxbarcode/qrcode/BC_QRDataMask.cpp')
-rw-r--r-- | xfa/fxbarcode/qrcode/BC_QRDataMask.cpp | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/xfa/fxbarcode/qrcode/BC_QRDataMask.cpp b/xfa/fxbarcode/qrcode/BC_QRDataMask.cpp index 20f94069f4..9b5e3ca014 100644 --- a/xfa/fxbarcode/qrcode/BC_QRDataMask.cpp +++ b/xfa/fxbarcode/qrcode/BC_QRDataMask.cpp @@ -24,43 +24,47 @@ #include "xfa/fxbarcode/qrcode/BC_QRDataMask.h" #include "xfa/fxbarcode/utils.h" -static int32_t N_DATA_MASKS = 0; -CFX_PtrArray* CBC_QRDataMask::DATA_MASKS = NULL; +namespace { + +int32_t N_DATA_MASKS = 0; +CFX_ArrayTemplate<CBC_QRDataMask*>* DATA_MASKS = nullptr; + +} // namespace void CBC_QRDataMask::Initialize() { - DATA_MASKS = new CFX_PtrArray(); + DATA_MASKS = new CFX_ArrayTemplate<CBC_QRDataMask*>(); N_DATA_MASKS = BuildDataMasks(); } + void CBC_QRDataMask::Finalize() { Destroy(); delete DATA_MASKS; + DATA_MASKS = nullptr; } + void CBC_QRDataMask::Destroy() { - int32_t i; - for (i = 0; i < N_DATA_MASKS; i++) { - CBC_QRDataMask* p = (CBC_QRDataMask*)(*DATA_MASKS)[i]; - if (p) { - delete p; - } - } + for (int32_t i = 0; i < N_DATA_MASKS; ++i) + delete (*DATA_MASKS)[i]; } -void CBC_QRDataMask::UnmaskBitMatirx(CBC_CommonBitMatrix* bits, + +void CBC_QRDataMask::UnmaskBitMatrix(CBC_CommonBitMatrix* bits, int32_t dimension) { for (int32_t i = 0; i < dimension; i++) { for (int32_t j = 0; j < dimension; j++) { - if (IsMasked(i, j)) { + if (IsMasked(i, j)) bits->Flip(j, i); - } } } } + CBC_QRDataMask* CBC_QRDataMask::ForReference(int32_t reference, int32_t& e) { if (reference < 0 || reference > 7) { e = BCExceptionReferenceMustBeBetween0And7; - BC_EXCEPTION_CHECK_ReturnValue(e, NULL); + BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); } - return (CBC_QRDataMask*)(*DATA_MASKS)[reference]; + return (*DATA_MASKS)[reference]; } + class DataMask000 : public CBC_QRDataMask { public: FX_BOOL IsMasked(int32_t x, int32_t y) { return ((x + y) % 2) == 0; } |