| 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/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 #include "ui/gfx/geometry/size.h" | 40 #include "ui/gfx/geometry/size.h" |
| 41 #include "ui/gfx/geometry/vector2d_f.h" | 41 #include "ui/gfx/geometry/vector2d_f.h" |
| 42 #include "ui/gfx/transform.h" | 42 #include "ui/gfx/transform.h" |
| 43 | 43 |
| 44 using ::testing::AnyNumber; | 44 using ::testing::AnyNumber; |
| 45 using ::testing::AtLeast; | 45 using ::testing::AtLeast; |
| 46 using ::testing::Mock; | 46 using ::testing::Mock; |
| 47 using ::testing::StrictMock; | 47 using ::testing::StrictMock; |
| 48 using ::testing::_; | 48 using ::testing::_; |
| 49 | 49 |
| 50 #define EXPECT_SET_NEEDS_FULL_TREE_SYNC(expect, code_to_test) \ | 50 #define EXPECT_SET_NEEDS_FULL_TREE_SYNC(expect, code_to_test) \ |
| 51 do { \ | 51 do { \ |
| 52 EXPECT_CALL(*layer_tree_, SetNeedsFullTreeSync()).Times((expect)); \ | 52 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times((expect)); \ |
| 53 code_to_test; \ | 53 code_to_test; \ |
| 54 Mock::VerifyAndClearExpectations(layer_tree_); \ | 54 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); \ |
| 55 } while (false) | 55 } while (false) |
| 56 | 56 |
| 57 #define EXECUTE_AND_VERIFY_SUBTREE_CHANGED(code_to_test) \ | 57 #define EXECUTE_AND_VERIFY_SUBTREE_CHANGED(code_to_test) \ |
| 58 code_to_test; \ | 58 code_to_test; \ |
| 59 root->GetLayerTree()->BuildPropertyTreesForTesting(); \ | 59 root->layer_tree_host()->BuildPropertyTreesForTesting(); \ |
| 60 EXPECT_TRUE(root->subtree_property_changed()); \ | 60 EXPECT_TRUE(root->subtree_property_changed()); \ |
| 61 EXPECT_TRUE( \ | 61 EXPECT_TRUE(root->layer_tree_host()->LayerNeedsPushPropertiesForTesting( \ |
| 62 root->GetLayerTree()->LayerNeedsPushPropertiesForTesting(root.get())); \ | 62 root.get())); \ |
| 63 EXPECT_TRUE(child->subtree_property_changed()); \ | 63 EXPECT_TRUE(child->subtree_property_changed()); \ |
| 64 EXPECT_TRUE( \ | 64 EXPECT_TRUE(child->layer_tree_host()->LayerNeedsPushPropertiesForTesting( \ |
| 65 child->GetLayerTree()->LayerNeedsPushPropertiesForTesting(child.get())); \ | 65 child.get())); \ |
| 66 EXPECT_TRUE(grand_child->subtree_property_changed()); \ | 66 EXPECT_TRUE(grand_child->subtree_property_changed()); \ |
| 67 EXPECT_TRUE(grand_child->GetLayerTree()->LayerNeedsPushPropertiesForTesting( \ | 67 EXPECT_TRUE( \ |
| 68 grand_child.get())); | 68 grand_child->layer_tree_host()->LayerNeedsPushPropertiesForTesting( \ |
| 69 grand_child.get())); |
| 69 | 70 |
| 70 #define EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET(code_to_test) \ | 71 #define EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET(code_to_test) \ |
| 71 code_to_test; \ | 72 code_to_test; \ |
| 72 EXPECT_FALSE(root->subtree_property_changed()); \ | 73 EXPECT_FALSE(root->subtree_property_changed()); \ |
| 73 EXPECT_FALSE( \ | 74 EXPECT_FALSE(root->layer_tree_host()->LayerNeedsPushPropertiesForTesting( \ |
| 74 root->GetLayerTree()->LayerNeedsPushPropertiesForTesting(root.get())); \ | 75 root.get())); \ |
| 75 EXPECT_FALSE(child->subtree_property_changed()); \ | 76 EXPECT_FALSE(child->subtree_property_changed()); \ |
| 76 EXPECT_FALSE( \ | 77 EXPECT_FALSE(child->layer_tree_host()->LayerNeedsPushPropertiesForTesting( \ |
| 77 child->GetLayerTree()->LayerNeedsPushPropertiesForTesting(child.get())); \ | 78 child.get())); \ |
| 78 EXPECT_FALSE(grand_child->subtree_property_changed()); \ | 79 EXPECT_FALSE(grand_child->subtree_property_changed()); \ |
| 79 EXPECT_FALSE( \ | 80 EXPECT_FALSE( \ |
| 80 grand_child->GetLayerTree()->LayerNeedsPushPropertiesForTesting( \ | 81 grand_child->layer_tree_host()->LayerNeedsPushPropertiesForTesting( \ |
| 81 grand_child.get())); | 82 grand_child.get())); |
| 82 | 83 |
| 83 namespace cc { | 84 namespace cc { |
| 84 | 85 |
| 85 namespace { | 86 namespace { |
| 86 | 87 |
| 87 class MockLayerTree : public LayerTree { | |
| 88 public: | |
| 89 MockLayerTree(LayerTreeHost::InitParams* params, | |
| 90 LayerTreeHost* layer_tree_host) | |
| 91 : LayerTree(params->mutator_host, layer_tree_host) {} | |
| 92 ~MockLayerTree() override {} | |
| 93 | |
| 94 MOCK_METHOD0(SetNeedsFullTreeSync, void()); | |
| 95 }; | |
| 96 | |
| 97 class MockLayerTreeHost : public LayerTreeHost { | 88 class MockLayerTreeHost : public LayerTreeHost { |
| 98 public: | 89 public: |
| 99 MockLayerTreeHost(LayerTreeHostSingleThreadClient* single_thread_client, | 90 MockLayerTreeHost(LayerTreeHostSingleThreadClient* single_thread_client, |
| 100 LayerTreeHost::InitParams* params) | 91 LayerTreeHost::InitParams* params) |
| 101 : LayerTreeHost( | 92 : LayerTreeHost(params, CompositorMode::SINGLE_THREADED) { |
| 102 params, | |
| 103 CompositorMode::SINGLE_THREADED, | |
| 104 base::MakeUnique<StrictMock<MockLayerTree>>(params, this)) { | |
| 105 InitializeSingleThreaded(single_thread_client, | 93 InitializeSingleThreaded(single_thread_client, |
| 106 base::ThreadTaskRunnerHandle::Get()); | 94 base::ThreadTaskRunnerHandle::Get()); |
| 107 } | 95 } |
| 108 | 96 |
| 109 MOCK_METHOD0(SetNeedsCommit, void()); | 97 MOCK_METHOD0(SetNeedsCommit, void()); |
| 110 MOCK_METHOD0(SetNeedsUpdateLayers, void()); | 98 MOCK_METHOD0(SetNeedsUpdateLayers, void()); |
| 99 MOCK_METHOD0(SetNeedsFullTreeSync, void()); |
| 111 }; | 100 }; |
| 112 | 101 |
| 113 class LayerTest : public testing::Test { | 102 class LayerTest : public testing::Test { |
| 114 public: | 103 public: |
| 115 LayerTest() | 104 LayerTest() |
| 116 : host_impl_(LayerTreeSettings(), | 105 : host_impl_(LayerTreeSettings(), |
| 117 &task_runner_provider_, | 106 &task_runner_provider_, |
| 118 &task_graph_runner_) { | 107 &task_graph_runner_) { |
| 119 timeline_impl_ = | 108 timeline_impl_ = |
| 120 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); | 109 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); |
| 121 timeline_impl_->set_is_impl_only(true); | 110 timeline_impl_->set_is_impl_only(true); |
| 122 host_impl_.animation_host()->AddAnimationTimeline(timeline_impl_); | 111 host_impl_.animation_host()->AddAnimationTimeline(timeline_impl_); |
| 123 } | 112 } |
| 124 | 113 |
| 125 const LayerTreeSettings& settings() { return settings_; } | 114 const LayerTreeSettings& settings() { return settings_; } |
| 126 scoped_refptr<AnimationTimeline> timeline_impl() { return timeline_impl_; } | 115 scoped_refptr<AnimationTimeline> timeline_impl() { return timeline_impl_; } |
| 127 | 116 |
| 128 protected: | 117 protected: |
| 129 void SetUp() override { | 118 void SetUp() override { |
| 130 animation_host_ = AnimationHost::CreateForTesting(ThreadInstance::MAIN); | 119 animation_host_ = AnimationHost::CreateForTesting(ThreadInstance::MAIN); |
| 131 | 120 |
| 132 LayerTreeHost::InitParams params; | 121 LayerTreeHost::InitParams params; |
| 133 params.client = &fake_client_; | 122 params.client = &fake_client_; |
| 134 params.settings = &settings_; | 123 params.settings = &settings_; |
| 135 params.task_graph_runner = &task_graph_runner_; | 124 params.task_graph_runner = &task_graph_runner_; |
| 136 params.mutator_host = animation_host_.get(); | 125 params.mutator_host = animation_host_.get(); |
| 137 | 126 |
| 138 layer_tree_host_.reset( | 127 layer_tree_host_.reset( |
| 139 new StrictMock<MockLayerTreeHost>(&single_thread_client_, ¶ms)); | 128 new StrictMock<MockLayerTreeHost>(&single_thread_client_, ¶ms)); |
| 140 layer_tree_ = static_cast<StrictMock<MockLayerTree>*>( | |
| 141 layer_tree_host_->GetLayerTree()); | |
| 142 } | 129 } |
| 143 | 130 |
| 144 void TearDown() override { | 131 void TearDown() override { |
| 145 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 132 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
| 146 Mock::VerifyAndClearExpectations(layer_tree_); | 133 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(AnyNumber()); |
| 147 EXPECT_CALL(*layer_tree_, SetNeedsFullTreeSync()).Times(AnyNumber()); | |
| 148 parent_ = nullptr; | 134 parent_ = nullptr; |
| 149 child1_ = nullptr; | 135 child1_ = nullptr; |
| 150 child2_ = nullptr; | 136 child2_ = nullptr; |
| 151 child3_ = nullptr; | 137 child3_ = nullptr; |
| 152 grand_child1_ = nullptr; | 138 grand_child1_ = nullptr; |
| 153 grand_child2_ = nullptr; | 139 grand_child2_ = nullptr; |
| 154 grand_child3_ = nullptr; | 140 grand_child3_ = nullptr; |
| 155 | 141 |
| 156 layer_tree_->SetRootLayer(nullptr); | 142 layer_tree_host_->SetRootLayer(nullptr); |
| 157 animation_host_->SetMutatorHostClient(nullptr); | 143 animation_host_->SetMutatorHostClient(nullptr); |
| 158 layer_tree_host_ = nullptr; | 144 layer_tree_host_ = nullptr; |
| 159 animation_host_ = nullptr; | 145 animation_host_ = nullptr; |
| 160 layer_tree_ = nullptr; | |
| 161 } | 146 } |
| 162 | 147 |
| 163 void VerifyTestTreeInitialState() const { | 148 void VerifyTestTreeInitialState() const { |
| 164 ASSERT_EQ(3U, parent_->children().size()); | 149 ASSERT_EQ(3U, parent_->children().size()); |
| 165 EXPECT_EQ(child1_, parent_->children()[0]); | 150 EXPECT_EQ(child1_, parent_->children()[0]); |
| 166 EXPECT_EQ(child2_, parent_->children()[1]); | 151 EXPECT_EQ(child2_, parent_->children()[1]); |
| 167 EXPECT_EQ(child3_, parent_->children()[2]); | 152 EXPECT_EQ(child3_, parent_->children()[2]); |
| 168 EXPECT_EQ(parent_.get(), child1_->parent()); | 153 EXPECT_EQ(parent_.get(), child1_->parent()); |
| 169 EXPECT_EQ(parent_.get(), child2_->parent()); | 154 EXPECT_EQ(parent_.get(), child2_->parent()); |
| 170 EXPECT_EQ(parent_.get(), child3_->parent()); | 155 EXPECT_EQ(parent_.get(), child3_->parent()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 184 | 169 |
| 185 void CreateSimpleTestTree() { | 170 void CreateSimpleTestTree() { |
| 186 parent_ = Layer::Create(); | 171 parent_ = Layer::Create(); |
| 187 child1_ = Layer::Create(); | 172 child1_ = Layer::Create(); |
| 188 child2_ = Layer::Create(); | 173 child2_ = Layer::Create(); |
| 189 child3_ = Layer::Create(); | 174 child3_ = Layer::Create(); |
| 190 grand_child1_ = Layer::Create(); | 175 grand_child1_ = Layer::Create(); |
| 191 grand_child2_ = Layer::Create(); | 176 grand_child2_ = Layer::Create(); |
| 192 grand_child3_ = Layer::Create(); | 177 grand_child3_ = Layer::Create(); |
| 193 | 178 |
| 194 EXPECT_CALL(*layer_tree_, SetNeedsFullTreeSync()).Times(AnyNumber()); | 179 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(AnyNumber()); |
| 195 layer_tree_->SetRootLayer(parent_); | 180 layer_tree_host_->SetRootLayer(parent_); |
| 196 | 181 |
| 197 parent_->AddChild(child1_); | 182 parent_->AddChild(child1_); |
| 198 parent_->AddChild(child2_); | 183 parent_->AddChild(child2_); |
| 199 parent_->AddChild(child3_); | 184 parent_->AddChild(child3_); |
| 200 child1_->AddChild(grand_child1_); | 185 child1_->AddChild(grand_child1_); |
| 201 child1_->AddChild(grand_child2_); | 186 child1_->AddChild(grand_child2_); |
| 202 child2_->AddChild(grand_child3_); | 187 child2_->AddChild(grand_child3_); |
| 203 | 188 |
| 204 Mock::VerifyAndClearExpectations(layer_tree_); | 189 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
| 205 | 190 |
| 206 VerifyTestTreeInitialState(); | 191 VerifyTestTreeInitialState(); |
| 207 } | 192 } |
| 208 | 193 |
| 209 FakeImplTaskRunnerProvider task_runner_provider_; | 194 FakeImplTaskRunnerProvider task_runner_provider_; |
| 210 TestTaskGraphRunner task_graph_runner_; | 195 TestTaskGraphRunner task_graph_runner_; |
| 211 FakeLayerTreeHostImpl host_impl_; | 196 FakeLayerTreeHostImpl host_impl_; |
| 212 | 197 |
| 213 StubLayerTreeHostSingleThreadClient single_thread_client_; | 198 StubLayerTreeHostSingleThreadClient single_thread_client_; |
| 214 FakeLayerTreeHostClient fake_client_; | 199 FakeLayerTreeHostClient fake_client_; |
| 215 std::unique_ptr<StrictMock<MockLayerTreeHost>> layer_tree_host_; | 200 std::unique_ptr<StrictMock<MockLayerTreeHost>> layer_tree_host_; |
| 216 std::unique_ptr<AnimationHost> animation_host_; | 201 std::unique_ptr<AnimationHost> animation_host_; |
| 217 StrictMock<MockLayerTree>* layer_tree_; | |
| 218 scoped_refptr<Layer> parent_; | 202 scoped_refptr<Layer> parent_; |
| 219 scoped_refptr<Layer> child1_; | 203 scoped_refptr<Layer> child1_; |
| 220 scoped_refptr<Layer> child2_; | 204 scoped_refptr<Layer> child2_; |
| 221 scoped_refptr<Layer> child3_; | 205 scoped_refptr<Layer> child3_; |
| 222 scoped_refptr<Layer> grand_child1_; | 206 scoped_refptr<Layer> grand_child1_; |
| 223 scoped_refptr<Layer> grand_child2_; | 207 scoped_refptr<Layer> grand_child2_; |
| 224 scoped_refptr<Layer> grand_child3_; | 208 scoped_refptr<Layer> grand_child3_; |
| 225 | 209 |
| 226 scoped_refptr<AnimationTimeline> timeline_impl_; | 210 scoped_refptr<AnimationTimeline> timeline_impl_; |
| 227 | 211 |
| 228 LayerTreeSettings settings_; | 212 LayerTreeSettings settings_; |
| 229 }; | 213 }; |
| 230 | 214 |
| 231 TEST_F(LayerTest, BasicCreateAndDestroy) { | 215 TEST_F(LayerTest, BasicCreateAndDestroy) { |
| 232 scoped_refptr<Layer> test_layer = Layer::Create(); | 216 scoped_refptr<Layer> test_layer = Layer::Create(); |
| 233 ASSERT_TRUE(test_layer.get()); | 217 ASSERT_TRUE(test_layer.get()); |
| 234 | 218 |
| 235 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(0); | 219 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(0); |
| 236 test_layer->SetLayerTreeHost(layer_tree_host_.get()); | 220 test_layer->SetLayerTreeHost(layer_tree_host_.get()); |
| 237 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 221 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
| 238 | 222 |
| 239 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(0); | 223 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(0); |
| 240 test_layer->SetLayerTreeHost(nullptr); | 224 test_layer->SetLayerTreeHost(nullptr); |
| 241 } | 225 } |
| 242 | 226 |
| 243 TEST_F(LayerTest, LayerPropertyChangedForSubtree) { | 227 TEST_F(LayerTest, LayerPropertyChangedForSubtree) { |
| 244 EXPECT_CALL(*layer_tree_, SetNeedsFullTreeSync()).Times(AtLeast(1)); | 228 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(AtLeast(1)); |
| 245 scoped_refptr<Layer> root = Layer::Create(); | 229 scoped_refptr<Layer> root = Layer::Create(); |
| 246 scoped_refptr<Layer> child = Layer::Create(); | 230 scoped_refptr<Layer> child = Layer::Create(); |
| 247 scoped_refptr<Layer> child2 = Layer::Create(); | 231 scoped_refptr<Layer> child2 = Layer::Create(); |
| 248 scoped_refptr<Layer> grand_child = Layer::Create(); | 232 scoped_refptr<Layer> grand_child = Layer::Create(); |
| 249 scoped_refptr<Layer> dummy_layer1 = Layer::Create(); | 233 scoped_refptr<Layer> dummy_layer1 = Layer::Create(); |
| 250 | 234 |
| 251 layer_tree_->SetRootLayer(root); | 235 layer_tree_host_->SetRootLayer(root); |
| 252 root->AddChild(child); | 236 root->AddChild(child); |
| 253 root->AddChild(child2); | 237 root->AddChild(child2); |
| 254 child->AddChild(grand_child); | 238 child->AddChild(grand_child); |
| 255 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); | 239 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); |
| 256 child->SetForceRenderSurfaceForTesting(true); | 240 child->SetForceRenderSurfaceForTesting(true); |
| 257 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); | 241 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AtLeast(1)); |
| 258 child2->SetScrollParent(grand_child.get()); | 242 child2->SetScrollParent(grand_child.get()); |
| 259 SkBlendMode arbitrary_blend_mode = SkBlendMode::kMultiply; | 243 SkBlendMode arbitrary_blend_mode = SkBlendMode::kMultiply; |
| 260 std::unique_ptr<LayerImpl> root_impl = | 244 std::unique_ptr<LayerImpl> root_impl = |
| 261 LayerImpl::Create(host_impl_.active_tree(), root->id()); | 245 LayerImpl::Create(host_impl_.active_tree(), root->id()); |
| 262 std::unique_ptr<LayerImpl> child_impl = | 246 std::unique_ptr<LayerImpl> child_impl = |
| 263 LayerImpl::Create(host_impl_.active_tree(), child->id()); | 247 LayerImpl::Create(host_impl_.active_tree(), child->id()); |
| 264 std::unique_ptr<LayerImpl> child2_impl = | 248 std::unique_ptr<LayerImpl> child2_impl = |
| 265 LayerImpl::Create(host_impl_.active_tree(), child2->id()); | 249 LayerImpl::Create(host_impl_.active_tree(), child2->id()); |
| 266 std::unique_ptr<LayerImpl> grand_child_impl = | 250 std::unique_ptr<LayerImpl> grand_child_impl = |
| 267 LayerImpl::Create(host_impl_.active_tree(), grand_child->id()); | 251 LayerImpl::Create(host_impl_.active_tree(), grand_child->id()); |
| 268 std::unique_ptr<LayerImpl> dummy_layer1_impl = | 252 std::unique_ptr<LayerImpl> dummy_layer1_impl = |
| 269 LayerImpl::Create(host_impl_.active_tree(), dummy_layer1->id()); | 253 LayerImpl::Create(host_impl_.active_tree(), dummy_layer1->id()); |
| 270 | 254 |
| 271 EXPECT_CALL(*layer_tree_, SetNeedsFullTreeSync()).Times(1); | 255 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(1); |
| 272 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetMaskLayer(dummy_layer1.get())); | 256 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetMaskLayer(dummy_layer1.get())); |
| 273 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( | 257 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( |
| 274 root->PushPropertiesTo(root_impl.get()); | 258 root->PushPropertiesTo(root_impl.get()); |
| 275 child->PushPropertiesTo(child_impl.get()); | 259 child->PushPropertiesTo(child_impl.get()); |
| 276 child2->PushPropertiesTo(child2_impl.get()); | 260 child2->PushPropertiesTo(child2_impl.get()); |
| 277 grand_child->PushPropertiesTo(grand_child_impl.get()); | 261 grand_child->PushPropertiesTo(grand_child_impl.get()); |
| 278 dummy_layer1->PushPropertiesTo(dummy_layer1_impl.get())); | 262 dummy_layer1->PushPropertiesTo(dummy_layer1_impl.get())); |
| 279 | 263 |
| 280 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); | 264 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); |
| 281 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetMasksToBounds(true)); | 265 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetMasksToBounds(true)); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 root->SetBackgroundFilters(arbitrary_filters)); | 343 root->SetBackgroundFilters(arbitrary_filters)); |
| 360 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( | 344 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( |
| 361 root->PushPropertiesTo(root_impl.get()); | 345 root->PushPropertiesTo(root_impl.get()); |
| 362 child->PushPropertiesTo(child_impl.get()); | 346 child->PushPropertiesTo(child_impl.get()); |
| 363 child2->PushPropertiesTo(child2_impl.get()); | 347 child2->PushPropertiesTo(child2_impl.get()); |
| 364 grand_child->PushPropertiesTo(grand_child_impl.get())); | 348 grand_child->PushPropertiesTo(grand_child_impl.get())); |
| 365 | 349 |
| 366 gfx::PointF arbitrary_point_f = gfx::PointF(0.125f, 0.25f); | 350 gfx::PointF arbitrary_point_f = gfx::PointF(0.125f, 0.25f); |
| 367 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); | 351 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); |
| 368 root->SetPosition(arbitrary_point_f); | 352 root->SetPosition(arbitrary_point_f); |
| 369 TransformNode* node = layer_tree_->property_trees()->transform_tree.Node( | 353 TransformNode* node = layer_tree_host_->property_trees()->transform_tree.Node( |
| 370 root->transform_tree_index()); | 354 root->transform_tree_index()); |
| 371 EXPECT_TRUE(node->transform_changed); | 355 EXPECT_TRUE(node->transform_changed); |
| 372 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( | 356 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( |
| 373 root->PushPropertiesTo(root_impl.get()); | 357 root->PushPropertiesTo(root_impl.get()); |
| 374 child->PushPropertiesTo(child_impl.get()); | 358 child->PushPropertiesTo(child_impl.get()); |
| 375 child2->PushPropertiesTo(child2_impl.get()); | 359 child2->PushPropertiesTo(child2_impl.get()); |
| 376 grand_child->PushPropertiesTo(grand_child_impl.get()); | 360 grand_child->PushPropertiesTo(grand_child_impl.get()); |
| 377 layer_tree_->property_trees()->ResetAllChangeTracking()); | 361 layer_tree_host_->property_trees()->ResetAllChangeTracking()); |
| 378 EXPECT_FALSE(node->transform_changed); | 362 EXPECT_FALSE(node->transform_changed); |
| 379 | 363 |
| 380 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); | 364 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); |
| 381 child->SetPosition(arbitrary_point_f); | 365 child->SetPosition(arbitrary_point_f); |
| 382 node = layer_tree_->property_trees()->transform_tree.Node( | 366 node = layer_tree_host_->property_trees()->transform_tree.Node( |
| 383 child->transform_tree_index()); | 367 child->transform_tree_index()); |
| 384 EXPECT_TRUE(node->transform_changed); | 368 EXPECT_TRUE(node->transform_changed); |
| 385 // child2 is not in the subtree of child, but its scroll parent is. So, its | 369 // child2 is not in the subtree of child, but its scroll parent is. So, its |
| 386 // to_screen will be effected by change in position of child2. | 370 // to_screen will be effected by change in position of child2. |
| 387 layer_tree_->property_trees()->transform_tree.UpdateTransforms( | 371 layer_tree_host_->property_trees()->transform_tree.UpdateTransforms( |
| 388 child2->transform_tree_index()); | 372 child2->transform_tree_index()); |
| 389 node = layer_tree_->property_trees()->transform_tree.Node( | 373 node = layer_tree_host_->property_trees()->transform_tree.Node( |
| 390 child2->transform_tree_index()); | 374 child2->transform_tree_index()); |
| 391 EXPECT_TRUE(node->transform_changed); | 375 EXPECT_TRUE(node->transform_changed); |
| 392 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( | 376 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( |
| 393 child->PushPropertiesTo(child_impl.get()); | 377 child->PushPropertiesTo(child_impl.get()); |
| 394 grand_child->PushPropertiesTo(grand_child_impl.get()); | 378 grand_child->PushPropertiesTo(grand_child_impl.get()); |
| 395 layer_tree_->property_trees()->ResetAllChangeTracking()); | 379 layer_tree_host_->property_trees()->ResetAllChangeTracking()); |
| 396 node = layer_tree_->property_trees()->transform_tree.Node( | 380 node = layer_tree_host_->property_trees()->transform_tree.Node( |
| 397 child->transform_tree_index()); | 381 child->transform_tree_index()); |
| 398 EXPECT_FALSE(node->transform_changed); | 382 EXPECT_FALSE(node->transform_changed); |
| 399 | 383 |
| 400 gfx::Point3F arbitrary_point_3f = gfx::Point3F(0.125f, 0.25f, 0.f); | 384 gfx::Point3F arbitrary_point_3f = gfx::Point3F(0.125f, 0.25f, 0.f); |
| 401 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); | 385 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); |
| 402 root->SetTransformOrigin(arbitrary_point_3f); | 386 root->SetTransformOrigin(arbitrary_point_3f); |
| 403 node = layer_tree_->property_trees()->transform_tree.Node( | 387 node = layer_tree_host_->property_trees()->transform_tree.Node( |
| 404 root->transform_tree_index()); | 388 root->transform_tree_index()); |
| 405 EXPECT_TRUE(node->transform_changed); | 389 EXPECT_TRUE(node->transform_changed); |
| 406 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( | 390 EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET( |
| 407 root->PushPropertiesTo(root_impl.get()); | 391 root->PushPropertiesTo(root_impl.get()); |
| 408 child->PushPropertiesTo(child_impl.get()); | 392 child->PushPropertiesTo(child_impl.get()); |
| 409 child2->PushPropertiesTo(child2_impl.get()); | 393 child2->PushPropertiesTo(child2_impl.get()); |
| 410 grand_child->PushPropertiesTo(grand_child_impl.get()); | 394 grand_child->PushPropertiesTo(grand_child_impl.get()); |
| 411 layer_tree_->property_trees()->ResetAllChangeTracking()); | 395 layer_tree_host_->property_trees()->ResetAllChangeTracking()); |
| 412 | 396 |
| 413 gfx::Transform arbitrary_transform; | 397 gfx::Transform arbitrary_transform; |
| 414 arbitrary_transform.Scale3d(0.1f, 0.2f, 0.3f); | 398 arbitrary_transform.Scale3d(0.1f, 0.2f, 0.3f); |
| 415 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); | 399 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1); |
| 416 root->SetTransform(arbitrary_transform); | 400 root->SetTransform(arbitrary_transform); |
| 417 node = layer_tree_->property_trees()->transform_tree.Node( | 401 node = layer_tree_host_->property_trees()->transform_tree.Node( |
| 418 root->transform_tree_index()); | 402 root->transform_tree_index()); |
| 419 EXPECT_TRUE(node->transform_changed); | 403 EXPECT_TRUE(node->transform_changed); |
| 420 } | 404 } |
| 421 | 405 |
| 422 TEST_F(LayerTest, AddAndRemoveChild) { | 406 TEST_F(LayerTest, AddAndRemoveChild) { |
| 423 scoped_refptr<Layer> parent = Layer::Create(); | 407 scoped_refptr<Layer> parent = Layer::Create(); |
| 424 scoped_refptr<Layer> child = Layer::Create(); | 408 scoped_refptr<Layer> child = Layer::Create(); |
| 425 | 409 |
| 426 // Upon creation, layers should not have children or parent. | 410 // Upon creation, layers should not have children or parent. |
| 427 ASSERT_EQ(0U, parent->children().size()); | 411 ASSERT_EQ(0U, parent->children().size()); |
| 428 EXPECT_FALSE(child->parent()); | 412 EXPECT_FALSE(child->parent()); |
| 429 | 413 |
| 430 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(parent)); | 414 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(parent)); |
| 431 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->AddChild(child)); | 415 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->AddChild(child)); |
| 432 | 416 |
| 433 ASSERT_EQ(1U, parent->children().size()); | 417 ASSERT_EQ(1U, parent->children().size()); |
| 434 EXPECT_EQ(child.get(), parent->children()[0]); | 418 EXPECT_EQ(child.get(), parent->children()[0]); |
| 435 EXPECT_EQ(parent.get(), child->parent()); | 419 EXPECT_EQ(parent.get(), child->parent()); |
| 436 EXPECT_EQ(parent.get(), child->RootLayer()); | 420 EXPECT_EQ(parent.get(), child->RootLayer()); |
| 437 | 421 |
| 438 EXPECT_SET_NEEDS_FULL_TREE_SYNC(AtLeast(1), child->RemoveFromParent()); | 422 EXPECT_SET_NEEDS_FULL_TREE_SYNC(AtLeast(1), child->RemoveFromParent()); |
| 439 } | 423 } |
| 440 | 424 |
| 441 TEST_F(LayerTest, AddSameChildTwice) { | 425 TEST_F(LayerTest, AddSameChildTwice) { |
| 442 EXPECT_CALL(*layer_tree_, SetNeedsFullTreeSync()).Times(AtLeast(1)); | 426 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(AtLeast(1)); |
| 443 | 427 |
| 444 scoped_refptr<Layer> parent = Layer::Create(); | 428 scoped_refptr<Layer> parent = Layer::Create(); |
| 445 scoped_refptr<Layer> child = Layer::Create(); | 429 scoped_refptr<Layer> child = Layer::Create(); |
| 446 | 430 |
| 447 layer_tree_->SetRootLayer(parent); | 431 layer_tree_host_->SetRootLayer(parent); |
| 448 | 432 |
| 449 ASSERT_EQ(0u, parent->children().size()); | 433 ASSERT_EQ(0u, parent->children().size()); |
| 450 | 434 |
| 451 parent->AddChild(child); | 435 parent->AddChild(child); |
| 452 ASSERT_EQ(1u, parent->children().size()); | 436 ASSERT_EQ(1u, parent->children().size()); |
| 453 EXPECT_EQ(parent.get(), child->parent()); | 437 EXPECT_EQ(parent.get(), child->parent()); |
| 454 | 438 |
| 455 parent->AddChild(child); | 439 parent->AddChild(child); |
| 456 ASSERT_EQ(1u, parent->children().size()); | 440 ASSERT_EQ(1u, parent->children().size()); |
| 457 EXPECT_EQ(parent.get(), child->parent()); | 441 EXPECT_EQ(parent.get(), child->parent()); |
| 458 } | 442 } |
| 459 | 443 |
| 460 TEST_F(LayerTest, InsertChild) { | 444 TEST_F(LayerTest, InsertChild) { |
| 461 scoped_refptr<Layer> parent = Layer::Create(); | 445 scoped_refptr<Layer> parent = Layer::Create(); |
| 462 scoped_refptr<Layer> child1 = Layer::Create(); | 446 scoped_refptr<Layer> child1 = Layer::Create(); |
| 463 scoped_refptr<Layer> child2 = Layer::Create(); | 447 scoped_refptr<Layer> child2 = Layer::Create(); |
| 464 scoped_refptr<Layer> child3 = Layer::Create(); | 448 scoped_refptr<Layer> child3 = Layer::Create(); |
| 465 scoped_refptr<Layer> child4 = Layer::Create(); | 449 scoped_refptr<Layer> child4 = Layer::Create(); |
| 466 | 450 |
| 467 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(parent)); | 451 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(parent)); |
| 468 | 452 |
| 469 ASSERT_EQ(0U, parent->children().size()); | 453 ASSERT_EQ(0U, parent->children().size()); |
| 470 | 454 |
| 471 // Case 1: inserting to empty list. | 455 // Case 1: inserting to empty list. |
| 472 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child3, 0)); | 456 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child3, 0)); |
| 473 ASSERT_EQ(1U, parent->children().size()); | 457 ASSERT_EQ(1U, parent->children().size()); |
| 474 EXPECT_EQ(child3, parent->children()[0]); | 458 EXPECT_EQ(child3, parent->children()[0]); |
| 475 EXPECT_EQ(parent.get(), child3->parent()); | 459 EXPECT_EQ(parent.get(), child3->parent()); |
| 476 | 460 |
| 477 // Case 2: inserting to beginning of list | 461 // Case 2: inserting to beginning of list |
| (...skipping 14 matching lines...) Expand all Loading... |
| 492 // Case 4: inserting to end of list | 476 // Case 4: inserting to end of list |
| 493 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child4, 3)); | 477 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child4, 3)); |
| 494 | 478 |
| 495 ASSERT_EQ(4U, parent->children().size()); | 479 ASSERT_EQ(4U, parent->children().size()); |
| 496 EXPECT_EQ(child1, parent->children()[0]); | 480 EXPECT_EQ(child1, parent->children()[0]); |
| 497 EXPECT_EQ(child2, parent->children()[1]); | 481 EXPECT_EQ(child2, parent->children()[1]); |
| 498 EXPECT_EQ(child3, parent->children()[2]); | 482 EXPECT_EQ(child3, parent->children()[2]); |
| 499 EXPECT_EQ(child4, parent->children()[3]); | 483 EXPECT_EQ(child4, parent->children()[3]); |
| 500 EXPECT_EQ(parent.get(), child4->parent()); | 484 EXPECT_EQ(parent.get(), child4->parent()); |
| 501 | 485 |
| 502 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(nullptr)); | 486 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(nullptr)); |
| 503 } | 487 } |
| 504 | 488 |
| 505 TEST_F(LayerTest, InsertChildPastEndOfList) { | 489 TEST_F(LayerTest, InsertChildPastEndOfList) { |
| 506 scoped_refptr<Layer> parent = Layer::Create(); | 490 scoped_refptr<Layer> parent = Layer::Create(); |
| 507 scoped_refptr<Layer> child1 = Layer::Create(); | 491 scoped_refptr<Layer> child1 = Layer::Create(); |
| 508 scoped_refptr<Layer> child2 = Layer::Create(); | 492 scoped_refptr<Layer> child2 = Layer::Create(); |
| 509 | 493 |
| 510 ASSERT_EQ(0U, parent->children().size()); | 494 ASSERT_EQ(0U, parent->children().size()); |
| 511 | 495 |
| 512 // insert to an out-of-bounds index | 496 // insert to an out-of-bounds index |
| 513 parent->InsertChild(child1, 53); | 497 parent->InsertChild(child1, 53); |
| 514 | 498 |
| 515 ASSERT_EQ(1U, parent->children().size()); | 499 ASSERT_EQ(1U, parent->children().size()); |
| 516 EXPECT_EQ(child1, parent->children()[0]); | 500 EXPECT_EQ(child1, parent->children()[0]); |
| 517 | 501 |
| 518 // insert another child to out-of-bounds, when list is not already empty. | 502 // insert another child to out-of-bounds, when list is not already empty. |
| 519 parent->InsertChild(child2, 2459); | 503 parent->InsertChild(child2, 2459); |
| 520 | 504 |
| 521 ASSERT_EQ(2U, parent->children().size()); | 505 ASSERT_EQ(2U, parent->children().size()); |
| 522 EXPECT_EQ(child1, parent->children()[0]); | 506 EXPECT_EQ(child1, parent->children()[0]); |
| 523 EXPECT_EQ(child2, parent->children()[1]); | 507 EXPECT_EQ(child2, parent->children()[1]); |
| 524 } | 508 } |
| 525 | 509 |
| 526 TEST_F(LayerTest, InsertSameChildTwice) { | 510 TEST_F(LayerTest, InsertSameChildTwice) { |
| 527 scoped_refptr<Layer> parent = Layer::Create(); | 511 scoped_refptr<Layer> parent = Layer::Create(); |
| 528 scoped_refptr<Layer> child1 = Layer::Create(); | 512 scoped_refptr<Layer> child1 = Layer::Create(); |
| 529 scoped_refptr<Layer> child2 = Layer::Create(); | 513 scoped_refptr<Layer> child2 = Layer::Create(); |
| 530 | 514 |
| 531 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(parent)); | 515 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(parent)); |
| 532 | 516 |
| 533 ASSERT_EQ(0U, parent->children().size()); | 517 ASSERT_EQ(0U, parent->children().size()); |
| 534 | 518 |
| 535 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child1, 0)); | 519 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child1, 0)); |
| 536 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child2, 1)); | 520 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child2, 1)); |
| 537 | 521 |
| 538 ASSERT_EQ(2U, parent->children().size()); | 522 ASSERT_EQ(2U, parent->children().size()); |
| 539 EXPECT_EQ(child1, parent->children()[0]); | 523 EXPECT_EQ(child1, parent->children()[0]); |
| 540 EXPECT_EQ(child2, parent->children()[1]); | 524 EXPECT_EQ(child2, parent->children()[1]); |
| 541 | 525 |
| 542 // Inserting the same child again should cause the child to be removed and | 526 // Inserting the same child again should cause the child to be removed and |
| 543 // re-inserted at the new location. | 527 // re-inserted at the new location. |
| 544 EXPECT_SET_NEEDS_FULL_TREE_SYNC(AtLeast(1), parent->InsertChild(child1, 1)); | 528 EXPECT_SET_NEEDS_FULL_TREE_SYNC(AtLeast(1), parent->InsertChild(child1, 1)); |
| 545 | 529 |
| 546 // child1 should now be at the end of the list. | 530 // child1 should now be at the end of the list. |
| 547 ASSERT_EQ(2U, parent->children().size()); | 531 ASSERT_EQ(2U, parent->children().size()); |
| 548 EXPECT_EQ(child2, parent->children()[0]); | 532 EXPECT_EQ(child2, parent->children()[0]); |
| 549 EXPECT_EQ(child1, parent->children()[1]); | 533 EXPECT_EQ(child1, parent->children()[1]); |
| 550 | 534 |
| 551 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(nullptr)); | 535 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(nullptr)); |
| 552 } | 536 } |
| 553 | 537 |
| 554 TEST_F(LayerTest, ReplaceChildWithNewChild) { | 538 TEST_F(LayerTest, ReplaceChildWithNewChild) { |
| 555 CreateSimpleTestTree(); | 539 CreateSimpleTestTree(); |
| 556 scoped_refptr<Layer> child4 = Layer::Create(); | 540 scoped_refptr<Layer> child4 = Layer::Create(); |
| 557 | 541 |
| 558 EXPECT_FALSE(child4->parent()); | 542 EXPECT_FALSE(child4->parent()); |
| 559 | 543 |
| 560 EXPECT_SET_NEEDS_FULL_TREE_SYNC( | 544 EXPECT_SET_NEEDS_FULL_TREE_SYNC( |
| 561 AtLeast(1), parent_->ReplaceChild(child2_.get(), child4)); | 545 AtLeast(1), parent_->ReplaceChild(child2_.get(), child4)); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 // and child2 should no longer have a parent. | 582 // and child2 should no longer have a parent. |
| 599 ASSERT_EQ(0U, test_layer->children().size()); | 583 ASSERT_EQ(0U, test_layer->children().size()); |
| 600 EXPECT_FALSE(child2_->parent()); | 584 EXPECT_FALSE(child2_->parent()); |
| 601 } | 585 } |
| 602 | 586 |
| 603 TEST_F(LayerTest, DeleteRemovedScrollParent) { | 587 TEST_F(LayerTest, DeleteRemovedScrollParent) { |
| 604 scoped_refptr<Layer> parent = Layer::Create(); | 588 scoped_refptr<Layer> parent = Layer::Create(); |
| 605 scoped_refptr<Layer> child1 = Layer::Create(); | 589 scoped_refptr<Layer> child1 = Layer::Create(); |
| 606 scoped_refptr<Layer> child2 = Layer::Create(); | 590 scoped_refptr<Layer> child2 = Layer::Create(); |
| 607 | 591 |
| 608 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(parent)); | 592 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(parent)); |
| 609 | 593 |
| 610 ASSERT_EQ(0U, parent->children().size()); | 594 ASSERT_EQ(0U, parent->children().size()); |
| 611 | 595 |
| 612 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child1, 0)); | 596 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child1, 0)); |
| 613 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child2, 1)); | 597 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child2, 1)); |
| 614 | 598 |
| 615 ASSERT_EQ(2U, parent->children().size()); | 599 ASSERT_EQ(2U, parent->children().size()); |
| 616 EXPECT_EQ(child1, parent->children()[0]); | 600 EXPECT_EQ(child1, parent->children()[0]); |
| 617 EXPECT_EQ(child2, parent->children()[1]); | 601 EXPECT_EQ(child2, parent->children()[1]); |
| 618 | 602 |
| 619 EXPECT_SET_NEEDS_COMMIT(2, child1->SetScrollParent(child2.get())); | 603 EXPECT_SET_NEEDS_COMMIT(2, child1->SetScrollParent(child2.get())); |
| 620 | 604 |
| 621 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, child2->RemoveFromParent()); | 605 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, child2->RemoveFromParent()); |
| 622 | 606 |
| 623 child1->ResetNeedsPushPropertiesForTesting(); | 607 child1->ResetNeedsPushPropertiesForTesting(); |
| 624 | 608 |
| 625 EXPECT_SET_NEEDS_COMMIT(1, child2 = nullptr); | 609 EXPECT_SET_NEEDS_COMMIT(1, child2 = nullptr); |
| 626 | 610 |
| 627 EXPECT_TRUE(layer_tree_->LayerNeedsPushPropertiesForTesting(child1.get())); | 611 EXPECT_TRUE( |
| 612 layer_tree_host_->LayerNeedsPushPropertiesForTesting(child1.get())); |
| 628 | 613 |
| 629 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(nullptr)); | 614 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(nullptr)); |
| 630 } | 615 } |
| 631 | 616 |
| 632 TEST_F(LayerTest, DeleteRemovedScrollChild) { | 617 TEST_F(LayerTest, DeleteRemovedScrollChild) { |
| 633 scoped_refptr<Layer> parent = Layer::Create(); | 618 scoped_refptr<Layer> parent = Layer::Create(); |
| 634 scoped_refptr<Layer> child1 = Layer::Create(); | 619 scoped_refptr<Layer> child1 = Layer::Create(); |
| 635 scoped_refptr<Layer> child2 = Layer::Create(); | 620 scoped_refptr<Layer> child2 = Layer::Create(); |
| 636 | 621 |
| 637 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(parent)); | 622 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(parent)); |
| 638 | 623 |
| 639 ASSERT_EQ(0U, parent->children().size()); | 624 ASSERT_EQ(0U, parent->children().size()); |
| 640 | 625 |
| 641 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child1, 0)); | 626 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child1, 0)); |
| 642 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child2, 1)); | 627 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child2, 1)); |
| 643 | 628 |
| 644 ASSERT_EQ(2U, parent->children().size()); | 629 ASSERT_EQ(2U, parent->children().size()); |
| 645 EXPECT_EQ(child1, parent->children()[0]); | 630 EXPECT_EQ(child1, parent->children()[0]); |
| 646 EXPECT_EQ(child2, parent->children()[1]); | 631 EXPECT_EQ(child2, parent->children()[1]); |
| 647 | 632 |
| 648 EXPECT_SET_NEEDS_COMMIT(2, child1->SetScrollParent(child2.get())); | 633 EXPECT_SET_NEEDS_COMMIT(2, child1->SetScrollParent(child2.get())); |
| 649 | 634 |
| 650 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, child1->RemoveFromParent()); | 635 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, child1->RemoveFromParent()); |
| 651 | 636 |
| 652 child2->ResetNeedsPushPropertiesForTesting(); | 637 child2->ResetNeedsPushPropertiesForTesting(); |
| 653 | 638 |
| 654 EXPECT_SET_NEEDS_COMMIT(1, child1 = nullptr); | 639 EXPECT_SET_NEEDS_COMMIT(1, child1 = nullptr); |
| 655 | 640 |
| 656 EXPECT_TRUE(layer_tree_->LayerNeedsPushPropertiesForTesting(child2.get())); | 641 EXPECT_TRUE( |
| 642 layer_tree_host_->LayerNeedsPushPropertiesForTesting(child2.get())); |
| 657 | 643 |
| 658 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(nullptr)); | 644 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(nullptr)); |
| 659 } | 645 } |
| 660 | 646 |
| 661 TEST_F(LayerTest, ReplaceChildWithSameChild) { | 647 TEST_F(LayerTest, ReplaceChildWithSameChild) { |
| 662 CreateSimpleTestTree(); | 648 CreateSimpleTestTree(); |
| 663 | 649 |
| 664 // SetNeedsFullTreeSync / SetNeedsCommit should not be called because its the | 650 // SetNeedsFullTreeSync / SetNeedsCommit should not be called because its the |
| 665 // same child. | 651 // same child. |
| 666 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(0); | 652 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(0); |
| 667 EXPECT_CALL(*layer_tree_, SetNeedsFullTreeSync()).Times(0); | 653 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(0); |
| 668 parent_->ReplaceChild(child2_.get(), child2_); | 654 parent_->ReplaceChild(child2_.get(), child2_); |
| 669 | 655 |
| 670 VerifyTestTreeInitialState(); | 656 VerifyTestTreeInitialState(); |
| 671 } | 657 } |
| 672 | 658 |
| 673 TEST_F(LayerTest, RemoveAllChildren) { | 659 TEST_F(LayerTest, RemoveAllChildren) { |
| 674 CreateSimpleTestTree(); | 660 CreateSimpleTestTree(); |
| 675 | 661 |
| 676 EXPECT_SET_NEEDS_FULL_TREE_SYNC(AtLeast(3), parent_->RemoveAllChildren()); | 662 EXPECT_SET_NEEDS_FULL_TREE_SYNC(AtLeast(3), parent_->RemoveAllChildren()); |
| 677 | 663 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 692 new_children.push_back(child1); | 678 new_children.push_back(child1); |
| 693 new_children.push_back(child2); | 679 new_children.push_back(child2); |
| 694 | 680 |
| 695 // Set up and verify initial test conditions: child1 has a parent, child2 has | 681 // Set up and verify initial test conditions: child1 has a parent, child2 has |
| 696 // no parent. | 682 // no parent. |
| 697 old_parent->AddChild(child1); | 683 old_parent->AddChild(child1); |
| 698 ASSERT_EQ(0U, new_parent->children().size()); | 684 ASSERT_EQ(0U, new_parent->children().size()); |
| 699 EXPECT_EQ(old_parent.get(), child1->parent()); | 685 EXPECT_EQ(old_parent.get(), child1->parent()); |
| 700 EXPECT_FALSE(child2->parent()); | 686 EXPECT_FALSE(child2->parent()); |
| 701 | 687 |
| 702 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(new_parent)); | 688 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, |
| 689 layer_tree_host_->SetRootLayer(new_parent)); |
| 703 | 690 |
| 704 EXPECT_SET_NEEDS_FULL_TREE_SYNC( | 691 EXPECT_SET_NEEDS_FULL_TREE_SYNC( |
| 705 AtLeast(1), new_parent->SetChildren(new_children)); | 692 AtLeast(1), new_parent->SetChildren(new_children)); |
| 706 | 693 |
| 707 ASSERT_EQ(2U, new_parent->children().size()); | 694 ASSERT_EQ(2U, new_parent->children().size()); |
| 708 EXPECT_EQ(new_parent.get(), child1->parent()); | 695 EXPECT_EQ(new_parent.get(), child1->parent()); |
| 709 EXPECT_EQ(new_parent.get(), child2->parent()); | 696 EXPECT_EQ(new_parent.get(), child2->parent()); |
| 710 | 697 |
| 711 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(nullptr)); | 698 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(nullptr)); |
| 712 } | 699 } |
| 713 | 700 |
| 714 TEST_F(LayerTest, HasAncestor) { | 701 TEST_F(LayerTest, HasAncestor) { |
| 715 scoped_refptr<Layer> parent = Layer::Create(); | 702 scoped_refptr<Layer> parent = Layer::Create(); |
| 716 EXPECT_FALSE(parent->HasAncestor(parent.get())); | 703 EXPECT_FALSE(parent->HasAncestor(parent.get())); |
| 717 | 704 |
| 718 scoped_refptr<Layer> child = Layer::Create(); | 705 scoped_refptr<Layer> child = Layer::Create(); |
| 719 parent->AddChild(child); | 706 parent->AddChild(child); |
| 720 | 707 |
| 721 EXPECT_FALSE(child->HasAncestor(child.get())); | 708 EXPECT_FALSE(child->HasAncestor(child.get())); |
| 722 EXPECT_TRUE(child->HasAncestor(parent.get())); | 709 EXPECT_TRUE(child->HasAncestor(parent.get())); |
| 723 EXPECT_FALSE(parent->HasAncestor(child.get())); | 710 EXPECT_FALSE(parent->HasAncestor(child.get())); |
| 724 | 711 |
| 725 scoped_refptr<Layer> child_child = Layer::Create(); | 712 scoped_refptr<Layer> child_child = Layer::Create(); |
| 726 child->AddChild(child_child); | 713 child->AddChild(child_child); |
| 727 | 714 |
| 728 EXPECT_FALSE(child_child->HasAncestor(child_child.get())); | 715 EXPECT_FALSE(child_child->HasAncestor(child_child.get())); |
| 729 EXPECT_TRUE(child_child->HasAncestor(parent.get())); | 716 EXPECT_TRUE(child_child->HasAncestor(parent.get())); |
| 730 EXPECT_TRUE(child_child->HasAncestor(child.get())); | 717 EXPECT_TRUE(child_child->HasAncestor(child.get())); |
| 731 EXPECT_FALSE(parent->HasAncestor(child.get())); | 718 EXPECT_FALSE(parent->HasAncestor(child.get())); |
| 732 EXPECT_FALSE(parent->HasAncestor(child_child.get())); | 719 EXPECT_FALSE(parent->HasAncestor(child_child.get())); |
| 733 } | 720 } |
| 734 | 721 |
| 735 TEST_F(LayerTest, GetRootLayerAfterTreeManipulations) { | 722 TEST_F(LayerTest, GetRootLayerAfterTreeManipulations) { |
| 736 CreateSimpleTestTree(); | 723 CreateSimpleTestTree(); |
| 737 | 724 |
| 738 // For this test we don't care about SetNeedsFullTreeSync calls. | 725 // For this test we don't care about SetNeedsFullTreeSync calls. |
| 739 EXPECT_CALL(*layer_tree_, SetNeedsFullTreeSync()).Times(AnyNumber()); | 726 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(AnyNumber()); |
| 740 | 727 |
| 741 scoped_refptr<Layer> child4 = Layer::Create(); | 728 scoped_refptr<Layer> child4 = Layer::Create(); |
| 742 | 729 |
| 743 EXPECT_EQ(parent_.get(), parent_->RootLayer()); | 730 EXPECT_EQ(parent_.get(), parent_->RootLayer()); |
| 744 EXPECT_EQ(parent_.get(), child1_->RootLayer()); | 731 EXPECT_EQ(parent_.get(), child1_->RootLayer()); |
| 745 EXPECT_EQ(parent_.get(), child2_->RootLayer()); | 732 EXPECT_EQ(parent_.get(), child2_->RootLayer()); |
| 746 EXPECT_EQ(parent_.get(), child3_->RootLayer()); | 733 EXPECT_EQ(parent_.get(), child3_->RootLayer()); |
| 747 EXPECT_EQ(child4.get(), child4->RootLayer()); | 734 EXPECT_EQ(child4.get(), child4->RootLayer()); |
| 748 EXPECT_EQ(parent_.get(), grand_child1_->RootLayer()); | 735 EXPECT_EQ(parent_.get(), grand_child1_->RootLayer()); |
| 749 EXPECT_EQ(parent_.get(), grand_child2_->RootLayer()); | 736 EXPECT_EQ(parent_.get(), grand_child2_->RootLayer()); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 787 EXPECT_EQ(grand_child3_.get(), grand_child3_->RootLayer()); | 774 EXPECT_EQ(grand_child3_.get(), grand_child3_->RootLayer()); |
| 788 } | 775 } |
| 789 | 776 |
| 790 TEST_F(LayerTest, CheckSetNeedsDisplayCausesCorrectBehavior) { | 777 TEST_F(LayerTest, CheckSetNeedsDisplayCausesCorrectBehavior) { |
| 791 // The semantics for SetNeedsDisplay which are tested here: | 778 // The semantics for SetNeedsDisplay which are tested here: |
| 792 // 1. sets NeedsDisplay flag appropriately. | 779 // 1. sets NeedsDisplay flag appropriately. |
| 793 // 2. indirectly calls SetNeedsUpdate, exactly once for each call to | 780 // 2. indirectly calls SetNeedsUpdate, exactly once for each call to |
| 794 // SetNeedsDisplay. | 781 // SetNeedsDisplay. |
| 795 | 782 |
| 796 scoped_refptr<Layer> test_layer = Layer::Create(); | 783 scoped_refptr<Layer> test_layer = Layer::Create(); |
| 797 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(test_layer)); | 784 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, |
| 785 layer_tree_host_->SetRootLayer(test_layer)); |
| 798 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetIsDrawable(true)); | 786 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetIsDrawable(true)); |
| 799 | 787 |
| 800 gfx::Size test_bounds = gfx::Size(501, 508); | 788 gfx::Size test_bounds = gfx::Size(501, 508); |
| 801 | 789 |
| 802 gfx::Rect dirty_rect = gfx::Rect(10, 15, 1, 2); | 790 gfx::Rect dirty_rect = gfx::Rect(10, 15, 1, 2); |
| 803 gfx::Rect out_of_bounds_dirty_rect = gfx::Rect(400, 405, 500, 502); | 791 gfx::Rect out_of_bounds_dirty_rect = gfx::Rect(400, 405, 500, 502); |
| 804 | 792 |
| 805 // Before anything, test_layer should not be dirty. | 793 // Before anything, test_layer should not be dirty. |
| 806 EXPECT_FALSE(test_layer->NeedsDisplayForTesting()); | 794 EXPECT_FALSE(test_layer->NeedsDisplayForTesting()); |
| 807 | 795 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 838 // Case 4: SetNeedsDisplay() with a non-drawable layer | 826 // Case 4: SetNeedsDisplay() with a non-drawable layer |
| 839 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetIsDrawable(false)); | 827 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetIsDrawable(false)); |
| 840 test_layer->ResetNeedsDisplayForTesting(); | 828 test_layer->ResetNeedsDisplayForTesting(); |
| 841 EXPECT_FALSE(test_layer->NeedsDisplayForTesting()); | 829 EXPECT_FALSE(test_layer->NeedsDisplayForTesting()); |
| 842 EXPECT_SET_NEEDS_UPDATE(0, test_layer->SetNeedsDisplayRect(dirty_rect)); | 830 EXPECT_SET_NEEDS_UPDATE(0, test_layer->SetNeedsDisplayRect(dirty_rect)); |
| 843 EXPECT_TRUE(test_layer->NeedsDisplayForTesting()); | 831 EXPECT_TRUE(test_layer->NeedsDisplayForTesting()); |
| 844 } | 832 } |
| 845 | 833 |
| 846 TEST_F(LayerTest, TestSettingMainThreadScrollingReason) { | 834 TEST_F(LayerTest, TestSettingMainThreadScrollingReason) { |
| 847 scoped_refptr<Layer> test_layer = Layer::Create(); | 835 scoped_refptr<Layer> test_layer = Layer::Create(); |
| 848 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(test_layer)); | 836 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, |
| 837 layer_tree_host_->SetRootLayer(test_layer)); |
| 849 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetIsDrawable(true)); | 838 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetIsDrawable(true)); |
| 850 | 839 |
| 851 // sanity check of initial test condition | 840 // sanity check of initial test condition |
| 852 EXPECT_FALSE(test_layer->NeedsDisplayForTesting()); | 841 EXPECT_FALSE(test_layer->NeedsDisplayForTesting()); |
| 853 | 842 |
| 854 uint32_t reasons = 0, reasons_to_clear = 0, reasons_after_clearing = 0; | 843 uint32_t reasons = 0, reasons_to_clear = 0, reasons_after_clearing = 0; |
| 855 reasons |= MainThreadScrollingReason::kNonFastScrollableRegion; | 844 reasons |= MainThreadScrollingReason::kNonFastScrollableRegion; |
| 856 reasons |= MainThreadScrollingReason::kContinuingMainThreadScroll; | 845 reasons |= MainThreadScrollingReason::kContinuingMainThreadScroll; |
| 857 reasons |= MainThreadScrollingReason::kScrollbarScrolling; | 846 reasons |= MainThreadScrollingReason::kScrollbarScrolling; |
| 858 | 847 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 890 test_layer->main_thread_scrolling_reasons()); | 879 test_layer->main_thread_scrolling_reasons()); |
| 891 | 880 |
| 892 // Check that adding an existing condition doesn't set needs commit. | 881 // Check that adding an existing condition doesn't set needs commit. |
| 893 EXPECT_SET_NEEDS_COMMIT( | 882 EXPECT_SET_NEEDS_COMMIT( |
| 894 0, test_layer->AddMainThreadScrollingReasons( | 883 0, test_layer->AddMainThreadScrollingReasons( |
| 895 MainThreadScrollingReason::kNonFastScrollableRegion)); | 884 MainThreadScrollingReason::kNonFastScrollableRegion)); |
| 896 } | 885 } |
| 897 | 886 |
| 898 TEST_F(LayerTest, CheckPropertyChangeCausesCorrectBehavior) { | 887 TEST_F(LayerTest, CheckPropertyChangeCausesCorrectBehavior) { |
| 899 scoped_refptr<Layer> test_layer = Layer::Create(); | 888 scoped_refptr<Layer> test_layer = Layer::Create(); |
| 900 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(test_layer)); | 889 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, |
| 890 layer_tree_host_->SetRootLayer(test_layer)); |
| 901 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetIsDrawable(true)); | 891 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetIsDrawable(true)); |
| 902 | 892 |
| 903 scoped_refptr<Layer> dummy_layer1 = Layer::Create(); | 893 scoped_refptr<Layer> dummy_layer1 = Layer::Create(); |
| 904 | 894 |
| 905 // sanity check of initial test condition | 895 // sanity check of initial test condition |
| 906 EXPECT_FALSE(test_layer->NeedsDisplayForTesting()); | 896 EXPECT_FALSE(test_layer->NeedsDisplayForTesting()); |
| 907 | 897 |
| 908 // Next, test properties that should call SetNeedsCommit (but not | 898 // Next, test properties that should call SetNeedsCommit (but not |
| 909 // SetNeedsDisplay). All properties need to be set to new values in order for | 899 // SetNeedsDisplay). All properties need to be set to new values in order for |
| 910 // SetNeedsCommit to be called. | 900 // SetNeedsCommit to be called. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 939 EXPECT_SET_NEEDS_COMMIT( | 929 EXPECT_SET_NEEDS_COMMIT( |
| 940 1, test_layer->SetMutableProperties(MutableProperty::kTransform)); | 930 1, test_layer->SetMutableProperties(MutableProperty::kTransform)); |
| 941 | 931 |
| 942 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, test_layer->SetMaskLayer( | 932 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, test_layer->SetMaskLayer( |
| 943 dummy_layer1.get())); | 933 dummy_layer1.get())); |
| 944 | 934 |
| 945 // The above tests should not have caused a change to the needs_display flag. | 935 // The above tests should not have caused a change to the needs_display flag. |
| 946 EXPECT_FALSE(test_layer->NeedsDisplayForTesting()); | 936 EXPECT_FALSE(test_layer->NeedsDisplayForTesting()); |
| 947 | 937 |
| 948 // As layers are removed from the tree, they will cause a tree sync. | 938 // As layers are removed from the tree, they will cause a tree sync. |
| 949 EXPECT_CALL(*layer_tree_, SetNeedsFullTreeSync()).Times((AnyNumber())); | 939 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times((AnyNumber())); |
| 950 } | 940 } |
| 951 | 941 |
| 952 TEST_F(LayerTest, PushPropertiesAccumulatesUpdateRect) { | 942 TEST_F(LayerTest, PushPropertiesAccumulatesUpdateRect) { |
| 953 scoped_refptr<Layer> test_layer = Layer::Create(); | 943 scoped_refptr<Layer> test_layer = Layer::Create(); |
| 954 std::unique_ptr<LayerImpl> impl_layer = | 944 std::unique_ptr<LayerImpl> impl_layer = |
| 955 LayerImpl::Create(host_impl_.active_tree(), 1); | 945 LayerImpl::Create(host_impl_.active_tree(), 1); |
| 956 | 946 |
| 957 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(test_layer)); | 947 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, |
| 948 layer_tree_host_->SetRootLayer(test_layer)); |
| 958 | 949 |
| 959 host_impl_.active_tree()->SetRootLayerForTesting(std::move(impl_layer)); | 950 host_impl_.active_tree()->SetRootLayerForTesting(std::move(impl_layer)); |
| 960 host_impl_.active_tree()->BuildLayerListForTesting(); | 951 host_impl_.active_tree()->BuildLayerListForTesting(); |
| 961 LayerImpl* impl_layer_ptr = host_impl_.active_tree()->LayerById(1); | 952 LayerImpl* impl_layer_ptr = host_impl_.active_tree()->LayerById(1); |
| 962 test_layer->SetNeedsDisplayRect(gfx::Rect(5, 5)); | 953 test_layer->SetNeedsDisplayRect(gfx::Rect(5, 5)); |
| 963 test_layer->PushPropertiesTo(impl_layer_ptr); | 954 test_layer->PushPropertiesTo(impl_layer_ptr); |
| 964 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0.f, 0.f, 5.f, 5.f), | 955 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0.f, 0.f, 5.f, 5.f), |
| 965 impl_layer_ptr->update_rect()); | 956 impl_layer_ptr->update_rect()); |
| 966 | 957 |
| 967 // The LayerImpl's update_rect() should be accumulated here, since we did not | 958 // The LayerImpl's update_rect() should be accumulated here, since we did not |
| (...skipping 10 matching lines...) Expand all Loading... |
| 978 test_layer->PushPropertiesTo(impl_layer_ptr); | 969 test_layer->PushPropertiesTo(impl_layer_ptr); |
| 979 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10.f, 10.f, 5.f, 5.f), | 970 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10.f, 10.f, 5.f, 5.f), |
| 980 impl_layer_ptr->update_rect()); | 971 impl_layer_ptr->update_rect()); |
| 981 } | 972 } |
| 982 | 973 |
| 983 TEST_F(LayerTest, PushPropertiesCausesLayerPropertyChangedForTransform) { | 974 TEST_F(LayerTest, PushPropertiesCausesLayerPropertyChangedForTransform) { |
| 984 scoped_refptr<Layer> test_layer = Layer::Create(); | 975 scoped_refptr<Layer> test_layer = Layer::Create(); |
| 985 std::unique_ptr<LayerImpl> impl_layer = | 976 std::unique_ptr<LayerImpl> impl_layer = |
| 986 LayerImpl::Create(host_impl_.active_tree(), 1); | 977 LayerImpl::Create(host_impl_.active_tree(), 1); |
| 987 | 978 |
| 988 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(test_layer)); | 979 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, |
| 980 layer_tree_host_->SetRootLayer(test_layer)); |
| 989 | 981 |
| 990 gfx::Transform transform; | 982 gfx::Transform transform; |
| 991 transform.Rotate(45.0); | 983 transform.Rotate(45.0); |
| 992 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetTransform(transform)); | 984 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetTransform(transform)); |
| 993 | 985 |
| 994 EXPECT_FALSE(impl_layer->LayerPropertyChanged()); | 986 EXPECT_FALSE(impl_layer->LayerPropertyChanged()); |
| 995 | 987 |
| 996 test_layer->PushPropertiesTo(impl_layer.get()); | 988 test_layer->PushPropertiesTo(impl_layer.get()); |
| 997 | 989 |
| 998 EXPECT_TRUE(impl_layer->LayerPropertyChanged()); | 990 EXPECT_TRUE(impl_layer->LayerPropertyChanged()); |
| 999 } | 991 } |
| 1000 | 992 |
| 1001 TEST_F(LayerTest, PushPropertiesCausesLayerPropertyChangedForOpacity) { | 993 TEST_F(LayerTest, PushPropertiesCausesLayerPropertyChangedForOpacity) { |
| 1002 scoped_refptr<Layer> test_layer = Layer::Create(); | 994 scoped_refptr<Layer> test_layer = Layer::Create(); |
| 1003 std::unique_ptr<LayerImpl> impl_layer = | 995 std::unique_ptr<LayerImpl> impl_layer = |
| 1004 LayerImpl::Create(host_impl_.active_tree(), 1); | 996 LayerImpl::Create(host_impl_.active_tree(), 1); |
| 1005 | 997 |
| 1006 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(test_layer)); | 998 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, |
| 999 layer_tree_host_->SetRootLayer(test_layer)); |
| 1007 | 1000 |
| 1008 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetOpacity(0.5f)); | 1001 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetOpacity(0.5f)); |
| 1009 | 1002 |
| 1010 EXPECT_FALSE(impl_layer->LayerPropertyChanged()); | 1003 EXPECT_FALSE(impl_layer->LayerPropertyChanged()); |
| 1011 | 1004 |
| 1012 test_layer->PushPropertiesTo(impl_layer.get()); | 1005 test_layer->PushPropertiesTo(impl_layer.get()); |
| 1013 | 1006 |
| 1014 EXPECT_TRUE(impl_layer->LayerPropertyChanged()); | 1007 EXPECT_TRUE(impl_layer->LayerPropertyChanged()); |
| 1015 } | 1008 } |
| 1016 | 1009 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1077 parent->AddChild(child); | 1070 parent->AddChild(child); |
| 1078 child->SetMaskLayer(mask.get()); | 1071 child->SetMaskLayer(mask.get()); |
| 1079 | 1072 |
| 1080 AssertLayerTreeHostMatchesForSubtree(parent.get(), nullptr); | 1073 AssertLayerTreeHostMatchesForSubtree(parent.get(), nullptr); |
| 1081 | 1074 |
| 1082 LayerTreeHostFactory factory; | 1075 LayerTreeHostFactory factory; |
| 1083 | 1076 |
| 1084 auto animation_host = AnimationHost::CreateForTesting(ThreadInstance::MAIN); | 1077 auto animation_host = AnimationHost::CreateForTesting(ThreadInstance::MAIN); |
| 1085 std::unique_ptr<LayerTreeHost> layer_tree_host = | 1078 std::unique_ptr<LayerTreeHost> layer_tree_host = |
| 1086 factory.Create(animation_host.get()); | 1079 factory.Create(animation_host.get()); |
| 1087 LayerTree* layer_tree = layer_tree_host->GetLayerTree(); | |
| 1088 // Setting the root layer should set the host pointer for all layers in the | 1080 // Setting the root layer should set the host pointer for all layers in the |
| 1089 // tree. | 1081 // tree. |
| 1090 layer_tree->SetRootLayer(parent.get()); | 1082 layer_tree_host->SetRootLayer(parent.get()); |
| 1091 | 1083 |
| 1092 AssertLayerTreeHostMatchesForSubtree(parent.get(), layer_tree_host.get()); | 1084 AssertLayerTreeHostMatchesForSubtree(parent.get(), layer_tree_host.get()); |
| 1093 | 1085 |
| 1094 // Clearing the root layer should also clear out the host pointers for all | 1086 // Clearing the root layer should also clear out the host pointers for all |
| 1095 // layers in the tree. | 1087 // layers in the tree. |
| 1096 layer_tree->SetRootLayer(nullptr); | 1088 layer_tree_host->SetRootLayer(nullptr); |
| 1097 | 1089 |
| 1098 AssertLayerTreeHostMatchesForSubtree(parent.get(), nullptr); | 1090 AssertLayerTreeHostMatchesForSubtree(parent.get(), nullptr); |
| 1099 } | 1091 } |
| 1100 | 1092 |
| 1101 TEST_F(LayerLayerTreeHostTest, AddingLayerSubtree) { | 1093 TEST_F(LayerLayerTreeHostTest, AddingLayerSubtree) { |
| 1102 scoped_refptr<Layer> parent = Layer::Create(); | 1094 scoped_refptr<Layer> parent = Layer::Create(); |
| 1103 LayerTreeHostFactory factory; | 1095 LayerTreeHostFactory factory; |
| 1104 | 1096 |
| 1105 auto animation_host = AnimationHost::CreateForTesting(ThreadInstance::MAIN); | 1097 auto animation_host = AnimationHost::CreateForTesting(ThreadInstance::MAIN); |
| 1106 std::unique_ptr<LayerTreeHost> layer_tree_host = | 1098 std::unique_ptr<LayerTreeHost> layer_tree_host = |
| 1107 factory.Create(animation_host.get()); | 1099 factory.Create(animation_host.get()); |
| 1108 LayerTree* layer_tree = layer_tree_host->GetLayerTree(); | |
| 1109 | 1100 |
| 1110 layer_tree->SetRootLayer(parent.get()); | 1101 layer_tree_host->SetRootLayer(parent.get()); |
| 1111 | 1102 |
| 1112 EXPECT_EQ(parent->GetLayerTreeHostForTesting(), layer_tree_host.get()); | 1103 EXPECT_EQ(parent->GetLayerTreeHostForTesting(), layer_tree_host.get()); |
| 1113 | 1104 |
| 1114 // Adding a subtree to a layer already associated with a host should set the | 1105 // Adding a subtree to a layer already associated with a host should set the |
| 1115 // host pointer on all layers in that subtree. | 1106 // host pointer on all layers in that subtree. |
| 1116 scoped_refptr<Layer> child = Layer::Create(); | 1107 scoped_refptr<Layer> child = Layer::Create(); |
| 1117 scoped_refptr<Layer> grand_child = Layer::Create(); | 1108 scoped_refptr<Layer> grand_child = Layer::Create(); |
| 1118 child->AddChild(grand_child); | 1109 child->AddChild(grand_child); |
| 1119 | 1110 |
| 1120 // Masks should pick up the new host too. | 1111 // Masks should pick up the new host too. |
| 1121 scoped_refptr<Layer> child_mask = Layer::Create(); | 1112 scoped_refptr<Layer> child_mask = Layer::Create(); |
| 1122 child->SetMaskLayer(child_mask.get()); | 1113 child->SetMaskLayer(child_mask.get()); |
| 1123 | 1114 |
| 1124 parent->AddChild(child); | 1115 parent->AddChild(child); |
| 1125 AssertLayerTreeHostMatchesForSubtree(parent.get(), layer_tree_host.get()); | 1116 AssertLayerTreeHostMatchesForSubtree(parent.get(), layer_tree_host.get()); |
| 1126 | 1117 |
| 1127 layer_tree->SetRootLayer(nullptr); | 1118 layer_tree_host->SetRootLayer(nullptr); |
| 1128 } | 1119 } |
| 1129 | 1120 |
| 1130 TEST_F(LayerLayerTreeHostTest, ChangeHost) { | 1121 TEST_F(LayerLayerTreeHostTest, ChangeHost) { |
| 1131 scoped_refptr<Layer> parent = Layer::Create(); | 1122 scoped_refptr<Layer> parent = Layer::Create(); |
| 1132 scoped_refptr<Layer> child = Layer::Create(); | 1123 scoped_refptr<Layer> child = Layer::Create(); |
| 1133 scoped_refptr<Layer> mask = Layer::Create(); | 1124 scoped_refptr<Layer> mask = Layer::Create(); |
| 1134 | 1125 |
| 1135 // Same setup as the previous test. | 1126 // Same setup as the previous test. |
| 1136 parent->AddChild(child); | 1127 parent->AddChild(child); |
| 1137 child->SetMaskLayer(mask.get()); | 1128 child->SetMaskLayer(mask.get()); |
| 1138 | 1129 |
| 1139 LayerTreeHostFactory factory; | 1130 LayerTreeHostFactory factory; |
| 1140 auto animation_host1 = AnimationHost::CreateForTesting(ThreadInstance::MAIN); | 1131 auto animation_host1 = AnimationHost::CreateForTesting(ThreadInstance::MAIN); |
| 1141 std::unique_ptr<LayerTreeHost> first_layer_tree_host = | 1132 std::unique_ptr<LayerTreeHost> first_layer_tree_host = |
| 1142 factory.Create(animation_host1.get()); | 1133 factory.Create(animation_host1.get()); |
| 1143 first_layer_tree_host->GetLayerTree()->SetRootLayer(parent.get()); | 1134 first_layer_tree_host->SetRootLayer(parent.get()); |
| 1144 | 1135 |
| 1145 AssertLayerTreeHostMatchesForSubtree(parent.get(), | 1136 AssertLayerTreeHostMatchesForSubtree(parent.get(), |
| 1146 first_layer_tree_host.get()); | 1137 first_layer_tree_host.get()); |
| 1147 | 1138 |
| 1148 // Now re-root the tree to a new host (simulating what we do on a context lost | 1139 // Now re-root the tree to a new host (simulating what we do on a context lost |
| 1149 // event). This should update the host pointers for all layers in the tree. | 1140 // event). This should update the host pointers for all layers in the tree. |
| 1150 auto animation_host2 = AnimationHost::CreateForTesting(ThreadInstance::MAIN); | 1141 auto animation_host2 = AnimationHost::CreateForTesting(ThreadInstance::MAIN); |
| 1151 std::unique_ptr<LayerTreeHost> second_layer_tree_host = | 1142 std::unique_ptr<LayerTreeHost> second_layer_tree_host = |
| 1152 factory.Create(animation_host2.get()); | 1143 factory.Create(animation_host2.get()); |
| 1153 second_layer_tree_host->GetLayerTree()->SetRootLayer(parent.get()); | 1144 second_layer_tree_host->SetRootLayer(parent.get()); |
| 1154 | 1145 |
| 1155 AssertLayerTreeHostMatchesForSubtree(parent.get(), | 1146 AssertLayerTreeHostMatchesForSubtree(parent.get(), |
| 1156 second_layer_tree_host.get()); | 1147 second_layer_tree_host.get()); |
| 1157 | 1148 |
| 1158 second_layer_tree_host->GetLayerTree()->SetRootLayer(nullptr); | 1149 second_layer_tree_host->SetRootLayer(nullptr); |
| 1159 } | 1150 } |
| 1160 | 1151 |
| 1161 TEST_F(LayerLayerTreeHostTest, ChangeHostInSubtree) { | 1152 TEST_F(LayerLayerTreeHostTest, ChangeHostInSubtree) { |
| 1162 scoped_refptr<Layer> first_parent = Layer::Create(); | 1153 scoped_refptr<Layer> first_parent = Layer::Create(); |
| 1163 scoped_refptr<Layer> first_child = Layer::Create(); | 1154 scoped_refptr<Layer> first_child = Layer::Create(); |
| 1164 scoped_refptr<Layer> second_parent = Layer::Create(); | 1155 scoped_refptr<Layer> second_parent = Layer::Create(); |
| 1165 scoped_refptr<Layer> second_child = Layer::Create(); | 1156 scoped_refptr<Layer> second_child = Layer::Create(); |
| 1166 scoped_refptr<Layer> second_grand_child = Layer::Create(); | 1157 scoped_refptr<Layer> second_grand_child = Layer::Create(); |
| 1167 | 1158 |
| 1168 // First put all children under the first parent and set the first host. | 1159 // First put all children under the first parent and set the first host. |
| 1169 first_parent->AddChild(first_child); | 1160 first_parent->AddChild(first_child); |
| 1170 second_child->AddChild(second_grand_child); | 1161 second_child->AddChild(second_grand_child); |
| 1171 first_parent->AddChild(second_child); | 1162 first_parent->AddChild(second_child); |
| 1172 | 1163 |
| 1173 LayerTreeHostFactory factory; | 1164 LayerTreeHostFactory factory; |
| 1174 auto animation_host1 = AnimationHost::CreateForTesting(ThreadInstance::MAIN); | 1165 auto animation_host1 = AnimationHost::CreateForTesting(ThreadInstance::MAIN); |
| 1175 std::unique_ptr<LayerTreeHost> first_layer_tree_host = | 1166 std::unique_ptr<LayerTreeHost> first_layer_tree_host = |
| 1176 factory.Create(animation_host1.get()); | 1167 factory.Create(animation_host1.get()); |
| 1177 first_layer_tree_host->GetLayerTree()->SetRootLayer(first_parent.get()); | 1168 first_layer_tree_host->SetRootLayer(first_parent.get()); |
| 1178 | 1169 |
| 1179 AssertLayerTreeHostMatchesForSubtree(first_parent.get(), | 1170 AssertLayerTreeHostMatchesForSubtree(first_parent.get(), |
| 1180 first_layer_tree_host.get()); | 1171 first_layer_tree_host.get()); |
| 1181 | 1172 |
| 1182 // Now reparent the subtree starting at second_child to a layer in a different | 1173 // Now reparent the subtree starting at second_child to a layer in a different |
| 1183 // tree. | 1174 // tree. |
| 1184 auto animation_host2 = AnimationHost::CreateForTesting(ThreadInstance::MAIN); | 1175 auto animation_host2 = AnimationHost::CreateForTesting(ThreadInstance::MAIN); |
| 1185 std::unique_ptr<LayerTreeHost> second_layer_tree_host = | 1176 std::unique_ptr<LayerTreeHost> second_layer_tree_host = |
| 1186 factory.Create(animation_host2.get()); | 1177 factory.Create(animation_host2.get()); |
| 1187 second_layer_tree_host->GetLayerTree()->SetRootLayer(second_parent.get()); | 1178 second_layer_tree_host->SetRootLayer(second_parent.get()); |
| 1188 | 1179 |
| 1189 second_parent->AddChild(second_child); | 1180 second_parent->AddChild(second_child); |
| 1190 | 1181 |
| 1191 // The moved layer and its children should point to the new host. | 1182 // The moved layer and its children should point to the new host. |
| 1192 EXPECT_EQ(second_layer_tree_host.get(), | 1183 EXPECT_EQ(second_layer_tree_host.get(), |
| 1193 second_child->GetLayerTreeHostForTesting()); | 1184 second_child->GetLayerTreeHostForTesting()); |
| 1194 EXPECT_EQ(second_layer_tree_host.get(), | 1185 EXPECT_EQ(second_layer_tree_host.get(), |
| 1195 second_grand_child->GetLayerTreeHostForTesting()); | 1186 second_grand_child->GetLayerTreeHostForTesting()); |
| 1196 | 1187 |
| 1197 // Test over, cleanup time. | 1188 // Test over, cleanup time. |
| 1198 first_layer_tree_host->GetLayerTree()->SetRootLayer(nullptr); | 1189 first_layer_tree_host->SetRootLayer(nullptr); |
| 1199 second_layer_tree_host->GetLayerTree()->SetRootLayer(nullptr); | 1190 second_layer_tree_host->SetRootLayer(nullptr); |
| 1200 } | 1191 } |
| 1201 | 1192 |
| 1202 TEST_F(LayerLayerTreeHostTest, ReplaceMaskLayer) { | 1193 TEST_F(LayerLayerTreeHostTest, ReplaceMaskLayer) { |
| 1203 scoped_refptr<Layer> parent = Layer::Create(); | 1194 scoped_refptr<Layer> parent = Layer::Create(); |
| 1204 scoped_refptr<Layer> mask = Layer::Create(); | 1195 scoped_refptr<Layer> mask = Layer::Create(); |
| 1205 scoped_refptr<Layer> mask_child = Layer::Create(); | 1196 scoped_refptr<Layer> mask_child = Layer::Create(); |
| 1206 scoped_refptr<Layer> mask_replacement = Layer::Create(); | 1197 scoped_refptr<Layer> mask_replacement = Layer::Create(); |
| 1207 | 1198 |
| 1208 parent->SetMaskLayer(mask.get()); | 1199 parent->SetMaskLayer(mask.get()); |
| 1209 mask->AddChild(mask_child); | 1200 mask->AddChild(mask_child); |
| 1210 | 1201 |
| 1211 LayerTreeHostFactory factory; | 1202 LayerTreeHostFactory factory; |
| 1212 auto animation_host = AnimationHost::CreateForTesting(ThreadInstance::MAIN); | 1203 auto animation_host = AnimationHost::CreateForTesting(ThreadInstance::MAIN); |
| 1213 std::unique_ptr<LayerTreeHost> layer_tree_host = | 1204 std::unique_ptr<LayerTreeHost> layer_tree_host = |
| 1214 factory.Create(animation_host.get()); | 1205 factory.Create(animation_host.get()); |
| 1215 layer_tree_host->GetLayerTree()->SetRootLayer(parent.get()); | 1206 layer_tree_host->SetRootLayer(parent.get()); |
| 1216 | 1207 |
| 1217 AssertLayerTreeHostMatchesForSubtree(parent.get(), layer_tree_host.get()); | 1208 AssertLayerTreeHostMatchesForSubtree(parent.get(), layer_tree_host.get()); |
| 1218 | 1209 |
| 1219 // Replacing the mask should clear out the old mask's subtree's host pointers. | 1210 // Replacing the mask should clear out the old mask's subtree's host pointers. |
| 1220 parent->SetMaskLayer(mask_replacement.get()); | 1211 parent->SetMaskLayer(mask_replacement.get()); |
| 1221 EXPECT_EQ(nullptr, mask->GetLayerTreeHostForTesting()); | 1212 EXPECT_EQ(nullptr, mask->GetLayerTreeHostForTesting()); |
| 1222 EXPECT_EQ(nullptr, mask_child->GetLayerTreeHostForTesting()); | 1213 EXPECT_EQ(nullptr, mask_child->GetLayerTreeHostForTesting()); |
| 1223 | 1214 |
| 1224 // Test over, cleanup time. | 1215 // Test over, cleanup time. |
| 1225 layer_tree_host->GetLayerTree()->SetRootLayer(nullptr); | 1216 layer_tree_host->SetRootLayer(nullptr); |
| 1226 } | 1217 } |
| 1227 | 1218 |
| 1228 TEST_F(LayerLayerTreeHostTest, DestroyHostWithNonNullRootLayer) { | 1219 TEST_F(LayerLayerTreeHostTest, DestroyHostWithNonNullRootLayer) { |
| 1229 scoped_refptr<Layer> root = Layer::Create(); | 1220 scoped_refptr<Layer> root = Layer::Create(); |
| 1230 scoped_refptr<Layer> child = Layer::Create(); | 1221 scoped_refptr<Layer> child = Layer::Create(); |
| 1231 root->AddChild(child); | 1222 root->AddChild(child); |
| 1232 LayerTreeHostFactory factory; | 1223 LayerTreeHostFactory factory; |
| 1233 auto animation_host = AnimationHost::CreateForTesting(ThreadInstance::MAIN); | 1224 auto animation_host = AnimationHost::CreateForTesting(ThreadInstance::MAIN); |
| 1234 std::unique_ptr<LayerTreeHost> layer_tree_host = | 1225 std::unique_ptr<LayerTreeHost> layer_tree_host = |
| 1235 factory.Create(animation_host.get()); | 1226 factory.Create(animation_host.get()); |
| 1236 layer_tree_host->GetLayerTree()->SetRootLayer(root); | 1227 layer_tree_host->SetRootLayer(root); |
| 1237 } | 1228 } |
| 1238 | 1229 |
| 1239 TEST_F(LayerTest, SafeOpaqueBackgroundColor) { | 1230 TEST_F(LayerTest, SafeOpaqueBackgroundColor) { |
| 1240 LayerTreeHostFactory factory; | 1231 LayerTreeHostFactory factory; |
| 1241 auto animation_host = AnimationHost::CreateForTesting(ThreadInstance::MAIN); | 1232 auto animation_host = AnimationHost::CreateForTesting(ThreadInstance::MAIN); |
| 1242 std::unique_ptr<LayerTreeHost> layer_tree_host = | 1233 std::unique_ptr<LayerTreeHost> layer_tree_host = |
| 1243 factory.Create(animation_host.get()); | 1234 factory.Create(animation_host.get()); |
| 1244 LayerTree* layer_tree = layer_tree_host->GetLayerTree(); | |
| 1245 | 1235 |
| 1246 scoped_refptr<Layer> layer = Layer::Create(); | 1236 scoped_refptr<Layer> layer = Layer::Create(); |
| 1247 layer_tree->SetRootLayer(layer); | 1237 layer_tree_host->SetRootLayer(layer); |
| 1248 | 1238 |
| 1249 for (int contents_opaque = 0; contents_opaque < 2; ++contents_opaque) { | 1239 for (int contents_opaque = 0; contents_opaque < 2; ++contents_opaque) { |
| 1250 for (int layer_opaque = 0; layer_opaque < 2; ++layer_opaque) { | 1240 for (int layer_opaque = 0; layer_opaque < 2; ++layer_opaque) { |
| 1251 for (int host_opaque = 0; host_opaque < 2; ++host_opaque) { | 1241 for (int host_opaque = 0; host_opaque < 2; ++host_opaque) { |
| 1252 layer->SetContentsOpaque(!!contents_opaque); | 1242 layer->SetContentsOpaque(!!contents_opaque); |
| 1253 layer->SetBackgroundColor(layer_opaque ? SK_ColorRED | 1243 layer->SetBackgroundColor(layer_opaque ? SK_ColorRED |
| 1254 : SK_ColorTRANSPARENT); | 1244 : SK_ColorTRANSPARENT); |
| 1255 layer_tree->set_background_color(host_opaque ? SK_ColorRED | 1245 layer_tree_host->set_background_color( |
| 1256 : SK_ColorTRANSPARENT); | 1246 host_opaque ? SK_ColorRED : SK_ColorTRANSPARENT); |
| 1257 | 1247 |
| 1258 layer_tree->property_trees()->needs_rebuild = true; | 1248 layer_tree_host->property_trees()->needs_rebuild = true; |
| 1259 layer_tree_host->GetLayerTree()->BuildPropertyTreesForTesting(); | 1249 layer_tree_host->BuildPropertyTreesForTesting(); |
| 1260 SkColor safe_color = layer->SafeOpaqueBackgroundColor(); | 1250 SkColor safe_color = layer->SafeOpaqueBackgroundColor(); |
| 1261 if (contents_opaque) { | 1251 if (contents_opaque) { |
| 1262 EXPECT_EQ(SkColorGetA(safe_color), 255u) | 1252 EXPECT_EQ(SkColorGetA(safe_color), 255u) |
| 1263 << "Flags: " << contents_opaque << ", " << layer_opaque << ", " | 1253 << "Flags: " << contents_opaque << ", " << layer_opaque << ", " |
| 1264 << host_opaque << "\n"; | 1254 << host_opaque << "\n"; |
| 1265 } else { | 1255 } else { |
| 1266 EXPECT_NE(SkColorGetA(safe_color), 255u) | 1256 EXPECT_NE(SkColorGetA(safe_color), 255u) |
| 1267 << "Flags: " << contents_opaque << ", " << layer_opaque << ", " | 1257 << "Flags: " << contents_opaque << ", " << layer_opaque << ", " |
| 1268 << host_opaque << "\n"; | 1258 << host_opaque << "\n"; |
| 1269 } | 1259 } |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1381 // When the layer is destroyed, the other three requests should be aborted. | 1371 // When the layer is destroyed, the other three requests should be aborted. |
| 1382 layer = nullptr; | 1372 layer = nullptr; |
| 1383 EXPECT_EQ(1, did_receive_first_result_from_this_source); | 1373 EXPECT_EQ(1, did_receive_first_result_from_this_source); |
| 1384 EXPECT_EQ(1, did_receive_result_from_different_source); | 1374 EXPECT_EQ(1, did_receive_result_from_different_source); |
| 1385 EXPECT_EQ(1, did_receive_result_from_anonymous_source); | 1375 EXPECT_EQ(1, did_receive_result_from_anonymous_source); |
| 1386 EXPECT_EQ(1, did_receive_second_result_from_this_source); | 1376 EXPECT_EQ(1, did_receive_second_result_from_this_source); |
| 1387 } | 1377 } |
| 1388 | 1378 |
| 1389 TEST_F(LayerTest, AnimationSchedulesLayerUpdate) { | 1379 TEST_F(LayerTest, AnimationSchedulesLayerUpdate) { |
| 1390 scoped_refptr<Layer> layer = Layer::Create(); | 1380 scoped_refptr<Layer> layer = Layer::Create(); |
| 1391 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(layer)); | 1381 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(layer)); |
| 1392 | 1382 |
| 1393 LayerInternalsForTest layer_internals(layer.get()); | 1383 LayerInternalsForTest layer_internals(layer.get()); |
| 1394 | 1384 |
| 1395 EXPECT_CALL(*layer_tree_host_, SetNeedsUpdateLayers()).Times(1); | 1385 EXPECT_CALL(*layer_tree_host_, SetNeedsUpdateLayers()).Times(1); |
| 1396 layer_internals.OnOpacityAnimated(0.5f); | 1386 layer_internals.OnOpacityAnimated(0.5f); |
| 1397 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 1387 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
| 1398 | 1388 |
| 1399 EXPECT_CALL(*layer_tree_host_, SetNeedsUpdateLayers()).Times(1); | 1389 EXPECT_CALL(*layer_tree_host_, SetNeedsUpdateLayers()).Times(1); |
| 1400 gfx::Transform transform; | 1390 gfx::Transform transform; |
| 1401 transform.Rotate(45.0); | 1391 transform.Rotate(45.0); |
| 1402 layer_internals.OnTransformAnimated(transform); | 1392 layer_internals.OnTransformAnimated(transform); |
| 1403 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 1393 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
| 1404 | 1394 |
| 1405 // Scroll offset animation should not schedule a layer update since it is | 1395 // Scroll offset animation should not schedule a layer update since it is |
| 1406 // handled similarly to normal compositor scroll updates. | 1396 // handled similarly to normal compositor scroll updates. |
| 1407 EXPECT_CALL(*layer_tree_host_, SetNeedsUpdateLayers()).Times(0); | 1397 EXPECT_CALL(*layer_tree_host_, SetNeedsUpdateLayers()).Times(0); |
| 1408 layer_internals.OnScrollOffsetAnimated(gfx::ScrollOffset(10, 10)); | 1398 layer_internals.OnScrollOffsetAnimated(gfx::ScrollOffset(10, 10)); |
| 1409 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 1399 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
| 1410 } | 1400 } |
| 1411 | 1401 |
| 1412 TEST_F(LayerTest, ElementIdAndMutablePropertiesArePushed) { | 1402 TEST_F(LayerTest, ElementIdAndMutablePropertiesArePushed) { |
| 1413 scoped_refptr<Layer> test_layer = Layer::Create(); | 1403 scoped_refptr<Layer> test_layer = Layer::Create(); |
| 1414 std::unique_ptr<LayerImpl> impl_layer = | 1404 std::unique_ptr<LayerImpl> impl_layer = |
| 1415 LayerImpl::Create(host_impl_.active_tree(), 1); | 1405 LayerImpl::Create(host_impl_.active_tree(), 1); |
| 1416 | 1406 |
| 1417 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(test_layer)); | 1407 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, |
| 1408 layer_tree_host_->SetRootLayer(test_layer)); |
| 1418 | 1409 |
| 1419 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(2); | 1410 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(2); |
| 1420 | 1411 |
| 1421 test_layer->SetElementId(ElementId(2, 0)); | 1412 test_layer->SetElementId(ElementId(2, 0)); |
| 1422 test_layer->SetMutableProperties(MutableProperty::kTransform); | 1413 test_layer->SetMutableProperties(MutableProperty::kTransform); |
| 1423 | 1414 |
| 1424 EXPECT_FALSE(impl_layer->element_id()); | 1415 EXPECT_FALSE(impl_layer->element_id()); |
| 1425 EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties()); | 1416 EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties()); |
| 1426 | 1417 |
| 1427 test_layer->PushPropertiesTo(impl_layer.get()); | 1418 test_layer->PushPropertiesTo(impl_layer.get()); |
| 1428 | 1419 |
| 1429 EXPECT_EQ(ElementId(2, 0), impl_layer->element_id()); | 1420 EXPECT_EQ(ElementId(2, 0), impl_layer->element_id()); |
| 1430 EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties()); | 1421 EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties()); |
| 1431 } | 1422 } |
| 1432 | 1423 |
| 1433 } // namespace | 1424 } // namespace |
| 1434 } // namespace cc | 1425 } // namespace cc |
| OLD | NEW |