Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(305)

Side by Side Diff: cc/trees/layer_tree_host_unittest_serialization.cc

Issue 1907053004: cc: Make CallFunctionForEveryLayer use LayerListIterator (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: FindLayers should skip layers instead of returning when switching from call-function to iteration l… Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/trees/layer_tree_host_unittest.cc ('k') | cc/trees/layer_tree_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "cc/layers/heads_up_display_layer.h" 7 #include "cc/layers/heads_up_display_layer.h"
8 #include "cc/layers/layer.h" 8 #include "cc/layers/layer.h"
9 #include "cc/proto/layer.pb.h" 9 #include "cc/proto/layer.pb.h"
10 #include "cc/proto/layer_tree_host.pb.h" 10 #include "cc/proto/layer_tree_host.pb.h"
(...skipping 29 matching lines...) Expand all
40 layer_tree_host_src_->in_paint_layer_contents_ = false; 40 layer_tree_host_src_->in_paint_layer_contents_ = false;
41 layer_tree_host_dst_->in_paint_layer_contents_ = false; 41 layer_tree_host_dst_->in_paint_layer_contents_ = false;
42 42
43 // Need to reset LayerTreeHost pointers before tear down. 43 // Need to reset LayerTreeHost pointers before tear down.
44 layer_tree_host_src_ = nullptr; 44 layer_tree_host_src_ = nullptr;
45 layer_tree_host_dst_ = nullptr; 45 layer_tree_host_dst_ = nullptr;
46 } 46 }
47 47
48 void VerifyHostHasAllExpectedLayersInTree(Layer* root_layer) { 48 void VerifyHostHasAllExpectedLayersInTree(Layer* root_layer) {
49 LayerTreeHostCommon::CallFunctionForEveryLayer( 49 LayerTreeHostCommon::CallFunctionForEveryLayer(
50 root_layer->layer_tree_host(), 50 root_layer->layer_tree_host(), [root_layer](Layer* layer) {
51 [root_layer](Layer* layer) {
52 DCHECK(layer->layer_tree_host()); 51 DCHECK(layer->layer_tree_host());
53 EXPECT_EQ(layer, layer->layer_tree_host()->LayerById(layer->id())); 52 EXPECT_EQ(layer, layer->layer_tree_host()->LayerById(layer->id()));
54 }, 53 });
55 CallFunctionLayerType::ALL_LAYERS);
56 } 54 }
57 55
58 void VerifySerializationAndDeserialization() { 56 void VerifySerializationAndDeserialization() {
59 proto::LayerTreeHost proto; 57 proto::LayerTreeHost proto;
60 58
61 std::unordered_set<Layer*> layers_that_should_push_properties_src = 59 std::unordered_set<Layer*> layers_that_should_push_properties_src =
62 layer_tree_host_src_->LayersThatShouldPushProperties(); 60 layer_tree_host_src_->LayersThatShouldPushProperties();
63 layer_tree_host_src_->ToProtobufForCommit(&proto); 61 layer_tree_host_src_->ToProtobufForCommit(&proto);
64 layer_tree_host_dst_->FromProtobufForCommit(proto); 62 layer_tree_host_dst_->FromProtobufForCommit(proto);
65 63
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 layer_tree_host_dst_->property_trees_); 165 layer_tree_host_dst_->property_trees_);
168 EXPECT_EQ(layer_tree_host_src_->surface_id_namespace_, 166 EXPECT_EQ(layer_tree_host_src_->surface_id_namespace_,
169 layer_tree_host_dst_->surface_id_namespace_); 167 layer_tree_host_dst_->surface_id_namespace_);
170 EXPECT_EQ(layer_tree_host_src_->next_surface_sequence_, 168 EXPECT_EQ(layer_tree_host_src_->next_surface_sequence_,
171 layer_tree_host_dst_->next_surface_sequence_); 169 layer_tree_host_dst_->next_surface_sequence_);
172 170
173 // All layers must have a property tree index that matches PropertyTrees. 171 // All layers must have a property tree index that matches PropertyTrees.
174 if (layer_tree_host_dst_->property_trees_.sequence_number) { 172 if (layer_tree_host_dst_->property_trees_.sequence_number) {
175 int seq_num = layer_tree_host_dst_->property_trees_.sequence_number; 173 int seq_num = layer_tree_host_dst_->property_trees_.sequence_number;
176 LayerTreeHostCommon::CallFunctionForEveryLayer( 174 LayerTreeHostCommon::CallFunctionForEveryLayer(
177 layer_tree_host_dst_.get(), 175 layer_tree_host_dst_.get(), [seq_num](Layer* layer) {
178 [seq_num](Layer* layer) {
179 EXPECT_EQ(seq_num, layer->property_tree_sequence_number()); 176 EXPECT_EQ(seq_num, layer->property_tree_sequence_number());
180 }, 177 });
181 CallFunctionLayerType::ALL_LAYERS);
182 } 178 }
183 } 179 }
184 180
185 void RunAllMembersChangedTest() { 181 void RunAllMembersChangedTest() {
186 layer_tree_host_src_->needs_full_tree_sync_ = 182 layer_tree_host_src_->needs_full_tree_sync_ =
187 !layer_tree_host_src_->needs_full_tree_sync_; 183 !layer_tree_host_src_->needs_full_tree_sync_;
188 layer_tree_host_src_->needs_meta_info_recomputation_ = 184 layer_tree_host_src_->needs_meta_info_recomputation_ =
189 !layer_tree_host_src_->needs_meta_info_recomputation_; 185 !layer_tree_host_src_->needs_meta_info_recomputation_;
190 layer_tree_host_src_->source_frame_number_ *= 3; 186 layer_tree_host_src_->source_frame_number_ *= 3;
191 layer_tree_host_src_->meta_information_sequence_number_ *= 3; 187 layer_tree_host_src_->meta_information_sequence_number_ *= 3;
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 366
371 TEST_F(LayerTreeHostSerializationTest, LayersChangedMultipleSerializations) { 367 TEST_F(LayerTreeHostSerializationTest, LayersChangedMultipleSerializations) {
372 RunLayersChangedMultipleSerializations(); 368 RunLayersChangedMultipleSerializations();
373 } 369 }
374 370
375 TEST_F(LayerTreeHostSerializationTest, AddAndRemoveNodeFromLayerTree) { 371 TEST_F(LayerTreeHostSerializationTest, AddAndRemoveNodeFromLayerTree) {
376 RunAddAndRemoveNodeFromLayerTree(); 372 RunAddAndRemoveNodeFromLayerTree();
377 } 373 }
378 374
379 } // namespace cc 375 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_unittest.cc ('k') | cc/trees/layer_tree_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698