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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 layer_tree_host_src_->GetLayerTree()->in_paint_layer_contents_ = false; | 85 layer_tree_host_src_->GetLayerTree()->in_paint_layer_contents_ = false; |
86 layer_tree_host_dst_->GetLayerTree()->in_paint_layer_contents_ = false; | 86 layer_tree_host_dst_->GetLayerTree()->in_paint_layer_contents_ = false; |
87 | 87 |
88 // Need to reset LayerTreeHost pointers before tear down. | 88 // Need to reset LayerTreeHost pointers before tear down. |
89 layer_tree_host_src_ = nullptr; | 89 layer_tree_host_src_ = nullptr; |
90 layer_tree_host_dst_ = nullptr; | 90 layer_tree_host_dst_ = nullptr; |
91 } | 91 } |
92 | 92 |
93 void VerifyHostHasAllExpectedLayersInTree(Layer* root_layer) { | 93 void VerifyHostHasAllExpectedLayersInTree(Layer* root_layer) { |
94 LayerTreeHostCommon::CallFunctionForEveryLayer( | 94 LayerTreeHostCommon::CallFunctionForEveryLayer( |
95 root_layer->layer_tree_host(), [root_layer](Layer* layer) { | 95 root_layer->GetLayerTree(), [root_layer](Layer* layer) { |
96 DCHECK(layer->layer_tree_host()); | 96 DCHECK(layer->layer_tree_host()); |
97 EXPECT_EQ(layer, layer->layer_tree_host()->LayerById(layer->id())); | 97 EXPECT_EQ(layer, layer->GetLayerTree()->LayerById(layer->id())); |
98 }); | 98 }); |
99 } | 99 } |
100 | 100 |
101 void VerifySerializationAndDeserialization() { | 101 void VerifySerializationAndDeserialization() { |
102 proto::LayerTreeHost proto; | 102 proto::LayerTreeHost proto; |
103 LayerTree* layer_tree_src = layer_tree_host_src_->GetLayerTree(); | 103 LayerTree* layer_tree_src = layer_tree_host_src_->GetLayerTree(); |
104 LayerTree* layer_tree_dst = layer_tree_host_dst_->GetLayerTree(); | 104 LayerTree* layer_tree_dst = layer_tree_host_dst_->GetLayerTree(); |
105 | 105 |
106 std::unordered_set<Layer*> layers_that_should_push_properties_src = | 106 std::unordered_set<Layer*> layers_that_should_push_properties_src = |
107 layer_tree_src->LayersThatShouldPushProperties(); | 107 layer_tree_src->LayersThatShouldPushProperties(); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 EXPECT_EQ(layer_tree_src->property_trees_, layer_tree_dst->property_trees_); | 211 EXPECT_EQ(layer_tree_src->property_trees_, layer_tree_dst->property_trees_); |
212 EXPECT_EQ(layer_tree_host_src_->surface_client_id_, | 212 EXPECT_EQ(layer_tree_host_src_->surface_client_id_, |
213 layer_tree_host_dst_->surface_client_id_); | 213 layer_tree_host_dst_->surface_client_id_); |
214 EXPECT_EQ(layer_tree_host_src_->next_surface_sequence_, | 214 EXPECT_EQ(layer_tree_host_src_->next_surface_sequence_, |
215 layer_tree_host_dst_->next_surface_sequence_); | 215 layer_tree_host_dst_->next_surface_sequence_); |
216 | 216 |
217 // All layers must have a property tree index that matches PropertyTrees. | 217 // All layers must have a property tree index that matches PropertyTrees. |
218 if (layer_tree_dst->property_trees_.sequence_number) { | 218 if (layer_tree_dst->property_trees_.sequence_number) { |
219 int seq_num = layer_tree_dst->property_trees_.sequence_number; | 219 int seq_num = layer_tree_dst->property_trees_.sequence_number; |
220 LayerTreeHostCommon::CallFunctionForEveryLayer( | 220 LayerTreeHostCommon::CallFunctionForEveryLayer( |
221 layer_tree_host_dst_.get(), [seq_num](Layer* layer) { | 221 layer_tree_host_dst_->GetLayerTree(), [seq_num](Layer* layer) { |
222 EXPECT_EQ(seq_num, layer->property_tree_sequence_number()); | 222 EXPECT_EQ(seq_num, layer->property_tree_sequence_number()); |
223 }); | 223 }); |
224 } | 224 } |
225 } | 225 } |
226 | 226 |
227 void RunAllMembersChangedTest() { | 227 void RunAllMembersChangedTest() { |
228 LayerTree* layer_tree_src = layer_tree_host_src_->GetLayerTree(); | 228 LayerTree* layer_tree_src = layer_tree_host_src_->GetLayerTree(); |
229 | 229 |
230 layer_tree_src->needs_full_tree_sync_ = | 230 layer_tree_src->needs_full_tree_sync_ = |
231 !layer_tree_src->needs_full_tree_sync_; | 231 !layer_tree_src->needs_full_tree_sync_; |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 | 463 |
464 TEST_F(LayerTreeHostSerializationTest, AddAndRemoveNodeFromLayerTree) { | 464 TEST_F(LayerTreeHostSerializationTest, AddAndRemoveNodeFromLayerTree) { |
465 RunAddAndRemoveNodeFromLayerTree(); | 465 RunAddAndRemoveNodeFromLayerTree(); |
466 } | 466 } |
467 | 467 |
468 TEST_F(LayerTreeHostSerializationTest, PictureLayerMultipleSerializations) { | 468 TEST_F(LayerTreeHostSerializationTest, PictureLayerMultipleSerializations) { |
469 RunPictureLayerMultipleSerializationsTest(); | 469 RunPictureLayerMultipleSerializationsTest(); |
470 } | 470 } |
471 | 471 |
472 } // namespace cc | 472 } // namespace cc |
OLD | NEW |