OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/animation/transform_operations.h" | 5 #include "cc/animation/transform_operations.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <limits> | 9 #include <limits> |
10 #include <vector> | 10 #include <vector> |
(...skipping 1315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1326 box, identity, min_progress, max_progress, &bounds)); | 1326 box, identity, min_progress, max_progress, &bounds)); |
1327 EXPECT_EQ(gfx::BoxF(-33.f, -13.f, 3.f, 57.f, 19.f, 52.f).ToString(), | 1327 EXPECT_EQ(gfx::BoxF(-33.f, -13.f, 3.f, 57.f, 19.f, 52.f).ToString(), |
1328 bounds.ToString()); | 1328 bounds.ToString()); |
1329 | 1329 |
1330 EXPECT_TRUE(identity.BlendedBoundsForBox( | 1330 EXPECT_TRUE(identity.BlendedBoundsForBox( |
1331 box, operations_from, min_progress, max_progress, &bounds)); | 1331 box, operations_from, min_progress, max_progress, &bounds)); |
1332 EXPECT_EQ(gfx::BoxF(-7.f, -3.f, 2.f, 15.f, 23.f, 20.f).ToString(), | 1332 EXPECT_EQ(gfx::BoxF(-7.f, -3.f, 2.f, 15.f, 23.f, 20.f).ToString(), |
1333 bounds.ToString()); | 1333 bounds.ToString()); |
1334 } | 1334 } |
1335 | 1335 |
1336 TEST(TransformOperationTest, AffectsScaleWithSingleOperation) { | |
1337 TransformOperations empty_operations; | |
1338 EXPECT_FALSE(empty_operations.AffectsScale()); | |
1339 | |
1340 TransformOperations identity; | |
1341 identity.AppendIdentity(); | |
1342 EXPECT_FALSE(identity.AffectsScale()); | |
1343 | |
1344 TransformOperations translate; | |
1345 translate.AppendTranslate(1.f, 2.f, 3.f); | |
1346 EXPECT_FALSE(translate.AffectsScale()); | |
1347 | |
1348 TransformOperations rotate; | |
1349 rotate.AppendRotate(1.f, 2.f, 3.f, 4.f); | |
1350 EXPECT_FALSE(rotate.AffectsScale()); | |
1351 | |
1352 TransformOperations scale; | |
1353 scale.AppendScale(1.f, 2.f, 3.f); | |
1354 EXPECT_TRUE(scale.AffectsScale()); | |
1355 | |
1356 TransformOperations skew; | |
1357 skew.AppendSkew(1.f, 2.f); | |
1358 EXPECT_FALSE(skew.AffectsScale()); | |
1359 | |
1360 TransformOperations perspective; | |
1361 perspective.AppendPerspective(1.f); | |
1362 EXPECT_FALSE(perspective.AffectsScale()); | |
1363 | |
1364 TransformOperations identity_matrix; | |
1365 identity_matrix.AppendMatrix(gfx::Transform()); | |
1366 EXPECT_FALSE(identity_matrix.AffectsScale()); | |
1367 | |
1368 TransformOperations translation_matrix; | |
1369 gfx::Transform translation_transform; | |
1370 translation_transform.Translate3d(1.f, 2.f, 3.f); | |
1371 translation_matrix.AppendMatrix(translation_transform); | |
1372 EXPECT_FALSE(translation_matrix.AffectsScale()); | |
1373 | |
1374 TransformOperations scaling_matrix; | |
1375 gfx::Transform scaling_transform; | |
1376 scaling_transform.Scale(2.f, 2.f); | |
1377 scaling_matrix.AppendMatrix(scaling_transform); | |
1378 EXPECT_TRUE(scaling_matrix.AffectsScale()); | |
1379 } | |
1380 | |
1381 TEST(TransformOperationTest, AffectsScaleWithMultipleOperations) { | |
1382 TransformOperations operations1; | |
1383 operations1.AppendSkew(1.f, 2.f); | |
1384 operations1.AppendTranslate(1.f, 2.f, 3.f); | |
1385 operations1.AppendIdentity(); | |
1386 EXPECT_FALSE(operations1.AffectsScale()); | |
1387 | |
1388 TransformOperations operations2; | |
1389 operations2.AppendPerspective(2.f); | |
1390 operations2.AppendScale(1.f, 2.f, 3.f); | |
1391 operations2.AppendTranslate(3.f, 2.f, 1.f); | |
1392 EXPECT_TRUE(operations2.AffectsScale()); | |
1393 } | |
1394 | |
1395 TEST(TransformOperationTest, IsTranslationWithSingleOperation) { | 1336 TEST(TransformOperationTest, IsTranslationWithSingleOperation) { |
1396 TransformOperations empty_operations; | 1337 TransformOperations empty_operations; |
1397 EXPECT_TRUE(empty_operations.IsTranslation()); | 1338 EXPECT_TRUE(empty_operations.IsTranslation()); |
1398 | 1339 |
1399 TransformOperations identity; | 1340 TransformOperations identity; |
1400 identity.AppendIdentity(); | 1341 identity.AppendIdentity(); |
1401 EXPECT_TRUE(identity.IsTranslation()); | 1342 EXPECT_TRUE(identity.IsTranslation()); |
1402 | 1343 |
1403 TransformOperations translate; | 1344 TransformOperations translate; |
1404 translate.AppendTranslate(1.f, 2.f, 3.f); | 1345 translate.AppendTranslate(1.f, 2.f, 3.f); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1527 | 1468 |
1528 // Scale + Perspective can't. | 1469 // Scale + Perspective can't. |
1529 TransformOperations operations11; | 1470 TransformOperations operations11; |
1530 operations11.AppendScale(2.f, 2.f, 2.f); | 1471 operations11.AppendScale(2.f, 2.f, 2.f); |
1531 operations11.AppendPerspective(1.f); | 1472 operations11.AppendPerspective(1.f); |
1532 EXPECT_FALSE(operations11.ScaleComponent(&scale)); | 1473 EXPECT_FALSE(operations11.ScaleComponent(&scale)); |
1533 } | 1474 } |
1534 | 1475 |
1535 } // namespace | 1476 } // namespace |
1536 } // namespace cc | 1477 } // namespace cc |
OLD | NEW |