OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/trees/layer_tree_host.h" | 5 #include "cc/trees/layer_tree_host.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "cc/layers/empty_content_layer_client.h" | 10 #include "cc/layers/empty_content_layer_client.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 CompositorMode::SINGLE_THREADED, image_serialization_processor_.get()); | 74 CompositorMode::SINGLE_THREADED, image_serialization_processor_.get()); |
75 layer_tree_host_dst_ = FakeLayerTreeHost::Create( | 75 layer_tree_host_dst_ = FakeLayerTreeHost::Create( |
76 &client_dst_, &task_graph_runner_dst_, settings, | 76 &client_dst_, &task_graph_runner_dst_, settings, |
77 CompositorMode::SINGLE_THREADED, image_serialization_processor_.get()); | 77 CompositorMode::SINGLE_THREADED, image_serialization_processor_.get()); |
78 layer_tree_host_src_->InitializePictureCacheForTesting(); | 78 layer_tree_host_src_->InitializePictureCacheForTesting(); |
79 layer_tree_host_dst_->InitializePictureCacheForTesting(); | 79 layer_tree_host_dst_->InitializePictureCacheForTesting(); |
80 } | 80 } |
81 | 81 |
82 void TearDown() override { | 82 void TearDown() override { |
83 // Need to reset |in_paint_layer_contents_| to tear down. | 83 // Need to reset |in_paint_layer_contents_| to tear down. |
84 layer_tree_host_src_->in_paint_layer_contents_ = false; | 84 |
85 layer_tree_host_dst_->in_paint_layer_contents_ = false; | 85 layer_tree_host_src_->GetLayerTree()->set_in_paint_layer_contents(false); |
| 86 layer_tree_host_dst_->GetLayerTree()->set_in_paint_layer_contents(false); |
86 | 87 |
87 // Need to reset LayerTreeHost pointers before tear down. | 88 // Need to reset LayerTreeHost pointers before tear down. |
88 layer_tree_host_src_ = nullptr; | 89 layer_tree_host_src_ = nullptr; |
89 layer_tree_host_dst_ = nullptr; | 90 layer_tree_host_dst_ = nullptr; |
90 } | 91 } |
91 | 92 |
92 void VerifyHostHasAllExpectedLayersInTree(Layer* root_layer) { | 93 void VerifyHostHasAllExpectedLayersInTree(Layer* root_layer) { |
93 LayerTreeHostCommon::CallFunctionForEveryLayer( | 94 LayerTreeHostCommon::CallFunctionForEveryLayer( |
94 root_layer->layer_tree_host(), [root_layer](Layer* layer) { | 95 root_layer->layer_tree_host(), [root_layer](Layer* layer) { |
95 DCHECK(layer->layer_tree_host()); | 96 DCHECK(layer->layer_tree_host()); |
96 EXPECT_EQ(layer, layer->layer_tree_host()->LayerById(layer->id())); | 97 EXPECT_EQ(layer, layer->layer_tree_host()->LayerById(layer->id())); |
97 }); | 98 }); |
98 } | 99 } |
99 | 100 |
100 void VerifySerializationAndDeserialization() { | 101 void VerifySerializationAndDeserialization() { |
101 proto::LayerTreeHost proto; | 102 proto::LayerTreeHost proto; |
| 103 LayerTree* layer_tree_src = layer_tree_host_src_->GetLayerTree(); |
| 104 LayerTree* layer_tree_dst = layer_tree_host_dst_->GetLayerTree(); |
102 | 105 |
103 std::unordered_set<Layer*> layers_that_should_push_properties_src = | 106 std::unordered_set<Layer*> layers_that_should_push_properties_src = |
104 layer_tree_host_src_->LayersThatShouldPushProperties(); | 107 layer_tree_src->LayersThatShouldPushProperties(); |
105 std::vector<std::unique_ptr<SwapPromise>> swap_promises; | 108 std::vector<std::unique_ptr<SwapPromise>> swap_promises; |
106 layer_tree_host_src_->ToProtobufForCommit(&proto, &swap_promises); | 109 layer_tree_host_src_->ToProtobufForCommit(&proto, &swap_promises); |
107 layer_tree_host_dst_->FromProtobufForCommit(proto); | 110 layer_tree_host_dst_->FromProtobufForCommit(proto); |
108 | 111 |
109 EXPECT_EQ(layer_tree_host_src_->needs_full_tree_sync_, | 112 EXPECT_EQ(layer_tree_host_src_->needs_full_tree_sync_, |
110 layer_tree_host_dst_->needs_full_tree_sync_); | 113 layer_tree_host_dst_->needs_full_tree_sync_); |
111 EXPECT_EQ(layer_tree_host_src_->needs_meta_info_recomputation_, | 114 EXPECT_EQ(layer_tree_host_src_->needs_meta_info_recomputation_, |
112 layer_tree_host_dst_->needs_meta_info_recomputation_); | 115 layer_tree_host_dst_->needs_meta_info_recomputation_); |
113 EXPECT_EQ(layer_tree_host_src_->source_frame_number_, | 116 EXPECT_EQ(layer_tree_host_src_->source_frame_number_, |
114 layer_tree_host_dst_->source_frame_number_); | 117 layer_tree_host_dst_->source_frame_number_); |
(...skipping 27 matching lines...) Expand all Loading... |
142 EXPECT_EQ(layer_tree_host_src_->elastic_overscroll_, | 145 EXPECT_EQ(layer_tree_host_src_->elastic_overscroll_, |
143 layer_tree_host_dst_->elastic_overscroll_); | 146 layer_tree_host_dst_->elastic_overscroll_); |
144 EXPECT_EQ(layer_tree_host_src_->has_gpu_rasterization_trigger_, | 147 EXPECT_EQ(layer_tree_host_src_->has_gpu_rasterization_trigger_, |
145 layer_tree_host_dst_->has_gpu_rasterization_trigger_); | 148 layer_tree_host_dst_->has_gpu_rasterization_trigger_); |
146 EXPECT_EQ(layer_tree_host_src_->content_is_suitable_for_gpu_rasterization_, | 149 EXPECT_EQ(layer_tree_host_src_->content_is_suitable_for_gpu_rasterization_, |
147 layer_tree_host_dst_->content_is_suitable_for_gpu_rasterization_); | 150 layer_tree_host_dst_->content_is_suitable_for_gpu_rasterization_); |
148 EXPECT_EQ(layer_tree_host_src_->background_color_, | 151 EXPECT_EQ(layer_tree_host_src_->background_color_, |
149 layer_tree_host_dst_->background_color_); | 152 layer_tree_host_dst_->background_color_); |
150 EXPECT_EQ(layer_tree_host_src_->has_transparent_background_, | 153 EXPECT_EQ(layer_tree_host_src_->has_transparent_background_, |
151 layer_tree_host_dst_->has_transparent_background_); | 154 layer_tree_host_dst_->has_transparent_background_); |
152 EXPECT_EQ(layer_tree_host_src_->in_paint_layer_contents_, | 155 EXPECT_EQ(layer_tree_src->in_paint_layer_contents(), |
153 layer_tree_host_dst_->in_paint_layer_contents_); | 156 layer_tree_dst->in_paint_layer_contents()); |
154 EXPECT_EQ(layer_tree_host_src_->id_, layer_tree_host_dst_->id_); | 157 EXPECT_EQ(layer_tree_host_src_->id_, layer_tree_host_dst_->id_); |
155 EXPECT_EQ(layer_tree_host_src_->next_commit_forces_redraw_, | 158 EXPECT_EQ(layer_tree_host_src_->next_commit_forces_redraw_, |
156 layer_tree_host_dst_->next_commit_forces_redraw_); | 159 layer_tree_host_dst_->next_commit_forces_redraw_); |
157 for (auto layer : layers_that_should_push_properties_src) { | 160 for (auto layer : layers_that_should_push_properties_src) { |
158 EXPECT_TRUE(layer_tree_host_dst_->LayerNeedsPushPropertiesForTesting( | 161 EXPECT_TRUE(layer_tree_host_dst_->LayerNeedsPushPropertiesForTesting( |
159 layer_tree_host_dst_->LayerById(layer->id()))); | 162 layer_tree_host_dst_->LayerById(layer->id()))); |
160 } | 163 } |
161 | 164 |
162 if (layer_tree_host_src_->hud_layer_) { | 165 if (layer_tree_host_src_->hud_layer_) { |
163 EXPECT_EQ(layer_tree_host_src_->hud_layer_->id(), | 166 EXPECT_EQ(layer_tree_host_src_->hud_layer_->id(), |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 root_layer_src->AddChild(layer_tree_host_src_->page_scale_layer_); | 277 root_layer_src->AddChild(layer_tree_host_src_->page_scale_layer_); |
275 layer_tree_host_src_->inner_viewport_scroll_layer_ = Layer::Create(); | 278 layer_tree_host_src_->inner_viewport_scroll_layer_ = Layer::Create(); |
276 root_layer_src->AddChild( | 279 root_layer_src->AddChild( |
277 layer_tree_host_src_->inner_viewport_scroll_layer_); | 280 layer_tree_host_src_->inner_viewport_scroll_layer_); |
278 layer_tree_host_src_->outer_viewport_scroll_layer_ = Layer::Create(); | 281 layer_tree_host_src_->outer_viewport_scroll_layer_ = Layer::Create(); |
279 root_layer_src->AddChild( | 282 root_layer_src->AddChild( |
280 layer_tree_host_src_->outer_viewport_scroll_layer_); | 283 layer_tree_host_src_->outer_viewport_scroll_layer_); |
281 | 284 |
282 // Set in_paint_layer_contents_ only after all calls to AddChild() have | 285 // Set in_paint_layer_contents_ only after all calls to AddChild() have |
283 // finished to ensure it's allowed to do so at that time. | 286 // finished to ensure it's allowed to do so at that time. |
284 layer_tree_host_src_->in_paint_layer_contents_ = | 287 LayerTree* layer_tree_src = layer_tree_host_src_->GetLayerTree(); |
285 !layer_tree_host_src_->in_paint_layer_contents_; | 288 layer_tree_src->set_in_paint_layer_contents( |
| 289 layer_tree_src->in_paint_layer_contents()); |
286 | 290 |
287 LayerSelectionBound sel_bound; | 291 LayerSelectionBound sel_bound; |
288 sel_bound.edge_top = gfx::Point(14, 3); | 292 sel_bound.edge_top = gfx::Point(14, 3); |
289 LayerSelection selection; | 293 LayerSelection selection; |
290 selection.start = sel_bound; | 294 selection.start = sel_bound; |
291 layer_tree_host_src_->selection_ = selection; | 295 layer_tree_host_src_->selection_ = selection; |
292 | 296 |
293 layer_tree_host_src_->property_trees_.sequence_number = | 297 layer_tree_host_src_->property_trees_.sequence_number = |
294 layer_tree_host_src_->property_trees_.sequence_number * 3 + 1; | 298 layer_tree_host_src_->property_trees_.sequence_number * 3 + 1; |
295 | 299 |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 | 451 |
448 TEST_F(LayerTreeHostSerializationTest, AddAndRemoveNodeFromLayerTree) { | 452 TEST_F(LayerTreeHostSerializationTest, AddAndRemoveNodeFromLayerTree) { |
449 RunAddAndRemoveNodeFromLayerTree(); | 453 RunAddAndRemoveNodeFromLayerTree(); |
450 } | 454 } |
451 | 455 |
452 TEST_F(LayerTreeHostSerializationTest, PictureLayerMultipleSerializations) { | 456 TEST_F(LayerTreeHostSerializationTest, PictureLayerMultipleSerializations) { |
453 RunPictureLayerMultipleSerializationsTest(); | 457 RunPictureLayerMultipleSerializationsTest(); |
454 } | 458 } |
455 | 459 |
456 } // namespace cc | 460 } // namespace cc |
OLD | NEW |