summaryrefslogtreecommitdiff
path: root/xfa/fxbarcode/qrcode
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fxbarcode/qrcode')
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRDetector.cpp18
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRDetectorResult.cpp24
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRDetectorResult.h24
3 files changed, 35 insertions, 31 deletions
diff --git a/xfa/fxbarcode/qrcode/BC_QRDetector.cpp b/xfa/fxbarcode/qrcode/BC_QRDetector.cpp
index 030ee43c20..15ae3e26f1 100644
--- a/xfa/fxbarcode/qrcode/BC_QRDetector.cpp
+++ b/xfa/fxbarcode/qrcode/BC_QRDetector.cpp
@@ -28,6 +28,7 @@
#include "xfa/fxbarcode/BC_ResultPoint.h"
#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h"
#include "xfa/fxbarcode/qrcode/BC_FinderPatternInfo.h"
+#include "xfa/fxbarcode/qrcode/BC_QRAlignmentPattern.h"
#include "xfa/fxbarcode/qrcode/BC_QRAlignmentPatternFinder.h"
#include "xfa/fxbarcode/qrcode/BC_QRCoderVersion.h"
#include "xfa/fxbarcode/qrcode/BC_QRDetectorResult.h"
@@ -90,17 +91,14 @@ CBC_QRDetectorResult* CBC_QRDetector::ProcessFinderPatternInfo(
SampleGrid(m_image, topLeft.get(), topRight.get(), bottomLeft.get(),
(CBC_ResultPoint*)(alignmentPattern), dimension, e);
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CFX_PtrArray* points = new CFX_PtrArray;
- if (alignmentPattern == NULL) {
- points->Add(bottomLeft.release());
- points->Add(topLeft.release());
- points->Add(topRight.release());
- } else {
- points->Add(bottomLeft.release());
- points->Add(topLeft.release());
- points->Add(topRight.release());
+
+ CFX_ArrayTemplate<CBC_ResultPoint*>* points =
+ new CFX_ArrayTemplate<CBC_ResultPoint*>();
+ points->Add(bottomLeft.release());
+ points->Add(topLeft.release());
+ points->Add(topRight.release());
+ if (alignmentPattern)
points->Add(alignmentPattern);
- }
return new CBC_QRDetectorResult(bits, points);
}
CBC_CommonBitMatrix* CBC_QRDetector::SampleGrid(
diff --git a/xfa/fxbarcode/qrcode/BC_QRDetectorResult.cpp b/xfa/fxbarcode/qrcode/BC_QRDetectorResult.cpp
index 18e5d9ad4c..5ce2e75762 100644
--- a/xfa/fxbarcode/qrcode/BC_QRDetectorResult.cpp
+++ b/xfa/fxbarcode/qrcode/BC_QRDetectorResult.cpp
@@ -24,20 +24,20 @@
#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h"
#include "xfa/fxbarcode/qrcode/BC_QRDetectorResult.h"
-CBC_QRDetectorResult::CBC_QRDetectorResult(CBC_CommonBitMatrix* bits,
- CFX_PtrArray* points)
+CBC_QRDetectorResult::CBC_QRDetectorResult(
+ CBC_CommonBitMatrix* bits,
+ CFX_ArrayTemplate<CBC_ResultPoint*>* points)
: m_bits(bits), m_points(points) {}
+
CBC_QRDetectorResult::~CBC_QRDetectorResult() {
- for (int32_t i = 0; i < m_points->GetSize(); i++) {
- delete (CBC_ResultPoint*)(*m_points)[i];
- }
- m_points->RemoveAll();
- delete m_points;
- delete m_bits;
+ for (int32_t i = 0; i < m_points->GetSize(); i++)
+ delete (*m_points)[i];
}
-CBC_CommonBitMatrix* CBC_QRDetectorResult::GetBits() {
- return m_bits;
+
+CBC_CommonBitMatrix* CBC_QRDetectorResult::GetBits() const {
+ return m_bits.get();
}
-CFX_PtrArray* CBC_QRDetectorResult::GetPoints() {
- return m_points;
+
+CFX_ArrayTemplate<CBC_ResultPoint*>* CBC_QRDetectorResult::GetPoints() const {
+ return m_points.get();
}
diff --git a/xfa/fxbarcode/qrcode/BC_QRDetectorResult.h b/xfa/fxbarcode/qrcode/BC_QRDetectorResult.h
index 1570777afe..5948c2a01c 100644
--- a/xfa/fxbarcode/qrcode/BC_QRDetectorResult.h
+++ b/xfa/fxbarcode/qrcode/BC_QRDetectorResult.h
@@ -7,20 +7,26 @@
#ifndef XFA_FXBARCODE_QRCODE_BC_QRDETECTORRESULT_H_
#define XFA_FXBARCODE_QRCODE_BC_QRDETECTORRESULT_H_
+#include <memory>
+
#include "core/fxcrt/include/fx_basic.h"
class CBC_CommonBitMatrix;
+class CBC_ResultPoint;
-class CBC_QRDetectorResult {
- private:
- CBC_CommonBitMatrix* m_bits;
- CFX_PtrArray* m_points;
-
+class CBC_QRDetectorResult final {
public:
- CBC_QRDetectorResult(CBC_CommonBitMatrix* bits, CFX_PtrArray* points);
- virtual ~CBC_QRDetectorResult();
- CBC_CommonBitMatrix* GetBits();
- CFX_PtrArray* GetPoints();
+ // Takes ownership of |bits| and |points|.
+ CBC_QRDetectorResult(CBC_CommonBitMatrix* bits,
+ CFX_ArrayTemplate<CBC_ResultPoint*>* points);
+ ~CBC_QRDetectorResult();
+
+ CBC_CommonBitMatrix* GetBits() const;
+ CFX_ArrayTemplate<CBC_ResultPoint*>* GetPoints() const;
+
+ private:
+ std::unique_ptr<CBC_CommonBitMatrix> m_bits;
+ std::unique_ptr<CFX_ArrayTemplate<CBC_ResultPoint*>> m_points;
};
#endif // XFA_FXBARCODE_QRCODE_BC_QRDETECTORRESULT_H_