From c1a3e24918f99fc0b975111afb39dca38c50eb5c Mon Sep 17 00:00:00 2001 From: msarett Date: Thu, 23 Jun 2016 12:42:29 -0700 Subject: SkMatrix44 clarifications and clean-ups Fixed row/col major bug and added comments to the header. Made SkMatrix::I() thread safe using constexpr. Added a test set3x3RowMajorf(). BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2098583002 Review-Url: https://codereview.chromium.org/2098583002 --- tests/Matrix44Test.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'tests/Matrix44Test.cpp') diff --git a/tests/Matrix44Test.cpp b/tests/Matrix44Test.cpp index f4b6783c36..75086b68ae 100644 --- a/tests/Matrix44Test.cpp +++ b/tests/Matrix44Test.cpp @@ -484,6 +484,23 @@ static void test_get_set_double(skiatest::Reporter* reporter) { } } +static void test_set_3x3(skiatest::Reporter* r) { + static float vals[9] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, }; + + SkMatrix44 mat(SkMatrix44::kUninitialized_Constructor); + mat.set3x3RowMajorf(vals); + + REPORTER_ASSERT(r, 1.0f == mat.getFloat(0, 0)); + REPORTER_ASSERT(r, 2.0f == mat.getFloat(0, 1)); + REPORTER_ASSERT(r, 3.0f == mat.getFloat(0, 2)); + REPORTER_ASSERT(r, 4.0f == mat.getFloat(1, 0)); + REPORTER_ASSERT(r, 5.0f == mat.getFloat(1, 1)); + REPORTER_ASSERT(r, 6.0f == mat.getFloat(1, 2)); + REPORTER_ASSERT(r, 7.0f == mat.getFloat(2, 0)); + REPORTER_ASSERT(r, 8.0f == mat.getFloat(2, 1)); + REPORTER_ASSERT(r, 9.0f == mat.getFloat(2, 2)); +} + static void test_set_row_col_major(skiatest::Reporter* reporter) { SkMatrix44 a(SkMatrix44::kUninitialized_Constructor); SkMatrix44 b(SkMatrix44::kUninitialized_Constructor); @@ -916,6 +933,7 @@ DEF_TEST(Matrix44, reporter) { test_transpose(reporter); test_get_set_double(reporter); test_set_row_col_major(reporter); + test_set_3x3(reporter); test_translate(reporter); test_scale(reporter); test_map2(reporter); -- cgit v1.2.3