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

Side by Side Diff: cc/animation/transform_operations_unittest.cc

Issue 15972006: TransformOperations should be able to blend outside the range [0, 1] (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 6 months 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
« no previous file with comments | « cc/animation/transform_operations.cc ('k') | ui/gfx/transform.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 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 <limits> 5 #include <limits>
6 6
7 #include "base/memory/scoped_vector.h" 7 #include "base/memory/scoped_vector.h"
8 #include "cc/animation/transform_operations.h" 8 #include "cc/animation/transform_operations.h"
9 #include "cc/test/geometry_test_utils.h" 9 #include "cc/test/geometry_test_utils.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 TransformOperations operations; 425 TransformOperations operations;
426 operations.AppendRotate(0, 0, 1, 360); 426 operations.AppendRotate(0, 0, 1, 360);
427 427
428 double progress = 0.5; 428 double progress = 0.5;
429 429
430 gfx::Transform expected; 430 gfx::Transform expected;
431 expected.RotateAbout(gfx::Vector3dF(0, 0, 1), 180); 431 expected.RotateAbout(gfx::Vector3dF(0, 0, 1), 180);
432 432
433 EXPECT_TRANSFORMATION_MATRIX_EQ( 433 EXPECT_TRANSFORMATION_MATRIX_EQ(
434 expected, operations.Blend(*identity_operations[i], progress)); 434 expected, operations.Blend(*identity_operations[i], progress));
435
436 progress = -0.5;
437
438 expected.MakeIdentity();
439 expected.RotateAbout(gfx::Vector3dF(0, 0, 1), -180);
440
441 EXPECT_TRANSFORMATION_MATRIX_EQ(
442 expected, operations.Blend(*identity_operations[i], progress));
443
444 progress = 1.5;
445
446 expected.MakeIdentity();
447 expected.RotateAbout(gfx::Vector3dF(0, 0, 1), 540);
448
449 EXPECT_TRANSFORMATION_MATRIX_EQ(
450 expected, operations.Blend(*identity_operations[i], progress));
435 } 451 }
436 } 452 }
437 453
438 TEST(TransformOperationTest, BlendTranslationFromIdentity) { 454 TEST(TransformOperationTest, BlendTranslationFromIdentity) {
439 ScopedVector<TransformOperations> identity_operations; 455 ScopedVector<TransformOperations> identity_operations;
440 GetIdentityOperations(&identity_operations); 456 GetIdentityOperations(&identity_operations);
441 457
442 for (size_t i = 0; i < identity_operations.size(); ++i) { 458 for (size_t i = 0; i < identity_operations.size(); ++i) {
443 TransformOperations operations; 459 TransformOperations operations;
444 operations.AppendTranslate(2, 2, 2); 460 operations.AppendTranslate(2, 2, 2);
445 461
446 double progress = 0.5; 462 double progress = 0.5;
447 463
448 gfx::Transform expected; 464 gfx::Transform expected;
449 expected.Translate3d(1, 1, 1); 465 expected.Translate3d(1, 1, 1);
450 466
451 EXPECT_TRANSFORMATION_MATRIX_EQ( 467 EXPECT_TRANSFORMATION_MATRIX_EQ(
452 expected, operations.Blend(*identity_operations[i], progress)); 468 expected, operations.Blend(*identity_operations[i], progress));
469
470 progress = -0.5;
471
472 expected.MakeIdentity();
473 expected.Translate3d(-1, -1, -1);
474
475 EXPECT_TRANSFORMATION_MATRIX_EQ(
476 expected, operations.Blend(*identity_operations[i], progress));
477
478 progress = 1.5;
479
480 expected.MakeIdentity();
481 expected.Translate3d(3, 3, 3);
482
483 EXPECT_TRANSFORMATION_MATRIX_EQ(
484 expected, operations.Blend(*identity_operations[i], progress));
453 } 485 }
454 } 486 }
455 487
456 TEST(TransformOperationTest, BlendScaleFromIdentity) { 488 TEST(TransformOperationTest, BlendScaleFromIdentity) {
457 ScopedVector<TransformOperations> identity_operations; 489 ScopedVector<TransformOperations> identity_operations;
458 GetIdentityOperations(&identity_operations); 490 GetIdentityOperations(&identity_operations);
459 491
460 for (size_t i = 0; i < identity_operations.size(); ++i) { 492 for (size_t i = 0; i < identity_operations.size(); ++i) {
461 TransformOperations operations; 493 TransformOperations operations;
462 operations.AppendScale(3, 3, 3); 494 operations.AppendScale(3, 3, 3);
463 495
464 double progress = 0.5; 496 double progress = 0.5;
465 497
466 gfx::Transform expected; 498 gfx::Transform expected;
467 expected.Scale3d(2, 2, 2); 499 expected.Scale3d(2, 2, 2);
468 500
469 EXPECT_TRANSFORMATION_MATRIX_EQ( 501 EXPECT_TRANSFORMATION_MATRIX_EQ(
470 expected, operations.Blend(*identity_operations[i], progress)); 502 expected, operations.Blend(*identity_operations[i], progress));
503
504 progress = -0.5;
505
506 expected.MakeIdentity();
507 expected.Scale3d(0, 0, 0);
508
509 EXPECT_TRANSFORMATION_MATRIX_EQ(
510 expected, operations.Blend(*identity_operations[i], progress));
511
512 progress = 1.5;
513
514 expected.MakeIdentity();
515 expected.Scale3d(4, 4, 4);
516
517 EXPECT_TRANSFORMATION_MATRIX_EQ(
518 expected, operations.Blend(*identity_operations[i], progress));
471 } 519 }
472 } 520 }
473 521
474 TEST(TransformOperationTest, BlendSkewFromIdentity) { 522 TEST(TransformOperationTest, BlendSkewFromIdentity) {
475 ScopedVector<TransformOperations> identity_operations; 523 ScopedVector<TransformOperations> identity_operations;
476 GetIdentityOperations(&identity_operations); 524 GetIdentityOperations(&identity_operations);
477 525
478 for (size_t i = 0; i < identity_operations.size(); ++i) { 526 for (size_t i = 0; i < identity_operations.size(); ++i) {
479 TransformOperations operations; 527 TransformOperations operations;
480 operations.AppendSkew(2, 2); 528 operations.AppendSkew(2, 2);
481 529
482 double progress = 0.5; 530 double progress = 0.5;
483 531
484 gfx::Transform expected; 532 gfx::Transform expected;
485 expected.SkewX(1); 533 expected.SkewX(1);
486 expected.SkewY(1); 534 expected.SkewY(1);
487 535
488 EXPECT_TRANSFORMATION_MATRIX_EQ( 536 EXPECT_TRANSFORMATION_MATRIX_EQ(
489 expected, operations.Blend(*identity_operations[i], progress)); 537 expected, operations.Blend(*identity_operations[i], progress));
538
539 progress = -0.5;
540
541 expected.MakeIdentity();
542 expected.SkewX(-1);
543 expected.SkewY(-1);
544
545 EXPECT_TRANSFORMATION_MATRIX_EQ(
546 expected, operations.Blend(*identity_operations[i], progress));
547
548 progress = 1.5;
549
550 expected.MakeIdentity();
551 expected.SkewX(3);
552 expected.SkewY(3);
553
554 EXPECT_TRANSFORMATION_MATRIX_EQ(
555 expected, operations.Blend(*identity_operations[i], progress));
490 } 556 }
491 } 557 }
492 558
493 TEST(TransformOperationTest, BlendPerspectiveFromIdentity) { 559 TEST(TransformOperationTest, BlendPerspectiveFromIdentity) {
494 ScopedVector<TransformOperations> identity_operations; 560 ScopedVector<TransformOperations> identity_operations;
495 GetIdentityOperations(&identity_operations); 561 GetIdentityOperations(&identity_operations);
496 562
497 for (size_t i = 0; i < identity_operations.size(); ++i) { 563 for (size_t i = 0; i < identity_operations.size(); ++i) {
498 TransformOperations operations; 564 TransformOperations operations;
499 operations.AppendPerspective(1000); 565 operations.AppendPerspective(1000);
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 660
595 gfx::Transform expected; 661 gfx::Transform expected;
596 expected.ApplyPerspectiveDepth( 662 expected.ApplyPerspectiveDepth(
597 500 + 0.5 * std::numeric_limits<double>::max()); 663 500 + 0.5 * std::numeric_limits<double>::max());
598 664
599 EXPECT_TRANSFORMATION_MATRIX_EQ( 665 EXPECT_TRANSFORMATION_MATRIX_EQ(
600 expected, identity_operations[i]->Blend(operations, progress)); 666 expected, identity_operations[i]->Blend(operations, progress));
601 } 667 }
602 } 668 }
603 669
670 TEST(TransformOperationTest, ExtrapolatePerspectiveBlending) {
671 TransformOperations operations1;
672 operations1.AppendPerspective(1000);
673
674 TransformOperations operations2;
675 operations2.AppendPerspective(500);
676
677 gfx::Transform expected;
678 expected.ApplyPerspectiveDepth(250);
679
680 EXPECT_TRANSFORMATION_MATRIX_EQ(
681 expected, operations1.Blend(operations2, -0.5));
682
683 expected.MakeIdentity();
684 expected.ApplyPerspectiveDepth(1250);
685
686 EXPECT_TRANSFORMATION_MATRIX_EQ(
687 expected, operations1.Blend(operations2, 1.5));
688 }
689
690 TEST(TransformOperationTest, ExtrapolateMatrixBlending) {
691 gfx::Transform transform1;
692 transform1.Translate3d(1, 1, 1);
693 TransformOperations operations1;
694 operations1.AppendMatrix(transform1);
695
696 gfx::Transform transform2;
697 transform2.Translate3d(3, 3, 3);
698 TransformOperations operations2;
699 operations2.AppendMatrix(transform2);
700
701 gfx::Transform expected;
702 EXPECT_TRANSFORMATION_MATRIX_EQ(
703 expected, operations1.Blend(operations2, 1.5));
704
705 expected.Translate3d(4, 4, 4);
706 EXPECT_TRANSFORMATION_MATRIX_EQ(
707 expected, operations1.Blend(operations2, -0.5));
708 }
709
604 } // namespace 710 } // namespace
605 } // namespace cc 711 } // namespace cc
OLDNEW
« no previous file with comments | « cc/animation/transform_operations.cc ('k') | ui/gfx/transform.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698