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