summaryrefslogtreecommitdiff
path: root/core/fxcrt/fx_coordinates.h
diff options
context:
space:
mode:
Diffstat (limited to 'core/fxcrt/fx_coordinates.h')
-rw-r--r--core/fxcrt/fx_coordinates.h120
1 files changed, 55 insertions, 65 deletions
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);