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