OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/test/geometry_test_utils.h" | 5 #include "cc/test/geometry_test_utils.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 #include "ui/gfx/transform.h" | 9 #include "ui/gfx/transform.h" |
10 | 10 |
11 namespace cc { | 11 namespace cc { |
12 | 12 |
13 // NOTE: even though transform data types use double precision, we only check | 13 // NOTE: even though transform data types use double precision, we only check |
14 // for equality within single-precision error bounds because many transforms | 14 // for equality within single-precision error bounds because many transforms |
15 // originate from single-precision data types such as quads/rects/etc. | 15 // originate from single-precision data types such as quads/rects/etc. |
16 | 16 |
17 void ExpectTransformationMatrixEq(const gfx::Transform& expected, | 17 void ExpectTransformationMatrixEq(const gfx::Transform& expected, |
18 const gfx::Transform& actual) { | 18 const gfx::Transform& actual) { |
19 EXPECT_FLOAT_EQ((expected).matrix().getDouble(0, 0), | 19 EXPECT_FLOAT_EQ((expected).matrix().get(0, 0), (actual).matrix().get(0, 0)); |
20 (actual).matrix().getDouble(0, 0)); | 20 EXPECT_FLOAT_EQ((expected).matrix().get(1, 0), (actual).matrix().get(1, 0)); |
21 EXPECT_FLOAT_EQ((expected).matrix().getDouble(1, 0), | 21 EXPECT_FLOAT_EQ((expected).matrix().get(2, 0), (actual).matrix().get(2, 0)); |
22 (actual).matrix().getDouble(1, 0)); | 22 EXPECT_FLOAT_EQ((expected).matrix().get(3, 0), (actual).matrix().get(3, 0)); |
23 EXPECT_FLOAT_EQ((expected).matrix().getDouble(2, 0), | 23 EXPECT_FLOAT_EQ((expected).matrix().get(0, 1), (actual).matrix().get(0, 1)); |
24 (actual).matrix().getDouble(2, 0)); | 24 EXPECT_FLOAT_EQ((expected).matrix().get(1, 1), (actual).matrix().get(1, 1)); |
25 EXPECT_FLOAT_EQ((expected).matrix().getDouble(3, 0), | 25 EXPECT_FLOAT_EQ((expected).matrix().get(2, 1), (actual).matrix().get(2, 1)); |
26 (actual).matrix().getDouble(3, 0)); | 26 EXPECT_FLOAT_EQ((expected).matrix().get(3, 1), (actual).matrix().get(3, 1)); |
27 EXPECT_FLOAT_EQ((expected).matrix().getDouble(0, 1), | 27 EXPECT_FLOAT_EQ((expected).matrix().get(0, 2), (actual).matrix().get(0, 2)); |
28 (actual).matrix().getDouble(0, 1)); | 28 EXPECT_FLOAT_EQ((expected).matrix().get(1, 2), (actual).matrix().get(1, 2)); |
29 EXPECT_FLOAT_EQ((expected).matrix().getDouble(1, 1), | 29 EXPECT_FLOAT_EQ((expected).matrix().get(2, 2), (actual).matrix().get(2, 2)); |
30 (actual).matrix().getDouble(1, 1)); | 30 EXPECT_FLOAT_EQ((expected).matrix().get(3, 2), (actual).matrix().get(3, 2)); |
31 EXPECT_FLOAT_EQ((expected).matrix().getDouble(2, 1), | 31 EXPECT_FLOAT_EQ((expected).matrix().get(0, 3), (actual).matrix().get(0, 3)); |
32 (actual).matrix().getDouble(2, 1)); | 32 EXPECT_FLOAT_EQ((expected).matrix().get(1, 3), (actual).matrix().get(1, 3)); |
33 EXPECT_FLOAT_EQ((expected).matrix().getDouble(3, 1), | 33 EXPECT_FLOAT_EQ((expected).matrix().get(2, 3), (actual).matrix().get(2, 3)); |
34 (actual).matrix().getDouble(3, 1)); | 34 EXPECT_FLOAT_EQ((expected).matrix().get(3, 3), (actual).matrix().get(3, 3)); |
35 EXPECT_FLOAT_EQ((expected).matrix().getDouble(0, 2), | |
36 (actual).matrix().getDouble(0, 2)); | |
37 EXPECT_FLOAT_EQ((expected).matrix().getDouble(1, 2), | |
38 (actual).matrix().getDouble(1, 2)); | |
39 EXPECT_FLOAT_EQ((expected).matrix().getDouble(2, 2), | |
40 (actual).matrix().getDouble(2, 2)); | |
41 EXPECT_FLOAT_EQ((expected).matrix().getDouble(3, 2), | |
42 (actual).matrix().getDouble(3, 2)); | |
43 EXPECT_FLOAT_EQ((expected).matrix().getDouble(0, 3), | |
44 (actual).matrix().getDouble(0, 3)); | |
45 EXPECT_FLOAT_EQ((expected).matrix().getDouble(1, 3), | |
46 (actual).matrix().getDouble(1, 3)); | |
47 EXPECT_FLOAT_EQ((expected).matrix().getDouble(2, 3), | |
48 (actual).matrix().getDouble(2, 3)); | |
49 EXPECT_FLOAT_EQ((expected).matrix().getDouble(3, 3), | |
50 (actual).matrix().getDouble(3, 3)); | |
51 } | 35 } |
52 | 36 |
53 gfx::Transform Inverse(const gfx::Transform& transform) { | 37 gfx::Transform Inverse(const gfx::Transform& transform) { |
54 gfx::Transform result(gfx::Transform::kSkipInitialization); | 38 gfx::Transform result(gfx::Transform::kSkipInitialization); |
55 bool inverted_successfully = transform.GetInverse(&result); | 39 bool inverted_successfully = transform.GetInverse(&result); |
56 DCHECK(inverted_successfully); | 40 DCHECK(inverted_successfully); |
57 return result; | 41 return result; |
58 } | 42 } |
59 | 43 |
60 } // namespace cc | 44 } // namespace cc |
OLD | NEW |