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 8925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8936 transform.Scale3d(1.0, 2.0, 3.0); | 8936 transform.Scale3d(1.0, 2.0, 3.0); |
8937 TransformOperations operation; | 8937 TransformOperations operation; |
8938 operation.AppendMatrix(transform); | 8938 operation.AppendMatrix(transform); |
8939 curve->AddKeyframe( | 8939 curve->AddKeyframe( |
8940 TransformKeyframe::Create(base::TimeDelta(), start, nullptr)); | 8940 TransformKeyframe::Create(base::TimeDelta(), start, nullptr)); |
8941 curve->AddKeyframe(TransformKeyframe::Create( | 8941 curve->AddKeyframe(TransformKeyframe::Create( |
8942 base::TimeDelta::FromSecondsD(1.0), operation, nullptr)); | 8942 base::TimeDelta::FromSecondsD(1.0), operation, nullptr)); |
8943 std::unique_ptr<Animation> transform_animation( | 8943 std::unique_ptr<Animation> transform_animation( |
8944 Animation::Create(std::move(curve), 3, 3, TargetProperty::TRANSFORM)); | 8944 Animation::Create(std::move(curve), 3, 3, TargetProperty::TRANSFORM)); |
8945 scoped_refptr<AnimationPlayer> player(AnimationPlayer::Create(1)); | 8945 scoped_refptr<AnimationPlayer> player(AnimationPlayer::Create(1)); |
8946 host_impl.active_tree()->animation_host()->RegisterPlayerForLayer( | 8946 host_impl.active_tree()->animation_host()->RegisterPlayerForElement( |
8947 root_ptr->id(), player.get()); | 8947 root_ptr->id(), player.get()); |
8948 host_impl.active_tree() | 8948 host_impl.active_tree() |
8949 ->animation_host() | 8949 ->animation_host() |
8950 ->GetElementAnimationsForLayerId(root_ptr->id()) | 8950 ->GetElementAnimationsForElementId(root_ptr->id()) |
8951 ->AddAnimation(std::move(transform_animation)); | 8951 ->AddAnimation(std::move(transform_animation)); |
8952 grandchild_ptr->set_visible_layer_rect(gfx::Rect()); | 8952 grandchild_ptr->set_visible_layer_rect(gfx::Rect()); |
8953 child_ptr->SetScrollClipLayer(root_ptr->id()); | 8953 child_ptr->SetScrollClipLayer(root_ptr->id()); |
8954 root_ptr->SetTransform(singular); | 8954 root_ptr->SetTransform(singular); |
8955 child_ptr->SetTransform(singular); | 8955 child_ptr->SetTransform(singular); |
8956 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; | 8956 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; |
8957 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); | 8957 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); |
8958 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); | 8958 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); |
8959 | 8959 |
8960 host_impl.active_tree()->animation_host()->UnregisterPlayerForLayer( | 8960 host_impl.active_tree()->animation_host()->UnregisterPlayerForElement( |
8961 root_ptr->id(), player.get()); | 8961 root_ptr->id(), player.get()); |
8962 } | 8962 } |
8963 | 8963 |
8964 TEST_F(LayerTreeHostCommonTest, LayerSkippingInSubtreeOfSingularTransform) { | 8964 TEST_F(LayerTreeHostCommonTest, LayerSkippingInSubtreeOfSingularTransform) { |
8965 LayerImpl* root = root_layer(); | 8965 LayerImpl* root = root_layer(); |
8966 LayerImpl* child = AddChild<LayerImpl>(root); | 8966 LayerImpl* child = AddChild<LayerImpl>(root); |
8967 LayerImpl* grand_child = AddChild<LayerImpl>(child); | 8967 LayerImpl* grand_child = AddChild<LayerImpl>(child); |
8968 | 8968 |
8969 gfx::Transform identity; | 8969 gfx::Transform identity; |
8970 SetLayerPropertiesForTesting(root, identity, gfx::Point3F(), gfx::PointF(), | 8970 SetLayerPropertiesForTesting(root, identity, gfx::Point3F(), gfx::PointF(), |
(...skipping 20 matching lines...) Expand all Loading... |
8991 transform.Scale3d(1.0, 2.0, 3.0); | 8991 transform.Scale3d(1.0, 2.0, 3.0); |
8992 TransformOperations operation; | 8992 TransformOperations operation; |
8993 operation.AppendMatrix(transform); | 8993 operation.AppendMatrix(transform); |
8994 curve->AddKeyframe( | 8994 curve->AddKeyframe( |
8995 TransformKeyframe::Create(base::TimeDelta(), start, nullptr)); | 8995 TransformKeyframe::Create(base::TimeDelta(), start, nullptr)); |
8996 curve->AddKeyframe(TransformKeyframe::Create( | 8996 curve->AddKeyframe(TransformKeyframe::Create( |
8997 base::TimeDelta::FromSecondsD(1.0), operation, nullptr)); | 8997 base::TimeDelta::FromSecondsD(1.0), operation, nullptr)); |
8998 std::unique_ptr<Animation> transform_animation( | 8998 std::unique_ptr<Animation> transform_animation( |
8999 Animation::Create(std::move(curve), 3, 3, TargetProperty::TRANSFORM)); | 8999 Animation::Create(std::move(curve), 3, 3, TargetProperty::TRANSFORM)); |
9000 scoped_refptr<AnimationPlayer> player(AnimationPlayer::Create(1)); | 9000 scoped_refptr<AnimationPlayer> player(AnimationPlayer::Create(1)); |
9001 host_impl()->active_tree()->animation_host()->RegisterPlayerForLayer( | 9001 host_impl()->active_tree()->animation_host()->RegisterPlayerForElement( |
9002 grand_child->id(), player.get()); | 9002 grand_child->id(), player.get()); |
9003 host_impl() | 9003 host_impl() |
9004 ->active_tree() | 9004 ->active_tree() |
9005 ->animation_host() | 9005 ->animation_host() |
9006 ->GetElementAnimationsForLayerId(grand_child->id()) | 9006 ->GetElementAnimationsForElementId(grand_child->id()) |
9007 ->AddAnimation(std::move(transform_animation)); | 9007 ->AddAnimation(std::move(transform_animation)); |
9008 | 9008 |
9009 ExecuteCalculateDrawProperties(root); | 9009 ExecuteCalculateDrawProperties(root); |
9010 EXPECT_EQ(gfx::Rect(0, 0), grand_child->visible_layer_rect()); | 9010 EXPECT_EQ(gfx::Rect(0, 0), grand_child->visible_layer_rect()); |
9011 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect()); | 9011 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect()); |
9012 | 9012 |
9013 host_impl()->active_tree()->animation_host()->UnregisterPlayerForLayer( | 9013 host_impl()->active_tree()->animation_host()->UnregisterPlayerForElement( |
9014 grand_child->id(), player.get()); | 9014 grand_child->id(), player.get()); |
9015 } | 9015 } |
9016 | 9016 |
9017 TEST_F(LayerTreeHostCommonTest, SkippingPendingLayerImpl) { | 9017 TEST_F(LayerTreeHostCommonTest, SkippingPendingLayerImpl) { |
9018 FakeImplTaskRunnerProvider task_runner_provider; | 9018 FakeImplTaskRunnerProvider task_runner_provider; |
9019 TestSharedBitmapManager shared_bitmap_manager; | 9019 TestSharedBitmapManager shared_bitmap_manager; |
9020 TestTaskGraphRunner task_graph_runner; | 9020 TestTaskGraphRunner task_graph_runner; |
9021 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, | 9021 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, |
9022 &task_graph_runner); | 9022 &task_graph_runner); |
9023 | 9023 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9062 std::unique_ptr<KeyframedFloatAnimationCurve> curve( | 9062 std::unique_ptr<KeyframedFloatAnimationCurve> curve( |
9063 KeyframedFloatAnimationCurve::Create()); | 9063 KeyframedFloatAnimationCurve::Create()); |
9064 std::unique_ptr<TimingFunction> func = EaseTimingFunction::Create(); | 9064 std::unique_ptr<TimingFunction> func = EaseTimingFunction::Create(); |
9065 curve->AddKeyframe( | 9065 curve->AddKeyframe( |
9066 FloatKeyframe::Create(base::TimeDelta(), 0.9f, std::move(func))); | 9066 FloatKeyframe::Create(base::TimeDelta(), 0.9f, std::move(func))); |
9067 curve->AddKeyframe( | 9067 curve->AddKeyframe( |
9068 FloatKeyframe::Create(base::TimeDelta::FromSecondsD(1.0), 0.3f, nullptr)); | 9068 FloatKeyframe::Create(base::TimeDelta::FromSecondsD(1.0), 0.3f, nullptr)); |
9069 std::unique_ptr<Animation> animation( | 9069 std::unique_ptr<Animation> animation( |
9070 Animation::Create(std::move(curve), 3, 3, TargetProperty::OPACITY)); | 9070 Animation::Create(std::move(curve), 3, 3, TargetProperty::OPACITY)); |
9071 scoped_refptr<AnimationPlayer> player(AnimationPlayer::Create(1)); | 9071 scoped_refptr<AnimationPlayer> player(AnimationPlayer::Create(1)); |
9072 host_impl.active_tree()->animation_host()->RegisterPlayerForLayer( | 9072 host_impl.active_tree()->animation_host()->RegisterPlayerForElement( |
9073 root_ptr->id(), player.get()); | 9073 root_ptr->id(), player.get()); |
9074 host_impl.active_tree() | 9074 host_impl.active_tree() |
9075 ->animation_host() | 9075 ->animation_host() |
9076 ->GetElementAnimationsForLayerId(root_ptr->id()) | 9076 ->GetElementAnimationsForElementId(root_ptr->id()) |
9077 ->AddAnimation(std::move(animation)); | 9077 ->AddAnimation(std::move(animation)); |
9078 root_ptr->SetOpacity(0); | 9078 root_ptr->SetOpacity(0); |
9079 grandchild_ptr->set_visible_layer_rect(gfx::Rect()); | 9079 grandchild_ptr->set_visible_layer_rect(gfx::Rect()); |
9080 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; | 9080 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; |
9081 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); | 9081 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); |
9082 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); | 9082 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); |
9083 | 9083 |
9084 host_impl.active_tree()->animation_host()->UnregisterPlayerForLayer( | 9084 host_impl.active_tree()->animation_host()->UnregisterPlayerForElement( |
9085 root_ptr->id(), player.get()); | 9085 root_ptr->id(), player.get()); |
9086 } | 9086 } |
9087 | 9087 |
9088 TEST_F(LayerTreeHostCommonTest, SkippingLayer) { | 9088 TEST_F(LayerTreeHostCommonTest, SkippingLayer) { |
9089 gfx::Transform identity; | 9089 gfx::Transform identity; |
9090 LayerImpl* root = root_layer(); | 9090 LayerImpl* root = root_layer(); |
9091 LayerImpl* child = AddChild<LayerImpl>(root); | 9091 LayerImpl* child = AddChild<LayerImpl>(root); |
9092 | 9092 |
9093 SetLayerPropertiesForTesting(root, identity, gfx::Point3F(), gfx::PointF(), | 9093 SetLayerPropertiesForTesting(root, identity, gfx::Point3F(), gfx::PointF(), |
9094 gfx::Size(100, 100), true, false, true); | 9094 gfx::Size(100, 100), true, false, true); |
(...skipping 1031 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10126 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); | 10126 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); |
10127 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); | 10127 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); |
10128 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); | 10128 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); |
10129 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); | 10129 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); |
10130 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); | 10130 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); |
10131 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); | 10131 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); |
10132 } | 10132 } |
10133 | 10133 |
10134 } // namespace | 10134 } // namespace |
10135 } // namespace cc | 10135 } // namespace cc |
OLD | NEW |