Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(433)

Side by Side Diff: xfa/src/fxbarcode/datamatrix/BC_DataMatrixDetector.cpp

Issue 1726373002: Remove foo != NULL checks in xfa/src/fxbarcode. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 // Original code is licensed as follows: 6 // Original code is licensed as follows:
7 /* 7 /*
8 * Copyright 2008 ZXing authors 8 * Copyright 2008 ZXing authors
9 * 9 *
10 * Licensed under the Apache License, Version 2.0 (the "License"); 10 * Licensed under the Apache License, Version 2.0 (the "License");
(...skipping 21 matching lines...) Expand all
32 #include "xfa/src/fxbarcode/qrcode/BC_QRGridSampler.h" 32 #include "xfa/src/fxbarcode/qrcode/BC_QRGridSampler.h"
33 const int32_t CBC_DataMatrixDetector::INTEGERS[5] = {0, 1, 2, 3, 4}; 33 const int32_t CBC_DataMatrixDetector::INTEGERS[5] = {0, 1, 2, 3, 4};
34 CBC_DataMatrixDetector::CBC_DataMatrixDetector(CBC_CommonBitMatrix* image) 34 CBC_DataMatrixDetector::CBC_DataMatrixDetector(CBC_CommonBitMatrix* image)
35 : m_image(image), m_rectangleDetector(NULL) {} 35 : m_image(image), m_rectangleDetector(NULL) {}
36 void CBC_DataMatrixDetector::Init(int32_t& e) { 36 void CBC_DataMatrixDetector::Init(int32_t& e) {
37 m_rectangleDetector = new CBC_WhiteRectangleDetector(m_image); 37 m_rectangleDetector = new CBC_WhiteRectangleDetector(m_image);
38 m_rectangleDetector->Init(e); 38 m_rectangleDetector->Init(e);
39 BC_EXCEPTION_CHECK_ReturnVoid(e); 39 BC_EXCEPTION_CHECK_ReturnVoid(e);
40 } 40 }
41 CBC_DataMatrixDetector::~CBC_DataMatrixDetector() { 41 CBC_DataMatrixDetector::~CBC_DataMatrixDetector() {
42 if (m_rectangleDetector != NULL) { 42 delete m_rectangleDetector;
43 delete m_rectangleDetector;
44 }
45 m_rectangleDetector = NULL;
46 } 43 }
47 inline FX_BOOL ResultPointsAndTransitionsComparator(void* a, void* b) { 44 inline FX_BOOL ResultPointsAndTransitionsComparator(void* a, void* b) {
48 return ((CBC_ResultPointsAndTransitions*)b)->GetTransitions() > 45 return ((CBC_ResultPointsAndTransitions*)b)->GetTransitions() >
49 ((CBC_ResultPointsAndTransitions*)a)->GetTransitions(); 46 ((CBC_ResultPointsAndTransitions*)a)->GetTransitions();
50 } 47 }
51 CBC_QRDetectorResult* CBC_DataMatrixDetector::Detect(int32_t& e) { 48 CBC_QRDetectorResult* CBC_DataMatrixDetector::Detect(int32_t& e) {
52 CFX_PtrArray* cornerPoints = m_rectangleDetector->Detect(e); 49 CFX_PtrArray* cornerPoints = m_rectangleDetector->Detect(e);
53 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 50 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
54 CBC_ResultPoint* pointA = (CBC_ResultPoint*)(*cornerPoints)[0]; 51 CBC_ResultPoint* pointA = (CBC_ResultPoint*)(*cornerPoints)[0];
55 CBC_ResultPoint* pointB = (CBC_ResultPoint*)(*cornerPoints)[1]; 52 CBC_ResultPoint* pointB = (CBC_ResultPoint*)(*cornerPoints)[1];
(...skipping 18 matching lines...) Expand all
74 Increment(pointCount, lSideOne->GetTo()); 71 Increment(pointCount, lSideOne->GetTo());
75 Increment(pointCount, lSideTwo->GetFrom()); 72 Increment(pointCount, lSideTwo->GetFrom());
76 Increment(pointCount, lSideTwo->GetTo()); 73 Increment(pointCount, lSideTwo->GetTo());
77 delete ((CBC_ResultPointsAndTransitions*)transitions[1]); 74 delete ((CBC_ResultPointsAndTransitions*)transitions[1]);
78 delete ((CBC_ResultPointsAndTransitions*)transitions[0]); 75 delete ((CBC_ResultPointsAndTransitions*)transitions[0]);
79 transitions.RemoveAll(); 76 transitions.RemoveAll();
80 CBC_ResultPoint* maybeTopLeft = NULL; 77 CBC_ResultPoint* maybeTopLeft = NULL;
81 CBC_ResultPoint* bottomLeft = NULL; 78 CBC_ResultPoint* bottomLeft = NULL;
82 CBC_ResultPoint* maybeBottomRight = NULL; 79 CBC_ResultPoint* maybeBottomRight = NULL;
83 FX_POSITION itBegin = pointCount.GetStartPosition(); 80 FX_POSITION itBegin = pointCount.GetStartPosition();
84 while (itBegin != NULL) { 81 while (itBegin) {
85 CBC_ResultPoint* key = 0; 82 CBC_ResultPoint* key = 0;
86 int32_t value = 0; 83 int32_t value = 0;
87 pointCount.GetNextAssoc(itBegin, key, value); 84 pointCount.GetNextAssoc(itBegin, key, value);
88 if (value == 2) { 85 if (value == 2) {
89 bottomLeft = key; 86 bottomLeft = key;
90 } else { 87 } else {
91 if (maybeBottomRight == NULL) { 88 if (maybeBottomRight == NULL) {
92 maybeBottomRight = key; 89 maybeBottomRight = key;
93 } else { 90 } else {
94 maybeTopLeft = key; 91 maybeTopLeft = key;
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 (bottomLeft->GetX() - topLeft->GetX()) * 394 (bottomLeft->GetX() - topLeft->GetX()) *
398 (topRight->GetY() - topLeft->GetY())) { 395 (topRight->GetY() - topLeft->GetY())) {
399 CBC_ResultPoint* temp = topRight; 396 CBC_ResultPoint* temp = topRight;
400 topRight = bottomLeft; 397 topRight = bottomLeft;
401 bottomLeft = temp; 398 bottomLeft = temp;
402 } 399 }
403 (*patterns)[0] = bottomLeft; 400 (*patterns)[0] = bottomLeft;
404 (*patterns)[1] = topLeft; 401 (*patterns)[1] = topLeft;
405 (*patterns)[2] = topRight; 402 (*patterns)[2] = topRight;
406 } 403 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698