| OLD | NEW |
| (Empty) |
| 1 // Copyright 2011 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. | |
| 4 | |
| 5 #include "cc/math_util.h" | |
| 6 #include "testing/gtest/include/gtest/gtest.h" | |
| 7 #include "ui/gfx/rect_f.h" | |
| 8 #include "ui/gfx/quad_f.h" | |
| 9 #include "ui/gfx/transform.h" | |
| 10 | |
| 11 namespace cc { | |
| 12 namespace { | |
| 13 | |
| 14 // TODO(danakj) Move this test to ui/gfx/ when we don't need MathUtil::mapQuad. | |
| 15 TEST(FloatQuadTest, IsRectilinearTest) | |
| 16 { | |
| 17 const int numRectilinear = 8; | |
| 18 gfx::Transform rectilinearTrans[numRectilinear]; | |
| 19 rectilinearTrans[1].Rotate(90); | |
| 20 rectilinearTrans[2].Rotate(180); | |
| 21 rectilinearTrans[3].Rotate(270); | |
| 22 rectilinearTrans[4].SkewX(0.00000000001); | |
| 23 rectilinearTrans[5].SkewY(0.00000000001); | |
| 24 rectilinearTrans[6].Scale(0.00001, 0.00001); | |
| 25 rectilinearTrans[6].Rotate(180); | |
| 26 rectilinearTrans[7].Scale(100000, 100000); | |
| 27 rectilinearTrans[7].Rotate(180); | |
| 28 | |
| 29 for (int i = 0; i < numRectilinear; ++i) { | |
| 30 bool clipped = false; | |
| 31 gfx::QuadF quad = MathUtil::mapQuad(rectilinearTrans[i], gfx::QuadF(gfx:
:RectF(0.01010101f, 0.01010101f, 100.01010101f, 100.01010101f)), clipped); | |
| 32 ASSERT_TRUE(!clipped); | |
| 33 EXPECT_TRUE(quad.IsRectilinear()); | |
| 34 } | |
| 35 | |
| 36 const int numNonRectilinear = 10; | |
| 37 gfx::Transform nonRectilinearTrans[numNonRectilinear]; | |
| 38 nonRectilinearTrans[0].Rotate(359.999); | |
| 39 nonRectilinearTrans[1].Rotate(0.0000001); | |
| 40 nonRectilinearTrans[2].Rotate(89.999999); | |
| 41 nonRectilinearTrans[3].Rotate(90.0000001); | |
| 42 nonRectilinearTrans[4].Rotate(179.999999); | |
| 43 nonRectilinearTrans[5].Rotate(180.0000001); | |
| 44 nonRectilinearTrans[6].Rotate(269.999999); | |
| 45 nonRectilinearTrans[7].Rotate(270.0000001); | |
| 46 nonRectilinearTrans[8].SkewX(0.00001); | |
| 47 nonRectilinearTrans[9].SkewY(0.00001); | |
| 48 | |
| 49 for (int i = 0; i < numNonRectilinear; ++i) { | |
| 50 bool clipped = false; | |
| 51 gfx::QuadF quad = MathUtil::mapQuad(nonRectilinearTrans[i], gfx::QuadF(g
fx::RectF(0.01010101f, 0.01010101f, 100.01010101f, 100.01010101f)), clipped); | |
| 52 ASSERT_TRUE(!clipped); | |
| 53 EXPECT_FALSE(quad.IsRectilinear()); | |
| 54 } | |
| 55 } | |
| 56 | |
| 57 } // namespace | |
| 58 } // namespace cc | |
| OLD | NEW |