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->layerAnimationController()->setAnimationRegistrar(registrar.get()
); |
| 654 |
| 655 addAnimatedTransformToController(*implLayer->layerAnimationController(), 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->layerAnimationController(), 1.0
, 0, 100); |
| 667 implLayer->layerAnimationController()->getAnimation(Animation::Transform)->s
etIsImplOnly(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->layerAnimationController()->setAnimationRegistrar(registrar.get()
); |
| 683 |
| 684 addOpacityTransitionToController(*implLayer->layerAnimationController(), 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->layerAnimationController(), 1.0
, 0.3f, 0.7f, false); |
| 694 implLayer->layerAnimationController()->getAnimation(Animation::Opacity)->set
IsImplOnly(true); |
| 695 testLayer->setOpacity(0.75f); |
| 696 |
| 697 EXPECT_FALSE(implLayer->layerSurfacePropertyChanged()); |
| 698 testLayer->pushPropertiesTo(implLayer.get()); |
| 699 EXPECT_FALSE(implLayer->layerSurfacePropertyChanged()); |
| 700 } |
| 701 |
646 TEST_F(LayerTest, maskAndReplicaHasParent) | 702 TEST_F(LayerTest, maskAndReplicaHasParent) |
647 { | 703 { |
648 scoped_refptr<Layer> parent = Layer::create(); | 704 scoped_refptr<Layer> parent = Layer::create(); |
649 scoped_refptr<Layer> child = Layer::create(); | 705 scoped_refptr<Layer> child = Layer::create(); |
650 scoped_refptr<Layer> mask = Layer::create(); | 706 scoped_refptr<Layer> mask = Layer::create(); |
651 scoped_refptr<Layer> replica = Layer::create(); | 707 scoped_refptr<Layer> replica = Layer::create(); |
652 scoped_refptr<Layer> replicaMask = Layer::create(); | 708 scoped_refptr<Layer> replicaMask = Layer::create(); |
653 scoped_refptr<Layer> maskReplacement = Layer::create(); | 709 scoped_refptr<Layer> maskReplacement = Layer::create(); |
654 scoped_refptr<Layer> replicaReplacement = Layer::create(); | 710 scoped_refptr<Layer> replicaReplacement = Layer::create(); |
655 scoped_refptr<Layer> replicaMaskReplacement = Layer::create(); | 711 scoped_refptr<Layer> replicaMaskReplacement = Layer::create(); |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
911 layer->setLayerTreeHost(layerTreeHost.get()); | 967 layer->setLayerTreeHost(layerTreeHost.get()); |
912 assertLayerTreeHostMatchesForSubtree(layer.get(), layerTreeHost.get()); | 968 assertLayerTreeHostMatchesForSubtree(layer.get(), layerTreeHost.get()); |
913 | 969 |
914 // Case 3: with a LayerTreeHost where accelerated animation is disabled, the | 970 // Case 3: with a LayerTreeHost where accelerated animation is disabled, the |
915 // animation should be rejected. | 971 // animation should be rejected. |
916 EXPECT_FALSE(addTestAnimation(layer.get())); | 972 EXPECT_FALSE(addTestAnimation(layer.get())); |
917 } | 973 } |
918 | 974 |
919 } // namespace | 975 } // namespace |
920 } // namespace cc | 976 } // namespace cc |
OLD | NEW |