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
3 // found in the LICENSE file.
5 #include "cc/test/geometry_test_utils.h"
7 #include "base/logging.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "ui/gfx/transform.h"
13 // NOTE: even though transform data types use double precision, we only check
14 // for equality within single-precision error bounds because many transforms
15 // originate from single-precision data types such as quads/rects/etc.
17 void ExpectTransformationMatrixEq(const gfx::Transform
& expected
,
18 const gfx::Transform
& actual
) {
19 EXPECT_FLOAT_EQ((expected
).matrix().getDouble(0, 0),
20 (actual
).matrix().getDouble(0, 0));
21 EXPECT_FLOAT_EQ((expected
).matrix().getDouble(1, 0),
22 (actual
).matrix().getDouble(1, 0));
23 EXPECT_FLOAT_EQ((expected
).matrix().getDouble(2, 0),
24 (actual
).matrix().getDouble(2, 0));
25 EXPECT_FLOAT_EQ((expected
).matrix().getDouble(3, 0),
26 (actual
).matrix().getDouble(3, 0));
27 EXPECT_FLOAT_EQ((expected
).matrix().getDouble(0, 1),
28 (actual
).matrix().getDouble(0, 1));
29 EXPECT_FLOAT_EQ((expected
).matrix().getDouble(1, 1),
30 (actual
).matrix().getDouble(1, 1));
31 EXPECT_FLOAT_EQ((expected
).matrix().getDouble(2, 1),
32 (actual
).matrix().getDouble(2, 1));
33 EXPECT_FLOAT_EQ((expected
).matrix().getDouble(3, 1),
34 (actual
).matrix().getDouble(3, 1));
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));
53 gfx::Transform
Inverse(const gfx::Transform
& transform
) {
54 gfx::Transform
result(gfx::Transform::kSkipInitialization
);
55 bool inverted_successfully
= transform
.GetInverse(&result
);
56 DCHECK(inverted_successfully
);