mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
[Impeller] Fix handling of perspective matrices in Matrix::Translate (flutter/engine#55536)
Fixes https://github.com/flutter/flutter/issues/155450
This commit is contained in:
parent
56f6d72cd1
commit
8478ab1dfb
@ -245,7 +245,7 @@ struct Matrix {
|
||||
m[0] * t.x + m[4] * t.y + m[8] * t.z + m[12],
|
||||
m[1] * t.x + m[5] * t.y + m[9] * t.z + m[13],
|
||||
m[2] * t.x + m[6] * t.y + m[10] * t.z + m[14],
|
||||
m[15]);
|
||||
m[3] * t.x + m[7] * t.y + m[11] * t.z + m[15]);
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
|
||||
@ -187,5 +187,17 @@ TEST(MatrixTest, GetMaxBasisXYWithLargeAndSmallScalingFactorNonScaleTranslate) {
|
||||
EXPECT_TRUE(std::isinf(m.GetMaxBasisLengthXY()));
|
||||
}
|
||||
|
||||
TEST(MatrixTest, TranslateWithPerspective) {
|
||||
Matrix m = Matrix::MakeRow(1.0, 0.0, 0.0, 10.0, //
|
||||
0.0, 1.0, 0.0, 20.0, //
|
||||
0.0, 0.0, 1.0, 0.0, //
|
||||
0.0, 2.0, 0.0, 30.0);
|
||||
Matrix result = m.Translate({100, 200});
|
||||
EXPECT_TRUE(MatrixNear(result, Matrix::MakeRow(1.0, 0.0, 0.0, 110.0, //
|
||||
0.0, 1.0, 0.0, 220.0, //
|
||||
0.0, 0.0, 1.0, 0.0, //
|
||||
0.0, 2.0, 0.0, 430.0)));
|
||||
}
|
||||
|
||||
} // namespace testing
|
||||
} // namespace impeller
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user