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/layers/layer.h" | 5 #include "cc/layers/layer.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/threading/thread_task_runner_handle.h" | 9 #include "base/threading/thread_task_runner_handle.h" |
10 #include "cc/animation/animation_host.h" | 10 #include "cc/animation/animation_host.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 #include "ui/gfx/geometry/size.h" | 42 #include "ui/gfx/geometry/size.h" |
43 #include "ui/gfx/geometry/vector2d_f.h" | 43 #include "ui/gfx/geometry/vector2d_f.h" |
44 #include "ui/gfx/transform.h" | 44 #include "ui/gfx/transform.h" |
45 | 45 |
46 using ::testing::AnyNumber; | 46 using ::testing::AnyNumber; |
47 using ::testing::AtLeast; | 47 using ::testing::AtLeast; |
48 using ::testing::Mock; | 48 using ::testing::Mock; |
49 using ::testing::StrictMock; | 49 using ::testing::StrictMock; |
50 using ::testing::_; | 50 using ::testing::_; |
51 | 51 |
52 #define EXPECT_SET_NEEDS_FULL_TREE_SYNC(expect, code_to_test) \ | 52 #define EXPECT_SET_NEEDS_FULL_TREE_SYNC(expect, code_to_test) \ |
53 do { \ | 53 do { \ |
54 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times((expect)); \ | 54 EXPECT_CALL(*layer_tree_, SetNeedsFullTreeSync()).Times((expect)); \ |
55 code_to_test; \ | 55 code_to_test; \ |
56 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); \ | 56 Mock::VerifyAndClearExpectations(layer_tree_); \ |
57 } while (false) | 57 } while (false) |
58 | 58 |
59 #define EXECUTE_AND_VERIFY_SUBTREE_CHANGED(code_to_test) \ | 59 #define EXECUTE_AND_VERIFY_SUBTREE_CHANGED(code_to_test) \ |
60 code_to_test; \ | 60 code_to_test; \ |
61 root->layer_tree_host()->BuildPropertyTreesForTesting(); \ | 61 root->layer_tree_host()->BuildPropertyTreesForTesting(); \ |
62 EXPECT_TRUE(root->subtree_property_changed()); \ | 62 EXPECT_TRUE(root->subtree_property_changed()); \ |
63 EXPECT_TRUE( \ | 63 EXPECT_TRUE( \ |
64 root->GetLayerTree()->LayerNeedsPushPropertiesForTesting(root.get())); \ | 64 root->GetLayerTree()->LayerNeedsPushPropertiesForTesting(root.get())); \ |
65 EXPECT_TRUE(child->subtree_property_changed()); \ | 65 EXPECT_TRUE(child->subtree_property_changed()); \ |
66 EXPECT_TRUE( \ | 66 EXPECT_TRUE( \ |
(...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
881 layer_dest_root->SetLayerTreeHost(nullptr); | 881 layer_dest_root->SetLayerTreeHost(nullptr); |
882 } | 882 } |
883 | 883 |
884 TestTaskGraphRunner task_graph_runner_; | 884 TestTaskGraphRunner task_graph_runner_; |
885 FakeLayerTreeHostClient fake_client_; | 885 FakeLayerTreeHostClient fake_client_; |
886 std::unique_ptr<FakeLayerTreeHost> layer_tree_host_; | 886 std::unique_ptr<FakeLayerTreeHost> layer_tree_host_; |
887 }; | 887 }; |
888 | 888 |
889 namespace { | 889 namespace { |
890 | 890 |
| 891 class MockLayerTree : public LayerTree { |
| 892 public: |
| 893 MockLayerTree(LayerTreeHost::InitParams* params, |
| 894 LayerTreeHost* layer_tree_host) |
| 895 : LayerTree(std::move(params->animation_host), layer_tree_host) {} |
| 896 ~MockLayerTree() override {} |
| 897 |
| 898 MOCK_METHOD0(SetNeedsFullTreeSync, void()); |
| 899 }; |
| 900 |
891 class MockLayerTreeHost : public LayerTreeHost { | 901 class MockLayerTreeHost : public LayerTreeHost { |
892 public: | 902 public: |
893 MockLayerTreeHost(LayerTreeHostSingleThreadClient* single_thread_client, | 903 MockLayerTreeHost(LayerTreeHostSingleThreadClient* single_thread_client, |
894 LayerTreeHost::InitParams* params) | 904 LayerTreeHost::InitParams* params) |
895 : LayerTreeHost(params, CompositorMode::SINGLE_THREADED) { | 905 : LayerTreeHost( |
| 906 params, |
| 907 CompositorMode::SINGLE_THREADED, |
| 908 base::MakeUnique<StrictMock<MockLayerTree>>(params, this)) { |
896 InitializeSingleThreaded(single_thread_client, | 909 InitializeSingleThreaded(single_thread_client, |
897 base::ThreadTaskRunnerHandle::Get(), nullptr); | 910 base::ThreadTaskRunnerHandle::Get(), nullptr); |
898 } | 911 } |
899 | 912 |
900 MOCK_METHOD0(SetNeedsCommit, void()); | 913 MOCK_METHOD0(SetNeedsCommit, void()); |
901 MOCK_METHOD0(SetNeedsUpdateLayers, void()); | 914 MOCK_METHOD0(SetNeedsUpdateLayers, void()); |
902 MOCK_METHOD0(SetNeedsFullTreeSync, void()); | |
903 }; | 915 }; |
904 | 916 |
905 class LayerTest : public testing::Test { | 917 class LayerTest : public testing::Test { |
906 public: | 918 public: |
907 LayerTest() | 919 LayerTest() |
908 : host_impl_(LayerTreeSettings(), | 920 : host_impl_(LayerTreeSettings(), |
909 &task_runner_provider_, | 921 &task_runner_provider_, |
910 &shared_bitmap_manager_, | 922 &shared_bitmap_manager_, |
911 &task_graph_runner_) { | 923 &task_graph_runner_) { |
912 timeline_impl_ = | 924 timeline_impl_ = |
913 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); | 925 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); |
914 timeline_impl_->set_is_impl_only(true); | 926 timeline_impl_->set_is_impl_only(true); |
915 host_impl_.animation_host()->AddAnimationTimeline(timeline_impl_); | 927 host_impl_.animation_host()->AddAnimationTimeline(timeline_impl_); |
916 } | 928 } |
917 | 929 |
918 const LayerTreeSettings& settings() { return settings_; } | 930 const LayerTreeSettings& settings() { return settings_; } |
919 scoped_refptr<AnimationTimeline> timeline_impl() { return timeline_impl_; } | 931 scoped_refptr<AnimationTimeline> timeline_impl() { return timeline_impl_; } |
920 | 932 |
921 protected: | 933 protected: |
922 void SetUp() override { | 934 void SetUp() override { |
923 LayerTreeHost::InitParams params; | 935 LayerTreeHost::InitParams params; |
924 params.client = &fake_client_; | 936 params.client = &fake_client_; |
925 params.settings = &settings_; | 937 params.settings = &settings_; |
926 params.task_graph_runner = &task_graph_runner_; | 938 params.task_graph_runner = &task_graph_runner_; |
927 params.animation_host = | 939 params.animation_host = |
928 AnimationHost::CreateForTesting(ThreadInstance::MAIN); | 940 AnimationHost::CreateForTesting(ThreadInstance::MAIN); |
929 | 941 |
930 layer_tree_host_.reset( | 942 layer_tree_host_.reset( |
931 new StrictMock<MockLayerTreeHost>(&single_thread_client_, ¶ms)); | 943 new StrictMock<MockLayerTreeHost>(&single_thread_client_, ¶ms)); |
| 944 layer_tree_ = static_cast<StrictMock<MockLayerTree>*>( |
| 945 layer_tree_host_->GetLayerTree()); |
932 } | 946 } |
933 | 947 |
934 void TearDown() override { | 948 void TearDown() override { |
935 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 949 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
936 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(AnyNumber()); | 950 Mock::VerifyAndClearExpectations(layer_tree_); |
| 951 EXPECT_CALL(*layer_tree_, SetNeedsFullTreeSync()).Times(AnyNumber()); |
937 parent_ = nullptr; | 952 parent_ = nullptr; |
938 child1_ = nullptr; | 953 child1_ = nullptr; |
939 child2_ = nullptr; | 954 child2_ = nullptr; |
940 child3_ = nullptr; | 955 child3_ = nullptr; |
941 grand_child1_ = nullptr; | 956 grand_child1_ = nullptr; |
942 grand_child2_ = nullptr; | 957 grand_child2_ = nullptr; |
943 grand_child3_ = nullptr; | 958 grand_child3_ = nullptr; |
944 | 959 |
945 layer_tree_host_->SetRootLayer(nullptr); | 960 layer_tree_->SetRootLayer(nullptr); |
946 layer_tree_host_ = nullptr; | 961 layer_tree_host_ = nullptr; |
| 962 layer_tree_ = nullptr; |
947 } | 963 } |
948 | 964 |
949 void VerifyTestTreeInitialState() const { | 965 void VerifyTestTreeInitialState() const { |
950 ASSERT_EQ(3U, parent_->children().size()); | 966 ASSERT_EQ(3U, parent_->children().size()); |
951 EXPECT_EQ(child1_, parent_->children()[0]); | 967 EXPECT_EQ(child1_, parent_->children()[0]); |
952 EXPECT_EQ(child2_, parent_->children()[1]); | 968 EXPECT_EQ(child2_, parent_->children()[1]); |
953 EXPECT_EQ(child3_, parent_->children()[2]); | 969 EXPECT_EQ(child3_, parent_->children()[2]); |
954 EXPECT_EQ(parent_.get(), child1_->parent()); | 970 EXPECT_EQ(parent_.get(), child1_->parent()); |
955 EXPECT_EQ(parent_.get(), child2_->parent()); | 971 EXPECT_EQ(parent_.get(), child2_->parent()); |
956 EXPECT_EQ(parent_.get(), child3_->parent()); | 972 EXPECT_EQ(parent_.get(), child3_->parent()); |
(...skipping 13 matching lines...) Expand all Loading... |
970 | 986 |
971 void CreateSimpleTestTree() { | 987 void CreateSimpleTestTree() { |
972 parent_ = Layer::Create(); | 988 parent_ = Layer::Create(); |
973 child1_ = Layer::Create(); | 989 child1_ = Layer::Create(); |
974 child2_ = Layer::Create(); | 990 child2_ = Layer::Create(); |
975 child3_ = Layer::Create(); | 991 child3_ = Layer::Create(); |
976 grand_child1_ = Layer::Create(); | 992 grand_child1_ = Layer::Create(); |
977 grand_child2_ = Layer::Create(); | 993 grand_child2_ = Layer::Create(); |
978 grand_child3_ = Layer::Create(); | 994 grand_child3_ = Layer::Create(); |
979 | 995 |
980 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(AnyNumber()); | 996 EXPECT_CALL(*layer_tree_, SetNeedsFullTreeSync()).Times(AnyNumber()); |
981 layer_tree_host_->SetRootLayer(parent_); | 997 layer_tree_->SetRootLayer(parent_); |
982 | 998 |
983 parent_->AddChild(child1_); | 999 parent_->AddChild(child1_); |
984 parent_->AddChild(child2_); | 1000 parent_->AddChild(child2_); |
985 parent_->AddChild(child3_); | 1001 parent_->AddChild(child3_); |
986 child1_->AddChild(grand_child1_); | 1002 child1_->AddChild(grand_child1_); |
987 child1_->AddChild(grand_child2_); | 1003 child1_->AddChild(grand_child2_); |
988 child2_->AddChild(grand_child3_); | 1004 child2_->AddChild(grand_child3_); |
989 | 1005 |
990 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 1006 Mock::VerifyAndClearExpectations(layer_tree_); |
991 | 1007 |
992 VerifyTestTreeInitialState(); | 1008 VerifyTestTreeInitialState(); |
993 } | 1009 } |
994 | 1010 |
995 FakeImplTaskRunnerProvider task_runner_provider_; | 1011 FakeImplTaskRunnerProvider task_runner_provider_; |
996 TestSharedBitmapManager shared_bitmap_manager_; | 1012 TestSharedBitmapManager shared_bitmap_manager_; |
997 TestTaskGraphRunner task_graph_runner_; | 1013 TestTaskGraphRunner task_graph_runner_; |
998 FakeLayerTreeHostImpl host_impl_; | 1014 FakeLayerTreeHostImpl host_impl_; |
999 | 1015 |
1000 StubLayerTreeHostSingleThreadClient single_thread_client_; | 1016 StubLayerTreeHostSingleThreadClient single_thread_client_; |
1001 FakeLayerTreeHostClient fake_client_; | 1017 FakeLayerTreeHostClient fake_client_; |
1002 std::unique_ptr<StrictMock<MockLayerTreeHost>> layer_tree_host_; | 1018 std::unique_ptr<StrictMock<MockLayerTreeHost>> layer_tree_host_; |
| 1019 StrictMock<MockLayerTree>* layer_tree_; |
1003 scoped_refptr<Layer> parent_; | 1020 scoped_refptr<Layer> parent_; |
1004 scoped_refptr<Layer> child1_; | 1021 scoped_refptr<Layer> child1_; |
1005 scoped_refptr<Layer> child2_; | 1022 scoped_refptr<Layer> child2_; |
1006 scoped_refptr<Layer> child3_; | 1023 scoped_refptr<Layer> child3_; |
1007 scoped_refptr<Layer> grand_child1_; | 1024 scoped_refptr<Layer> grand_child1_; |
1008 scoped_refptr<Layer> grand_child2_; | 1025 scoped_refptr<Layer> grand_child2_; |
1009 scoped_refptr<Layer> grand_child3_; | 1026 scoped_refptr<Layer> grand_child3_; |
1010 | 1027 |
1011 scoped_refptr<AnimationTimeline> timeline_impl_; | 1028 scoped_refptr<AnimationTimeline> timeline_impl_; |
1012 | 1029 |
1013 LayerTreeSettings settings_; | 1030 LayerTreeSettings settings_; |
1014 }; | 1031 }; |
1015 | 1032 |
1016 TEST_F(LayerTest, BasicCreateAndDestroy) { | 1033 TEST_F(LayerTest, BasicCreateAndDestroy) { |
1017 scoped_refptr<Layer> test_layer = Layer::Create(); | 1034 scoped_refptr<Layer> test_layer = Layer::Create(); |
1018 ASSERT_TRUE(test_layer.get()); | 1035 ASSERT_TRUE(test_layer.get()); |
1019 | 1036 |
1020 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(0); | 1037 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(0); |
1021 test_layer->SetLayerTreeHost(layer_tree_host_.get()); | 1038 test_layer->SetLayerTreeHost(layer_tree_host_.get()); |
1022 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 1039 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
1023 | 1040 |
1024 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(0); | 1041 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(0); |
1025 test_layer->SetLayerTreeHost(nullptr); | 1042 test_layer->SetLayerTreeHost(nullptr); |
1026 } | 1043 } |
1027 | 1044 |
1028 TEST_F(LayerTest, LayerPropertyChangedForSubtree) { | 1045 TEST_F(LayerTest, LayerPropertyChangedForSubtree) { |
1029 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(AtLeast(1)); | 1046 EXPECT_CALL(*layer_tree_, SetNeedsFullTreeSync()).Times(AtLeast(1)); |
1030 scoped_refptr<Layer> root = Layer::Create(); | 1047 scoped_refptr<Layer> root = Layer::Create(); |
1031 scoped_refptr<Layer> child = Layer::Create(); | 1048 scoped_refptr<Layer> child = Layer::Create(); |
1032 scoped_refptr<Layer> child2 = Layer::Create(); | 1049 scoped_refptr<Layer> child2 = Layer::Create(); |
1033 scoped_refptr<Layer> grand_child = Layer::Create(); | 1050 scoped_refptr<Layer> grand_child = Layer::Create(); |
1034 scoped_refptr<Layer> dummy_layer1 = Layer::Create(); | 1051 scoped_refptr<Layer> dummy_layer1 = Layer::Create(); |
1035 scoped_refptr<Layer> dummy_layer2 = Layer::Create(); | 1052 scoped_refptr<Layer> dummy_layer2 = Layer::Create(); |
1036 | 1053 |
1037 layer_tree_host_->SetRootLayer(root); | 1054 layer_tree_->SetRootLayer(root); |
1038 root->AddChild(child); | 1055 root->AddChild(child); |
1039 root->AddChild(child2); | 1056 root->AddChild(child2); |
1040 child->AddChild(grand_child); | 1057 child->AddChild(grand_child); |
1041 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); | 1058 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); |
1042 child->SetForceRenderSurfaceForTesting(true); | 1059 child->SetForceRenderSurfaceForTesting(true); |
1043 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); | 1060 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); |
1044 child2->SetScrollParent(grand_child.get()); | 1061 child2->SetScrollParent(grand_child.get()); |
1045 SkXfermode::Mode arbitrary_blend_mode = SkXfermode::kMultiply_Mode; | 1062 SkXfermode::Mode arbitrary_blend_mode = SkXfermode::kMultiply_Mode; |
1046 std::unique_ptr<LayerImpl> root_impl = | 1063 std::unique_ptr<LayerImpl> root_impl = |
1047 LayerImpl::Create(host_impl_.active_tree(), root->id()); | 1064 LayerImpl::Create(host_impl_.active_tree(), root->id()); |
1048 std::unique_ptr<LayerImpl> child_impl = | 1065 std::unique_ptr<LayerImpl> child_impl = |
1049 LayerImpl::Create(host_impl_.active_tree(), child->id()); | 1066 LayerImpl::Create(host_impl_.active_tree(), child->id()); |
1050 std::unique_ptr<LayerImpl> child2_impl = | 1067 std::unique_ptr<LayerImpl> child2_impl = |
1051 LayerImpl::Create(host_impl_.active_tree(), child2->id()); | 1068 LayerImpl::Create(host_impl_.active_tree(), child2->id()); |
1052 std::unique_ptr<LayerImpl> grand_child_impl = | 1069 std::unique_ptr<LayerImpl> grand_child_impl = |
1053 LayerImpl::Create(host_impl_.active_tree(), grand_child->id()); | 1070 LayerImpl::Create(host_impl_.active_tree(), grand_child->id()); |
1054 std::unique_ptr<LayerImpl> dummy_layer1_impl = | 1071 std::unique_ptr<LayerImpl> dummy_layer1_impl = |
1055 LayerImpl::Create(host_impl_.active_tree(), dummy_layer1->id()); | 1072 LayerImpl::Create(host_impl_.active_tree(), dummy_layer1->id()); |
1056 std::unique_ptr<LayerImpl> dummy_layer2_impl = | 1073 std::unique_ptr<LayerImpl> dummy_layer2_impl = |
1057 LayerImpl::Create(host_impl_.active_tree(), dummy_layer2->id()); | 1074 LayerImpl::Create(host_impl_.active_tree(), dummy_layer2->id()); |
1058 | 1075 |
1059 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(1); | 1076 EXPECT_CALL(*layer_tree_, SetNeedsFullTreeSync()).Times(1); |
1060 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetMaskLayer(dummy_layer1.get())); | 1077 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetMaskLayer(dummy_layer1.get())); |
1061 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( | 1078 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( |
1062 root->PushPropertiesTo(root_impl.get()); | 1079 root->PushPropertiesTo(root_impl.get()); |
1063 child->PushPropertiesTo(child_impl.get()); | 1080 child->PushPropertiesTo(child_impl.get()); |
1064 child2->PushPropertiesTo(child2_impl.get()); | 1081 child2->PushPropertiesTo(child2_impl.get()); |
1065 grand_child->PushPropertiesTo(grand_child_impl.get()); | 1082 grand_child->PushPropertiesTo(grand_child_impl.get()); |
1066 dummy_layer1->PushPropertiesTo(dummy_layer1_impl.get())); | 1083 dummy_layer1->PushPropertiesTo(dummy_layer1_impl.get())); |
1067 | 1084 |
1068 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); | 1085 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); |
1069 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetMasksToBounds(true)); | 1086 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetMasksToBounds(true)); |
1070 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( | 1087 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( |
1071 root->PushPropertiesTo(root_impl.get()); | 1088 root->PushPropertiesTo(root_impl.get()); |
1072 child->PushPropertiesTo(child_impl.get()); | 1089 child->PushPropertiesTo(child_impl.get()); |
1073 child2->PushPropertiesTo(child2_impl.get()); | 1090 child2->PushPropertiesTo(child2_impl.get()); |
1074 grand_child->PushPropertiesTo(grand_child_impl.get())); | 1091 grand_child->PushPropertiesTo(grand_child_impl.get())); |
1075 | 1092 |
1076 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); | 1093 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); |
1077 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetContentsOpaque(true)); | 1094 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetContentsOpaque(true)); |
1078 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( | 1095 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( |
1079 root->PushPropertiesTo(root_impl.get()); | 1096 root->PushPropertiesTo(root_impl.get()); |
1080 child->PushPropertiesTo(child_impl.get()); | 1097 child->PushPropertiesTo(child_impl.get()); |
1081 child2->PushPropertiesTo(child2_impl.get()); | 1098 child2->PushPropertiesTo(child2_impl.get()); |
1082 grand_child->PushPropertiesTo(grand_child_impl.get())); | 1099 grand_child->PushPropertiesTo(grand_child_impl.get())); |
1083 | 1100 |
1084 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(1); | 1101 EXPECT_CALL(*layer_tree_, SetNeedsFullTreeSync()).Times(1); |
1085 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetReplicaLayer(dummy_layer2.get())); | 1102 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetReplicaLayer(dummy_layer2.get())); |
1086 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( | 1103 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( |
1087 root->PushPropertiesTo(root_impl.get()); | 1104 root->PushPropertiesTo(root_impl.get()); |
1088 child->PushPropertiesTo(child_impl.get()); | 1105 child->PushPropertiesTo(child_impl.get()); |
1089 child2->PushPropertiesTo(child2_impl.get()); | 1106 child2->PushPropertiesTo(child2_impl.get()); |
1090 grand_child->PushPropertiesTo(grand_child_impl.get()); | 1107 grand_child->PushPropertiesTo(grand_child_impl.get()); |
1091 dummy_layer2->PushPropertiesTo(dummy_layer2_impl.get())); | 1108 dummy_layer2->PushPropertiesTo(dummy_layer2_impl.get())); |
1092 | 1109 |
1093 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); | 1110 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); |
1094 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetShouldFlattenTransform(false)); | 1111 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetShouldFlattenTransform(false)); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1154 | 1171 |
1155 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); | 1172 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); |
1156 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED( | 1173 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED( |
1157 root->SetBackgroundFilters(arbitrary_filters)); | 1174 root->SetBackgroundFilters(arbitrary_filters)); |
1158 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( | 1175 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( |
1159 root->PushPropertiesTo(root_impl.get())); | 1176 root->PushPropertiesTo(root_impl.get())); |
1160 | 1177 |
1161 gfx::PointF arbitrary_point_f = gfx::PointF(0.125f, 0.25f); | 1178 gfx::PointF arbitrary_point_f = gfx::PointF(0.125f, 0.25f); |
1162 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); | 1179 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); |
1163 root->SetPosition(arbitrary_point_f); | 1180 root->SetPosition(arbitrary_point_f); |
1164 TransformNode* node = layer_tree_host_->property_trees()->transform_tree.Node( | 1181 TransformNode* node = layer_tree_->property_trees()->transform_tree.Node( |
1165 root->transform_tree_index()); | 1182 root->transform_tree_index()); |
1166 EXPECT_TRUE(node->transform_changed); | 1183 EXPECT_TRUE(node->transform_changed); |
1167 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( | 1184 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( |
1168 root->PushPropertiesTo(root_impl.get()); | 1185 root->PushPropertiesTo(root_impl.get()); |
1169 child->PushPropertiesTo(child_impl.get()); | 1186 child->PushPropertiesTo(child_impl.get()); |
1170 child2->PushPropertiesTo(child2_impl.get()); | 1187 child2->PushPropertiesTo(child2_impl.get()); |
1171 grand_child->PushPropertiesTo(grand_child_impl.get()); | 1188 grand_child->PushPropertiesTo(grand_child_impl.get()); |
1172 layer_tree_host_->property_trees()->ResetAllChangeTracking()); | 1189 layer_tree_->property_trees()->ResetAllChangeTracking()); |
1173 EXPECT_FALSE(node->transform_changed); | 1190 EXPECT_FALSE(node->transform_changed); |
1174 | 1191 |
1175 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); | 1192 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); |
1176 child->SetPosition(arbitrary_point_f); | 1193 child->SetPosition(arbitrary_point_f); |
1177 node = layer_tree_host_->property_trees()->transform_tree.Node( | 1194 node = layer_tree_->property_trees()->transform_tree.Node( |
1178 child->transform_tree_index()); | 1195 child->transform_tree_index()); |
1179 EXPECT_TRUE(node->transform_changed); | 1196 EXPECT_TRUE(node->transform_changed); |
1180 // child2 is not in the subtree of child, but its scroll parent is. So, its | 1197 // child2 is not in the subtree of child, but its scroll parent is. So, its |
1181 // to_screen will be effected by change in position of child2. | 1198 // to_screen will be effected by change in position of child2. |
1182 layer_tree_host_->property_trees()->transform_tree.UpdateTransforms( | 1199 layer_tree_->property_trees()->transform_tree.UpdateTransforms( |
1183 child2->transform_tree_index()); | 1200 child2->transform_tree_index()); |
1184 node = layer_tree_host_->property_trees()->transform_tree.Node( | 1201 node = layer_tree_->property_trees()->transform_tree.Node( |
1185 child2->transform_tree_index()); | 1202 child2->transform_tree_index()); |
1186 EXPECT_TRUE(node->transform_changed); | 1203 EXPECT_TRUE(node->transform_changed); |
1187 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( | 1204 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( |
1188 child->PushPropertiesTo(child_impl.get()); | 1205 child->PushPropertiesTo(child_impl.get()); |
1189 grand_child->PushPropertiesTo(grand_child_impl.get()); | 1206 grand_child->PushPropertiesTo(grand_child_impl.get()); |
1190 layer_tree_host_->property_trees()->ResetAllChangeTracking()); | 1207 layer_tree_->property_trees()->ResetAllChangeTracking()); |
1191 node = layer_tree_host_->property_trees()->transform_tree.Node( | 1208 node = layer_tree_->property_trees()->transform_tree.Node( |
1192 child->transform_tree_index()); | 1209 child->transform_tree_index()); |
1193 EXPECT_FALSE(node->transform_changed); | 1210 EXPECT_FALSE(node->transform_changed); |
1194 | 1211 |
1195 gfx::Point3F arbitrary_point_3f = gfx::Point3F(0.125f, 0.25f, 0.f); | 1212 gfx::Point3F arbitrary_point_3f = gfx::Point3F(0.125f, 0.25f, 0.f); |
1196 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); | 1213 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); |
1197 root->SetTransformOrigin(arbitrary_point_3f); | 1214 root->SetTransformOrigin(arbitrary_point_3f); |
1198 node = layer_tree_host_->property_trees()->transform_tree.Node( | 1215 node = layer_tree_->property_trees()->transform_tree.Node( |
1199 root->transform_tree_index()); | 1216 root->transform_tree_index()); |
1200 EXPECT_TRUE(node->transform_changed); | 1217 EXPECT_TRUE(node->transform_changed); |
1201 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( | 1218 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( |
1202 root->PushPropertiesTo(root_impl.get()); | 1219 root->PushPropertiesTo(root_impl.get()); |
1203 child->PushPropertiesTo(child_impl.get()); | 1220 child->PushPropertiesTo(child_impl.get()); |
1204 child2->PushPropertiesTo(child2_impl.get()); | 1221 child2->PushPropertiesTo(child2_impl.get()); |
1205 grand_child->PushPropertiesTo(grand_child_impl.get()); | 1222 grand_child->PushPropertiesTo(grand_child_impl.get()); |
1206 layer_tree_host_->property_trees()->ResetAllChangeTracking()); | 1223 layer_tree_->property_trees()->ResetAllChangeTracking()); |
1207 | 1224 |
1208 gfx::Transform arbitrary_transform; | 1225 gfx::Transform arbitrary_transform; |
1209 arbitrary_transform.Scale3d(0.1f, 0.2f, 0.3f); | 1226 arbitrary_transform.Scale3d(0.1f, 0.2f, 0.3f); |
1210 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); | 1227 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); |
1211 root->SetTransform(arbitrary_transform); | 1228 root->SetTransform(arbitrary_transform); |
1212 node = layer_tree_host_->property_trees()->transform_tree.Node( | 1229 node = layer_tree_->property_trees()->transform_tree.Node( |
1213 root->transform_tree_index()); | 1230 root->transform_tree_index()); |
1214 EXPECT_TRUE(node->transform_changed); | 1231 EXPECT_TRUE(node->transform_changed); |
1215 } | 1232 } |
1216 | 1233 |
1217 TEST_F(LayerTest, AddAndRemoveChild) { | 1234 TEST_F(LayerTest, AddAndRemoveChild) { |
1218 scoped_refptr<Layer> parent = Layer::Create(); | 1235 scoped_refptr<Layer> parent = Layer::Create(); |
1219 scoped_refptr<Layer> child = Layer::Create(); | 1236 scoped_refptr<Layer> child = Layer::Create(); |
1220 | 1237 |
1221 // Upon creation, layers should not have children or parent. | 1238 // Upon creation, layers should not have children or parent. |
1222 ASSERT_EQ(0U, parent->children().size()); | 1239 ASSERT_EQ(0U, parent->children().size()); |
1223 EXPECT_FALSE(child->parent()); | 1240 EXPECT_FALSE(child->parent()); |
1224 | 1241 |
1225 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(parent)); | 1242 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(parent)); |
1226 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->AddChild(child)); | 1243 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->AddChild(child)); |
1227 | 1244 |
1228 ASSERT_EQ(1U, parent->children().size()); | 1245 ASSERT_EQ(1U, parent->children().size()); |
1229 EXPECT_EQ(child.get(), parent->children()[0]); | 1246 EXPECT_EQ(child.get(), parent->children()[0]); |
1230 EXPECT_EQ(parent.get(), child->parent()); | 1247 EXPECT_EQ(parent.get(), child->parent()); |
1231 EXPECT_EQ(parent.get(), child->RootLayer()); | 1248 EXPECT_EQ(parent.get(), child->RootLayer()); |
1232 | 1249 |
1233 EXPECT_SET_NEEDS_FULL_TREE_SYNC(AtLeast(1), child->RemoveFromParent()); | 1250 EXPECT_SET_NEEDS_FULL_TREE_SYNC(AtLeast(1), child->RemoveFromParent()); |
1234 } | 1251 } |
1235 | 1252 |
1236 TEST_F(LayerTest, AddSameChildTwice) { | 1253 TEST_F(LayerTest, AddSameChildTwice) { |
1237 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(AtLeast(1)); | 1254 EXPECT_CALL(*layer_tree_, SetNeedsFullTreeSync()).Times(AtLeast(1)); |
1238 | 1255 |
1239 scoped_refptr<Layer> parent = Layer::Create(); | 1256 scoped_refptr<Layer> parent = Layer::Create(); |
1240 scoped_refptr<Layer> child = Layer::Create(); | 1257 scoped_refptr<Layer> child = Layer::Create(); |
1241 | 1258 |
1242 layer_tree_host_->SetRootLayer(parent); | 1259 layer_tree_->SetRootLayer(parent); |
1243 | 1260 |
1244 ASSERT_EQ(0u, parent->children().size()); | 1261 ASSERT_EQ(0u, parent->children().size()); |
1245 | 1262 |
1246 parent->AddChild(child); | 1263 parent->AddChild(child); |
1247 ASSERT_EQ(1u, parent->children().size()); | 1264 ASSERT_EQ(1u, parent->children().size()); |
1248 EXPECT_EQ(parent.get(), child->parent()); | 1265 EXPECT_EQ(parent.get(), child->parent()); |
1249 | 1266 |
1250 parent->AddChild(child); | 1267 parent->AddChild(child); |
1251 ASSERT_EQ(1u, parent->children().size()); | 1268 ASSERT_EQ(1u, parent->children().size()); |
1252 EXPECT_EQ(parent.get(), child->parent()); | 1269 EXPECT_EQ(parent.get(), child->parent()); |
1253 } | 1270 } |
1254 | 1271 |
1255 TEST_F(LayerTest, InsertChild) { | 1272 TEST_F(LayerTest, InsertChild) { |
1256 scoped_refptr<Layer> parent = Layer::Create(); | 1273 scoped_refptr<Layer> parent = Layer::Create(); |
1257 scoped_refptr<Layer> child1 = Layer::Create(); | 1274 scoped_refptr<Layer> child1 = Layer::Create(); |
1258 scoped_refptr<Layer> child2 = Layer::Create(); | 1275 scoped_refptr<Layer> child2 = Layer::Create(); |
1259 scoped_refptr<Layer> child3 = Layer::Create(); | 1276 scoped_refptr<Layer> child3 = Layer::Create(); |
1260 scoped_refptr<Layer> child4 = Layer::Create(); | 1277 scoped_refptr<Layer> child4 = Layer::Create(); |
1261 | 1278 |
1262 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(parent)); | 1279 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(parent)); |
1263 | 1280 |
1264 ASSERT_EQ(0U, parent->children().size()); | 1281 ASSERT_EQ(0U, parent->children().size()); |
1265 | 1282 |
1266 // Case 1: inserting to empty list. | 1283 // Case 1: inserting to empty list. |
1267 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child3, 0)); | 1284 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child3, 0)); |
1268 ASSERT_EQ(1U, parent->children().size()); | 1285 ASSERT_EQ(1U, parent->children().size()); |
1269 EXPECT_EQ(child3, parent->children()[0]); | 1286 EXPECT_EQ(child3, parent->children()[0]); |
1270 EXPECT_EQ(parent.get(), child3->parent()); | 1287 EXPECT_EQ(parent.get(), child3->parent()); |
1271 | 1288 |
1272 // Case 2: inserting to beginning of list | 1289 // Case 2: inserting to beginning of list |
(...skipping 14 matching lines...) Expand all Loading... |
1287 // Case 4: inserting to end of list | 1304 // Case 4: inserting to end of list |
1288 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child4, 3)); | 1305 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child4, 3)); |
1289 | 1306 |
1290 ASSERT_EQ(4U, parent->children().size()); | 1307 ASSERT_EQ(4U, parent->children().size()); |
1291 EXPECT_EQ(child1, parent->children()[0]); | 1308 EXPECT_EQ(child1, parent->children()[0]); |
1292 EXPECT_EQ(child2, parent->children()[1]); | 1309 EXPECT_EQ(child2, parent->children()[1]); |
1293 EXPECT_EQ(child3, parent->children()[2]); | 1310 EXPECT_EQ(child3, parent->children()[2]); |
1294 EXPECT_EQ(child4, parent->children()[3]); | 1311 EXPECT_EQ(child4, parent->children()[3]); |
1295 EXPECT_EQ(parent.get(), child4->parent()); | 1312 EXPECT_EQ(parent.get(), child4->parent()); |
1296 | 1313 |
1297 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(nullptr)); | 1314 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(nullptr)); |
1298 } | 1315 } |
1299 | 1316 |
1300 TEST_F(LayerTest, InsertChildPastEndOfList) { | 1317 TEST_F(LayerTest, InsertChildPastEndOfList) { |
1301 scoped_refptr<Layer> parent = Layer::Create(); | 1318 scoped_refptr<Layer> parent = Layer::Create(); |
1302 scoped_refptr<Layer> child1 = Layer::Create(); | 1319 scoped_refptr<Layer> child1 = Layer::Create(); |
1303 scoped_refptr<Layer> child2 = Layer::Create(); | 1320 scoped_refptr<Layer> child2 = Layer::Create(); |
1304 | 1321 |
1305 ASSERT_EQ(0U, parent->children().size()); | 1322 ASSERT_EQ(0U, parent->children().size()); |
1306 | 1323 |
1307 // insert to an out-of-bounds index | 1324 // insert to an out-of-bounds index |
1308 parent->InsertChild(child1, 53); | 1325 parent->InsertChild(child1, 53); |
1309 | 1326 |
1310 ASSERT_EQ(1U, parent->children().size()); | 1327 ASSERT_EQ(1U, parent->children().size()); |
1311 EXPECT_EQ(child1, parent->children()[0]); | 1328 EXPECT_EQ(child1, parent->children()[0]); |
1312 | 1329 |
1313 // insert another child to out-of-bounds, when list is not already empty. | 1330 // insert another child to out-of-bounds, when list is not already empty. |
1314 parent->InsertChild(child2, 2459); | 1331 parent->InsertChild(child2, 2459); |
1315 | 1332 |
1316 ASSERT_EQ(2U, parent->children().size()); | 1333 ASSERT_EQ(2U, parent->children().size()); |
1317 EXPECT_EQ(child1, parent->children()[0]); | 1334 EXPECT_EQ(child1, parent->children()[0]); |
1318 EXPECT_EQ(child2, parent->children()[1]); | 1335 EXPECT_EQ(child2, parent->children()[1]); |
1319 } | 1336 } |
1320 | 1337 |
1321 TEST_F(LayerTest, InsertSameChildTwice) { | 1338 TEST_F(LayerTest, InsertSameChildTwice) { |
1322 scoped_refptr<Layer> parent = Layer::Create(); | 1339 scoped_refptr<Layer> parent = Layer::Create(); |
1323 scoped_refptr<Layer> child1 = Layer::Create(); | 1340 scoped_refptr<Layer> child1 = Layer::Create(); |
1324 scoped_refptr<Layer> child2 = Layer::Create(); | 1341 scoped_refptr<Layer> child2 = Layer::Create(); |
1325 | 1342 |
1326 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(parent)); | 1343 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(parent)); |
1327 | 1344 |
1328 ASSERT_EQ(0U, parent->children().size()); | 1345 ASSERT_EQ(0U, parent->children().size()); |
1329 | 1346 |
1330 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child1, 0)); | 1347 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child1, 0)); |
1331 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child2, 1)); | 1348 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child2, 1)); |
1332 | 1349 |
1333 ASSERT_EQ(2U, parent->children().size()); | 1350 ASSERT_EQ(2U, parent->children().size()); |
1334 EXPECT_EQ(child1, parent->children()[0]); | 1351 EXPECT_EQ(child1, parent->children()[0]); |
1335 EXPECT_EQ(child2, parent->children()[1]); | 1352 EXPECT_EQ(child2, parent->children()[1]); |
1336 | 1353 |
1337 // Inserting the same child again should cause the child to be removed and | 1354 // Inserting the same child again should cause the child to be removed and |
1338 // re-inserted at the new location. | 1355 // re-inserted at the new location. |
1339 EXPECT_SET_NEEDS_FULL_TREE_SYNC(AtLeast(1), parent->InsertChild(child1, 1)); | 1356 EXPECT_SET_NEEDS_FULL_TREE_SYNC(AtLeast(1), parent->InsertChild(child1, 1)); |
1340 | 1357 |
1341 // child1 should now be at the end of the list. | 1358 // child1 should now be at the end of the list. |
1342 ASSERT_EQ(2U, parent->children().size()); | 1359 ASSERT_EQ(2U, parent->children().size()); |
1343 EXPECT_EQ(child2, parent->children()[0]); | 1360 EXPECT_EQ(child2, parent->children()[0]); |
1344 EXPECT_EQ(child1, parent->children()[1]); | 1361 EXPECT_EQ(child1, parent->children()[1]); |
1345 | 1362 |
1346 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(nullptr)); | 1363 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(nullptr)); |
1347 } | 1364 } |
1348 | 1365 |
1349 TEST_F(LayerTest, ReplaceChildWithNewChild) { | 1366 TEST_F(LayerTest, ReplaceChildWithNewChild) { |
1350 CreateSimpleTestTree(); | 1367 CreateSimpleTestTree(); |
1351 scoped_refptr<Layer> child4 = Layer::Create(); | 1368 scoped_refptr<Layer> child4 = Layer::Create(); |
1352 | 1369 |
1353 EXPECT_FALSE(child4->parent()); | 1370 EXPECT_FALSE(child4->parent()); |
1354 | 1371 |
1355 EXPECT_SET_NEEDS_FULL_TREE_SYNC( | 1372 EXPECT_SET_NEEDS_FULL_TREE_SYNC( |
1356 AtLeast(1), parent_->ReplaceChild(child2_.get(), child4)); | 1373 AtLeast(1), parent_->ReplaceChild(child2_.get(), child4)); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1393 // and child2 should no longer have a parent. | 1410 // and child2 should no longer have a parent. |
1394 ASSERT_EQ(0U, test_layer->children().size()); | 1411 ASSERT_EQ(0U, test_layer->children().size()); |
1395 EXPECT_FALSE(child2_->parent()); | 1412 EXPECT_FALSE(child2_->parent()); |
1396 } | 1413 } |
1397 | 1414 |
1398 TEST_F(LayerTest, DeleteRemovedScrollParent) { | 1415 TEST_F(LayerTest, DeleteRemovedScrollParent) { |
1399 scoped_refptr<Layer> parent = Layer::Create(); | 1416 scoped_refptr<Layer> parent = Layer::Create(); |
1400 scoped_refptr<Layer> child1 = Layer::Create(); | 1417 scoped_refptr<Layer> child1 = Layer::Create(); |
1401 scoped_refptr<Layer> child2 = Layer::Create(); | 1418 scoped_refptr<Layer> child2 = Layer::Create(); |
1402 | 1419 |
1403 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(parent)); | 1420 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(parent)); |
1404 | 1421 |
1405 ASSERT_EQ(0U, parent->children().size()); | 1422 ASSERT_EQ(0U, parent->children().size()); |
1406 | 1423 |
1407 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child1, 0)); | 1424 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child1, 0)); |
1408 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child2, 1)); | 1425 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child2, 1)); |
1409 | 1426 |
1410 ASSERT_EQ(2U, parent->children().size()); | 1427 ASSERT_EQ(2U, parent->children().size()); |
1411 EXPECT_EQ(child1, parent->children()[0]); | 1428 EXPECT_EQ(child1, parent->children()[0]); |
1412 EXPECT_EQ(child2, parent->children()[1]); | 1429 EXPECT_EQ(child2, parent->children()[1]); |
1413 | 1430 |
1414 EXPECT_SET_NEEDS_COMMIT(2, child1->SetScrollParent(child2.get())); | 1431 EXPECT_SET_NEEDS_COMMIT(2, child1->SetScrollParent(child2.get())); |
1415 | 1432 |
1416 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, child2->RemoveFromParent()); | 1433 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, child2->RemoveFromParent()); |
1417 | 1434 |
1418 child1->ResetNeedsPushPropertiesForTesting(); | 1435 child1->ResetNeedsPushPropertiesForTesting(); |
1419 | 1436 |
1420 EXPECT_SET_NEEDS_COMMIT(1, child2 = nullptr); | 1437 EXPECT_SET_NEEDS_COMMIT(1, child2 = nullptr); |
1421 | 1438 |
1422 EXPECT_TRUE( | 1439 EXPECT_TRUE(layer_tree_->LayerNeedsPushPropertiesForTesting(child1.get())); |
1423 layer_tree_host_->GetLayerTree()->LayerNeedsPushPropertiesForTesting( | |
1424 child1.get())); | |
1425 | 1440 |
1426 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(nullptr)); | 1441 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(nullptr)); |
1427 } | 1442 } |
1428 | 1443 |
1429 TEST_F(LayerTest, DeleteRemovedScrollChild) { | 1444 TEST_F(LayerTest, DeleteRemovedScrollChild) { |
1430 scoped_refptr<Layer> parent = Layer::Create(); | 1445 scoped_refptr<Layer> parent = Layer::Create(); |
1431 scoped_refptr<Layer> child1 = Layer::Create(); | 1446 scoped_refptr<Layer> child1 = Layer::Create(); |
1432 scoped_refptr<Layer> child2 = Layer::Create(); | 1447 scoped_refptr<Layer> child2 = Layer::Create(); |
1433 | 1448 |
1434 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(parent)); | 1449 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(parent)); |
1435 | 1450 |
1436 ASSERT_EQ(0U, parent->children().size()); | 1451 ASSERT_EQ(0U, parent->children().size()); |
1437 | 1452 |
1438 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child1, 0)); | 1453 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child1, 0)); |
1439 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child2, 1)); | 1454 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child2, 1)); |
1440 | 1455 |
1441 ASSERT_EQ(2U, parent->children().size()); | 1456 ASSERT_EQ(2U, parent->children().size()); |
1442 EXPECT_EQ(child1, parent->children()[0]); | 1457 EXPECT_EQ(child1, parent->children()[0]); |
1443 EXPECT_EQ(child2, parent->children()[1]); | 1458 EXPECT_EQ(child2, parent->children()[1]); |
1444 | 1459 |
1445 EXPECT_SET_NEEDS_COMMIT(2, child1->SetScrollParent(child2.get())); | 1460 EXPECT_SET_NEEDS_COMMIT(2, child1->SetScrollParent(child2.get())); |
1446 | 1461 |
1447 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, child1->RemoveFromParent()); | 1462 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, child1->RemoveFromParent()); |
1448 | 1463 |
1449 child2->ResetNeedsPushPropertiesForTesting(); | 1464 child2->ResetNeedsPushPropertiesForTesting(); |
1450 | 1465 |
1451 EXPECT_SET_NEEDS_COMMIT(1, child1 = nullptr); | 1466 EXPECT_SET_NEEDS_COMMIT(1, child1 = nullptr); |
1452 | 1467 |
1453 EXPECT_TRUE( | 1468 EXPECT_TRUE(layer_tree_->LayerNeedsPushPropertiesForTesting(child2.get())); |
1454 layer_tree_host_->GetLayerTree()->LayerNeedsPushPropertiesForTesting( | |
1455 child2.get())); | |
1456 | 1469 |
1457 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(nullptr)); | 1470 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(nullptr)); |
1458 } | 1471 } |
1459 | 1472 |
1460 TEST_F(LayerTest, ReplaceChildWithSameChild) { | 1473 TEST_F(LayerTest, ReplaceChildWithSameChild) { |
1461 CreateSimpleTestTree(); | 1474 CreateSimpleTestTree(); |
1462 | 1475 |
1463 // SetNeedsFullTreeSync / SetNeedsCommit should not be called because its the | 1476 // SetNeedsFullTreeSync / SetNeedsCommit should not be called because its the |
1464 // same child. | 1477 // same child. |
1465 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(0); | 1478 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(0); |
1466 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(0); | 1479 EXPECT_CALL(*layer_tree_, SetNeedsFullTreeSync()).Times(0); |
1467 parent_->ReplaceChild(child2_.get(), child2_); | 1480 parent_->ReplaceChild(child2_.get(), child2_); |
1468 | 1481 |
1469 VerifyTestTreeInitialState(); | 1482 VerifyTestTreeInitialState(); |
1470 } | 1483 } |
1471 | 1484 |
1472 TEST_F(LayerTest, RemoveAllChildren) { | 1485 TEST_F(LayerTest, RemoveAllChildren) { |
1473 CreateSimpleTestTree(); | 1486 CreateSimpleTestTree(); |
1474 | 1487 |
1475 EXPECT_SET_NEEDS_FULL_TREE_SYNC(AtLeast(3), parent_->RemoveAllChildren()); | 1488 EXPECT_SET_NEEDS_FULL_TREE_SYNC(AtLeast(3), parent_->RemoveAllChildren()); |
1476 | 1489 |
(...skipping 14 matching lines...) Expand all Loading... |
1491 new_children.push_back(child1); | 1504 new_children.push_back(child1); |
1492 new_children.push_back(child2); | 1505 new_children.push_back(child2); |
1493 | 1506 |
1494 // Set up and verify initial test conditions: child1 has a parent, child2 has | 1507 // Set up and verify initial test conditions: child1 has a parent, child2 has |
1495 // no parent. | 1508 // no parent. |
1496 old_parent->AddChild(child1); | 1509 old_parent->AddChild(child1); |
1497 ASSERT_EQ(0U, new_parent->children().size()); | 1510 ASSERT_EQ(0U, new_parent->children().size()); |
1498 EXPECT_EQ(old_parent.get(), child1->parent()); | 1511 EXPECT_EQ(old_parent.get(), child1->parent()); |
1499 EXPECT_FALSE(child2->parent()); | 1512 EXPECT_FALSE(child2->parent()); |
1500 | 1513 |
1501 EXPECT_SET_NEEDS_FULL_TREE_SYNC( | 1514 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(new_parent)); |
1502 1, layer_tree_host_->SetRootLayer(new_parent)); | |
1503 | 1515 |
1504 EXPECT_SET_NEEDS_FULL_TREE_SYNC( | 1516 EXPECT_SET_NEEDS_FULL_TREE_SYNC( |
1505 AtLeast(1), new_parent->SetChildren(new_children)); | 1517 AtLeast(1), new_parent->SetChildren(new_children)); |
1506 | 1518 |
1507 ASSERT_EQ(2U, new_parent->children().size()); | 1519 ASSERT_EQ(2U, new_parent->children().size()); |
1508 EXPECT_EQ(new_parent.get(), child1->parent()); | 1520 EXPECT_EQ(new_parent.get(), child1->parent()); |
1509 EXPECT_EQ(new_parent.get(), child2->parent()); | 1521 EXPECT_EQ(new_parent.get(), child2->parent()); |
1510 | 1522 |
1511 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(nullptr)); | 1523 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(nullptr)); |
1512 } | 1524 } |
1513 | 1525 |
1514 TEST_F(LayerTest, HasAncestor) { | 1526 TEST_F(LayerTest, HasAncestor) { |
1515 scoped_refptr<Layer> parent = Layer::Create(); | 1527 scoped_refptr<Layer> parent = Layer::Create(); |
1516 EXPECT_FALSE(parent->HasAncestor(parent.get())); | 1528 EXPECT_FALSE(parent->HasAncestor(parent.get())); |
1517 | 1529 |
1518 scoped_refptr<Layer> child = Layer::Create(); | 1530 scoped_refptr<Layer> child = Layer::Create(); |
1519 parent->AddChild(child); | 1531 parent->AddChild(child); |
1520 | 1532 |
1521 EXPECT_FALSE(child->HasAncestor(child.get())); | 1533 EXPECT_FALSE(child->HasAncestor(child.get())); |
1522 EXPECT_TRUE(child->HasAncestor(parent.get())); | 1534 EXPECT_TRUE(child->HasAncestor(parent.get())); |
1523 EXPECT_FALSE(parent->HasAncestor(child.get())); | 1535 EXPECT_FALSE(parent->HasAncestor(child.get())); |
1524 | 1536 |
1525 scoped_refptr<Layer> child_child = Layer::Create(); | 1537 scoped_refptr<Layer> child_child = Layer::Create(); |
1526 child->AddChild(child_child); | 1538 child->AddChild(child_child); |
1527 | 1539 |
1528 EXPECT_FALSE(child_child->HasAncestor(child_child.get())); | 1540 EXPECT_FALSE(child_child->HasAncestor(child_child.get())); |
1529 EXPECT_TRUE(child_child->HasAncestor(parent.get())); | 1541 EXPECT_TRUE(child_child->HasAncestor(parent.get())); |
1530 EXPECT_TRUE(child_child->HasAncestor(child.get())); | 1542 EXPECT_TRUE(child_child->HasAncestor(child.get())); |
1531 EXPECT_FALSE(parent->HasAncestor(child.get())); | 1543 EXPECT_FALSE(parent->HasAncestor(child.get())); |
1532 EXPECT_FALSE(parent->HasAncestor(child_child.get())); | 1544 EXPECT_FALSE(parent->HasAncestor(child_child.get())); |
1533 } | 1545 } |
1534 | 1546 |
1535 TEST_F(LayerTest, GetRootLayerAfterTreeManipulations) { | 1547 TEST_F(LayerTest, GetRootLayerAfterTreeManipulations) { |
1536 CreateSimpleTestTree(); | 1548 CreateSimpleTestTree(); |
1537 | 1549 |
1538 // For this test we don't care about SetNeedsFullTreeSync calls. | 1550 // For this test we don't care about SetNeedsFullTreeSync calls. |
1539 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(AnyNumber()); | 1551 EXPECT_CALL(*layer_tree_, SetNeedsFullTreeSync()).Times(AnyNumber()); |
1540 | 1552 |
1541 scoped_refptr<Layer> child4 = Layer::Create(); | 1553 scoped_refptr<Layer> child4 = Layer::Create(); |
1542 | 1554 |
1543 EXPECT_EQ(parent_.get(), parent_->RootLayer()); | 1555 EXPECT_EQ(parent_.get(), parent_->RootLayer()); |
1544 EXPECT_EQ(parent_.get(), child1_->RootLayer()); | 1556 EXPECT_EQ(parent_.get(), child1_->RootLayer()); |
1545 EXPECT_EQ(parent_.get(), child2_->RootLayer()); | 1557 EXPECT_EQ(parent_.get(), child2_->RootLayer()); |
1546 EXPECT_EQ(parent_.get(), child3_->RootLayer()); | 1558 EXPECT_EQ(parent_.get(), child3_->RootLayer()); |
1547 EXPECT_EQ(child4.get(), child4->RootLayer()); | 1559 EXPECT_EQ(child4.get(), child4->RootLayer()); |
1548 EXPECT_EQ(parent_.get(), grand_child1_->RootLayer()); | 1560 EXPECT_EQ(parent_.get(), grand_child1_->RootLayer()); |
1549 EXPECT_EQ(parent_.get(), grand_child2_->RootLayer()); | 1561 EXPECT_EQ(parent_.get(), grand_child2_->RootLayer()); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1587 EXPECT_EQ(grand_child3_.get(), grand_child3_->RootLayer()); | 1599 EXPECT_EQ(grand_child3_.get(), grand_child3_->RootLayer()); |
1588 } | 1600 } |
1589 | 1601 |
1590 TEST_F(LayerTest, CheckSetNeedsDisplayCausesCorrectBehavior) { | 1602 TEST_F(LayerTest, CheckSetNeedsDisplayCausesCorrectBehavior) { |
1591 // The semantics for SetNeedsDisplay which are tested here: | 1603 // The semantics for SetNeedsDisplay which are tested here: |
1592 // 1. sets NeedsDisplay flag appropriately. | 1604 // 1. sets NeedsDisplay flag appropriately. |
1593 // 2. indirectly calls SetNeedsUpdate, exactly once for each call to | 1605 // 2. indirectly calls SetNeedsUpdate, exactly once for each call to |
1594 // SetNeedsDisplay. | 1606 // SetNeedsDisplay. |
1595 | 1607 |
1596 scoped_refptr<Layer> test_layer = Layer::Create(); | 1608 scoped_refptr<Layer> test_layer = Layer::Create(); |
1597 EXPECT_SET_NEEDS_FULL_TREE_SYNC( | 1609 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(test_layer)); |
1598 1, layer_tree_host_->SetRootLayer(test_layer)); | |
1599 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetIsDrawable(true)); | 1610 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetIsDrawable(true)); |
1600 | 1611 |
1601 gfx::Size test_bounds = gfx::Size(501, 508); | 1612 gfx::Size test_bounds = gfx::Size(501, 508); |
1602 | 1613 |
1603 gfx::Rect dirty_rect = gfx::Rect(10, 15, 1, 2); | 1614 gfx::Rect dirty_rect = gfx::Rect(10, 15, 1, 2); |
1604 gfx::Rect out_of_bounds_dirty_rect = gfx::Rect(400, 405, 500, 502); | 1615 gfx::Rect out_of_bounds_dirty_rect = gfx::Rect(400, 405, 500, 502); |
1605 | 1616 |
1606 // Before anything, test_layer should not be dirty. | 1617 // Before anything, test_layer should not be dirty. |
1607 EXPECT_FALSE(test_layer->NeedsDisplayForTesting()); | 1618 EXPECT_FALSE(test_layer->NeedsDisplayForTesting()); |
1608 | 1619 |
(...skipping 30 matching lines...) Expand all Loading... |
1639 // Case 4: SetNeedsDisplay() with a non-drawable layer | 1650 // Case 4: SetNeedsDisplay() with a non-drawable layer |
1640 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetIsDrawable(false)); | 1651 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetIsDrawable(false)); |
1641 test_layer->ResetNeedsDisplayForTesting(); | 1652 test_layer->ResetNeedsDisplayForTesting(); |
1642 EXPECT_FALSE(test_layer->NeedsDisplayForTesting()); | 1653 EXPECT_FALSE(test_layer->NeedsDisplayForTesting()); |
1643 EXPECT_SET_NEEDS_UPDATE(0, test_layer->SetNeedsDisplayRect(dirty_rect)); | 1654 EXPECT_SET_NEEDS_UPDATE(0, test_layer->SetNeedsDisplayRect(dirty_rect)); |
1644 EXPECT_TRUE(test_layer->NeedsDisplayForTesting()); | 1655 EXPECT_TRUE(test_layer->NeedsDisplayForTesting()); |
1645 } | 1656 } |
1646 | 1657 |
1647 TEST_F(LayerTest, TestSettingMainThreadScrollingReason) { | 1658 TEST_F(LayerTest, TestSettingMainThreadScrollingReason) { |
1648 scoped_refptr<Layer> test_layer = Layer::Create(); | 1659 scoped_refptr<Layer> test_layer = Layer::Create(); |
1649 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, | 1660 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(test_layer)); |
1650 layer_tree_host_->SetRootLayer(test_layer)); | |
1651 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetIsDrawable(true)); | 1661 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetIsDrawable(true)); |
1652 | 1662 |
1653 // sanity check of initial test condition | 1663 // sanity check of initial test condition |
1654 EXPECT_FALSE(test_layer->NeedsDisplayForTesting()); | 1664 EXPECT_FALSE(test_layer->NeedsDisplayForTesting()); |
1655 | 1665 |
1656 uint32_t reasons = 0, reasons_to_clear = 0, reasons_after_clearing = 0; | 1666 uint32_t reasons = 0, reasons_to_clear = 0, reasons_after_clearing = 0; |
1657 reasons |= MainThreadScrollingReason::kEventHandlers; | 1667 reasons |= MainThreadScrollingReason::kEventHandlers; |
1658 reasons |= MainThreadScrollingReason::kContinuingMainThreadScroll; | 1668 reasons |= MainThreadScrollingReason::kContinuingMainThreadScroll; |
1659 reasons |= MainThreadScrollingReason::kScrollbarScrolling; | 1669 reasons |= MainThreadScrollingReason::kScrollbarScrolling; |
1660 | 1670 |
(...skipping 29 matching lines...) Expand all Loading... |
1690 EXPECT_EQ(reasons_after_clearing, | 1700 EXPECT_EQ(reasons_after_clearing, |
1691 test_layer->main_thread_scrolling_reasons()); | 1701 test_layer->main_thread_scrolling_reasons()); |
1692 | 1702 |
1693 // Check that adding an existing condition doesn't set needs commit. | 1703 // Check that adding an existing condition doesn't set needs commit. |
1694 EXPECT_SET_NEEDS_COMMIT(0, test_layer->AddMainThreadScrollingReasons( | 1704 EXPECT_SET_NEEDS_COMMIT(0, test_layer->AddMainThreadScrollingReasons( |
1695 MainThreadScrollingReason::kEventHandlers)); | 1705 MainThreadScrollingReason::kEventHandlers)); |
1696 } | 1706 } |
1697 | 1707 |
1698 TEST_F(LayerTest, CheckPropertyChangeCausesCorrectBehavior) { | 1708 TEST_F(LayerTest, CheckPropertyChangeCausesCorrectBehavior) { |
1699 scoped_refptr<Layer> test_layer = Layer::Create(); | 1709 scoped_refptr<Layer> test_layer = Layer::Create(); |
1700 EXPECT_SET_NEEDS_FULL_TREE_SYNC( | 1710 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(test_layer)); |
1701 1, layer_tree_host_->SetRootLayer(test_layer)); | |
1702 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetIsDrawable(true)); | 1711 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetIsDrawable(true)); |
1703 | 1712 |
1704 scoped_refptr<Layer> dummy_layer1 = Layer::Create(); | 1713 scoped_refptr<Layer> dummy_layer1 = Layer::Create(); |
1705 scoped_refptr<Layer> dummy_layer2 = Layer::Create(); | 1714 scoped_refptr<Layer> dummy_layer2 = Layer::Create(); |
1706 | 1715 |
1707 // sanity check of initial test condition | 1716 // sanity check of initial test condition |
1708 EXPECT_FALSE(test_layer->NeedsDisplayForTesting()); | 1717 EXPECT_FALSE(test_layer->NeedsDisplayForTesting()); |
1709 | 1718 |
1710 // Next, test properties that should call SetNeedsCommit (but not | 1719 // Next, test properties that should call SetNeedsCommit (but not |
1711 // SetNeedsDisplay). All properties need to be set to new values in order for | 1720 // SetNeedsDisplay). All properties need to be set to new values in order for |
(...skipping 30 matching lines...) Expand all Loading... |
1742 | 1751 |
1743 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, test_layer->SetMaskLayer( | 1752 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, test_layer->SetMaskLayer( |
1744 dummy_layer1.get())); | 1753 dummy_layer1.get())); |
1745 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, test_layer->SetReplicaLayer( | 1754 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, test_layer->SetReplicaLayer( |
1746 dummy_layer2.get())); | 1755 dummy_layer2.get())); |
1747 | 1756 |
1748 // The above tests should not have caused a change to the needs_display flag. | 1757 // The above tests should not have caused a change to the needs_display flag. |
1749 EXPECT_FALSE(test_layer->NeedsDisplayForTesting()); | 1758 EXPECT_FALSE(test_layer->NeedsDisplayForTesting()); |
1750 | 1759 |
1751 // As layers are removed from the tree, they will cause a tree sync. | 1760 // As layers are removed from the tree, they will cause a tree sync. |
1752 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times((AnyNumber())); | 1761 EXPECT_CALL(*layer_tree_, SetNeedsFullTreeSync()).Times((AnyNumber())); |
1753 } | 1762 } |
1754 | 1763 |
1755 TEST_F(LayerTest, PushPropertiesAccumulatesUpdateRect) { | 1764 TEST_F(LayerTest, PushPropertiesAccumulatesUpdateRect) { |
1756 scoped_refptr<Layer> test_layer = Layer::Create(); | 1765 scoped_refptr<Layer> test_layer = Layer::Create(); |
1757 std::unique_ptr<LayerImpl> impl_layer = | 1766 std::unique_ptr<LayerImpl> impl_layer = |
1758 LayerImpl::Create(host_impl_.active_tree(), 1); | 1767 LayerImpl::Create(host_impl_.active_tree(), 1); |
1759 | 1768 |
1760 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, | 1769 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(test_layer)); |
1761 layer_tree_host_->SetRootLayer(test_layer)); | |
1762 | 1770 |
1763 host_impl_.active_tree()->SetRootLayerForTesting(std::move(impl_layer)); | 1771 host_impl_.active_tree()->SetRootLayerForTesting(std::move(impl_layer)); |
1764 host_impl_.active_tree()->BuildLayerListForTesting(); | 1772 host_impl_.active_tree()->BuildLayerListForTesting(); |
1765 LayerImpl* impl_layer_ptr = host_impl_.active_tree()->LayerById(1); | 1773 LayerImpl* impl_layer_ptr = host_impl_.active_tree()->LayerById(1); |
1766 test_layer->SetNeedsDisplayRect(gfx::Rect(5, 5)); | 1774 test_layer->SetNeedsDisplayRect(gfx::Rect(5, 5)); |
1767 test_layer->PushPropertiesTo(impl_layer_ptr); | 1775 test_layer->PushPropertiesTo(impl_layer_ptr); |
1768 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0.f, 0.f, 5.f, 5.f), | 1776 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0.f, 0.f, 5.f, 5.f), |
1769 impl_layer_ptr->update_rect()); | 1777 impl_layer_ptr->update_rect()); |
1770 | 1778 |
1771 // The LayerImpl's update_rect() should be accumulated here, since we did not | 1779 // The LayerImpl's update_rect() should be accumulated here, since we did not |
(...skipping 10 matching lines...) Expand all Loading... |
1782 test_layer->PushPropertiesTo(impl_layer_ptr); | 1790 test_layer->PushPropertiesTo(impl_layer_ptr); |
1783 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10.f, 10.f, 5.f, 5.f), | 1791 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10.f, 10.f, 5.f, 5.f), |
1784 impl_layer_ptr->update_rect()); | 1792 impl_layer_ptr->update_rect()); |
1785 } | 1793 } |
1786 | 1794 |
1787 TEST_F(LayerTest, PushPropertiesCausesLayerPropertyChangedForTransform) { | 1795 TEST_F(LayerTest, PushPropertiesCausesLayerPropertyChangedForTransform) { |
1788 scoped_refptr<Layer> test_layer = Layer::Create(); | 1796 scoped_refptr<Layer> test_layer = Layer::Create(); |
1789 std::unique_ptr<LayerImpl> impl_layer = | 1797 std::unique_ptr<LayerImpl> impl_layer = |
1790 LayerImpl::Create(host_impl_.active_tree(), 1); | 1798 LayerImpl::Create(host_impl_.active_tree(), 1); |
1791 | 1799 |
1792 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, | 1800 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(test_layer)); |
1793 layer_tree_host_->SetRootLayer(test_layer)); | |
1794 | 1801 |
1795 gfx::Transform transform; | 1802 gfx::Transform transform; |
1796 transform.Rotate(45.0); | 1803 transform.Rotate(45.0); |
1797 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetTransform(transform)); | 1804 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetTransform(transform)); |
1798 | 1805 |
1799 EXPECT_FALSE(impl_layer->LayerPropertyChanged()); | 1806 EXPECT_FALSE(impl_layer->LayerPropertyChanged()); |
1800 | 1807 |
1801 test_layer->PushPropertiesTo(impl_layer.get()); | 1808 test_layer->PushPropertiesTo(impl_layer.get()); |
1802 | 1809 |
1803 EXPECT_TRUE(impl_layer->LayerPropertyChanged()); | 1810 EXPECT_TRUE(impl_layer->LayerPropertyChanged()); |
1804 } | 1811 } |
1805 | 1812 |
1806 TEST_F(LayerTest, PushPropertiesCausesLayerPropertyChangedForOpacity) { | 1813 TEST_F(LayerTest, PushPropertiesCausesLayerPropertyChangedForOpacity) { |
1807 scoped_refptr<Layer> test_layer = Layer::Create(); | 1814 scoped_refptr<Layer> test_layer = Layer::Create(); |
1808 std::unique_ptr<LayerImpl> impl_layer = | 1815 std::unique_ptr<LayerImpl> impl_layer = |
1809 LayerImpl::Create(host_impl_.active_tree(), 1); | 1816 LayerImpl::Create(host_impl_.active_tree(), 1); |
1810 | 1817 |
1811 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, | 1818 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(test_layer)); |
1812 layer_tree_host_->SetRootLayer(test_layer)); | |
1813 | 1819 |
1814 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetOpacity(0.5f)); | 1820 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetOpacity(0.5f)); |
1815 | 1821 |
1816 EXPECT_FALSE(impl_layer->LayerPropertyChanged()); | 1822 EXPECT_FALSE(impl_layer->LayerPropertyChanged()); |
1817 | 1823 |
1818 test_layer->PushPropertiesTo(impl_layer.get()); | 1824 test_layer->PushPropertiesTo(impl_layer.get()); |
1819 | 1825 |
1820 EXPECT_TRUE(impl_layer->LayerPropertyChanged()); | 1826 EXPECT_TRUE(impl_layer->LayerPropertyChanged()); |
1821 } | 1827 } |
1822 | 1828 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1908 // layers. | 1914 // layers. |
1909 parent->AddChild(child); | 1915 parent->AddChild(child); |
1910 child->SetMaskLayer(mask.get()); | 1916 child->SetMaskLayer(mask.get()); |
1911 child->SetReplicaLayer(replica.get()); | 1917 child->SetReplicaLayer(replica.get()); |
1912 replica->SetMaskLayer(replica_mask.get()); | 1918 replica->SetMaskLayer(replica_mask.get()); |
1913 | 1919 |
1914 AssertLayerTreeHostMatchesForSubtree(parent.get(), nullptr); | 1920 AssertLayerTreeHostMatchesForSubtree(parent.get(), nullptr); |
1915 | 1921 |
1916 LayerTreeHostFactory factory; | 1922 LayerTreeHostFactory factory; |
1917 std::unique_ptr<LayerTreeHost> layer_tree_host = factory.Create(); | 1923 std::unique_ptr<LayerTreeHost> layer_tree_host = factory.Create(); |
| 1924 LayerTree* layer_tree = layer_tree_host->GetLayerTree(); |
1918 // Setting the root layer should set the host pointer for all layers in the | 1925 // Setting the root layer should set the host pointer for all layers in the |
1919 // tree. | 1926 // tree. |
1920 layer_tree_host->SetRootLayer(parent.get()); | 1927 layer_tree->SetRootLayer(parent.get()); |
1921 | 1928 |
1922 AssertLayerTreeHostMatchesForSubtree(parent.get(), layer_tree_host.get()); | 1929 AssertLayerTreeHostMatchesForSubtree(parent.get(), layer_tree_host.get()); |
1923 | 1930 |
1924 // Clearing the root layer should also clear out the host pointers for all | 1931 // Clearing the root layer should also clear out the host pointers for all |
1925 // layers in the tree. | 1932 // layers in the tree. |
1926 layer_tree_host->SetRootLayer(nullptr); | 1933 layer_tree->SetRootLayer(nullptr); |
1927 | 1934 |
1928 AssertLayerTreeHostMatchesForSubtree(parent.get(), nullptr); | 1935 AssertLayerTreeHostMatchesForSubtree(parent.get(), nullptr); |
1929 } | 1936 } |
1930 | 1937 |
1931 TEST_F(LayerLayerTreeHostTest, AddingLayerSubtree) { | 1938 TEST_F(LayerLayerTreeHostTest, AddingLayerSubtree) { |
1932 scoped_refptr<Layer> parent = Layer::Create(); | 1939 scoped_refptr<Layer> parent = Layer::Create(); |
1933 LayerTreeHostFactory factory; | 1940 LayerTreeHostFactory factory; |
1934 std::unique_ptr<LayerTreeHost> layer_tree_host = factory.Create(); | 1941 std::unique_ptr<LayerTreeHost> layer_tree_host = factory.Create(); |
| 1942 LayerTree* layer_tree = layer_tree_host->GetLayerTree(); |
1935 | 1943 |
1936 layer_tree_host->SetRootLayer(parent.get()); | 1944 layer_tree->SetRootLayer(parent.get()); |
1937 | 1945 |
1938 EXPECT_EQ(parent->layer_tree_host(), layer_tree_host.get()); | 1946 EXPECT_EQ(parent->layer_tree_host(), layer_tree_host.get()); |
1939 | 1947 |
1940 // Adding a subtree to a layer already associated with a host should set the | 1948 // Adding a subtree to a layer already associated with a host should set the |
1941 // host pointer on all layers in that subtree. | 1949 // host pointer on all layers in that subtree. |
1942 scoped_refptr<Layer> child = Layer::Create(); | 1950 scoped_refptr<Layer> child = Layer::Create(); |
1943 scoped_refptr<Layer> grand_child = Layer::Create(); | 1951 scoped_refptr<Layer> grand_child = Layer::Create(); |
1944 child->AddChild(grand_child); | 1952 child->AddChild(grand_child); |
1945 | 1953 |
1946 // Masks, replicas, and replica masks should pick up the new host too. | 1954 // Masks, replicas, and replica masks should pick up the new host too. |
1947 scoped_refptr<Layer> child_mask = Layer::Create(); | 1955 scoped_refptr<Layer> child_mask = Layer::Create(); |
1948 child->SetMaskLayer(child_mask.get()); | 1956 child->SetMaskLayer(child_mask.get()); |
1949 scoped_refptr<Layer> child_replica = Layer::Create(); | 1957 scoped_refptr<Layer> child_replica = Layer::Create(); |
1950 child->SetReplicaLayer(child_replica.get()); | 1958 child->SetReplicaLayer(child_replica.get()); |
1951 scoped_refptr<Layer> child_replica_mask = Layer::Create(); | 1959 scoped_refptr<Layer> child_replica_mask = Layer::Create(); |
1952 child_replica->SetMaskLayer(child_replica_mask.get()); | 1960 child_replica->SetMaskLayer(child_replica_mask.get()); |
1953 | 1961 |
1954 parent->AddChild(child); | 1962 parent->AddChild(child); |
1955 AssertLayerTreeHostMatchesForSubtree(parent.get(), layer_tree_host.get()); | 1963 AssertLayerTreeHostMatchesForSubtree(parent.get(), layer_tree_host.get()); |
1956 | 1964 |
1957 layer_tree_host->SetRootLayer(nullptr); | 1965 layer_tree->SetRootLayer(nullptr); |
1958 } | 1966 } |
1959 | 1967 |
1960 TEST_F(LayerLayerTreeHostTest, ChangeHost) { | 1968 TEST_F(LayerLayerTreeHostTest, ChangeHost) { |
1961 scoped_refptr<Layer> parent = Layer::Create(); | 1969 scoped_refptr<Layer> parent = Layer::Create(); |
1962 scoped_refptr<Layer> child = Layer::Create(); | 1970 scoped_refptr<Layer> child = Layer::Create(); |
1963 scoped_refptr<Layer> mask = Layer::Create(); | 1971 scoped_refptr<Layer> mask = Layer::Create(); |
1964 scoped_refptr<Layer> replica = Layer::Create(); | 1972 scoped_refptr<Layer> replica = Layer::Create(); |
1965 scoped_refptr<Layer> replica_mask = Layer::Create(); | 1973 scoped_refptr<Layer> replica_mask = Layer::Create(); |
1966 | 1974 |
1967 // Same setup as the previous test. | 1975 // Same setup as the previous test. |
1968 parent->AddChild(child); | 1976 parent->AddChild(child); |
1969 child->SetMaskLayer(mask.get()); | 1977 child->SetMaskLayer(mask.get()); |
1970 child->SetReplicaLayer(replica.get()); | 1978 child->SetReplicaLayer(replica.get()); |
1971 replica->SetMaskLayer(replica_mask.get()); | 1979 replica->SetMaskLayer(replica_mask.get()); |
1972 | 1980 |
1973 LayerTreeHostFactory factory; | 1981 LayerTreeHostFactory factory; |
1974 std::unique_ptr<LayerTreeHost> first_layer_tree_host = factory.Create(); | 1982 std::unique_ptr<LayerTreeHost> first_layer_tree_host = factory.Create(); |
1975 first_layer_tree_host->SetRootLayer(parent.get()); | 1983 first_layer_tree_host->GetLayerTree()->SetRootLayer(parent.get()); |
1976 | 1984 |
1977 AssertLayerTreeHostMatchesForSubtree(parent.get(), | 1985 AssertLayerTreeHostMatchesForSubtree(parent.get(), |
1978 first_layer_tree_host.get()); | 1986 first_layer_tree_host.get()); |
1979 | 1987 |
1980 // Now re-root the tree to a new host (simulating what we do on a context lost | 1988 // Now re-root the tree to a new host (simulating what we do on a context lost |
1981 // event). This should update the host pointers for all layers in the tree. | 1989 // event). This should update the host pointers for all layers in the tree. |
1982 std::unique_ptr<LayerTreeHost> second_layer_tree_host = factory.Create(); | 1990 std::unique_ptr<LayerTreeHost> second_layer_tree_host = factory.Create(); |
1983 second_layer_tree_host->SetRootLayer(parent.get()); | 1991 second_layer_tree_host->GetLayerTree()->SetRootLayer(parent.get()); |
1984 | 1992 |
1985 AssertLayerTreeHostMatchesForSubtree(parent.get(), | 1993 AssertLayerTreeHostMatchesForSubtree(parent.get(), |
1986 second_layer_tree_host.get()); | 1994 second_layer_tree_host.get()); |
1987 | 1995 |
1988 second_layer_tree_host->SetRootLayer(nullptr); | 1996 second_layer_tree_host->GetLayerTree()->SetRootLayer(nullptr); |
1989 } | 1997 } |
1990 | 1998 |
1991 TEST_F(LayerLayerTreeHostTest, ChangeHostInSubtree) { | 1999 TEST_F(LayerLayerTreeHostTest, ChangeHostInSubtree) { |
1992 scoped_refptr<Layer> first_parent = Layer::Create(); | 2000 scoped_refptr<Layer> first_parent = Layer::Create(); |
1993 scoped_refptr<Layer> first_child = Layer::Create(); | 2001 scoped_refptr<Layer> first_child = Layer::Create(); |
1994 scoped_refptr<Layer> second_parent = Layer::Create(); | 2002 scoped_refptr<Layer> second_parent = Layer::Create(); |
1995 scoped_refptr<Layer> second_child = Layer::Create(); | 2003 scoped_refptr<Layer> second_child = Layer::Create(); |
1996 scoped_refptr<Layer> second_grand_child = Layer::Create(); | 2004 scoped_refptr<Layer> second_grand_child = Layer::Create(); |
1997 | 2005 |
1998 // First put all children under the first parent and set the first host. | 2006 // First put all children under the first parent and set the first host. |
1999 first_parent->AddChild(first_child); | 2007 first_parent->AddChild(first_child); |
2000 second_child->AddChild(second_grand_child); | 2008 second_child->AddChild(second_grand_child); |
2001 first_parent->AddChild(second_child); | 2009 first_parent->AddChild(second_child); |
2002 | 2010 |
2003 LayerTreeHostFactory factory; | 2011 LayerTreeHostFactory factory; |
2004 std::unique_ptr<LayerTreeHost> first_layer_tree_host = factory.Create(); | 2012 std::unique_ptr<LayerTreeHost> first_layer_tree_host = factory.Create(); |
2005 first_layer_tree_host->SetRootLayer(first_parent.get()); | 2013 first_layer_tree_host->GetLayerTree()->SetRootLayer(first_parent.get()); |
2006 | 2014 |
2007 AssertLayerTreeHostMatchesForSubtree(first_parent.get(), | 2015 AssertLayerTreeHostMatchesForSubtree(first_parent.get(), |
2008 first_layer_tree_host.get()); | 2016 first_layer_tree_host.get()); |
2009 | 2017 |
2010 // Now reparent the subtree starting at second_child to a layer in a different | 2018 // Now reparent the subtree starting at second_child to a layer in a different |
2011 // tree. | 2019 // tree. |
2012 std::unique_ptr<LayerTreeHost> second_layer_tree_host = factory.Create(); | 2020 std::unique_ptr<LayerTreeHost> second_layer_tree_host = factory.Create(); |
2013 second_layer_tree_host->SetRootLayer(second_parent.get()); | 2021 second_layer_tree_host->GetLayerTree()->SetRootLayer(second_parent.get()); |
2014 | 2022 |
2015 second_parent->AddChild(second_child); | 2023 second_parent->AddChild(second_child); |
2016 | 2024 |
2017 // The moved layer and its children should point to the new host. | 2025 // The moved layer and its children should point to the new host. |
2018 EXPECT_EQ(second_layer_tree_host.get(), second_child->layer_tree_host()); | 2026 EXPECT_EQ(second_layer_tree_host.get(), second_child->layer_tree_host()); |
2019 EXPECT_EQ(second_layer_tree_host.get(), | 2027 EXPECT_EQ(second_layer_tree_host.get(), |
2020 second_grand_child->layer_tree_host()); | 2028 second_grand_child->layer_tree_host()); |
2021 | 2029 |
2022 // Test over, cleanup time. | 2030 // Test over, cleanup time. |
2023 first_layer_tree_host->SetRootLayer(nullptr); | 2031 first_layer_tree_host->GetLayerTree()->SetRootLayer(nullptr); |
2024 second_layer_tree_host->SetRootLayer(nullptr); | 2032 second_layer_tree_host->GetLayerTree()->SetRootLayer(nullptr); |
2025 } | 2033 } |
2026 | 2034 |
2027 TEST_F(LayerLayerTreeHostTest, ReplaceMaskAndReplicaLayer) { | 2035 TEST_F(LayerLayerTreeHostTest, ReplaceMaskAndReplicaLayer) { |
2028 scoped_refptr<Layer> parent = Layer::Create(); | 2036 scoped_refptr<Layer> parent = Layer::Create(); |
2029 scoped_refptr<Layer> mask = Layer::Create(); | 2037 scoped_refptr<Layer> mask = Layer::Create(); |
2030 scoped_refptr<Layer> replica = Layer::Create(); | 2038 scoped_refptr<Layer> replica = Layer::Create(); |
2031 scoped_refptr<Layer> mask_child = Layer::Create(); | 2039 scoped_refptr<Layer> mask_child = Layer::Create(); |
2032 scoped_refptr<Layer> replica_child = Layer::Create(); | 2040 scoped_refptr<Layer> replica_child = Layer::Create(); |
2033 scoped_refptr<Layer> mask_replacement = Layer::Create(); | 2041 scoped_refptr<Layer> mask_replacement = Layer::Create(); |
2034 scoped_refptr<Layer> replica_replacement = Layer::Create(); | 2042 scoped_refptr<Layer> replica_replacement = Layer::Create(); |
2035 | 2043 |
2036 parent->SetMaskLayer(mask.get()); | 2044 parent->SetMaskLayer(mask.get()); |
2037 parent->SetReplicaLayer(replica.get()); | 2045 parent->SetReplicaLayer(replica.get()); |
2038 mask->AddChild(mask_child); | 2046 mask->AddChild(mask_child); |
2039 replica->AddChild(replica_child); | 2047 replica->AddChild(replica_child); |
2040 | 2048 |
2041 LayerTreeHostFactory factory; | 2049 LayerTreeHostFactory factory; |
2042 std::unique_ptr<LayerTreeHost> layer_tree_host = factory.Create(); | 2050 std::unique_ptr<LayerTreeHost> layer_tree_host = factory.Create(); |
2043 layer_tree_host->SetRootLayer(parent.get()); | 2051 layer_tree_host->GetLayerTree()->SetRootLayer(parent.get()); |
2044 | 2052 |
2045 AssertLayerTreeHostMatchesForSubtree(parent.get(), layer_tree_host.get()); | 2053 AssertLayerTreeHostMatchesForSubtree(parent.get(), layer_tree_host.get()); |
2046 | 2054 |
2047 // Replacing the mask should clear out the old mask's subtree's host pointers. | 2055 // Replacing the mask should clear out the old mask's subtree's host pointers. |
2048 parent->SetMaskLayer(mask_replacement.get()); | 2056 parent->SetMaskLayer(mask_replacement.get()); |
2049 EXPECT_EQ(nullptr, mask->layer_tree_host()); | 2057 EXPECT_EQ(nullptr, mask->layer_tree_host()); |
2050 EXPECT_EQ(nullptr, mask_child->layer_tree_host()); | 2058 EXPECT_EQ(nullptr, mask_child->layer_tree_host()); |
2051 | 2059 |
2052 // Same for replacing a replica layer. | 2060 // Same for replacing a replica layer. |
2053 parent->SetReplicaLayer(replica_replacement.get()); | 2061 parent->SetReplicaLayer(replica_replacement.get()); |
2054 EXPECT_EQ(nullptr, replica->layer_tree_host()); | 2062 EXPECT_EQ(nullptr, replica->layer_tree_host()); |
2055 EXPECT_EQ(nullptr, replica_child->layer_tree_host()); | 2063 EXPECT_EQ(nullptr, replica_child->layer_tree_host()); |
2056 | 2064 |
2057 // Test over, cleanup time. | 2065 // Test over, cleanup time. |
2058 layer_tree_host->SetRootLayer(nullptr); | 2066 layer_tree_host->GetLayerTree()->SetRootLayer(nullptr); |
2059 } | 2067 } |
2060 | 2068 |
2061 TEST_F(LayerLayerTreeHostTest, DestroyHostWithNonNullRootLayer) { | 2069 TEST_F(LayerLayerTreeHostTest, DestroyHostWithNonNullRootLayer) { |
2062 scoped_refptr<Layer> root = Layer::Create(); | 2070 scoped_refptr<Layer> root = Layer::Create(); |
2063 scoped_refptr<Layer> child = Layer::Create(); | 2071 scoped_refptr<Layer> child = Layer::Create(); |
2064 root->AddChild(child); | 2072 root->AddChild(child); |
2065 LayerTreeHostFactory factory; | 2073 LayerTreeHostFactory factory; |
2066 std::unique_ptr<LayerTreeHost> layer_tree_host = factory.Create(); | 2074 std::unique_ptr<LayerTreeHost> layer_tree_host = factory.Create(); |
2067 layer_tree_host->SetRootLayer(root); | 2075 layer_tree_host->GetLayerTree()->SetRootLayer(root); |
2068 } | 2076 } |
2069 | 2077 |
2070 TEST_F(LayerTest, SafeOpaqueBackgroundColor) { | 2078 TEST_F(LayerTest, SafeOpaqueBackgroundColor) { |
2071 LayerTreeHostFactory factory; | 2079 LayerTreeHostFactory factory; |
2072 std::unique_ptr<LayerTreeHost> layer_tree_host = factory.Create(); | 2080 std::unique_ptr<LayerTreeHost> layer_tree_host = factory.Create(); |
| 2081 LayerTree* layer_tree = layer_tree_host->GetLayerTree(); |
2073 | 2082 |
2074 scoped_refptr<Layer> layer = Layer::Create(); | 2083 scoped_refptr<Layer> layer = Layer::Create(); |
2075 layer_tree_host->SetRootLayer(layer); | 2084 layer_tree->SetRootLayer(layer); |
2076 | 2085 |
2077 for (int contents_opaque = 0; contents_opaque < 2; ++contents_opaque) { | 2086 for (int contents_opaque = 0; contents_opaque < 2; ++contents_opaque) { |
2078 for (int layer_opaque = 0; layer_opaque < 2; ++layer_opaque) { | 2087 for (int layer_opaque = 0; layer_opaque < 2; ++layer_opaque) { |
2079 for (int host_opaque = 0; host_opaque < 2; ++host_opaque) { | 2088 for (int host_opaque = 0; host_opaque < 2; ++host_opaque) { |
2080 layer->SetContentsOpaque(!!contents_opaque); | 2089 layer->SetContentsOpaque(!!contents_opaque); |
2081 layer->SetBackgroundColor(layer_opaque ? SK_ColorRED | 2090 layer->SetBackgroundColor(layer_opaque ? SK_ColorRED |
2082 : SK_ColorTRANSPARENT); | 2091 : SK_ColorTRANSPARENT); |
2083 layer_tree_host->set_background_color( | 2092 layer_tree->set_background_color(host_opaque ? SK_ColorRED |
2084 host_opaque ? SK_ColorRED : SK_ColorTRANSPARENT); | 2093 : SK_ColorTRANSPARENT); |
2085 | 2094 |
2086 layer_tree_host->property_trees()->needs_rebuild = true; | 2095 layer_tree->property_trees()->needs_rebuild = true; |
2087 layer_tree_host->BuildPropertyTreesForTesting(); | 2096 layer_tree_host->BuildPropertyTreesForTesting(); |
2088 SkColor safe_color = layer->SafeOpaqueBackgroundColor(); | 2097 SkColor safe_color = layer->SafeOpaqueBackgroundColor(); |
2089 if (contents_opaque) { | 2098 if (contents_opaque) { |
2090 EXPECT_EQ(SkColorGetA(safe_color), 255u) | 2099 EXPECT_EQ(SkColorGetA(safe_color), 255u) |
2091 << "Flags: " << contents_opaque << ", " << layer_opaque << ", " | 2100 << "Flags: " << contents_opaque << ", " << layer_opaque << ", " |
2092 << host_opaque << "\n"; | 2101 << host_opaque << "\n"; |
2093 } else { | 2102 } else { |
2094 EXPECT_NE(SkColorGetA(safe_color), 255u) | 2103 EXPECT_NE(SkColorGetA(safe_color), 255u) |
2095 << "Flags: " << contents_opaque << ", " << layer_opaque << ", " | 2104 << "Flags: " << contents_opaque << ", " << layer_opaque << ", " |
2096 << host_opaque << "\n"; | 2105 << host_opaque << "\n"; |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2209 // When the layer is destroyed, the other three requests should be aborted. | 2218 // When the layer is destroyed, the other three requests should be aborted. |
2210 layer = nullptr; | 2219 layer = nullptr; |
2211 EXPECT_EQ(1, did_receive_first_result_from_this_source); | 2220 EXPECT_EQ(1, did_receive_first_result_from_this_source); |
2212 EXPECT_EQ(1, did_receive_result_from_different_source); | 2221 EXPECT_EQ(1, did_receive_result_from_different_source); |
2213 EXPECT_EQ(1, did_receive_result_from_anonymous_source); | 2222 EXPECT_EQ(1, did_receive_result_from_anonymous_source); |
2214 EXPECT_EQ(1, did_receive_second_result_from_this_source); | 2223 EXPECT_EQ(1, did_receive_second_result_from_this_source); |
2215 } | 2224 } |
2216 | 2225 |
2217 TEST_F(LayerTest, AnimationSchedulesLayerUpdate) { | 2226 TEST_F(LayerTest, AnimationSchedulesLayerUpdate) { |
2218 scoped_refptr<Layer> layer = Layer::Create(); | 2227 scoped_refptr<Layer> layer = Layer::Create(); |
2219 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(layer)); | 2228 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(layer)); |
2220 | 2229 |
2221 LayerInternalsForTest layer_internals(layer.get()); | 2230 LayerInternalsForTest layer_internals(layer.get()); |
2222 | 2231 |
2223 EXPECT_CALL(*layer_tree_host_, SetNeedsUpdateLayers()).Times(1); | 2232 EXPECT_CALL(*layer_tree_host_, SetNeedsUpdateLayers()).Times(1); |
2224 layer_internals.OnOpacityAnimated(0.5f); | 2233 layer_internals.OnOpacityAnimated(0.5f); |
2225 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 2234 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
2226 | 2235 |
2227 EXPECT_CALL(*layer_tree_host_, SetNeedsUpdateLayers()).Times(1); | 2236 EXPECT_CALL(*layer_tree_host_, SetNeedsUpdateLayers()).Times(1); |
2228 gfx::Transform transform; | 2237 gfx::Transform transform; |
2229 transform.Rotate(45.0); | 2238 transform.Rotate(45.0); |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2525 VerifySolidColorScrollbarLayerAfterSerializationAndDeserialization( | 2534 VerifySolidColorScrollbarLayerAfterSerializationAndDeserialization( |
2526 scrollbar_layers[i]); | 2535 scrollbar_layers[i]); |
2527 } | 2536 } |
2528 } | 2537 } |
2529 | 2538 |
2530 TEST_F(LayerTest, ElementIdAndMutablePropertiesArePushed) { | 2539 TEST_F(LayerTest, ElementIdAndMutablePropertiesArePushed) { |
2531 scoped_refptr<Layer> test_layer = Layer::Create(); | 2540 scoped_refptr<Layer> test_layer = Layer::Create(); |
2532 std::unique_ptr<LayerImpl> impl_layer = | 2541 std::unique_ptr<LayerImpl> impl_layer = |
2533 LayerImpl::Create(host_impl_.active_tree(), 1); | 2542 LayerImpl::Create(host_impl_.active_tree(), 1); |
2534 | 2543 |
2535 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, | 2544 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(test_layer)); |
2536 layer_tree_host_->SetRootLayer(test_layer)); | |
2537 | 2545 |
2538 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(2); | 2546 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(2); |
2539 | 2547 |
2540 test_layer->SetElementId(ElementId(2, 0)); | 2548 test_layer->SetElementId(ElementId(2, 0)); |
2541 test_layer->SetMutableProperties(MutableProperty::kTransform); | 2549 test_layer->SetMutableProperties(MutableProperty::kTransform); |
2542 | 2550 |
2543 EXPECT_FALSE(impl_layer->element_id()); | 2551 EXPECT_FALSE(impl_layer->element_id()); |
2544 EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties()); | 2552 EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties()); |
2545 | 2553 |
2546 test_layer->PushPropertiesTo(impl_layer.get()); | 2554 test_layer->PushPropertiesTo(impl_layer.get()); |
2547 | 2555 |
2548 EXPECT_EQ(ElementId(2, 0), impl_layer->element_id()); | 2556 EXPECT_EQ(ElementId(2, 0), impl_layer->element_id()); |
2549 EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties()); | 2557 EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties()); |
2550 } | 2558 } |
2551 | 2559 |
2552 } // namespace | 2560 } // namespace |
2553 } // namespace cc | 2561 } // namespace cc |
OLD | NEW |