summaryrefslogtreecommitdiff
path: root/xfa/src/fxbarcode/qrcode/BC_QRGridSampler.cpp
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2015-08-04 13:00:21 -0700
committerNico Weber <thakis@chromium.org>2015-08-04 13:00:21 -0700
commit9d8ec5a6e37e8d1d4d4edca9040de234e2d4728f (patch)
treec97037f398d714665aefccb6eb54d0969ad7030c /xfa/src/fxbarcode/qrcode/BC_QRGridSampler.cpp
parent780cee82236d1b3b0f9b01a22424e4b8ec9a6f12 (diff)
downloadpdfium-9d8ec5a6e37e8d1d4d4edca9040de234e2d4728f.tar.xz
XFA: clang-format all pdfium code.
No behavior change. Generated by: find . -name '*.cpp' -o -name '*.h' | \ grep -E -v 'third_party|thirdparties|lpng_v163|tiff_v403' | \ xargs ../../buildtools/mac/clang-format -i Then manually merged https://codereview.chromium.org/1269223002/ See thread "tabs vs spaces" on pdfium@googlegroups.com for discussion. BUG=none
Diffstat (limited to 'xfa/src/fxbarcode/qrcode/BC_QRGridSampler.cpp')
-rw-r--r--xfa/src/fxbarcode/qrcode/BC_QRGridSampler.cpp197
1 files changed, 102 insertions, 95 deletions
diff --git a/xfa/src/fxbarcode/qrcode/BC_QRGridSampler.cpp b/xfa/src/fxbarcode/qrcode/BC_QRGridSampler.cpp
index a5e478e1da..50ffa104e8 100644
--- a/xfa/src/fxbarcode/qrcode/BC_QRGridSampler.cpp
+++ b/xfa/src/fxbarcode/qrcode/BC_QRGridSampler.cpp
@@ -25,104 +25,111 @@
#include "../common/BC_CommonBitMatrix.h"
#include "BC_QRGridSampler.h"
CBC_QRGridSampler CBC_QRGridSampler::m_gridSampler;
-CBC_QRGridSampler::CBC_QRGridSampler()
-{
+CBC_QRGridSampler::CBC_QRGridSampler() {}
+CBC_QRGridSampler::~CBC_QRGridSampler() {}
+CBC_QRGridSampler& CBC_QRGridSampler::GetInstance() {
+ return m_gridSampler;
}
-CBC_QRGridSampler::~CBC_QRGridSampler()
-{
-}
-CBC_QRGridSampler &CBC_QRGridSampler::GetInstance()
-{
- return m_gridSampler;
-}
-void CBC_QRGridSampler::CheckAndNudgePoints(CBC_CommonBitMatrix *image, CFX_FloatArray *points, int32_t &e)
-{
- int32_t width = image->GetWidth();
- int32_t height = image->GetHeight();
- FX_BOOL nudged = TRUE;
- int32_t offset;
- for (offset = 0; offset < points->GetSize() && nudged; offset += 2) {
- int32_t x = (int32_t) (*points)[offset];
- int32_t y = (int32_t) (*points)[offset + 1];
- if (x < -1 || x > width || y < -1 || y > height) {
- e = BCExceptionRead;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
- }
- nudged = FALSE;
- if (x == -1) {
- (*points)[offset] = 0.0f;
- nudged = TRUE;
- } else if (x == width) {
- (*points)[offset] = (FX_FLOAT)(width - 1);
- nudged = TRUE;
- }
- if (y == -1) {
- (*points)[offset + 1] = 0.0f;
- nudged = TRUE;
- } else if (y == height) {
- (*points)[offset + 1] = (FX_FLOAT)(height - 1);
- nudged = TRUE;
- }
+void CBC_QRGridSampler::CheckAndNudgePoints(CBC_CommonBitMatrix* image,
+ CFX_FloatArray* points,
+ int32_t& e) {
+ int32_t width = image->GetWidth();
+ int32_t height = image->GetHeight();
+ FX_BOOL nudged = TRUE;
+ int32_t offset;
+ for (offset = 0; offset < points->GetSize() && nudged; offset += 2) {
+ int32_t x = (int32_t)(*points)[offset];
+ int32_t y = (int32_t)(*points)[offset + 1];
+ if (x < -1 || x > width || y < -1 || y > height) {
+ e = BCExceptionRead;
+ BC_EXCEPTION_CHECK_ReturnVoid(e);
+ }
+ nudged = FALSE;
+ if (x == -1) {
+ (*points)[offset] = 0.0f;
+ nudged = TRUE;
+ } else if (x == width) {
+ (*points)[offset] = (FX_FLOAT)(width - 1);
+ nudged = TRUE;
+ }
+ if (y == -1) {
+ (*points)[offset + 1] = 0.0f;
+ nudged = TRUE;
+ } else if (y == height) {
+ (*points)[offset + 1] = (FX_FLOAT)(height - 1);
+ nudged = TRUE;
}
- nudged = TRUE;
- for (offset = (*points).GetSize() - 2; offset >= 0 && nudged; offset -= 2) {
- int32_t x = (int32_t) (*points)[offset];
- int32_t y = (int32_t) (*points)[offset + 1];
- if (x < -1 || x > width || y < -1 || y > height) {
- e = BCExceptionRead;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
- }
- nudged = FALSE;
- if (x == -1) {
- (*points)[offset] = 0.0f;
- nudged = TRUE;
- } else if (x == width) {
- (*points)[offset] = (FX_FLOAT)(width - 1);
- nudged = TRUE;
- }
- if (y == -1) {
- (*points)[offset + 1] = 0.0f;
- nudged = TRUE;
- } else if (y == height) {
- (*points)[offset + 1] = (FX_FLOAT)(height - 1);
- nudged = TRUE;
- }
+ }
+ nudged = TRUE;
+ for (offset = (*points).GetSize() - 2; offset >= 0 && nudged; offset -= 2) {
+ int32_t x = (int32_t)(*points)[offset];
+ int32_t y = (int32_t)(*points)[offset + 1];
+ if (x < -1 || x > width || y < -1 || y > height) {
+ e = BCExceptionRead;
+ BC_EXCEPTION_CHECK_ReturnVoid(e);
}
+ nudged = FALSE;
+ if (x == -1) {
+ (*points)[offset] = 0.0f;
+ nudged = TRUE;
+ } else if (x == width) {
+ (*points)[offset] = (FX_FLOAT)(width - 1);
+ nudged = TRUE;
+ }
+ if (y == -1) {
+ (*points)[offset + 1] = 0.0f;
+ nudged = TRUE;
+ } else if (y == height) {
+ (*points)[offset + 1] = (FX_FLOAT)(height - 1);
+ nudged = TRUE;
+ }
+ }
}
-CBC_CommonBitMatrix *CBC_QRGridSampler::SampleGrid(CBC_CommonBitMatrix *image, int32_t dimensionX, int32_t dimensionY,
- FX_FLOAT p1ToX, FX_FLOAT p1ToY,
- FX_FLOAT p2ToX, FX_FLOAT p2ToY,
- FX_FLOAT p3ToX, FX_FLOAT p3ToY,
- FX_FLOAT p4ToX, FX_FLOAT p4ToY,
- FX_FLOAT p1FromX, FX_FLOAT p1FromY,
- FX_FLOAT p2FromX, FX_FLOAT p2FromY,
- FX_FLOAT p3FromX, FX_FLOAT p3FromY,
- FX_FLOAT p4FromX, FX_FLOAT p4FromY, int32_t &e)
-{
- CBC_AutoPtr<CBC_CommonPerspectiveTransform> transform(CBC_CommonPerspectiveTransform::QuadrilateralToQuadrilateral(
- p1ToX, p1ToY, p2ToX, p2ToY, p3ToX, p3ToY, p4ToX, p4ToY,
- p1FromX, p1FromY, p2FromX, p2FromY, p3FromX, p3FromY, p4FromX, p4FromY));
- CBC_CommonBitMatrix *tempBitM = FX_NEW CBC_CommonBitMatrix();
- tempBitM->Init(dimensionX, dimensionY);
- CBC_AutoPtr<CBC_CommonBitMatrix> bits(tempBitM);
- CFX_FloatArray points;
- points.SetSize(dimensionX << 1);
- for (int32_t y = 0; y < dimensionY; y++) {
- int32_t max = points.GetSize();
- FX_FLOAT iValue = (FX_FLOAT) (y + 0.5f);
- int32_t x;
- for (x = 0; x < max; x += 2) {
- points[x] = (FX_FLOAT) ((x >> 1) + 0.5f);
- points[x + 1] = iValue;
- }
- transform->TransformPoints(&points);
- CheckAndNudgePoints(image, &points, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- for (x = 0; x < max; x += 2) {
- if (image->Get((int32_t) points[x], (int32_t) points[x + 1])) {
- bits->Set(x >> 1, y);
- }
- }
+CBC_CommonBitMatrix* CBC_QRGridSampler::SampleGrid(CBC_CommonBitMatrix* image,
+ int32_t dimensionX,
+ int32_t dimensionY,
+ FX_FLOAT p1ToX,
+ FX_FLOAT p1ToY,
+ FX_FLOAT p2ToX,
+ FX_FLOAT p2ToY,
+ FX_FLOAT p3ToX,
+ FX_FLOAT p3ToY,
+ FX_FLOAT p4ToX,
+ FX_FLOAT p4ToY,
+ FX_FLOAT p1FromX,
+ FX_FLOAT p1FromY,
+ FX_FLOAT p2FromX,
+ FX_FLOAT p2FromY,
+ FX_FLOAT p3FromX,
+ FX_FLOAT p3FromY,
+ FX_FLOAT p4FromX,
+ FX_FLOAT p4FromY,
+ int32_t& e) {
+ CBC_AutoPtr<CBC_CommonPerspectiveTransform> transform(
+ CBC_CommonPerspectiveTransform::QuadrilateralToQuadrilateral(
+ p1ToX, p1ToY, p2ToX, p2ToY, p3ToX, p3ToY, p4ToX, p4ToY, p1FromX,
+ p1FromY, p2FromX, p2FromY, p3FromX, p3FromY, p4FromX, p4FromY));
+ CBC_CommonBitMatrix* tempBitM = FX_NEW CBC_CommonBitMatrix();
+ tempBitM->Init(dimensionX, dimensionY);
+ CBC_AutoPtr<CBC_CommonBitMatrix> bits(tempBitM);
+ CFX_FloatArray points;
+ points.SetSize(dimensionX << 1);
+ for (int32_t y = 0; y < dimensionY; y++) {
+ int32_t max = points.GetSize();
+ FX_FLOAT iValue = (FX_FLOAT)(y + 0.5f);
+ int32_t x;
+ for (x = 0; x < max; x += 2) {
+ points[x] = (FX_FLOAT)((x >> 1) + 0.5f);
+ points[x + 1] = iValue;
+ }
+ transform->TransformPoints(&points);
+ CheckAndNudgePoints(image, &points, e);
+ BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ for (x = 0; x < max; x += 2) {
+ if (image->Get((int32_t)points[x], (int32_t)points[x + 1])) {
+ bits->Set(x >> 1, y);
+ }
}
- return bits.release();
+ }
+ return bits.release();
}