OLD | NEW |
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/layer.h" | 5 #include "cc/layer.h" |
6 | 6 |
7 #include "cc/keyframed_animation_curve.h" | 7 #include "cc/keyframed_animation_curve.h" |
8 #include "cc/layer_impl.h" | 8 #include "cc/layer_impl.h" |
9 #include "cc/layer_painter.h" | 9 #include "cc/layer_painter.h" |
10 #include "cc/layer_tree_host.h" | 10 #include "cc/layer_tree_host.h" |
11 #include "cc/math_util.h" | 11 #include "cc/math_util.h" |
12 #include "cc/single_thread_proxy.h" | 12 #include "cc/single_thread_proxy.h" |
| 13 #include "cc/test/animation_test_common.h" |
13 #include "cc/test/fake_impl_proxy.h" | 14 #include "cc/test/fake_impl_proxy.h" |
14 #include "cc/test/fake_layer_tree_host_client.h" | 15 #include "cc/test/fake_layer_tree_host_client.h" |
15 #include "cc/test/fake_layer_tree_host_impl.h" | 16 #include "cc/test/fake_layer_tree_host_impl.h" |
16 #include "cc/test/geometry_test_utils.h" | 17 #include "cc/test/geometry_test_utils.h" |
17 #include "cc/thread.h" | 18 #include "cc/thread.h" |
18 #include "testing/gmock/include/gmock/gmock.h" | 19 #include "testing/gmock/include/gmock/gmock.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
20 #include "ui/gfx/transform.h" | 21 #include "ui/gfx/transform.h" |
21 | 22 |
22 using ::testing::AnyNumber; | 23 using ::testing::AnyNumber; |
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
636 | 637 |
637 testLayer->SetOpacity(0.5); | 638 testLayer->SetOpacity(0.5); |
638 | 639 |
639 EXPECT_FALSE(implLayer->LayerSurfacePropertyChanged()); | 640 EXPECT_FALSE(implLayer->LayerSurfacePropertyChanged()); |
640 | 641 |
641 testLayer->PushPropertiesTo(implLayer.get()); | 642 testLayer->PushPropertiesTo(implLayer.get()); |
642 | 643 |
643 EXPECT_TRUE(implLayer->LayerSurfacePropertyChanged()); | 644 EXPECT_TRUE(implLayer->LayerSurfacePropertyChanged()); |
644 } | 645 } |
645 | 646 |
| 647 TEST_F(LayerTest, verifyPushPropertiesDoesNotCauseSurfacePropertyChangedDuringIm
plOnlyTransformAnimation) |
| 648 { |
| 649 scoped_refptr<Layer> testLayer = Layer::Create(); |
| 650 scoped_ptr<LayerImpl> implLayer = LayerImpl::Create(m_hostImpl.activeTree(),
1); |
| 651 |
| 652 scoped_ptr<AnimationRegistrar> registrar = AnimationRegistrar::create(); |
| 653 implLayer->layer_animation_controller()->SetAnimationRegistrar(registrar.get
()); |
| 654 |
| 655 addAnimatedTransformToController(*implLayer->layer_animation_controller(), 1
.0, 0, 100); |
| 656 |
| 657 gfx::Transform transform; |
| 658 transform.Rotate(45.0); |
| 659 testLayer->SetTransform(transform); |
| 660 |
| 661 EXPECT_FALSE(implLayer->LayerSurfacePropertyChanged()); |
| 662 testLayer->PushPropertiesTo(implLayer.get()); |
| 663 EXPECT_TRUE(implLayer->LayerSurfacePropertyChanged()); |
| 664 |
| 665 implLayer->ResetAllChangeTrackingForSubtree(); |
| 666 addAnimatedTransformToController(*implLayer->layer_animation_controller(), 1
.0, 0, 100); |
| 667 implLayer->layer_animation_controller()->GetAnimation(Animation::Transform)-
>set_is_impl_only(true); |
| 668 transform.Rotate(45.0); |
| 669 testLayer->SetTransform(transform); |
| 670 |
| 671 EXPECT_FALSE(implLayer->LayerSurfacePropertyChanged()); |
| 672 testLayer->PushPropertiesTo(implLayer.get()); |
| 673 EXPECT_FALSE(implLayer->LayerSurfacePropertyChanged()); |
| 674 } |
| 675 |
| 676 TEST_F(LayerTest, verifyPushPropertiesDoesNotCauseSurfacePropertyChangedDuringIm
plOnlyOpacityAnimation) |
| 677 { |
| 678 scoped_refptr<Layer> testLayer = Layer::Create(); |
| 679 scoped_ptr<LayerImpl> implLayer = LayerImpl::Create(m_hostImpl.activeTree(),
1); |
| 680 |
| 681 scoped_ptr<AnimationRegistrar> registrar = AnimationRegistrar::create(); |
| 682 implLayer->layer_animation_controller()->SetAnimationRegistrar(registrar.get
()); |
| 683 |
| 684 addOpacityTransitionToController(*implLayer->layer_animation_controller(), 1
.0, 0.3f, 0.7f, false); |
| 685 |
| 686 testLayer->SetOpacity(0.5f); |
| 687 |
| 688 EXPECT_FALSE(implLayer->LayerSurfacePropertyChanged()); |
| 689 testLayer->PushPropertiesTo(implLayer.get()); |
| 690 EXPECT_TRUE(implLayer->LayerSurfacePropertyChanged()); |
| 691 |
| 692 implLayer->ResetAllChangeTrackingForSubtree(); |
| 693 addOpacityTransitionToController(*implLayer->layer_animation_controller(), 1
.0, 0.3f, 0.7f, false); |
| 694 implLayer->layer_animation_controller()->GetAnimation(Animation::Opacity)->s
et_is_impl_only(true); |
| 695 testLayer->SetOpacity(0.75f); |
| 696 |
| 697 EXPECT_FALSE(implLayer->LayerSurfacePropertyChanged()); |
| 698 testLayer->PushPropertiesTo(implLayer.get()); |
| 699 EXPECT_FALSE(implLayer->LayerSurfacePropertyChanged()); |
| 700 } |
| 701 |
| 702 |
646 TEST_F(LayerTest, maskAndReplicaHasParent) | 703 TEST_F(LayerTest, maskAndReplicaHasParent) |
647 { | 704 { |
648 scoped_refptr<Layer> parent = Layer::Create(); | 705 scoped_refptr<Layer> parent = Layer::Create(); |
649 scoped_refptr<Layer> child = Layer::Create(); | 706 scoped_refptr<Layer> child = Layer::Create(); |
650 scoped_refptr<Layer> mask = Layer::Create(); | 707 scoped_refptr<Layer> mask = Layer::Create(); |
651 scoped_refptr<Layer> replica = Layer::Create(); | 708 scoped_refptr<Layer> replica = Layer::Create(); |
652 scoped_refptr<Layer> replicaMask = Layer::Create(); | 709 scoped_refptr<Layer> replicaMask = Layer::Create(); |
653 scoped_refptr<Layer> maskReplacement = Layer::Create(); | 710 scoped_refptr<Layer> maskReplacement = Layer::Create(); |
654 scoped_refptr<Layer> replicaReplacement = Layer::Create(); | 711 scoped_refptr<Layer> replicaReplacement = Layer::Create(); |
655 scoped_refptr<Layer> replicaMaskReplacement = Layer::Create(); | 712 scoped_refptr<Layer> replicaMaskReplacement = Layer::Create(); |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
911 layer->SetLayerTreeHost(layerTreeHost.get()); | 968 layer->SetLayerTreeHost(layerTreeHost.get()); |
912 assertLayerTreeHostMatchesForSubtree(layer.get(), layerTreeHost.get()); | 969 assertLayerTreeHostMatchesForSubtree(layer.get(), layerTreeHost.get()); |
913 | 970 |
914 // Case 3: with a LayerTreeHost where accelerated animation is disabled, the | 971 // Case 3: with a LayerTreeHost where accelerated animation is disabled, the |
915 // animation should be rejected. | 972 // animation should be rejected. |
916 EXPECT_FALSE(addTestAnimation(layer.get())); | 973 EXPECT_FALSE(addTestAnimation(layer.get())); |
917 } | 974 } |
918 | 975 |
919 } // namespace | 976 } // namespace |
920 } // namespace cc | 977 } // namespace cc |
OLD | NEW |