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

Side by Side Diff: ui/gfx/transform_unittest.cc

Issue 692593003: More robust matrix decomposition (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
« no previous file with comments | « no previous file | ui/gfx/transform_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 // MSVC++ requires this to be set before any other includes to get M_PI. 5 // MSVC++ requires this to be set before any other includes to get M_PI.
6 #define _USE_MATH_DEFINES 6 #define _USE_MATH_DEFINES
7 7
8 #include "ui/gfx/transform.h" 8 #include "ui/gfx/transform.h"
9 9
10 #include <cmath> 10 #include <cmath>
(...skipping 1343 matching lines...) Expand 10 before | Expand all | Expand 10 after
1354 while (rotation > 360.0) 1354 while (rotation > 360.0)
1355 rotation -= 360.0; 1355 rotation -= 360.0;
1356 1356
1357 const float epsilon = 0.00015f; 1357 const float epsilon = 0.00015f;
1358 EXPECT_NEAR(rotation, degrees, epsilon); 1358 EXPECT_NEAR(rotation, degrees, epsilon);
1359 EXPECT_NEAR(decomp.scale[0], degrees + 1, epsilon); 1359 EXPECT_NEAR(decomp.scale[0], degrees + 1, epsilon);
1360 EXPECT_NEAR(decomp.scale[1], 2 * degrees + 1, epsilon); 1360 EXPECT_NEAR(decomp.scale[1], 2 * degrees + 1, epsilon);
1361 } 1361 }
1362 } 1362 }
1363 1363
1364 TEST(XFormTest, DecomposeTransform) {
1365 for (float scale = 0.001f; scale < 2.0f; scale += 0.001f) {
1366 gfx::Transform transform;
1367 transform.Scale(scale, scale);
1368 EXPECT_TRUE(transform.Preserves2dAxisAlignment());
1369
1370 DecomposedTransform decomp;
1371 bool success = DecomposeTransform(&decomp, transform);
1372 EXPECT_TRUE(success);
1373
1374 gfx::Transform compose_transform = ComposeTransform(decomp);
1375 EXPECT_TRUE(compose_transform.Preserves2dAxisAlignment());
1376 }
1377 }
1378
1364 TEST(XFormTest, IntegerTranslation) { 1379 TEST(XFormTest, IntegerTranslation) {
1365 gfx::Transform transform; 1380 gfx::Transform transform;
1366 EXPECT_TRUE(transform.IsIdentityOrIntegerTranslation()); 1381 EXPECT_TRUE(transform.IsIdentityOrIntegerTranslation());
1367 1382
1368 transform.Translate3d(1, 2, 3); 1383 transform.Translate3d(1, 2, 3);
1369 EXPECT_TRUE(transform.IsIdentityOrIntegerTranslation()); 1384 EXPECT_TRUE(transform.IsIdentityOrIntegerTranslation());
1370 1385
1371 transform.MakeIdentity(); 1386 transform.MakeIdentity();
1372 transform.Translate3d(-1, -2, -3); 1387 transform.Translate3d(-1, -2, -3);
1373 EXPECT_TRUE(transform.IsIdentityOrIntegerTranslation()); 1388 EXPECT_TRUE(transform.IsIdentityOrIntegerTranslation());
(...skipping 1311 matching lines...) Expand 10 before | Expand all | Expand 10 after
2685 EXPECT_EQ(expected.ToString(), box.ToString()); 2700 EXPECT_EQ(expected.ToString(), box.ToString());
2686 2701
2687 Transform singular; 2702 Transform singular;
2688 singular.Scale3d(0.f, 0.f, 0.f); 2703 singular.Scale3d(0.f, 0.f, 0.f);
2689 EXPECT_FALSE(singular.TransformBoxReverse(&box)); 2704 EXPECT_FALSE(singular.TransformBoxReverse(&box));
2690 } 2705 }
2691 2706
2692 } // namespace 2707 } // namespace
2693 2708
2694 } // namespace gfx 2709 } // namespace gfx
OLDNEW
« no previous file with comments | « no previous file | ui/gfx/transform_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698