Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(189)

Unified Diff: tests/MatrixTest.cpp

Issue 520123002: Fix matrix similarity test on arm64 (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Minor clean-ups. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkMatrix.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/MatrixTest.cpp
diff --git a/tests/MatrixTest.cpp b/tests/MatrixTest.cpp
index cbec021b405273c2301a3629c790906f11d6b5d3..fc7ac42a99690d1269d1f2c04f360a918011b25a 100644
--- a/tests/MatrixTest.cpp
+++ b/tests/MatrixTest.cpp
@@ -245,88 +245,96 @@ static void test_matrix_min_max_scale(skiatest::Reporter* reporter) {
}
}
-static void test_matrix_is_similarity(skiatest::Reporter* reporter) {
+static void test_matrix_preserve_shape(skiatest::Reporter* reporter) {
SkMatrix mat;
// identity
mat.setIdentity();
REPORTER_ASSERT(reporter, mat.isSimilarity());
+ REPORTER_ASSERT(reporter, mat.preservesRightAngles());
// translation only
mat.reset();
mat.setTranslate(SkIntToScalar(100), SkIntToScalar(100));
REPORTER_ASSERT(reporter, mat.isSimilarity());
+ REPORTER_ASSERT(reporter, mat.preservesRightAngles());
// scale with same size
mat.reset();
mat.setScale(SkIntToScalar(15), SkIntToScalar(15));
REPORTER_ASSERT(reporter, mat.isSimilarity());
+ REPORTER_ASSERT(reporter, mat.preservesRightAngles());
// scale with one negative
mat.reset();
mat.setScale(SkIntToScalar(-15), SkIntToScalar(15));
REPORTER_ASSERT(reporter, mat.isSimilarity());
+ REPORTER_ASSERT(reporter, mat.preservesRightAngles());
// scale with different size
mat.reset();
mat.setScale(SkIntToScalar(15), SkIntToScalar(20));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
+ REPORTER_ASSERT(reporter, mat.preservesRightAngles());
// scale with same size at a pivot point
mat.reset();
mat.setScale(SkIntToScalar(15), SkIntToScalar(15),
SkIntToScalar(2), SkIntToScalar(2));
REPORTER_ASSERT(reporter, mat.isSimilarity());
+ REPORTER_ASSERT(reporter, mat.preservesRightAngles());
// scale with different size at a pivot point
mat.reset();
mat.setScale(SkIntToScalar(15), SkIntToScalar(20),
SkIntToScalar(2), SkIntToScalar(2));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
+ REPORTER_ASSERT(reporter, mat.preservesRightAngles());
// skew with same size
mat.reset();
mat.setSkew(SkIntToScalar(15), SkIntToScalar(15));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
+ REPORTER_ASSERT(reporter, !mat.preservesRightAngles());
// skew with different size
mat.reset();
mat.setSkew(SkIntToScalar(15), SkIntToScalar(20));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
+ REPORTER_ASSERT(reporter, !mat.preservesRightAngles());
// skew with same size at a pivot point
mat.reset();
mat.setSkew(SkIntToScalar(15), SkIntToScalar(15),
SkIntToScalar(2), SkIntToScalar(2));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
+ REPORTER_ASSERT(reporter, !mat.preservesRightAngles());
// skew with different size at a pivot point
mat.reset();
mat.setSkew(SkIntToScalar(15), SkIntToScalar(20),
SkIntToScalar(2), SkIntToScalar(2));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
+ REPORTER_ASSERT(reporter, !mat.preservesRightAngles());
// perspective x
mat.reset();
mat.setPerspX(SkScalarToPersp(SK_Scalar1 / 2));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
+ REPORTER_ASSERT(reporter, !mat.preservesRightAngles());
// perspective y
mat.reset();
mat.setPerspY(SkScalarToPersp(SK_Scalar1 / 2));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
+ REPORTER_ASSERT(reporter, !mat.preservesRightAngles());
// rotate
for (int angle = 0; angle < 360; ++angle) {
mat.reset();
mat.setRotate(SkIntToScalar(angle));
-#ifndef SK_CPU_ARM64
REPORTER_ASSERT(reporter, mat.isSimilarity());
-#else
- // 64-bit ARM devices built with -O2 and -ffp-contract=fast have a loss
- // of precision and require that we have a higher tolerance
- REPORTER_ASSERT(reporter, mat.isSimilarity(SK_ScalarNearlyZero + 0.00010113f));
-#endif
+ REPORTER_ASSERT(reporter, mat.preservesRightAngles());
}
// see if there are any accumulated precision issues
@@ -335,38 +343,60 @@ static void test_matrix_is_similarity(skiatest::Reporter* reporter) {
mat.postRotate(SkIntToScalar(1));
}
REPORTER_ASSERT(reporter, mat.isSimilarity());
+ REPORTER_ASSERT(reporter, mat.preservesRightAngles());
// rotate + translate
mat.reset();
mat.setRotate(SkIntToScalar(30));
mat.postTranslate(SkIntToScalar(10), SkIntToScalar(20));
REPORTER_ASSERT(reporter, mat.isSimilarity());
+ REPORTER_ASSERT(reporter, mat.preservesRightAngles());
// rotate + uniform scale
mat.reset();
mat.setRotate(SkIntToScalar(30));
mat.postScale(SkIntToScalar(2), SkIntToScalar(2));
REPORTER_ASSERT(reporter, mat.isSimilarity());
+ REPORTER_ASSERT(reporter, mat.preservesRightAngles());
// rotate + non-uniform scale
mat.reset();
mat.setRotate(SkIntToScalar(30));
mat.postScale(SkIntToScalar(3), SkIntToScalar(2));
REPORTER_ASSERT(reporter, !mat.isSimilarity());
+ REPORTER_ASSERT(reporter, !mat.preservesRightAngles());
+
+ // non-uniform scale + rotate
+ mat.reset();
+ mat.setScale(SkIntToScalar(3), SkIntToScalar(2));
+ mat.postRotate(SkIntToScalar(30));
+ REPORTER_ASSERT(reporter, !mat.isSimilarity());
+ REPORTER_ASSERT(reporter, mat.preservesRightAngles());
// all zero
mat.setAll(0, 0, 0, 0, 0, 0, 0, 0, 0);
REPORTER_ASSERT(reporter, !mat.isSimilarity());
+ REPORTER_ASSERT(reporter, !mat.preservesRightAngles());
// all zero except perspective
+ mat.reset();
mat.setAll(0, 0, 0, 0, 0, 0, 0, 0, SK_Scalar1);
REPORTER_ASSERT(reporter, !mat.isSimilarity());
+ REPORTER_ASSERT(reporter, !mat.preservesRightAngles());
+
+ // scales zero, only skews (rotation)
+ mat.setAll(0, SK_Scalar1, 0,
+ -SK_Scalar1, 0, 0,
+ 0, 0, SkMatrix::I()[8]);
+ REPORTER_ASSERT(reporter, mat.isSimilarity());
+ REPORTER_ASSERT(reporter, mat.preservesRightAngles());
- // scales zero, only skews
+ // scales zero, only skews (reflection)
mat.setAll(0, SK_Scalar1, 0,
SK_Scalar1, 0, 0,
0, 0, SkMatrix::I()[8]);
REPORTER_ASSERT(reporter, mat.isSimilarity());
+ REPORTER_ASSERT(reporter, mat.preservesRightAngles());
}
// For test_matrix_decomposition, below.
@@ -815,7 +845,7 @@ DEF_TEST(Matrix, reporter) {
REPORTER_ASSERT(reporter, !are_equal(reporter, mat, mat2));
test_matrix_min_max_scale(reporter);
- test_matrix_is_similarity(reporter);
+ test_matrix_preserve_shape(reporter);
test_matrix_recttorect(reporter);
test_matrix_decomposition(reporter);
test_matrix_homogeneous(reporter);
« no previous file with comments | « src/core/SkMatrix.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698