summaryrefslogtreecommitdiff
path: root/core/fxcrt
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-03-14 14:43:42 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-03-14 19:05:58 +0000
commit05df075154a832fcb476e1dfcfb865722d0ea898 (patch)
treeb8b771b62adae74d5d5ee561db75d10de3a848bf /core/fxcrt
parent6b94f01d1c8ad386d497428c7397b1a99614aeba (diff)
downloadpdfium-05df075154a832fcb476e1dfcfb865722d0ea898.tar.xz
Replace FX_FLOAT with underlying float type.
Change-Id: I158b7d80b0ec28b742a9f2d5a96f3dde7fb3ab56 Reviewed-on: https://pdfium-review.googlesource.com/3031 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org>
Diffstat (limited to 'core/fxcrt')
-rw-r--r--core/fxcrt/fx_basic.h45
-rw-r--r--core/fxcrt/fx_basic_bstring.cpp4
-rw-r--r--core/fxcrt/fx_basic_buffer.cpp4
-rw-r--r--core/fxcrt/fx_basic_coords.cpp97
-rw-r--r--core/fxcrt/fx_basic_util.cpp13
-rw-r--r--core/fxcrt/fx_basic_wstring.cpp10
-rw-r--r--core/fxcrt/fx_coordinates.h120
-rw-r--r--core/fxcrt/fx_ext.h18
-rw-r--r--core/fxcrt/fx_extension.cpp16
-rw-r--r--core/fxcrt/fx_string.h10
-rw-r--r--core/fxcrt/fx_system.h31
-rw-r--r--core/fxcrt/fx_xml.h14
-rw-r--r--core/fxcrt/fx_xml_parser.cpp4
13 files changed, 183 insertions, 203 deletions
diff --git a/core/fxcrt/fx_basic.h b/core/fxcrt/fx_basic.h
index 007c362ad6..a4069fddbd 100644
--- a/core/fxcrt/fx_basic.h
+++ b/core/fxcrt/fx_basic.h
@@ -506,12 +506,11 @@ class CFX_Vector_3by1 {
public:
CFX_Vector_3by1() : a(0.0f), b(0.0f), c(0.0f) {}
- CFX_Vector_3by1(FX_FLOAT a1, FX_FLOAT b1, FX_FLOAT c1)
- : a(a1), b(b1), c(c1) {}
+ CFX_Vector_3by1(float a1, float b1, float c1) : a(a1), b(b1), c(c1) {}
- FX_FLOAT a;
- FX_FLOAT b;
- FX_FLOAT c;
+ float a;
+ float b;
+ float c;
};
class CFX_Matrix_3by3 {
public:
@@ -526,15 +525,15 @@ class CFX_Matrix_3by3 {
h(0.0f),
i(0.0f) {}
- CFX_Matrix_3by3(FX_FLOAT a1,
- FX_FLOAT b1,
- FX_FLOAT c1,
- FX_FLOAT d1,
- FX_FLOAT e1,
- FX_FLOAT f1,
- FX_FLOAT g1,
- FX_FLOAT h1,
- FX_FLOAT i1)
+ CFX_Matrix_3by3(float a1,
+ float b1,
+ float c1,
+ float d1,
+ float e1,
+ float f1,
+ float g1,
+ float h1,
+ float i1)
: a(a1), b(b1), c(c1), d(d1), e(e1), f(f1), g(g1), h(h1), i(i1) {}
CFX_Matrix_3by3 Inverse();
@@ -543,15 +542,15 @@ class CFX_Matrix_3by3 {
CFX_Vector_3by1 TransformVector(const CFX_Vector_3by1& v);
- FX_FLOAT a;
- FX_FLOAT b;
- FX_FLOAT c;
- FX_FLOAT d;
- FX_FLOAT e;
- FX_FLOAT f;
- FX_FLOAT g;
- FX_FLOAT h;
- FX_FLOAT i;
+ float a;
+ float b;
+ float c;
+ float d;
+ float e;
+ float f;
+ float g;
+ float h;
+ float i;
};
uint32_t GetBits32(const uint8_t* pData, int bitpos, int nbits);
diff --git a/core/fxcrt/fx_basic_bstring.cpp b/core/fxcrt/fx_basic_bstring.cpp
index cbd8b379b9..b4eb4a75e0 100644
--- a/core/fxcrt/fx_basic_bstring.cpp
+++ b/core/fxcrt/fx_basic_bstring.cpp
@@ -958,7 +958,7 @@ void CFX_ByteString::TrimLeft() {
uint32_t CFX_ByteString::GetID(FX_STRSIZE start_pos) const {
return AsStringC().GetID(start_pos);
}
-FX_STRSIZE FX_ftoa(FX_FLOAT d, char* buf) {
+FX_STRSIZE FX_ftoa(float d, char* buf) {
buf[0] = '0';
buf[1] = '\0';
if (d == 0.0f) {
@@ -1004,7 +1004,7 @@ FX_STRSIZE FX_ftoa(FX_FLOAT d, char* buf) {
}
return buf_size;
}
-CFX_ByteString CFX_ByteString::FormatFloat(FX_FLOAT d, int precision) {
+CFX_ByteString CFX_ByteString::FormatFloat(float d, int precision) {
char buf[32];
FX_STRSIZE len = FX_ftoa(d, buf);
return CFX_ByteString(buf, len);
diff --git a/core/fxcrt/fx_basic_buffer.cpp b/core/fxcrt/fx_basic_buffer.cpp
index eaa79c9af1..341d9013ae 100644
--- a/core/fxcrt/fx_basic_buffer.cpp
+++ b/core/fxcrt/fx_basic_buffer.cpp
@@ -117,7 +117,7 @@ CFX_ByteTextBuf& CFX_ByteTextBuf::operator<<(uint32_t i) {
CFX_ByteTextBuf& CFX_ByteTextBuf::operator<<(double f) {
char buf[32];
- FX_STRSIZE len = FX_ftoa((FX_FLOAT)f, buf);
+ FX_STRSIZE len = FX_ftoa((float)f, buf);
AppendBlock(buf, len);
return *this;
}
@@ -158,7 +158,7 @@ CFX_WideTextBuf& CFX_WideTextBuf::operator<<(int i) {
CFX_WideTextBuf& CFX_WideTextBuf::operator<<(double f) {
char buf[32];
- FX_STRSIZE len = FX_ftoa((FX_FLOAT)f, buf);
+ FX_STRSIZE len = FX_ftoa((float)f, buf);
ExpandBuf(len * sizeof(wchar_t));
wchar_t* str = (wchar_t*)(m_pBuffer.get() + m_DataSize);
for (FX_STRSIZE i = 0; i < len; i++) {
diff --git a/core/fxcrt/fx_basic_coords.cpp b/core/fxcrt/fx_basic_coords.cpp
index cb5a010427..460f700f03 100644
--- a/core/fxcrt/fx_basic_coords.cpp
+++ b/core/fxcrt/fx_basic_coords.cpp
@@ -13,12 +13,12 @@
namespace {
-void MatchFloatRange(FX_FLOAT f1, FX_FLOAT f2, int* i1, int* i2) {
+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));
- FX_FLOAT error1 = f1 - i1_1 + (FX_FLOAT)FXSYS_fabs(f2 - i1_1 - length);
- FX_FLOAT error2 = i1_2 - f1 + (FX_FLOAT)FXSYS_fabs(f2 - i1_2 - length);
+ float error1 = f1 - i1_1 + (float)FXSYS_fabs(f2 - i1_1 - length);
+ float error2 = i1_2 - f1 + (float)FXSYS_fabs(f2 - i1_2 - length);
*i1 = (error1 > error2) ? i1_2 : i1_1;
*i2 = *i1 + length;
@@ -51,12 +51,12 @@ void FX_RECT::Intersect(const FX_RECT& src) {
}
}
-bool GetIntersection(FX_FLOAT low1,
- FX_FLOAT high1,
- FX_FLOAT low2,
- FX_FLOAT high2,
- FX_FLOAT& interlow,
- FX_FLOAT& interhigh) {
+bool GetIntersection(float low1,
+ float high1,
+ float low2,
+ float high2,
+ float& interlow,
+ float& interhigh) {
if (low1 >= high2 || low2 >= high1) {
return false;
}
@@ -64,24 +64,24 @@ bool GetIntersection(FX_FLOAT low1,
interhigh = high1 > high2 ? high2 : high1;
return true;
}
-extern "C" int FXSYS_round(FX_FLOAT d) {
- if (d < (FX_FLOAT)INT_MIN) {
+extern "C" int FXSYS_round(float d) {
+ if (d < (float)INT_MIN) {
return INT_MIN;
}
- if (d > (FX_FLOAT)INT_MAX) {
+ if (d > (float)INT_MAX) {
return INT_MAX;
}
return (int)round(d);
}
CFX_FloatRect::CFX_FloatRect(const FX_RECT& rect) {
- left = (FX_FLOAT)(rect.left);
- right = (FX_FLOAT)(rect.right);
- bottom = (FX_FLOAT)(rect.top);
- top = (FX_FLOAT)(rect.bottom);
+ left = (float)(rect.left);
+ right = (float)(rect.right);
+ bottom = (float)(rect.top);
+ top = (float)(rect.bottom);
}
void CFX_FloatRect::Normalize() {
- FX_FLOAT temp;
+ float temp;
if (left > right) {
temp = left;
left = right;
@@ -205,7 +205,7 @@ bool CFX_FloatRect::Contains(const CFX_FloatRect& other_rect) const {
n2.top <= n1.top;
}
-void CFX_FloatRect::UpdateRect(FX_FLOAT x, FX_FLOAT y) {
+void CFX_FloatRect::UpdateRect(float x, float y) {
left = std::min(left, x);
right = std::max(right, x);
bottom = std::min(bottom, y);
@@ -216,10 +216,10 @@ CFX_FloatRect CFX_FloatRect::GetBBox(const CFX_PointF* pPoints, int nPoints) {
if (nPoints == 0)
return CFX_FloatRect();
- FX_FLOAT min_x = pPoints->x;
- FX_FLOAT max_x = pPoints->x;
- FX_FLOAT min_y = pPoints->y;
- FX_FLOAT max_y = pPoints->y;
+ float min_x = pPoints->x;
+ float max_x = pPoints->x;
+ float min_y = pPoints->y;
+ float max_y = pPoints->y;
for (int i = 1; i < nPoints; i++) {
min_x = std::min(min_x, pPoints[i].x);
max_x = std::max(max_x, pPoints[i].x);
@@ -230,11 +230,11 @@ CFX_FloatRect CFX_FloatRect::GetBBox(const CFX_PointF* pPoints, int nPoints) {
}
void CFX_Matrix::SetReverse(const CFX_Matrix& m) {
- FX_FLOAT i = m.a * m.d - m.b * m.c;
+ float i = m.a * m.d - m.b * m.c;
if (FXSYS_fabs(i) == 0)
return;
- FX_FLOAT j = -i;
+ float j = -i;
a = m.d / i;
b = m.b / j;
c = m.c / j;
@@ -263,7 +263,7 @@ bool CFX_Matrix::IsScaled() const {
FXSYS_fabs(c * 1000) < FXSYS_fabs(d);
}
-void CFX_Matrix::Translate(FX_FLOAT x, FX_FLOAT y, bool bPrepended) {
+void CFX_Matrix::Translate(float x, float y, bool bPrepended) {
if (bPrepended) {
e += x * a + y * c;
f += y * d + x * b;
@@ -273,7 +273,7 @@ void CFX_Matrix::Translate(FX_FLOAT x, FX_FLOAT y, bool bPrepended) {
f += y;
}
-void CFX_Matrix::Scale(FX_FLOAT sx, FX_FLOAT sy, bool bPrepended) {
+void CFX_Matrix::Scale(float sx, float sy, bool bPrepended) {
a *= sx;
d *= sy;
if (bPrepended) {
@@ -288,25 +288,20 @@ void CFX_Matrix::Scale(FX_FLOAT sx, FX_FLOAT sy, bool bPrepended) {
f *= sy;
}
-void CFX_Matrix::Rotate(FX_FLOAT fRadian, bool bPrepended) {
- FX_FLOAT cosValue = FXSYS_cos(fRadian);
- FX_FLOAT sinValue = FXSYS_sin(fRadian);
+void CFX_Matrix::Rotate(float fRadian, bool bPrepended) {
+ float cosValue = FXSYS_cos(fRadian);
+ float sinValue = FXSYS_sin(fRadian);
ConcatInternal(CFX_Matrix(cosValue, sinValue, -sinValue, cosValue, 0, 0),
bPrepended);
}
-void CFX_Matrix::RotateAt(FX_FLOAT fRadian,
- FX_FLOAT dx,
- FX_FLOAT dy,
- bool bPrepended) {
+void CFX_Matrix::RotateAt(float fRadian, float dx, float dy, bool bPrepended) {
Translate(dx, dy, bPrepended);
Rotate(fRadian, bPrepended);
Translate(-dx, -dy, bPrepended);
}
-void CFX_Matrix::Shear(FX_FLOAT fAlphaRadian,
- FX_FLOAT fBetaRadian,
- 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);
@@ -314,7 +309,7 @@ void CFX_Matrix::Shear(FX_FLOAT fAlphaRadian,
void CFX_Matrix::MatchRect(const CFX_FloatRect& dest,
const CFX_FloatRect& src) {
- FX_FLOAT fDiff = src.left - src.right;
+ float fDiff = src.left - src.right;
a = FXSYS_fabs(fDiff) < 0.001f ? 1 : (dest.left - dest.right) / fDiff;
fDiff = src.bottom - src.top;
@@ -325,7 +320,7 @@ void CFX_Matrix::MatchRect(const CFX_FloatRect& dest,
c = 0;
}
-FX_FLOAT CFX_Matrix::GetXUnit() const {
+float CFX_Matrix::GetXUnit() const {
if (b == 0)
return (a > 0 ? a : -a);
if (a == 0)
@@ -333,7 +328,7 @@ FX_FLOAT CFX_Matrix::GetXUnit() const {
return FXSYS_sqrt(a * a + b * b);
}
-FX_FLOAT CFX_Matrix::GetYUnit() const {
+float CFX_Matrix::GetYUnit() const {
if (c == 0)
return (d > 0 ? d : -d);
if (d == 0)
@@ -347,19 +342,19 @@ CFX_FloatRect CFX_Matrix::GetUnitRect() const {
return rect;
}
-FX_FLOAT CFX_Matrix::TransformXDistance(FX_FLOAT dx) const {
- FX_FLOAT fx = a * dx;
- FX_FLOAT fy = b * dx;
+float CFX_Matrix::TransformXDistance(float dx) const {
+ float fx = a * dx;
+ float fy = b * dx;
return FXSYS_sqrt(fx * fx + fy * fy);
}
-FX_FLOAT CFX_Matrix::TransformDistance(FX_FLOAT dx, FX_FLOAT dy) const {
- FX_FLOAT fx = a * dx + c * dy;
- FX_FLOAT fy = b * dx + d * dy;
+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);
}
-FX_FLOAT CFX_Matrix::TransformDistance(FX_FLOAT distance) const {
+float CFX_Matrix::TransformDistance(float distance) const {
return distance * (GetXUnit() + GetYUnit()) / 2;
}
@@ -369,16 +364,16 @@ CFX_PointF CFX_Matrix::Transform(const CFX_PointF& point) const {
}
void CFX_Matrix::TransformRect(CFX_RectF& rect) const {
- FX_FLOAT right = rect.right(), bottom = rect.bottom();
+ float right = rect.right(), bottom = rect.bottom();
TransformRect(rect.left, right, bottom, rect.top);
rect.width = right - rect.left;
rect.height = bottom - rect.top;
}
-void CFX_Matrix::TransformRect(FX_FLOAT& left,
- FX_FLOAT& right,
- FX_FLOAT& top,
- FX_FLOAT& bottom) const {
+void CFX_Matrix::TransformRect(float& left,
+ float& right,
+ float& top,
+ float& bottom) const {
CFX_PointF points[] = {
{left, top}, {left, bottom}, {right, top}, {right, bottom}};
for (int i = 0; i < 4; i++)
diff --git a/core/fxcrt/fx_basic_util.cpp b/core/fxcrt/fx_basic_util.cpp
index 45543dc317..b3c5829fc9 100644
--- a/core/fxcrt/fx_basic_util.cpp
+++ b/core/fxcrt/fx_basic_util.cpp
@@ -14,7 +14,7 @@
bool FX_atonum(const CFX_ByteStringC& strc, void* pData) {
if (strc.Find('.') != -1) {
- FX_FLOAT* pFloat = static_cast<FX_FLOAT*>(pData);
+ float* pFloat = static_cast<float*>(pData);
*pFloat = FX_atof(strc);
return false;
}
@@ -69,7 +69,7 @@ bool FX_atonum(const CFX_ByteStringC& strc, void* pData) {
return true;
}
-static const FX_FLOAT fraction_scales[] = {
+static const float fraction_scales[] = {
0.1f, 0.01f, 0.001f, 0.0001f,
0.00001f, 0.000001f, 0.0000001f, 0.00000001f,
0.000000001f, 0.0000000001f, 0.00000000001f};
@@ -78,11 +78,11 @@ int FXSYS_FractionalScaleCount() {
return FX_ArraySize(fraction_scales);
}
-FX_FLOAT FXSYS_FractionalScale(size_t scale_factor, int value) {
+float FXSYS_FractionalScale(size_t scale_factor, int value) {
return fraction_scales[scale_factor] * value;
}
-FX_FLOAT FX_atof(const CFX_ByteStringC& strc) {
+float FX_atof(const CFX_ByteStringC& strc) {
if (strc.IsEmpty())
return 0.0;
@@ -100,7 +100,7 @@ FX_FLOAT FX_atof(const CFX_ByteStringC& strc) {
break;
cc++;
}
- FX_FLOAT value = 0;
+ float value = 0;
while (cc < len) {
if (strc[cc] == '.')
break;
@@ -206,8 +206,7 @@ wchar_t FX_GetFolderSeparator() {
}
CFX_Matrix_3by3 CFX_Matrix_3by3::Inverse() {
- FX_FLOAT det =
- a * (e * i - f * h) - b * (i * d - f * g) + c * (d * h - e * g);
+ float det = a * (e * i - f * h) - b * (i * d - f * g) + c * (d * h - e * g);
if (FXSYS_fabs(det) < 0.0000001)
return CFX_Matrix_3by3();
diff --git a/core/fxcrt/fx_basic_wstring.cpp b/core/fxcrt/fx_basic_wstring.cpp
index 3b9fa2435c..8522d42a38 100644
--- a/core/fxcrt/fx_basic_wstring.cpp
+++ b/core/fxcrt/fx_basic_wstring.cpp
@@ -945,7 +945,7 @@ void CFX_WideString::TrimLeft(wchar_t chTarget) {
void CFX_WideString::TrimLeft() {
TrimLeft(L"\x09\x0a\x0b\x0c\x0d\x20");
}
-FX_FLOAT FX_wtof(const wchar_t* str, int len) {
+float FX_wtof(const wchar_t* str, int len) {
if (len == 0) {
return 0.0;
}
@@ -965,17 +965,17 @@ FX_FLOAT FX_wtof(const wchar_t* str, int len) {
integer = integer * 10 + FXSYS_toDecimalDigit(str[cc]);
cc++;
}
- FX_FLOAT fraction = 0;
+ float fraction = 0;
if (str[cc] == '.') {
cc++;
- FX_FLOAT scale = 0.1f;
+ float scale = 0.1f;
while (cc < len) {
fraction += scale * FXSYS_toDecimalDigit(str[cc]);
scale *= 0.1f;
cc++;
}
}
- fraction += (FX_FLOAT)integer;
+ fraction += (float)integer;
return bNegative ? -fraction : fraction;
}
@@ -983,7 +983,7 @@ int CFX_WideString::GetInteger() const {
return m_pData ? FXSYS_wtoi(m_pData->m_String) : 0;
}
-FX_FLOAT CFX_WideString::GetFloat() const {
+float CFX_WideString::GetFloat() const {
return m_pData ? FX_wtof(m_pData->m_String, m_pData->m_nDataLength) : 0.0f;
}
diff --git a/core/fxcrt/fx_coordinates.h b/core/fxcrt/fx_coordinates.h
index 2c84d0776c..5ccaf3d229 100644
--- a/core/fxcrt/fx_coordinates.h
+++ b/core/fxcrt/fx_coordinates.h
@@ -71,7 +71,7 @@ class CFX_PTemplate {
BaseType y;
};
using CFX_Point = CFX_PTemplate<int32_t>;
-using CFX_PointF = CFX_PTemplate<FX_FLOAT>;
+using CFX_PointF = CFX_PTemplate<float>;
template <class BaseType>
class CFX_STemplate {
@@ -144,7 +144,7 @@ class CFX_STemplate {
BaseType height;
};
using CFX_Size = CFX_STemplate<int32_t>;
-using CFX_SizeF = CFX_STemplate<FX_FLOAT>;
+using CFX_SizeF = CFX_STemplate<float>;
template <class BaseType>
class CFX_VTemplate : public CFX_PTemplate<BaseType> {
@@ -162,9 +162,9 @@ class CFX_VTemplate : public CFX_PTemplate<BaseType> {
const CFX_PTemplate<BaseType>& point2)
: CFX_PTemplate<BaseType>(point2.x - point1.x, point2.y - point1.y) {}
- FX_FLOAT Length() const { return FXSYS_sqrt(x * x + y * y); }
+ float Length() const { return FXSYS_sqrt(x * x + y * y); }
void Normalize() {
- FX_FLOAT fLen = Length();
+ float fLen = Length();
if (fLen < 0.0001f)
return;
@@ -179,15 +179,15 @@ class CFX_VTemplate : public CFX_PTemplate<BaseType> {
x *= sx;
y *= sy;
}
- void Rotate(FX_FLOAT fRadian) {
- FX_FLOAT cosValue = FXSYS_cos(fRadian);
- FX_FLOAT sinValue = FXSYS_sin(fRadian);
+ void Rotate(float fRadian) {
+ float cosValue = FXSYS_cos(fRadian);
+ float sinValue = FXSYS_sin(fRadian);
x = x * cosValue - y * sinValue;
y = x * sinValue + y * cosValue;
}
};
using CFX_Vector = CFX_VTemplate<int32_t>;
-using CFX_VectorF = CFX_VTemplate<FX_FLOAT>;
+using CFX_VectorF = CFX_VTemplate<float>;
// Rectangles.
// TODO(tsepez): Consolidate all these different rectangle classes.
@@ -313,7 +313,7 @@ class CFX_RTemplate {
Deflate(rt.left, rt.top, rt.top + rt.width, rt.top + rt.height);
}
bool IsEmpty() const { return width <= 0 || height <= 0; }
- bool IsEmpty(FX_FLOAT fEpsilon) const {
+ bool IsEmpty(float fEpsilon) const {
return width <= fEpsilon || height <= fEpsilon;
}
void Empty() { width = height = 0; }
@@ -385,7 +385,7 @@ class CFX_RTemplate {
rect.Intersect(*this);
return !rect.IsEmpty();
}
- bool IntersectWith(const RectType& rt, FX_FLOAT fEpsilon) const {
+ bool IntersectWith(const RectType& rt, float fEpsilon) const {
RectType rect = rt;
rect.Intersect(*this);
return !rect.IsEmpty(fEpsilon);
@@ -404,7 +404,7 @@ class CFX_RTemplate {
BaseType height;
};
using CFX_Rect = CFX_RTemplate<int32_t>;
-using CFX_RectF = CFX_RTemplate<FX_FLOAT>;
+using CFX_RectF = CFX_RTemplate<float>;
// LTRB rectangles (y-axis runs downwards).
struct FX_RECT {
@@ -454,10 +454,10 @@ struct FX_RECT {
class CFX_FloatRect {
public:
CFX_FloatRect() : CFX_FloatRect(0.0f, 0.0f, 0.0f, 0.0f) {}
- CFX_FloatRect(FX_FLOAT l, FX_FLOAT b, FX_FLOAT r, FX_FLOAT t)
+ CFX_FloatRect(float l, float b, float r, float t)
: left(l), bottom(b), right(r), top(t) {}
- explicit CFX_FloatRect(const FX_FLOAT* pArray)
+ explicit CFX_FloatRect(const float* pArray)
: CFX_FloatRect(pArray[0], pArray[1], pArray[2], pArray[3]) {}
explicit CFX_FloatRect(const FX_RECT& rect);
@@ -485,18 +485,18 @@ class CFX_FloatRect {
int Substract4(CFX_FloatRect& substract_rect, CFX_FloatRect* pRects);
- void InitRect(FX_FLOAT x, FX_FLOAT y) {
+ void InitRect(float x, float y) {
left = x;
right = x;
bottom = y;
top = y;
}
- void UpdateRect(FX_FLOAT x, FX_FLOAT y);
+ void UpdateRect(float x, float y);
- FX_FLOAT Width() const { return right - left; }
- FX_FLOAT Height() const { return top - bottom; }
+ float Width() const { return right - left; }
+ float Height() const { return top - bottom; }
- void Inflate(FX_FLOAT x, FX_FLOAT y) {
+ void Inflate(float x, float y) {
Normalize();
left -= x;
right += x;
@@ -504,10 +504,10 @@ class CFX_FloatRect {
top += y;
}
- void Inflate(FX_FLOAT other_left,
- FX_FLOAT other_bottom,
- FX_FLOAT other_right,
- FX_FLOAT other_top) {
+ void Inflate(float other_left,
+ float other_bottom,
+ float other_right,
+ float other_top) {
Normalize();
left -= other_left;
bottom -= other_bottom;
@@ -519,7 +519,7 @@ class CFX_FloatRect {
Inflate(rt.left, rt.bottom, rt.right, rt.top);
}
- void Deflate(FX_FLOAT x, FX_FLOAT y) {
+ void Deflate(float x, float y) {
Normalize();
left += x;
right -= x;
@@ -527,10 +527,10 @@ class CFX_FloatRect {
top -= y;
}
- void Deflate(FX_FLOAT other_left,
- FX_FLOAT other_bottom,
- FX_FLOAT other_right,
- FX_FLOAT other_top) {
+ void Deflate(float other_left,
+ float other_bottom,
+ float other_right,
+ float other_top) {
Normalize();
left += other_left;
bottom += other_bottom;
@@ -542,7 +542,7 @@ class CFX_FloatRect {
Deflate(rt.left, rt.bottom, rt.right, rt.top);
}
- void Translate(FX_FLOAT e, FX_FLOAT f) {
+ void Translate(float e, float f) {
left += e;
right += e;
top += f;
@@ -560,17 +560,17 @@ class CFX_FloatRect {
return CFX_FloatRect(rect.left, rect.top, rect.right(), rect.bottom());
}
- FX_FLOAT left;
- FX_FLOAT bottom;
- FX_FLOAT right;
- FX_FLOAT top;
+ float left;
+ float bottom;
+ float right;
+ float top;
};
class CFX_Matrix {
public:
CFX_Matrix() { SetIdentity(); }
- explicit CFX_Matrix(const FX_FLOAT n[6])
+ explicit CFX_Matrix(const float n[6])
: a(n[0]), b(n[1]), c(n[2]), d(n[3]), e(n[4]), f(n[5]) {}
CFX_Matrix(const CFX_Matrix& other)
@@ -581,12 +581,7 @@ class CFX_Matrix {
e(other.e),
f(other.f) {}
- CFX_Matrix(FX_FLOAT a1,
- FX_FLOAT b1,
- FX_FLOAT c1,
- FX_FLOAT d1,
- FX_FLOAT e1,
- FX_FLOAT f1)
+ CFX_Matrix(float a1, float b1, float c1, float d1, float e1, float f1)
: a(a1), b(b1), c(c1), d(d1), e(e1), f(f1) {}
void operator=(const CFX_Matrix& other) {
@@ -620,49 +615,44 @@ class CFX_Matrix {
bool IsScaled() const;
bool WillScale() const { return a != 1.0f || b != 0 || c != 0 || d != 1.0f; }
- void Translate(FX_FLOAT x, FX_FLOAT y, bool bPrepended = false);
+ void Translate(float x, float y, bool bPrepended = false);
void Translate(int32_t x, int32_t y, bool bPrepended = false) {
- Translate(static_cast<FX_FLOAT>(x), static_cast<FX_FLOAT>(y), bPrepended);
+ Translate(static_cast<float>(x), static_cast<float>(y), bPrepended);
}
- void Scale(FX_FLOAT sx, FX_FLOAT sy, bool bPrepended = false);
- void Rotate(FX_FLOAT fRadian, bool bPrepended = false);
- void RotateAt(FX_FLOAT fRadian,
- FX_FLOAT x,
- FX_FLOAT y,
- bool bPrepended = false);
+ void Scale(float sx, float sy, bool bPrepended = false);
+ void Rotate(float fRadian, bool bPrepended = false);
+ void RotateAt(float fRadian, float x, float y, bool bPrepended = false);
- void Shear(FX_FLOAT fAlphaRadian,
- FX_FLOAT fBetaRadian,
- bool bPrepended = false);
+ void Shear(float fAlphaRadian, float fBetaRadian, bool bPrepended = false);
void MatchRect(const CFX_FloatRect& dest, const CFX_FloatRect& src);
- FX_FLOAT GetXUnit() const;
- FX_FLOAT GetYUnit() const;
+ float GetXUnit() const;
+ float GetYUnit() const;
CFX_FloatRect GetUnitRect() const;
- FX_FLOAT TransformXDistance(FX_FLOAT dx) const;
- FX_FLOAT TransformDistance(FX_FLOAT dx, FX_FLOAT dy) const;
- FX_FLOAT TransformDistance(FX_FLOAT distance) const;
+ float TransformXDistance(float dx) const;
+ float TransformDistance(float dx, float dy) const;
+ float TransformDistance(float distance) const;
CFX_PointF Transform(const CFX_PointF& point) const;
void TransformRect(CFX_RectF& rect) const;
- void TransformRect(FX_FLOAT& left,
- FX_FLOAT& right,
- FX_FLOAT& top,
- FX_FLOAT& bottom) const;
+ void TransformRect(float& left,
+ float& right,
+ float& top,
+ float& bottom) const;
void TransformRect(CFX_FloatRect& rect) const {
TransformRect(rect.left, rect.right, rect.top, rect.bottom);
}
- FX_FLOAT a;
- FX_FLOAT b;
- FX_FLOAT c;
- FX_FLOAT d;
- FX_FLOAT e;
- FX_FLOAT f;
+ float a;
+ float b;
+ float c;
+ float d;
+ float e;
+ float f;
private:
void ConcatInternal(const CFX_Matrix& other, bool prepend);
diff --git a/core/fxcrt/fx_ext.h b/core/fxcrt/fx_ext.h
index 3ee5a4f91f..e605d04077 100644
--- a/core/fxcrt/fx_ext.h
+++ b/core/fxcrt/fx_ext.h
@@ -15,14 +15,14 @@
#define FX_INVALID_OFFSET static_cast<uint32_t>(-1)
-FX_FLOAT FXSYS_tan(FX_FLOAT a);
-FX_FLOAT FXSYS_logb(FX_FLOAT b, FX_FLOAT x);
-FX_FLOAT FXSYS_strtof(const char* pcsStr,
- int32_t iLength = -1,
- int32_t* pUsedLen = nullptr);
-FX_FLOAT FXSYS_wcstof(const wchar_t* pwsStr,
- int32_t iLength = -1,
- int32_t* pUsedLen = nullptr);
+float FXSYS_tan(float a);
+float FXSYS_logb(float b, float x);
+float FXSYS_strtof(const char* pcsStr,
+ int32_t iLength = -1,
+ int32_t* pUsedLen = nullptr);
+float FXSYS_wcstof(const wchar_t* pwsStr,
+ int32_t iLength = -1,
+ int32_t* pUsedLen = nullptr);
wchar_t* FXSYS_wcsncpy(wchar_t* dstStr, const wchar_t* srcStr, size_t count);
int32_t FXSYS_wcsnicmp(const wchar_t* s1, const wchar_t* s2, size_t count);
int32_t FXSYS_strnicmp(const char* s1, const char* s2, size_t count);
@@ -75,7 +75,7 @@ inline int FXSYS_toDecimalDigit(const wchar_t c) {
return std::iswdigit(c) ? c - L'0' : 0;
}
-FX_FLOAT FXSYS_FractionalScale(size_t scale_factor, int value);
+float FXSYS_FractionalScale(size_t scale_factor, int value);
int FXSYS_FractionalScaleCount();
void* FX_Random_MT_Start(uint32_t dwSeed);
diff --git a/core/fxcrt/fx_extension.cpp b/core/fxcrt/fx_extension.cpp
index 0b7197ec7c..28c46c93f6 100644
--- a/core/fxcrt/fx_extension.cpp
+++ b/core/fxcrt/fx_extension.cpp
@@ -423,13 +423,13 @@ CFX_RetainPtr<IFX_MemoryStream> IFX_MemoryStream::Create(bool bConsecutive) {
return pdfium::MakeRetain<CFX_MemoryStream>(bConsecutive);
}
-FX_FLOAT FXSYS_tan(FX_FLOAT a) {
- return (FX_FLOAT)tan(a);
+float FXSYS_tan(float a) {
+ return (float)tan(a);
}
-FX_FLOAT FXSYS_logb(FX_FLOAT b, FX_FLOAT x) {
+float FXSYS_logb(float b, float x) {
return FXSYS_log(x) / FXSYS_log(b);
}
-FX_FLOAT FXSYS_strtof(const char* pcsStr, int32_t iLength, int32_t* pUsedLen) {
+float FXSYS_strtof(const char* pcsStr, int32_t iLength, int32_t* pUsedLen) {
ASSERT(pcsStr);
if (iLength < 0) {
iLength = (int32_t)FXSYS_strlen(pcsStr);
@@ -438,9 +438,7 @@ FX_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);
}
-FX_FLOAT FXSYS_wcstof(const wchar_t* pwsStr,
- int32_t iLength,
- int32_t* pUsedLen) {
+float FXSYS_wcstof(const wchar_t* pwsStr, int32_t iLength, int32_t* pUsedLen) {
ASSERT(pwsStr);
if (iLength < 0) {
iLength = (int32_t)FXSYS_wcslen(pwsStr);
@@ -457,7 +455,7 @@ FX_FLOAT FXSYS_wcstof(const wchar_t* pwsStr,
iUsedLen++;
break;
}
- FX_FLOAT fValue = 0.0f;
+ float fValue = 0.0f;
while (iUsedLen < iLength) {
wchar_t wch = pwsStr[iUsedLen];
if (wch >= L'0' && wch <= L'9') {
@@ -468,7 +466,7 @@ FX_FLOAT FXSYS_wcstof(const wchar_t* pwsStr,
iUsedLen++;
}
if (iUsedLen < iLength && pwsStr[iUsedLen] == L'.') {
- FX_FLOAT fPrecise = 0.1f;
+ float fPrecise = 0.1f;
while (++iUsedLen < iLength) {
wchar_t wch = pwsStr[iUsedLen];
if (wch >= L'0' && wch <= L'9') {
diff --git a/core/fxcrt/fx_string.h b/core/fxcrt/fx_string.h
index 01be6a1901..12304eb452 100644
--- a/core/fxcrt/fx_string.h
+++ b/core/fxcrt/fx_string.h
@@ -154,7 +154,7 @@ class CFX_ByteString {
#define FXFORMAT_CAPITAL 4
static CFX_ByteString FormatInteger(int i, uint32_t flags = 0);
- static CFX_ByteString FormatFloat(FX_FLOAT f, int precision = 0);
+ static CFX_ByteString FormatFloat(float f, int precision = 0);
protected:
using StringData = CFX_StringDataTemplate<char>;
@@ -336,7 +336,7 @@ class CFX_WideString {
void ReleaseBuffer(FX_STRSIZE len = -1);
int GetInteger() const;
- FX_FLOAT GetFloat() const;
+ float GetFloat() const;
FX_STRSIZE Find(const CFX_WideStringC& pSub, FX_STRSIZE start = 0) const;
FX_STRSIZE Find(wchar_t ch, FX_STRSIZE start = 0) const;
@@ -421,12 +421,12 @@ inline bool operator!=(const CFX_WideStringC& lhs, const CFX_WideString& rhs) {
}
CFX_ByteString FX_UTF8Encode(const CFX_WideStringC& wsStr);
-FX_FLOAT FX_atof(const CFX_ByteStringC& str);
-inline FX_FLOAT FX_atof(const CFX_WideStringC& wsStr) {
+float FX_atof(const CFX_ByteStringC& str);
+inline float FX_atof(const CFX_WideStringC& wsStr) {
return FX_atof(FX_UTF8Encode(wsStr).c_str());
}
bool FX_atonum(const CFX_ByteStringC& str, void* pData);
-FX_STRSIZE FX_ftoa(FX_FLOAT f, char* buf);
+FX_STRSIZE FX_ftoa(float f, char* buf);
uint32_t FX_HashCode_GetA(const CFX_ByteStringC& str, bool bIgnoreCase);
uint32_t FX_HashCode_GetW(const CFX_WideStringC& str, bool bIgnoreCase);
diff --git a/core/fxcrt/fx_system.h b/core/fxcrt/fx_system.h
index 4c938d9b27..321a8e272e 100644
--- a/core/fxcrt/fx_system.h
+++ b/core/fxcrt/fx_system.h
@@ -68,7 +68,6 @@ extern "C" {
#endif // __cplusplus
typedef void* FX_POSITION; // Keep until fxcrt containers gone
-typedef float FX_FLOAT; // Keep, allow upgrade to doubles.
#define IsFloatZero(f) ((f) < 0.0001 && (f) > -0.0001)
#define IsFloatBigger(fa, fb) ((fa) > (fb) && !IsFloatZero((fa) - (fb)))
@@ -247,21 +246,21 @@ wchar_t* FXSYS_wcsupr(wchar_t* str);
#endif // _FXM_PLATFORM == _FXM_PLATFORM_WINDOWS_
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
-#define FXSYS_pow(a, b) (FX_FLOAT) powf(a, b)
+#define FXSYS_pow(a, b) (float)powf(a, b)
#else
-#define FXSYS_pow(a, b) (FX_FLOAT) pow(a, b)
+#define FXSYS_pow(a, b) (float)pow(a, b)
#endif
-#define FXSYS_sqrt(a) (FX_FLOAT) sqrt(a)
-#define FXSYS_fabs(a) (FX_FLOAT) fabs(a)
-#define FXSYS_atan2(a, b) (FX_FLOAT) atan2(a, b)
-#define FXSYS_ceil(a) (FX_FLOAT) ceil(a)
-#define FXSYS_floor(a) (FX_FLOAT) floor(a)
-#define FXSYS_cos(a) (FX_FLOAT) cos(a)
-#define FXSYS_acos(a) (FX_FLOAT) acos(a)
-#define FXSYS_sin(a) (FX_FLOAT) sin(a)
-#define FXSYS_log(a) (FX_FLOAT) log(a)
-#define FXSYS_log10(a) (FX_FLOAT) log10(a)
-#define FXSYS_fmod(a, b) (FX_FLOAT) fmod(a, b)
+#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) | \
@@ -279,8 +278,8 @@ int32_t FXSYS_wtoi(const wchar_t* str);
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(FX_FLOAT f);
-#define FXSYS_sqrt2(a, b) (FX_FLOAT) FXSYS_sqrt((a) * (a) + (b) * (b))
+int FXSYS_round(float f);
+#define FXSYS_sqrt2(a, b) (float)FXSYS_sqrt((a) * (a) + (b) * (b))
#ifdef __cplusplus
};
#endif
diff --git a/core/fxcrt/fx_xml.h b/core/fxcrt/fx_xml.h
index 87f1915cb1..0b0de23d67 100644
--- a/core/fxcrt/fx_xml.h
+++ b/core/fxcrt/fx_xml.h
@@ -107,19 +107,19 @@ class CXML_Element {
return attr;
}
- bool GetAttrFloat(const CFX_ByteStringC& name, FX_FLOAT& attribute) const;
- FX_FLOAT GetAttrFloat(const CFX_ByteStringC& name) const {
- FX_FLOAT attr = 0;
+ bool GetAttrFloat(const CFX_ByteStringC& name, float& attribute) const;
+ float GetAttrFloat(const CFX_ByteStringC& name) const {
+ float attr = 0;
GetAttrFloat(name, attr);
return attr;
}
bool GetAttrFloat(const CFX_ByteStringC& space,
const CFX_ByteStringC& name,
- FX_FLOAT& attribute) const;
- FX_FLOAT GetAttrFloat(const CFX_ByteStringC& space,
- const CFX_ByteStringC& name) const {
- FX_FLOAT attr = 0;
+ float& attribute) const;
+ float GetAttrFloat(const CFX_ByteStringC& space,
+ const CFX_ByteStringC& name) const {
+ float attr = 0;
GetAttrFloat(space, name, attr);
return attr;
}
diff --git a/core/fxcrt/fx_xml_parser.cpp b/core/fxcrt/fx_xml_parser.cpp
index b81ae4e0d9..25024a1b2d 100644
--- a/core/fxcrt/fx_xml_parser.cpp
+++ b/core/fxcrt/fx_xml_parser.cpp
@@ -785,7 +785,7 @@ bool CXML_Element::GetAttrInteger(const CFX_ByteStringC& space,
}
bool CXML_Element::GetAttrFloat(const CFX_ByteStringC& name,
- FX_FLOAT& attribute) const {
+ float& attribute) const {
CFX_ByteStringC bsSpace;
CFX_ByteStringC bsName;
FX_XML_SplitQualifiedName(name, bsSpace, bsName);
@@ -794,7 +794,7 @@ bool CXML_Element::GetAttrFloat(const CFX_ByteStringC& name,
bool CXML_Element::GetAttrFloat(const CFX_ByteStringC& space,
const CFX_ByteStringC& name,
- FX_FLOAT& attribute) const {
+ float& attribute) const {
const CFX_WideString* pValue =
m_AttrMap.Lookup(CFX_ByteString(space), CFX_ByteString(name));
if (!pValue)