summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2020-03-28 20:21:12 +0100
committerTomaž Vajngerl <quikee@gmail.com>2020-03-29 13:20:04 +0200
commitd088b243cad18777f785abf704b0310f057f740b (patch)
tree544ba25768847fec11d07e4fd8e78c2d2b91b7da
parentcc7dc7552adb84dbd6954d01d2f347029d9302bc (diff)
basegfx: Fix the problem with Matrix Concatinate and Transform
In Concatinate and Transform methods we change the instance variables during calculation (matrix multiplication), which leads to the wrong result. This change fixes both calculations. Change-Id: I9f7ef7323707df1ab4a764f97f9bae8593c42940 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91311 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
-rw-r--r--include/basegfx/matrix/Matrix.hxx25
1 files changed, 17 insertions, 8 deletions
diff --git a/include/basegfx/matrix/Matrix.hxx b/include/basegfx/matrix/Matrix.hxx
index 9224e2784b60..e690216a3824 100644
--- a/include/basegfx/matrix/Matrix.hxx
+++ b/include/basegfx/matrix/Matrix.hxx
@@ -86,19 +86,28 @@ public:
/// Multiply this * other.
void Concatinate(const Matrix& other)
{
- ma = ma * other.ma + mb * other.mc;
- mb = ma * other.mb + mb * other.md;
- mc = mc * other.ma + md * other.mc;
- md = mc * other.mb + md * other.md;
- me = me * other.ma + mf * other.mc + other.me;
- mf = me * other.mb + mf * other.md + other.mf;
+ double newA = ma * other.ma + mb * other.mc;
+ double newB = ma * other.mb + mb * other.md;
+ double newC = mc * other.ma + md * other.mc;
+ double newD = mc * other.mb + md * other.md;
+ double newE = me * other.ma + mf * other.mc + other.me;
+ double newF = me * other.mb + mf * other.md + other.mf;
+
+ ma = newA;
+ mb = newB;
+ mc = newC;
+ md = newD;
+ me = newE;
+ mf = newF;
}
/// Transform the point (x, y) by this Matrix.
template <typename T> void Transform(T& x, T& y)
{
- x = ma * x + mc * y + me;
- y = mb * x + md * y + mf;
+ T newX = v00 * x + v01 * y + v02;
+ T newY = v10 * x + v11 * y + v12;
+ x = newX;
+ y = newY;
}
/// Transform the rectangle (left, right, top, bottom) by this Matrix.