diff --git a/tests/M44Test.cpp b/tests/M44Test.cpp index 6d0992c53f..9cbd65642d 100644 --- a/tests/M44Test.cpp +++ b/tests/M44Test.cpp @@ -358,3 +358,17 @@ DEF_TEST(M44_mapRect, reporter) { p.setRow(3, {-.2f, -.6f, 0.f, 8.f}); assertMapRect(p, src, nullptr); } + +DEF_TEST(M44_mapRect_skbug12335, r) { + // Stripped down test case from skbug.com/12335. Essentially, the corners of this rect would + // map to homogoneous coords with very small w's (below the old value of kW0PlaneDistance) and + // so they would be clipped "behind" the plane, resulting in an empty mapped rect. Coordinates + // with positive that wouldn't overflow when divided by w should still be included in the mapped + // rectangle. + SkRect rect = SkRect::MakeLTRB(0, 0, 319, 620); + SkM44 m(SkMatrix::MakeAll( 0.000152695269f, 0.00000000f, -6.53848401e-05f, + -1.75697533e-05f, 0.000157153074f, -1.10847975e-06f, + -6.00415362e-08f, 0.00000000f, 0.000169880834f)); + SkRect out = SkMatrixPriv::MapRect(m, rect); + REPORTER_ASSERT(r, !out.isEmpty()); +} diff --git a/tests/MatrixTest.cpp b/tests/MatrixTest.cpp index 562aa5c49d..22017f6acc 100644 --- a/tests/MatrixTest.cpp +++ b/tests/MatrixTest.cpp @@ -1025,6 +1025,20 @@ DEF_TEST(Matrix_maprects, r) { } } +DEF_TEST(Matrix_mapRect_skbug12335, r) { + // Stripped down test case from skbug.com/12335. Essentially, the corners of this rect would + // map to homogoneous coords with very small w's (below the old value of kW0PlaneDistance) and + // so they would be clipped "behind" the plane, resulting in an empty mapped rect. Coordinates + // with positive that wouldn't overflow when divided by w should still be included in the mapped + // rectangle. + SkRect rect = SkRect::MakeLTRB(0, 0, 319, 620); + SkMatrix m = SkMatrix::MakeAll( 0.000152695269f, 0.00000000f, -6.53848401e-05f, + -1.75697533e-05f, 0.000157153074f, -1.10847975e-06f, + -6.00415362e-08f, 0.00000000f, 0.000169880834f); + SkRect out = m.mapRect(rect); + REPORTER_ASSERT(r, !out.isEmpty()); +} + DEF_TEST(Matrix_Ctor, r) { REPORTER_ASSERT(r, SkMatrix{} == SkMatrix::I()); }