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

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: xfa 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
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..b8d421b68a9c3e38f53f265cd69df1ae7ab53ca2 100644
--- a/xfa/src/fxbarcode/BC_TwoDimWriter.cpp
+++ b/xfa/src/fxbarcode/BC_TwoDimWriter.cpp
@@ -4,6 +4,8 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+#include <algorithm>
+
#include "xfa/src/fxbarcode/barcode.h"
#include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h"
#include "xfa/src/fxbarcode/BC_Writer.h"
@@ -92,16 +94,15 @@ 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 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);
+ int32_t outputWidth = static_cast<int32_t>(
+ std::max(static_cast<int32_t>(tempWidth * moduleHSize), tempWidth));
Tom Sepez 2016/01/09 00:35:52 This code is troubling. moduleHSize is constrained
+ int32_t outputHeight = static_cast<int32_t>(
+ std::max(static_cast<int32_t>(tempHeight * moduleHSize), tempHeight));
Tom Sepez 2016/01/09 00:35:52 in any event, I don't think the outer cast is requ
int32_t multiX = 1;
int32_t multiY = 1;
if (m_bFixedSize) {
@@ -120,7 +121,7 @@ void CBC_TwoDimWriter::RenderResult(uint8_t* code,
multiX = (int32_t)ceil((FX_FLOAT)outputWidth / (FX_FLOAT)tempWidth);
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;

Powered by Google App Engine
This is Rietveld 408576698