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
)
20 EXPECT_FLOAT_EQ((expected
).matrix().getDouble(0, 0), (actual
).matrix().getDouble(0, 0));
21 EXPECT_FLOAT_EQ((expected
).matrix().getDouble(1, 0), (actual
).matrix().getDouble(1, 0));
22 EXPECT_FLOAT_EQ((expected
).matrix().getDouble(2, 0), (actual
).matrix().getDouble(2, 0));
23 EXPECT_FLOAT_EQ((expected
).matrix().getDouble(3, 0), (actual
).matrix().getDouble(3, 0));
24 EXPECT_FLOAT_EQ((expected
).matrix().getDouble(0, 1), (actual
).matrix().getDouble(0, 1));
25 EXPECT_FLOAT_EQ((expected
).matrix().getDouble(1, 1), (actual
).matrix().getDouble(1, 1));
26 EXPECT_FLOAT_EQ((expected
).matrix().getDouble(2, 1), (actual
).matrix().getDouble(2, 1));
27 EXPECT_FLOAT_EQ((expected
).matrix().getDouble(3, 1), (actual
).matrix().getDouble(3, 1));
28 EXPECT_FLOAT_EQ((expected
).matrix().getDouble(0, 2), (actual
).matrix().getDouble(0, 2));
29 EXPECT_FLOAT_EQ((expected
).matrix().getDouble(1, 2), (actual
).matrix().getDouble(1, 2));
30 EXPECT_FLOAT_EQ((expected
).matrix().getDouble(2, 2), (actual
).matrix().getDouble(2, 2));
31 EXPECT_FLOAT_EQ((expected
).matrix().getDouble(3, 2), (actual
).matrix().getDouble(3, 2));
32 EXPECT_FLOAT_EQ((expected
).matrix().getDouble(0, 3), (actual
).matrix().getDouble(0, 3));
33 EXPECT_FLOAT_EQ((expected
).matrix().getDouble(1, 3), (actual
).matrix().getDouble(1, 3));
34 EXPECT_FLOAT_EQ((expected
).matrix().getDouble(2, 3), (actual
).matrix().getDouble(2, 3));
35 EXPECT_FLOAT_EQ((expected
).matrix().getDouble(3, 3), (actual
).matrix().getDouble(3, 3));
38 gfx::Transform
inverse(const gfx::Transform
& transform
)
40 gfx::Transform
result(gfx::Transform::kSkipInitialization
);
41 bool invertedSuccessfully
= transform
.GetInverse(&result
);
42 DCHECK(invertedSuccessfully
);