Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(110)

Unified Diff: tests/Matrix44Test.cpp

Issue 4631068: Handle special angles with care in SkMatrix44 Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: '' Created 14 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/utils/SkMatrix44.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/Matrix44Test.cpp
===================================================================
--- tests/Matrix44Test.cpp (revision 1698)
+++ tests/Matrix44Test.cpp (working copy)
@@ -1,5 +1,6 @@
#include "Test.h"
#include "SkMatrix44.h"
+#include "SkRect.h"
static bool nearly_equal_scalar(SkMScalar a, SkMScalar b) {
// Note that we get more compounded error for multiple operations when
@@ -83,6 +84,7 @@
SkIntToScalar(0),
SkIntToScalar(-1),
SkIntToScalar(90));
+
mat.postConcat(rot);
REPORTER_ASSERT(reporter, mat.invert(NULL));
mat.invert(&inverse);
@@ -96,7 +98,7 @@
mat.setTranslate(2, 3, 4);
float dataf[16];
double datad[16];
-
+
mat.asColMajorf(dataf);
assert16<float>(reporter, dataf,
1, 0, 0, 0,
@@ -119,6 +121,19 @@
0, 0, 1, 4,
0, 0, 0, 1);
}
+
+ // Test precision of rotation in common cases
+ int common_angles[] = { 0, 90, -90, 180, -180, 270, -270, 360, -360 };
+ for (int i = 0; i < 9; ++i) {
+ rot.setRotateDegreesAbout(
+ SkIntToScalar(0),
+ SkIntToScalar(0),
+ SkIntToScalar(-1),
+ SkIntToScalar(common_angles[i]));
+
+ SkMatrix rot3x3 = rot;
+ REPORTER_ASSERT(reporter, rot3x3.rectStaysRect());
+ }
#endif
}
« no previous file with comments | « src/utils/SkMatrix44.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b