| 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/trees/layer_tree_host_common.h" | 5 #include "cc/trees/layer_tree_host_common.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 9732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9743 node = tree.Node(animated->effect_tree_index()); | 9743 node = tree.Node(animated->effect_tree_index()); |
| 9744 EXPECT_TRUE(node->data.is_currently_animating_opacity); | 9744 EXPECT_TRUE(node->data.is_currently_animating_opacity); |
| 9745 EXPECT_TRUE(node->data.has_potential_opacity_animation); | 9745 EXPECT_TRUE(node->data.has_potential_opacity_animation); |
| 9746 | 9746 |
| 9747 player->AbortAnimations(TargetProperty::OPACITY, false /*needs_completion*/); | 9747 player->AbortAnimations(TargetProperty::OPACITY, false /*needs_completion*/); |
| 9748 node = tree.Node(animated->effect_tree_index()); | 9748 node = tree.Node(animated->effect_tree_index()); |
| 9749 EXPECT_FALSE(node->data.is_currently_animating_opacity); | 9749 EXPECT_FALSE(node->data.is_currently_animating_opacity); |
| 9750 EXPECT_FALSE(node->data.has_potential_opacity_animation); | 9750 EXPECT_FALSE(node->data.has_potential_opacity_animation); |
| 9751 } | 9751 } |
| 9752 | 9752 |
| 9753 TEST_F(LayerTreeHostCommonTest, TransformAnimationsTrackingTest) { |
| 9754 const gfx::Transform identity_matrix; |
| 9755 scoped_refptr<Layer> root = Layer::Create(); |
| 9756 scoped_refptr<LayerWithForcedDrawsContent> animated = |
| 9757 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 9758 root->AddChild(animated); |
| 9759 |
| 9760 host()->SetRootLayer(root); |
| 9761 |
| 9762 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), |
| 9763 gfx::PointF(), gfx::Size(100, 100), true, false); |
| 9764 SetLayerPropertiesForTesting(animated.get(), identity_matrix, gfx::Point3F(), |
| 9765 gfx::PointF(), gfx::Size(20, 20), true, false); |
| 9766 |
| 9767 root->SetForceRenderSurfaceForTesting(true); |
| 9768 |
| 9769 scoped_refptr<AnimationPlayer> player = |
| 9770 AnimationPlayer::Create(AnimationIdProvider::NextPlayerId()); |
| 9771 timeline()->AttachPlayer(player); |
| 9772 player->AttachElement(animated->id()); |
| 9773 |
| 9774 std::unique_ptr<KeyframedTransformAnimationCurve> curve( |
| 9775 KeyframedTransformAnimationCurve::Create()); |
| 9776 TransformOperations start; |
| 9777 start.AppendTranslate(1.f, 2.f, 3.f); |
| 9778 gfx::Transform transform; |
| 9779 transform.Scale3d(1.0, 2.0, 3.0); |
| 9780 TransformOperations operation; |
| 9781 operation.AppendMatrix(transform); |
| 9782 curve->AddKeyframe( |
| 9783 TransformKeyframe::Create(base::TimeDelta(), start, nullptr)); |
| 9784 curve->AddKeyframe(TransformKeyframe::Create( |
| 9785 base::TimeDelta::FromSecondsD(1.0), operation, nullptr)); |
| 9786 std::unique_ptr<Animation> animation( |
| 9787 Animation::Create(std::move(curve), 3, 3, TargetProperty::TRANSFORM)); |
| 9788 animation->set_fill_mode(Animation::FillMode::NONE); |
| 9789 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); |
| 9790 Animation* animation_ptr = animation.get(); |
| 9791 AddAnimationToLayerWithExistingPlayer(animated->id(), timeline(), |
| 9792 std::move(animation)); |
| 9793 |
| 9794 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 9795 |
| 9796 TransformTree& tree = |
| 9797 root->layer_tree_host()->property_trees()->transform_tree; |
| 9798 TransformNode* node = tree.Node(animated->transform_tree_index()); |
| 9799 EXPECT_FALSE(node->data.is_currently_animating); |
| 9800 EXPECT_TRUE(node->data.has_potential_animation); |
| 9801 |
| 9802 animation_ptr->set_time_offset(base::TimeDelta::FromMilliseconds(0)); |
| 9803 root->layer_tree_host()->AnimateLayers( |
| 9804 base::TimeTicks::FromInternalValue(std::numeric_limits<int64_t>::max())); |
| 9805 node = tree.Node(animated->transform_tree_index()); |
| 9806 EXPECT_TRUE(node->data.is_currently_animating); |
| 9807 EXPECT_TRUE(node->data.has_potential_animation); |
| 9808 |
| 9809 player->AbortAnimations(TargetProperty::TRANSFORM, |
| 9810 false /*needs_completion*/); |
| 9811 node = tree.Node(animated->transform_tree_index()); |
| 9812 EXPECT_FALSE(node->data.is_currently_animating); |
| 9813 EXPECT_FALSE(node->data.has_potential_animation); |
| 9814 } |
| 9815 |
| 9753 TEST_F(LayerTreeHostCommonTest, SerializeScrollUpdateInfo) { | 9816 TEST_F(LayerTreeHostCommonTest, SerializeScrollUpdateInfo) { |
| 9754 LayerTreeHostCommon::ScrollUpdateInfo scroll; | 9817 LayerTreeHostCommon::ScrollUpdateInfo scroll; |
| 9755 scroll.layer_id = 2; | 9818 scroll.layer_id = 2; |
| 9756 scroll.scroll_delta = gfx::Vector2d(5, 10); | 9819 scroll.scroll_delta = gfx::Vector2d(5, 10); |
| 9757 | 9820 |
| 9758 proto::ScrollUpdateInfo proto; | 9821 proto::ScrollUpdateInfo proto; |
| 9759 scroll.ToProtobuf(&proto); | 9822 scroll.ToProtobuf(&proto); |
| 9760 LayerTreeHostCommon::ScrollUpdateInfo new_scroll; | 9823 LayerTreeHostCommon::ScrollUpdateInfo new_scroll; |
| 9761 new_scroll.FromProtobuf(proto); | 9824 new_scroll.FromProtobuf(proto); |
| 9762 | 9825 |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9975 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); | 10038 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); |
| 9976 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); | 10039 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); |
| 9977 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); | 10040 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); |
| 9978 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); | 10041 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); |
| 9979 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); | 10042 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); |
| 9980 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); | 10043 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); |
| 9981 } | 10044 } |
| 9982 | 10045 |
| 9983 } // namespace | 10046 } // namespace |
| 9984 } // namespace cc | 10047 } // namespace cc |
| OLD | NEW |