diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-05-16 13:35:36 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-05-16 13:35:36 +0000 |
commit | 7b463acd46b8df866d3a27fbaf69b0090c842d1e (patch) | |
tree | a97acffe381eab10085cbf5fee96249ddd6ba926 /tests/InfRectTest.cpp | |
parent | 5dd510f1d277a31752a4c6046c4e42385605a393 (diff) |
speedup SkRect::isFinite() (almost 2x)
add SkRect:set(p0, p1) for quick bounds of 2 points
git-svn-id: http://skia.googlecode.com/svn/trunk@3967 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests/InfRectTest.cpp')
-rw-r--r-- | tests/InfRectTest.cpp | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/tests/InfRectTest.cpp b/tests/InfRectTest.cpp index 12356d9c2f..1dc6ca7d0c 100644 --- a/tests/InfRectTest.cpp +++ b/tests/InfRectTest.cpp @@ -25,24 +25,28 @@ static void check_invalid(skiatest::Reporter* reporter, // as one of its coordinates. static void TestInfRect(skiatest::Reporter* reporter) { #ifdef SK_SCALAR_IS_FLOAT - float invalid = 1 / make_zero(); // infinity + float inf = 1 / make_zero(); // infinity + float nan = inf * 0; + SkASSERT(!(nan == nan)); #else - SkFixed invalid = SK_FixedNaN; + SkFixed inf = SK_FixedNaN; + SkFixed nan = SK_FixedNaN; #endif SkScalar small = SkIntToScalar(10); SkScalar big = SkIntToScalar(100); + REPORTER_ASSERT(reporter, SkRect::MakeEmpty().isFinite()); + SkRect rect = SkRect::MakeXYWH(small, small, big, big); REPORTER_ASSERT(reporter, rect.isFinite()); - check_invalid(reporter, small, small, big, invalid); - check_invalid(reporter, small, small, invalid, big); - check_invalid(reporter, small, invalid, big, big); - check_invalid(reporter, invalid, small, big, big); - check_invalid(reporter, small, small, big, -invalid); - check_invalid(reporter, small, small, -invalid, big); - check_invalid(reporter, small, -invalid, big, big); - check_invalid(reporter, -invalid, small, big, big); + const SkScalar invalid[] = { nan, inf, -inf }; + for (size_t i = 0; i < SK_ARRAY_COUNT(invalid); ++i) { + check_invalid(reporter, small, small, big, invalid[i]); + check_invalid(reporter, small, small, invalid[i], big); + check_invalid(reporter, small, invalid[i], big, big); + check_invalid(reporter, invalid[i], small, big, big); + } } // need tests for SkStrSearch |