summaryrefslogtreecommitdiff
path: root/include
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-04-01 16:19:41 +0200
commit17bb1ecae40aea4a9a9e6b4b0eb1d40f597b60a4 (patch)
treed942c175ac58aabd35cf3c6b2e9b4696eaa6cefa /include
parent3ce519f41724fa4bd61e761b0442b21e6c65232a (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> (cherry picked from commit d088b243cad18777f785abf704b0310f057f740b) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91451 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Diffstat (limited to 'include')
-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.