Bug 1621803 - Fix additional bugs in Matrix4x4Flagged::operator*(Matrix4x4). r=bas

Differential Revision: https://phabricator.services.mozilla.com/D66505

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Botond Ballo 2020-03-25 15:22:14 +00:00
Родитель 7359d3c9bc
Коммит 6a4407c26e
2 изменённых файлов: 21 добавлений и 8 удалений

Просмотреть файл

@ -2143,15 +2143,15 @@ class Matrix4x4TypedFlagged
matrix._11 = _11 * aMatrix._11 + _12 * aMatrix._21;
matrix._21 = _21 * aMatrix._11 + _22 * aMatrix._21;
matrix._31 = aMatrix._31;
matrix._41 = _41 * aMatrix._11 + _42 * aMatrix._21;
matrix._41 = _41 * aMatrix._11 + _42 * aMatrix._21 + aMatrix._41;
matrix._12 = _11 * aMatrix._12 + _12 * aMatrix._22;
matrix._22 = _21 * aMatrix._12 + _22 * aMatrix._22;
matrix._32 = aMatrix._32;
matrix._42 = _41 * aMatrix._12 + _42 * aMatrix._22;
matrix._42 = _41 * aMatrix._12 + _42 * aMatrix._22 + aMatrix._42;
matrix._13 = _11 * aMatrix._13 + _12 * aMatrix._23;
matrix._23 = _21 * aMatrix._13 + _22 * aMatrix._23;
matrix._33 = aMatrix._33;
matrix._43 = _41 * aMatrix._13 + _42 * aMatrix._23;
matrix._43 = _41 * aMatrix._13 + _42 * aMatrix._23 + aMatrix._43;
matrix._14 = _11 * aMatrix._14 + _12 * aMatrix._24;
matrix._24 = _21 * aMatrix._14 + _22 * aMatrix._24;
matrix._34 = aMatrix._34;

Просмотреть файл

@ -62,9 +62,22 @@ TEST(Matrix, TransformAndClipRect)
TEST(Matrix4x4Flagged, Mult)
{
Matrix4x4Flagged a = Matrix4x4::Translation(Point(42, 42));
Matrix4x4 b = Matrix4x4::Scaling(2, 2, 1);
Matrix4x4Flagged actual = a * b;
Matrix4x4Flagged expected(2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 1, 0, 84, 84, 0, 1);
EXPECT_EQ(expected, actual);
Matrix4x4Flagged simple =
Matrix4x4::Translation(Point(42, 42)) * Matrix4x4::Scaling(3, 3, 1);
// For the general matrix, put a value in every field to make sure
// nothing gets dropped.
Matrix4x4 general(2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2);
// Use Matrix4x4::operator*(Matrix4x4).
// For the purposes of this test, assume that's correct.
Matrix4x4Flagged realResult = Matrix4x4Flagged(simple.GetMatrix() * general);
// Check that Matrix4x4Flagged::operator*(Matrix4x4Flagged) produces the same
// result.
Matrix4x4Flagged flaggedResult = simple * Matrix4x4Flagged(general);
EXPECT_EQ(realResult, flaggedResult);
// Check that Matrix4x4Flagged::operator*(Matrix4x4) produces the same result.
Matrix4x4Flagged mixedResult = simple * general;
EXPECT_EQ(realResult, mixedResult);
}