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

Unified Diff: tests/MatrixTest.cpp

Issue 2111703002: speed up maprect for scale+trans case (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: apply comments from #14 Created 4 years, 6 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 2f91ccae97fdad1d5d4147c4ef9f944cc8a7e24b..01b2ba4e435a81ed876a35e286c11324e783041c 100644
--- a/tests/MatrixTest.cpp
+++ b/tests/MatrixTest.cpp
@@ -953,3 +953,29 @@ DEF_TEST(Matrix_Concat, r) {
REPORTER_ASSERT(r, expected == SkMatrix::Concat(a, b));
}
+
+// Test that all variants of maprect are correct.
+DEF_TEST(Matrix_maprects, r) {
+ const SkScalar scale = 1000;
+
+ SkMatrix mat;
+ mat.setScale(2, 3);
+ mat.postTranslate(1, 4);
+
+ SkRandom rand;
+ for (int i = 0; i < 10000; ++i) {
+ SkRect src = SkRect::MakeLTRB(rand.nextSScalar1() * scale,
+ rand.nextSScalar1() * scale,
+ rand.nextSScalar1() * scale,
+ rand.nextSScalar1() * scale);
+ SkRect dst[3];
+
+ mat.mapPoints((SkPoint*)&dst[0].fLeft, (SkPoint*)&src.fLeft, 2);
+ dst[0].sort();
+ mat.mapRect(&dst[1], src);
+ mat.mapRectScaleTranslate(&dst[2], src);
+
+ REPORTER_ASSERT(r, dst[0] == dst[1]);
+ REPORTER_ASSERT(r, dst[0] == dst[2]);
+ }
+}
« 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