Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(235)

Side by Side Diff: cc/float_quad_unittest.cc

Issue 11308153: Migrate most of cc/ from WebKit::WebTransformationMatrix to gfx::Transform (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 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 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/math_util.h" 5 #include "cc/math_util.h"
6 #include "testing/gtest/include/gtest/gtest.h" 6 #include "testing/gtest/include/gtest/gtest.h"
7 #include "ui/gfx/rect_f.h" 7 #include "ui/gfx/rect_f.h"
8 #include "ui/gfx/quad_f.h" 8 #include "ui/gfx/quad_f.h"
9 #include <public/WebTransformationMatrix.h> 9 #include "ui/gfx/transform.h"
10 10
11 using WebKit::WebTransformationMatrix; 11 using gfx::Transform;
12 12
13 namespace cc { 13 namespace cc {
14 namespace { 14 namespace {
15 15
16 // TODO(danakj) Move this test to ui/gfx/ when we don't use WebTransformationMat rix. 16 // TODO(danakj) Move this test to ui/gfx/ when we don't use Transform.
Ian Vollick 2012/11/21 22:07:09 Could this test move now, then?
shawnsingh 2012/11/23 08:10:45 It still requires gfx::Transform to support someth
17 TEST(FloatQuadTest, IsRectilinearTest) 17 TEST(FloatQuadTest, IsRectilinearTest)
18 { 18 {
19 const int numRectilinear = 8; 19 const int numRectilinear = 8;
20 WebTransformationMatrix rectilinearTrans[numRectilinear]; 20 Transform rectilinearTrans[numRectilinear];
21 rectilinearTrans[1].rotate(90); 21 rectilinearTrans[1].PreconcatRotate(90);
22 rectilinearTrans[2].rotate(180); 22 rectilinearTrans[2].PreconcatRotate(180);
23 rectilinearTrans[3].rotate(270); 23 rectilinearTrans[3].PreconcatRotate(270);
24 rectilinearTrans[4].skewX(0.00000000001); 24 rectilinearTrans[4].PreconcatSkewX(0.00000000001);
25 rectilinearTrans[5].skewY(0.00000000001); 25 rectilinearTrans[5].PreconcatSkewY(0.00000000001);
26 rectilinearTrans[6].scale(0.00001); 26 rectilinearTrans[6].PreconcatScale(0.00001, 0.00001);
27 rectilinearTrans[6].rotate(180); 27 rectilinearTrans[6].PreconcatRotate(180);
28 rectilinearTrans[7].scale(100000); 28 rectilinearTrans[7].PreconcatScale(100000, 100000);
29 rectilinearTrans[7].rotate(180); 29 rectilinearTrans[7].PreconcatRotate(180);
30 30
31 for (int i = 0; i < numRectilinear; ++i) { 31 for (int i = 0; i < numRectilinear; ++i) {
32 bool clipped = false; 32 bool clipped = false;
33 gfx::QuadF quad = MathUtil::mapQuad(rectilinearTrans[i], gfx::QuadF(gfx: :RectF(0.01010101f, 0.01010101f, 100.01010101f, 100.01010101f)), clipped); 33 gfx::QuadF quad = MathUtil::mapQuad(rectilinearTrans[i], gfx::QuadF(gfx: :RectF(0.01010101f, 0.01010101f, 100.01010101f, 100.01010101f)), clipped);
34 ASSERT_TRUE(!clipped); 34 ASSERT_TRUE(!clipped);
35 EXPECT_TRUE(quad.IsRectilinear()); 35 EXPECT_TRUE(quad.IsRectilinear());
36 } 36 }
37 37
38 const int numNonRectilinear = 10; 38 const int numNonRectilinear = 10;
39 WebTransformationMatrix nonRectilinearTrans[numNonRectilinear]; 39 Transform nonRectilinearTrans[numNonRectilinear];
40 nonRectilinearTrans[0].rotate(359.999); 40 nonRectilinearTrans[0].PreconcatRotate(359.999);
41 nonRectilinearTrans[1].rotate(0.0000001); 41 nonRectilinearTrans[1].PreconcatRotate(0.0000001);
42 nonRectilinearTrans[2].rotate(89.999999); 42 nonRectilinearTrans[2].PreconcatRotate(89.999999);
43 nonRectilinearTrans[3].rotate(90.0000001); 43 nonRectilinearTrans[3].PreconcatRotate(90.0000001);
44 nonRectilinearTrans[4].rotate(179.999999); 44 nonRectilinearTrans[4].PreconcatRotate(179.999999);
45 nonRectilinearTrans[5].rotate(180.0000001); 45 nonRectilinearTrans[5].PreconcatRotate(180.0000001);
46 nonRectilinearTrans[6].rotate(269.999999); 46 nonRectilinearTrans[6].PreconcatRotate(269.999999);
47 nonRectilinearTrans[7].rotate(270.0000001); 47 nonRectilinearTrans[7].PreconcatRotate(270.0000001);
48 nonRectilinearTrans[8].skewX(0.00001); 48 nonRectilinearTrans[8].PreconcatSkewX(0.00001);
49 nonRectilinearTrans[9].skewY(0.00001); 49 nonRectilinearTrans[9].PreconcatSkewY(0.00001);
50 50
51 for (int i = 0; i < numNonRectilinear; ++i) { 51 for (int i = 0; i < numNonRectilinear; ++i) {
52 bool clipped = false; 52 bool clipped = false;
53 gfx::QuadF quad = MathUtil::mapQuad(nonRectilinearTrans[i], gfx::QuadF(g fx::RectF(0.01010101f, 0.01010101f, 100.01010101f, 100.01010101f)), clipped); 53 gfx::QuadF quad = MathUtil::mapQuad(nonRectilinearTrans[i], gfx::QuadF(g fx::RectF(0.01010101f, 0.01010101f, 100.01010101f, 100.01010101f)), clipped);
54 ASSERT_TRUE(!clipped); 54 ASSERT_TRUE(!clipped);
55 EXPECT_FALSE(quad.IsRectilinear()); 55 EXPECT_FALSE(quad.IsRectilinear());
56 } 56 }
57 } 57 }
58 58
59 } // namespace 59 } // namespace
60 } // namespace cc 60 } // namespace cc
OLDNEW
« no previous file with comments | « cc/draw_quad_unittest.cc ('k') | cc/gl_renderer.h » ('j') | cc/gl_renderer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698