summaryrefslogtreecommitdiff
path: root/core/fxcrt/fx_coordinates.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/fxcrt/fx_coordinates.cpp')
-rw-r--r--core/fxcrt/fx_coordinates.cpp82
1 files changed, 33 insertions, 49 deletions
diff --git a/core/fxcrt/fx_coordinates.cpp b/core/fxcrt/fx_coordinates.cpp
index 13c6f1b6bc..12bf8b6c38 100644
--- a/core/fxcrt/fx_coordinates.cpp
+++ b/core/fxcrt/fx_coordinates.cpp
@@ -43,6 +43,15 @@ static_assert(sizeof(FX_RECT::bottom) == sizeof(RECT::bottom),
"FX_RECT vs. RECT mismatch");
#endif
+inline CFX_Matrix ConcatInternal(const CFX_Matrix& left,
+ const CFX_Matrix& right) {
+ return CFX_Matrix(
+ left.a * right.a + left.b * right.c, left.a * right.b + left.b * right.d,
+ left.c * right.a + left.d * right.c, left.c * right.b + left.d * right.d,
+ left.e * right.a + left.f * right.c + right.e,
+ left.e * right.b + left.f * right.d + right.f);
+}
+
} // namespace
void FX_RECT::Normalize() {
@@ -248,12 +257,20 @@ CFX_Matrix CFX_Matrix::GetInverse() const {
return inverse;
}
-void CFX_Matrix::Concat(const CFX_Matrix& m, bool bPrepended) {
- ConcatInternal(m, bPrepended);
+void CFX_Matrix::Concat(const CFX_Matrix& m) {
+ *this = ConcatInternal(*this, m);
+}
+
+void CFX_Matrix::ConcatPrepend(const CFX_Matrix& m) {
+ *this = ConcatInternal(m, *this);
+}
+
+void CFX_Matrix::ConcatInverse(const CFX_Matrix& src) {
+ Concat(src.GetInverse());
}
-void CFX_Matrix::ConcatInverse(const CFX_Matrix& src, bool bPrepended) {
- Concat(src.GetInverse(), bPrepended);
+void CFX_Matrix::ConcatInversePrepend(const CFX_Matrix& src) {
+ ConcatPrepend(src.GetInverse());
}
bool CFX_Matrix::Is90Rotated() const {
@@ -264,47 +281,33 @@ bool CFX_Matrix::IsScaled() const {
return fabs(b * 1000) < fabs(a) && fabs(c * 1000) < fabs(d);
}
-void CFX_Matrix::Translate(float x, float y, bool bPrepended) {
- if (bPrepended) {
- e += x * a + y * c;
- f += y * d + x * b;
- return;
- }
+void CFX_Matrix::Translate(float x, float y) {
e += x;
f += y;
}
-void CFX_Matrix::Scale(float sx, float sy, bool bPrepended) {
- a *= sx;
- d *= sy;
- if (bPrepended) {
- b *= sx;
- c *= sy;
- return;
- }
+void CFX_Matrix::TranslatePrepend(float x, float y) {
+ e += x * a + y * c;
+ f += y * d + x * b;
+}
+void CFX_Matrix::Scale(float sx, float sy) {
+ a *= sx;
b *= sy;
c *= sx;
+ d *= sy;
e *= sx;
f *= sy;
}
-void CFX_Matrix::Rotate(float fRadian, bool bPrepended) {
+void CFX_Matrix::Rotate(float fRadian) {
float cosValue = cos(fRadian);
float sinValue = sin(fRadian);
- ConcatInternal(CFX_Matrix(cosValue, sinValue, -sinValue, cosValue, 0, 0),
- bPrepended);
-}
-
-void CFX_Matrix::RotateAt(float fRadian, float x, float y, bool bPrepended) {
- Translate(-x, -y, bPrepended);
- Rotate(fRadian, bPrepended);
- Translate(x, y, bPrepended);
+ Concat(CFX_Matrix(cosValue, sinValue, -sinValue, cosValue, 0, 0));
}
-void CFX_Matrix::Shear(float fAlphaRadian, float fBetaRadian, bool bPrepended) {
- ConcatInternal(CFX_Matrix(1, tan(fAlphaRadian), tan(fBetaRadian), 1, 0, 0),
- bPrepended);
+void CFX_Matrix::Shear(float fAlphaRadian, float fBetaRadian) {
+ Concat(CFX_Matrix(1, tan(fAlphaRadian), tan(fBetaRadian), 1, 0, 0));
}
void CFX_Matrix::MatchRect(const CFX_FloatRect& dest,
@@ -396,22 +399,3 @@ CFX_FloatRect CFX_Matrix::TransformRect(const CFX_FloatRect& rect) const {
TransformRect(rect.left, rect.right, rect.top, rect.bottom);
return CFX_FloatRect(left, bottom, right, top);
}
-
-void CFX_Matrix::ConcatInternal(const CFX_Matrix& other, bool prepend) {
- CFX_Matrix left;
- CFX_Matrix right;
- if (prepend) {
- left = other;
- right = *this;
- } else {
- left = *this;
- right = other;
- }
-
- a = left.a * right.a + left.b * right.c;
- b = left.a * right.b + left.b * right.d;
- c = left.c * right.a + left.d * right.c;
- d = left.c * right.b + left.d * right.d;
- e = left.e * right.a + left.f * right.c + right.e;
- f = left.e * right.b + left.f * right.d + right.f;
-}