summaryrefslogtreecommitdiff
path: root/core/fxcrt
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-04-03 14:51:45 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-04-03 20:36:56 +0000
commit669a418f75c05d4a39e2bcaff2b7b93dec1c5764 (patch)
treeb76f5025c8e70b1ef449f317ff60a8eef7317ab9 /core/fxcrt
parentac978f83392e309488601eb382d5f318b6d366ad (diff)
downloadpdfium-669a418f75c05d4a39e2bcaff2b7b93dec1c5764.tar.xz
Drop FXSYS_ from math methods
This Cl drops the FXSYS_ from math methods which are the same on all platforms. Bug: pdfium:694 Change-Id: I85c9ff841fd9095b1434f67319847ba0cd9df7ac Reviewed-on: https://pdfium-review.googlesource.com/3598 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fxcrt')
-rw-r--r--core/fxcrt/cfx_decimal.cpp4
-rw-r--r--core/fxcrt/fx_basic_coords.cpp55
-rw-r--r--core/fxcrt/fx_coordinates.h6
-rw-r--r--core/fxcrt/fx_ext.h1
-rw-r--r--core/fxcrt/fx_extension.cpp7
-rw-r--r--core/fxcrt/fx_system.h14
6 files changed, 33 insertions, 54 deletions
diff --git a/core/fxcrt/cfx_decimal.cpp b/core/fxcrt/cfx_decimal.cpp
index 1baa6896a3..095978cd43 100644
--- a/core/fxcrt/cfx_decimal.cpp
+++ b/core/fxcrt/cfx_decimal.cpp
@@ -276,12 +276,12 @@ CFX_Decimal::CFX_Decimal(float val, uint8_t scale) {
plo = static_cast<uint64_t>(newval);
pmid = static_cast<uint64_t>(newval / 1e32);
phi = static_cast<uint64_t>(newval / 1e64);
- newval = FXSYS_fmod(newval, 1.0f);
+ newval = fmod(newval, 1.0f);
for (uint8_t iter = 0; iter < scale; iter++) {
decimal_helper_mul10(phi, pmid, plo);
newval *= 10;
plo += static_cast<uint64_t>(newval);
- newval = FXSYS_fmod(newval, 1.0f);
+ newval = fmod(newval, 1.0f);
}
plo += FXSYS_round(newval);
diff --git a/core/fxcrt/fx_basic_coords.cpp b/core/fxcrt/fx_basic_coords.cpp
index a1b403820e..71a15c0cec 100644
--- a/core/fxcrt/fx_basic_coords.cpp
+++ b/core/fxcrt/fx_basic_coords.cpp
@@ -13,11 +13,11 @@
namespace {
void MatchFloatRange(float f1, float f2, int* i1, int* i2) {
- int length = static_cast<int>(FXSYS_ceil(f2 - f1));
- int i1_1 = static_cast<int>(FXSYS_floor(f1));
- int i1_2 = static_cast<int>(FXSYS_ceil(f1));
- float error1 = f1 - i1_1 + (float)FXSYS_fabs(f2 - i1_1 - length);
- float error2 = i1_2 - f1 + (float)FXSYS_fabs(f2 - i1_2 - length);
+ int length = static_cast<int>(ceil(f2 - f1));
+ int i1_1 = static_cast<int>(floor(f1));
+ int i1_2 = static_cast<int>(ceil(f1));
+ float error1 = f1 - i1_1 + (float)fabs(f2 - i1_1 - length);
+ float error2 = i1_2 - f1 + (float)fabs(f2 - i1_2 - length);
*i1 = (error1 > error2) ? i1_2 : i1_1;
*i2 = *i1 + length;
@@ -160,10 +160,10 @@ int CFX_FloatRect::Substract4(CFX_FloatRect& s, CFX_FloatRect* pRects) {
FX_RECT CFX_FloatRect::GetOuterRect() const {
CFX_FloatRect rect1 = *this;
FX_RECT rect;
- rect.left = (int)FXSYS_floor(rect1.left);
- rect.right = (int)FXSYS_ceil(rect1.right);
- rect.top = (int)FXSYS_floor(rect1.bottom);
- rect.bottom = (int)FXSYS_ceil(rect1.top);
+ rect.left = (int)floor(rect1.left);
+ rect.right = (int)ceil(rect1.right);
+ rect.top = (int)floor(rect1.bottom);
+ rect.bottom = (int)ceil(rect1.top);
rect.Normalize();
return rect;
}
@@ -171,10 +171,10 @@ FX_RECT CFX_FloatRect::GetOuterRect() const {
FX_RECT CFX_FloatRect::GetInnerRect() const {
CFX_FloatRect rect1 = *this;
FX_RECT rect;
- rect.left = (int)FXSYS_ceil(rect1.left);
- rect.right = (int)FXSYS_floor(rect1.right);
- rect.top = (int)FXSYS_ceil(rect1.bottom);
- rect.bottom = (int)FXSYS_floor(rect1.top);
+ rect.left = (int)ceil(rect1.left);
+ rect.right = (int)floor(rect1.right);
+ rect.top = (int)ceil(rect1.bottom);
+ rect.bottom = (int)floor(rect1.top);
rect.Normalize();
return rect;
}
@@ -230,7 +230,7 @@ CFX_FloatRect CFX_FloatRect::GetBBox(const CFX_PointF* pPoints, int nPoints) {
void CFX_Matrix::SetReverse(const CFX_Matrix& m) {
float i = m.a * m.d - m.b * m.c;
- if (FXSYS_fabs(i) <= std::numeric_limits<float>::epsilon())
+ if (fabs(i) <= std::numeric_limits<float>::epsilon())
return;
float j = -i;
@@ -253,13 +253,11 @@ void CFX_Matrix::ConcatInverse(const CFX_Matrix& src, bool bPrepended) {
}
bool CFX_Matrix::Is90Rotated() const {
- return FXSYS_fabs(a * 1000) < FXSYS_fabs(b) &&
- FXSYS_fabs(d * 1000) < FXSYS_fabs(c);
+ return fabs(a * 1000) < fabs(b) && fabs(d * 1000) < fabs(c);
}
bool CFX_Matrix::IsScaled() const {
- return FXSYS_fabs(b * 1000) < FXSYS_fabs(a) &&
- FXSYS_fabs(c * 1000) < FXSYS_fabs(d);
+ return fabs(b * 1000) < fabs(a) && fabs(c * 1000) < fabs(d);
}
void CFX_Matrix::Translate(float x, float y, bool bPrepended) {
@@ -288,8 +286,8 @@ void CFX_Matrix::Scale(float sx, float sy, bool bPrepended) {
}
void CFX_Matrix::Rotate(float fRadian, bool bPrepended) {
- float cosValue = FXSYS_cos(fRadian);
- float sinValue = FXSYS_sin(fRadian);
+ float cosValue = cos(fRadian);
+ float sinValue = sin(fRadian);
ConcatInternal(CFX_Matrix(cosValue, sinValue, -sinValue, cosValue, 0, 0),
bPrepended);
}
@@ -301,18 +299,17 @@ void CFX_Matrix::RotateAt(float fRadian, float dx, float dy, bool bPrepended) {
}
void CFX_Matrix::Shear(float fAlphaRadian, float fBetaRadian, bool bPrepended) {
- ConcatInternal(
- CFX_Matrix(1, FXSYS_tan(fAlphaRadian), FXSYS_tan(fBetaRadian), 1, 0, 0),
- bPrepended);
+ ConcatInternal(CFX_Matrix(1, tan(fAlphaRadian), tan(fBetaRadian), 1, 0, 0),
+ bPrepended);
}
void CFX_Matrix::MatchRect(const CFX_FloatRect& dest,
const CFX_FloatRect& src) {
float fDiff = src.left - src.right;
- a = FXSYS_fabs(fDiff) < 0.001f ? 1 : (dest.left - dest.right) / fDiff;
+ a = fabs(fDiff) < 0.001f ? 1 : (dest.left - dest.right) / fDiff;
fDiff = src.bottom - src.top;
- d = FXSYS_fabs(fDiff) < 0.001f ? 1 : (dest.bottom - dest.top) / fDiff;
+ d = fabs(fDiff) < 0.001f ? 1 : (dest.bottom - dest.top) / fDiff;
e = dest.left - src.left * a;
f = dest.bottom - src.bottom * d;
b = 0;
@@ -324,7 +321,7 @@ float CFX_Matrix::GetXUnit() const {
return (a > 0 ? a : -a);
if (a == 0)
return (b > 0 ? b : -b);
- return FXSYS_sqrt(a * a + b * b);
+ return sqrt(a * a + b * b);
}
float CFX_Matrix::GetYUnit() const {
@@ -332,7 +329,7 @@ float CFX_Matrix::GetYUnit() const {
return (d > 0 ? d : -d);
if (d == 0)
return (c > 0 ? c : -c);
- return FXSYS_sqrt(c * c + d * d);
+ return sqrt(c * c + d * d);
}
CFX_FloatRect CFX_Matrix::GetUnitRect() const {
@@ -344,13 +341,13 @@ CFX_FloatRect CFX_Matrix::GetUnitRect() const {
float CFX_Matrix::TransformXDistance(float dx) const {
float fx = a * dx;
float fy = b * dx;
- return FXSYS_sqrt(fx * fx + fy * fy);
+ return sqrt(fx * fx + fy * fy);
}
float CFX_Matrix::TransformDistance(float dx, float dy) const {
float fx = a * dx + c * dy;
float fy = b * dx + d * dy;
- return FXSYS_sqrt(fx * fx + fy * fy);
+ return sqrt(fx * fx + fy * fy);
}
float CFX_Matrix::TransformDistance(float distance) const {
diff --git a/core/fxcrt/fx_coordinates.h b/core/fxcrt/fx_coordinates.h
index 5ccaf3d229..0262268f49 100644
--- a/core/fxcrt/fx_coordinates.h
+++ b/core/fxcrt/fx_coordinates.h
@@ -162,7 +162,7 @@ class CFX_VTemplate : public CFX_PTemplate<BaseType> {
const CFX_PTemplate<BaseType>& point2)
: CFX_PTemplate<BaseType>(point2.x - point1.x, point2.y - point1.y) {}
- float Length() const { return FXSYS_sqrt(x * x + y * y); }
+ float Length() const { return sqrt(x * x + y * y); }
void Normalize() {
float fLen = Length();
if (fLen < 0.0001f)
@@ -180,8 +180,8 @@ class CFX_VTemplate : public CFX_PTemplate<BaseType> {
y *= sy;
}
void Rotate(float fRadian) {
- float cosValue = FXSYS_cos(fRadian);
- float sinValue = FXSYS_sin(fRadian);
+ float cosValue = cos(fRadian);
+ float sinValue = sin(fRadian);
x = x * cosValue - y * sinValue;
y = x * sinValue + y * cosValue;
}
diff --git a/core/fxcrt/fx_ext.h b/core/fxcrt/fx_ext.h
index 2eafe6c7b9..7d42e90ce3 100644
--- a/core/fxcrt/fx_ext.h
+++ b/core/fxcrt/fx_ext.h
@@ -15,7 +15,6 @@
#define FX_INVALID_OFFSET static_cast<uint32_t>(-1)
-float FXSYS_tan(float a);
float FXSYS_strtof(const char* pcsStr,
int32_t iLength = -1,
int32_t* pUsedLen = nullptr);
diff --git a/core/fxcrt/fx_extension.cpp b/core/fxcrt/fx_extension.cpp
index 3fd3a0d500..f8abff376f 100644
--- a/core/fxcrt/fx_extension.cpp
+++ b/core/fxcrt/fx_extension.cpp
@@ -419,12 +419,6 @@ CFX_RetainPtr<IFX_MemoryStream> IFX_MemoryStream::Create(bool bConsecutive) {
return pdfium::MakeRetain<CFX_MemoryStream>(bConsecutive);
}
-float FXSYS_tan(float a) {
- return (float)tan(a);
-}
-float FXSYS_logb(float b, float x) {
- return FXSYS_log(x) / FXSYS_log(b);
-}
float FXSYS_strtof(const char* pcsStr, int32_t iLength, int32_t* pUsedLen) {
ASSERT(pcsStr);
if (iLength < 0) {
@@ -434,6 +428,7 @@ float FXSYS_strtof(const char* pcsStr, int32_t iLength, int32_t* pUsedLen) {
CFX_WideString::FromLocal(CFX_ByteStringC(pcsStr, iLength));
return FXSYS_wcstof(ws.c_str(), iLength, pUsedLen);
}
+
float FXSYS_wcstof(const wchar_t* pwsStr, int32_t iLength, int32_t* pUsedLen) {
ASSERT(pwsStr);
if (iLength < 0) {
diff --git a/core/fxcrt/fx_system.h b/core/fxcrt/fx_system.h
index d9a352c1d6..c471085e25 100644
--- a/core/fxcrt/fx_system.h
+++ b/core/fxcrt/fx_system.h
@@ -252,18 +252,6 @@ wchar_t* FXSYS_wcsupr(wchar_t* str);
#define FXSYS_pow(a, b) (float)pow(a, b)
#endif // _FXM_PLATFORM == _FXM_PLATFORM_WINDOWS_
-#define FXSYS_sqrt(a) (float)sqrt(a)
-#define FXSYS_fabs(a) (float)fabs(a)
-#define FXSYS_atan2(a, b) (float)atan2(a, b)
-#define FXSYS_ceil(a) (float)ceil(a)
-#define FXSYS_floor(a) (float)floor(a)
-#define FXSYS_cos(a) (float)cos(a)
-#define FXSYS_acos(a) (float)acos(a)
-#define FXSYS_sin(a) (float)sin(a)
-#define FXSYS_log(a) (float)log(a)
-#define FXSYS_log10(a) (float)log10(a)
-#define FXSYS_fmod(a, b) (float)fmod(a, b)
-#define FXSYS_abs abs
#define FXDWORD_GET_LSBFIRST(p) \
((static_cast<uint32_t>(p[3]) << 24) | (static_cast<uint32_t>(p[2]) << 16) | \
(static_cast<uint32_t>(p[1]) << 8) | (static_cast<uint32_t>(p[0])))
@@ -277,7 +265,7 @@ int64_t FXSYS_atoi64(const char* str);
int64_t FXSYS_wtoi64(const wchar_t* str);
const char* FXSYS_i64toa(int64_t value, char* str, int radix);
int FXSYS_round(float f);
-#define FXSYS_sqrt2(a, b) (float)FXSYS_sqrt((a) * (a) + (b) * (b))
+#define FXSYS_sqrt2(a, b) (float)sqrt((a) * (a) + (b) * (b))
#ifdef __cplusplus
}; // extern C
#endif // __cplusplus