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

Unified Diff: xfa/src/fxbarcode/BC_TwoDimWriter.cpp

Issue 1577503002: Merge to XFA: Switch most min/max macros to std::min/max. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: rebase Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « xfa/src/fwl/src/theme/widgettp.cpp ('k') | xfa/src/fxbarcode/common/BC_CommonByteArray.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: xfa/src/fxbarcode/BC_TwoDimWriter.cpp
diff --git a/xfa/src/fxbarcode/BC_TwoDimWriter.cpp b/xfa/src/fxbarcode/BC_TwoDimWriter.cpp
index d6d66144496022295876c36d7cfa32bb3845bcd9..b270378a874ff441f0c74469844053f3945400a6 100644
--- a/xfa/src/fxbarcode/BC_TwoDimWriter.cpp
+++ b/xfa/src/fxbarcode/BC_TwoDimWriter.cpp
@@ -4,10 +4,14 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+#include <algorithm>
+
+#include "third_party/base/numerics/safe_math.h"
#include "xfa/src/fxbarcode/barcode.h"
#include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h"
#include "xfa/src/fxbarcode/BC_Writer.h"
#include "xfa/src/fxbarcode/BC_TwoDimWriter.h"
+
CBC_TwoDimWriter::CBC_TwoDimWriter() {
m_iCorrectLevel = 1;
m_bFixedSize = TRUE;
@@ -92,18 +96,18 @@ void CBC_TwoDimWriter::RenderResult(uint8_t* code,
int32_t& e) {
int32_t inputWidth = codeWidth;
int32_t inputHeight = codeHeight;
- int32_t tempWidth = inputWidth + (1 << 1);
- int32_t tempHeight = inputHeight + (1 << 1);
- FX_FLOAT moduleHSize = (FX_FLOAT)FX_MIN(m_ModuleWidth, m_ModuleHeight);
- if (moduleHSize > 8) {
- moduleHSize = 8;
- } else if (moduleHSize < 1) {
- moduleHSize = 1;
- }
- int32_t outputWidth = (int32_t)FX_MAX(tempWidth * moduleHSize, tempWidth);
- int32_t outputHeight = (int32_t)FX_MAX(tempHeight * moduleHSize, tempHeight);
- int32_t multiX = 1;
- int32_t multiY = 1;
+ int32_t tempWidth = inputWidth + 2;
+ int32_t tempHeight = inputHeight + 2;
+ FX_FLOAT moduleHSize = std::min(m_ModuleWidth, m_ModuleHeight);
+ moduleHSize = std::min(moduleHSize, 8.0f);
+ moduleHSize = std::max(moduleHSize, 1.0f);
+ pdfium::base::CheckedNumeric<int32_t> scaledWidth = tempWidth;
+ pdfium::base::CheckedNumeric<int32_t> scaledHeight = tempHeight;
+ scaledWidth *= moduleHSize;
+ scaledHeight *= moduleHSize;
+
+ int32_t outputWidth = scaledWidth.ValueOrDie();
+ int32_t outputHeight = scaledHeight.ValueOrDie();
if (m_bFixedSize) {
if (m_Width < outputWidth || m_Height < outputHeight) {
e = BCExceptionBitmapSizeError;
@@ -117,10 +121,10 @@ void CBC_TwoDimWriter::RenderResult(uint8_t* code,
outputHeight * ceil((FX_FLOAT)m_Height / (FX_FLOAT)outputHeight));
}
}
- multiX = (int32_t)ceil((FX_FLOAT)outputWidth / (FX_FLOAT)tempWidth);
- multiY = (int32_t)ceil((FX_FLOAT)outputHeight / (FX_FLOAT)tempHeight);
+ int32_t multiX = (int32_t)ceil((FX_FLOAT)outputWidth / (FX_FLOAT)tempWidth);
+ int32_t multiY = (int32_t)ceil((FX_FLOAT)outputHeight / (FX_FLOAT)tempHeight);
if (m_bFixedSize) {
- multiX = FX_MIN(multiX, multiY);
+ multiX = std::min(multiX, multiY);
multiY = multiX;
}
int32_t leftPadding = (outputWidth - (inputWidth * multiX)) / 2;
« no previous file with comments | « xfa/src/fwl/src/theme/widgettp.cpp ('k') | xfa/src/fxbarcode/common/BC_CommonByteArray.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698