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 "third_party/WebKit/Source/Platform/chromium/public/WebTransformationMa
trix.h" | |
10 #include "ui/gfx/transform.h" | 9 #include "ui/gfx/transform.h" |
11 | 10 |
12 namespace cc { | 11 namespace cc { |
13 | 12 |
14 // 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 |
15 // for equality within single-precision error bounds because many transforms | 14 // for equality within single-precision error bounds because many transforms |
16 // originate from single-precision data types such as quads/rects/etc. | 15 // originate from single-precision data types such as quads/rects/etc. |
17 | 16 |
18 void ExpectTransformationMatrixEq(const WebKit::WebTransformationMatrix& expecte
d, | |
19 const WebKit::WebTransformationMatrix& actual) | |
20 { | |
21 EXPECT_FLOAT_EQ((expected).m11(), (actual).m11()); | |
22 EXPECT_FLOAT_EQ((expected).m12(), (actual).m12()); | |
23 EXPECT_FLOAT_EQ((expected).m13(), (actual).m13()); | |
24 EXPECT_FLOAT_EQ((expected).m14(), (actual).m14()); | |
25 EXPECT_FLOAT_EQ((expected).m21(), (actual).m21()); | |
26 EXPECT_FLOAT_EQ((expected).m22(), (actual).m22()); | |
27 EXPECT_FLOAT_EQ((expected).m23(), (actual).m23()); | |
28 EXPECT_FLOAT_EQ((expected).m24(), (actual).m24()); | |
29 EXPECT_FLOAT_EQ((expected).m31(), (actual).m31()); | |
30 EXPECT_FLOAT_EQ((expected).m32(), (actual).m32()); | |
31 EXPECT_FLOAT_EQ((expected).m33(), (actual).m33()); | |
32 EXPECT_FLOAT_EQ((expected).m34(), (actual).m34()); | |
33 EXPECT_FLOAT_EQ((expected).m41(), (actual).m41()); | |
34 EXPECT_FLOAT_EQ((expected).m42(), (actual).m42()); | |
35 EXPECT_FLOAT_EQ((expected).m43(), (actual).m43()); | |
36 EXPECT_FLOAT_EQ((expected).m44(), (actual).m44()); | |
37 } | |
38 | |
39 void ExpectTransformationMatrixEq(const gfx::Transform& expected, | 17 void ExpectTransformationMatrixEq(const gfx::Transform& expected, |
40 const gfx::Transform& actual) | 18 const gfx::Transform& actual) |
41 { | 19 { |
42 EXPECT_FLOAT_EQ((expected).matrix().getDouble(0, 0), (actual).matrix().getDo
uble(0, 0)); | 20 EXPECT_FLOAT_EQ((expected).matrix().getDouble(0, 0), (actual).matrix().getDo
uble(0, 0)); |
43 EXPECT_FLOAT_EQ((expected).matrix().getDouble(1, 0), (actual).matrix().getDo
uble(1, 0)); | 21 EXPECT_FLOAT_EQ((expected).matrix().getDouble(1, 0), (actual).matrix().getDo
uble(1, 0)); |
44 EXPECT_FLOAT_EQ((expected).matrix().getDouble(2, 0), (actual).matrix().getDo
uble(2, 0)); | 22 EXPECT_FLOAT_EQ((expected).matrix().getDouble(2, 0), (actual).matrix().getDo
uble(2, 0)); |
45 EXPECT_FLOAT_EQ((expected).matrix().getDouble(3, 0), (actual).matrix().getDo
uble(3, 0)); | 23 EXPECT_FLOAT_EQ((expected).matrix().getDouble(3, 0), (actual).matrix().getDo
uble(3, 0)); |
46 EXPECT_FLOAT_EQ((expected).matrix().getDouble(0, 1), (actual).matrix().getDo
uble(0, 1)); | 24 EXPECT_FLOAT_EQ((expected).matrix().getDouble(0, 1), (actual).matrix().getDo
uble(0, 1)); |
47 EXPECT_FLOAT_EQ((expected).matrix().getDouble(1, 1), (actual).matrix().getDo
uble(1, 1)); | 25 EXPECT_FLOAT_EQ((expected).matrix().getDouble(1, 1), (actual).matrix().getDo
uble(1, 1)); |
48 EXPECT_FLOAT_EQ((expected).matrix().getDouble(2, 1), (actual).matrix().getDo
uble(2, 1)); | 26 EXPECT_FLOAT_EQ((expected).matrix().getDouble(2, 1), (actual).matrix().getDo
uble(2, 1)); |
(...skipping 10 matching lines...) Expand all Loading... |
59 | 37 |
60 gfx::Transform inverse(const gfx::Transform& transform) | 38 gfx::Transform inverse(const gfx::Transform& transform) |
61 { | 39 { |
62 gfx::Transform result(gfx::Transform::kSkipInitialization); | 40 gfx::Transform result(gfx::Transform::kSkipInitialization); |
63 bool invertedSuccessfully = transform.GetInverse(&result); | 41 bool invertedSuccessfully = transform.GetInverse(&result); |
64 DCHECK(invertedSuccessfully); | 42 DCHECK(invertedSuccessfully); |
65 return result; | 43 return result; |
66 } | 44 } |
67 | 45 |
68 } // namespace cc | 46 } // namespace cc |
OLD | NEW |