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

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

Issue 2183403002: cc: Move data to LayerTree from LayerTreeHost. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@layer_tree_change
Patch Set: .. Created 4 years, 4 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
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 <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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 EXPECT_EQ(proto::LayerNode::HEADS_UP_DISPLAY_LAYER, 174 EXPECT_EQ(proto::LayerNode::HEADS_UP_DISPLAY_LAYER,
175 proto.root_layer().children(i).type()); 175 proto.root_layer().children(i).type());
176 found_hud_layer_type = true; 176 found_hud_layer_type = true;
177 break; 177 break;
178 } 178 }
179 } 179 }
180 EXPECT_TRUE(found_hud_layer_type); 180 EXPECT_TRUE(found_hud_layer_type);
181 } else { 181 } else {
182 EXPECT_FALSE(layer_tree_host_dst_->hud_layer_); 182 EXPECT_FALSE(layer_tree_host_dst_->hud_layer_);
183 } 183 }
184 if (layer_tree_host_src_->overscroll_elasticity_layer_) { 184 if (layer_tree_src->overscroll_elasticity_layer()) {
185 EXPECT_EQ(layer_tree_host_src_->overscroll_elasticity_layer_->id(), 185 EXPECT_EQ(layer_tree_src->overscroll_elasticity_layer()->id(),
186 layer_tree_host_dst_->overscroll_elasticity_layer_->id()); 186 layer_tree_dst->overscroll_elasticity_layer()->id());
187 } else { 187 } else {
188 EXPECT_FALSE(layer_tree_host_dst_->overscroll_elasticity_layer_); 188 EXPECT_FALSE(layer_tree_dst->overscroll_elasticity_layer());
189 } 189 }
190 if (layer_tree_host_src_->page_scale_layer_) { 190 if (layer_tree_src->page_scale_layer()) {
191 EXPECT_EQ(layer_tree_host_src_->page_scale_layer_->id(), 191 EXPECT_EQ(layer_tree_src->page_scale_layer()->id(),
192 layer_tree_host_dst_->page_scale_layer_->id()); 192 layer_tree_dst->page_scale_layer()->id());
193 } else { 193 } else {
194 EXPECT_FALSE(layer_tree_host_dst_->page_scale_layer_); 194 EXPECT_FALSE(layer_tree_dst->page_scale_layer());
195 } 195 }
196 if (layer_tree_host_src_->inner_viewport_scroll_layer_) { 196 if (layer_tree_src->inner_viewport_scroll_layer()) {
197 EXPECT_EQ(layer_tree_host_src_->inner_viewport_scroll_layer_->id(), 197 EXPECT_EQ(layer_tree_src->inner_viewport_scroll_layer()->id(),
198 layer_tree_host_dst_->inner_viewport_scroll_layer_->id()); 198 layer_tree_dst->inner_viewport_scroll_layer()->id());
199 } else { 199 } else {
200 EXPECT_FALSE(layer_tree_host_dst_->inner_viewport_scroll_layer_); 200 EXPECT_FALSE(layer_tree_dst->inner_viewport_scroll_layer());
201 } 201 }
202 if (layer_tree_host_src_->outer_viewport_scroll_layer_) { 202 if (layer_tree_src->outer_viewport_scroll_layer()) {
203 EXPECT_EQ(layer_tree_host_src_->outer_viewport_scroll_layer_->id(), 203 EXPECT_EQ(layer_tree_src->outer_viewport_scroll_layer()->id(),
204 layer_tree_host_dst_->outer_viewport_scroll_layer_->id()); 204 layer_tree_dst->outer_viewport_scroll_layer()->id());
205 } else { 205 } else {
206 EXPECT_FALSE(layer_tree_host_dst_->outer_viewport_scroll_layer_); 206 EXPECT_FALSE(layer_tree_dst->outer_viewport_scroll_layer());
207 } 207 }
208 EXPECT_EQ(layer_tree_host_src_->selection_, 208 EXPECT_EQ(layer_tree_host_src_->selection_,
209 layer_tree_host_dst_->selection_); 209 layer_tree_host_dst_->selection_);
210 EXPECT_EQ(layer_tree_host_src_->property_trees_, 210 EXPECT_EQ(layer_tree_host_src_->property_trees_,
211 layer_tree_host_dst_->property_trees_); 211 layer_tree_host_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
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 !layer_tree_host_src_->content_is_suitable_for_gpu_rasterization_; 263 !layer_tree_host_src_->content_is_suitable_for_gpu_rasterization_;
264 layer_tree_host_src_->background_color_ = SK_ColorMAGENTA; 264 layer_tree_host_src_->background_color_ = SK_ColorMAGENTA;
265 layer_tree_host_src_->has_transparent_background_ = 265 layer_tree_host_src_->has_transparent_background_ =
266 !layer_tree_host_src_->has_transparent_background_; 266 !layer_tree_host_src_->has_transparent_background_;
267 layer_tree_host_src_->id_ = layer_tree_host_src_->id_ * 3 + 1; 267 layer_tree_host_src_->id_ = layer_tree_host_src_->id_ * 3 + 1;
268 layer_tree_host_src_->next_commit_forces_redraw_ = 268 layer_tree_host_src_->next_commit_forces_redraw_ =
269 !layer_tree_host_src_->next_commit_forces_redraw_; 269 !layer_tree_host_src_->next_commit_forces_redraw_;
270 270
271 layer_tree_host_src_->hud_layer_ = HeadsUpDisplayLayer::Create(); 271 layer_tree_host_src_->hud_layer_ = HeadsUpDisplayLayer::Create();
272 root_layer_src->AddChild(layer_tree_host_src_->hud_layer_); 272 root_layer_src->AddChild(layer_tree_host_src_->hud_layer_);
273 layer_tree_host_src_->overscroll_elasticity_layer_ = Layer::Create(); 273
274 root_layer_src->AddChild( 274 scoped_refptr<Layer> overscroll_elasticity_layer = Layer::Create();
275 layer_tree_host_src_->overscroll_elasticity_layer_); 275 scoped_refptr<Layer> page_scale_layer = Layer::Create();
276 layer_tree_host_src_->page_scale_layer_ = Layer::Create(); 276 scoped_refptr<Layer> inner_viewport_scroll_layer = Layer::Create();
277 root_layer_src->AddChild(layer_tree_host_src_->page_scale_layer_); 277 scoped_refptr<Layer> outer_viewport_scroll_layer = Layer::Create();
278 layer_tree_host_src_->inner_viewport_scroll_layer_ = Layer::Create(); 278
279 root_layer_src->AddChild( 279 root_layer_src->AddChild(overscroll_elasticity_layer);
280 layer_tree_host_src_->inner_viewport_scroll_layer_); 280 root_layer_src->AddChild(page_scale_layer);
281 layer_tree_host_src_->outer_viewport_scroll_layer_ = Layer::Create(); 281 root_layer_src->AddChild(inner_viewport_scroll_layer);
282 root_layer_src->AddChild( 282 root_layer_src->AddChild(outer_viewport_scroll_layer);
283 layer_tree_host_src_->outer_viewport_scroll_layer_); 283
284 layer_tree_host_src_->GetLayerTree()->RegisterViewportLayers(
285 overscroll_elasticity_layer, page_scale_layer,
286 inner_viewport_scroll_layer, outer_viewport_scroll_layer);
284 287
285 // Set in_paint_layer_contents_ only after all calls to AddChild() have 288 // Set in_paint_layer_contents_ only after all calls to AddChild() have
286 // finished to ensure it's allowed to do so at that time. 289 // finished to ensure it's allowed to do so at that time.
287 LayerTree* layer_tree_src = layer_tree_host_src_->GetLayerTree(); 290 LayerTree* layer_tree_src = layer_tree_host_src_->GetLayerTree();
288 layer_tree_src->in_paint_layer_contents_ = 291 layer_tree_src->in_paint_layer_contents_ =
289 !layer_tree_src->in_paint_layer_contents(); 292 !layer_tree_src->in_paint_layer_contents();
290 293
291 LayerSelectionBound sel_bound; 294 LayerSelectionBound sel_bound;
292 sel_bound.edge_top = gfx::Point(14, 3); 295 sel_bound.edge_top = gfx::Point(14, 3);
293 LayerSelection selection; 296 LayerSelection selection;
(...skipping 13 matching lines...) Expand all
307 310
308 void RunLayersChangedTest() { 311 void RunLayersChangedTest() {
309 // Just fake setup a layer for both source and dest. 312 // Just fake setup a layer for both source and dest.
310 scoped_refptr<Layer> root_layer_src = Layer::Create(); 313 scoped_refptr<Layer> root_layer_src = Layer::Create();
311 layer_tree_host_src_->SetRootLayer(root_layer_src); 314 layer_tree_host_src_->SetRootLayer(root_layer_src);
312 layer_tree_host_dst_->SetRootLayer(Layer::Create()); 315 layer_tree_host_dst_->SetRootLayer(Layer::Create());
313 root_layer_src->SetDoubleSided(!root_layer_src->double_sided()); 316 root_layer_src->SetDoubleSided(!root_layer_src->double_sided());
314 317
315 // No HUD layer or |overscroll_elasticity_layer_|, or the inner/outer 318 // No HUD layer or |overscroll_elasticity_layer_|, or the inner/outer
316 // viewport scroll layers. 319 // viewport scroll layers.
317 layer_tree_host_src_->overscroll_elasticity_layer_ = Layer::Create(); 320 scoped_refptr<Layer> overscroll_elasticity_layer = Layer::Create();
318 root_layer_src->AddChild( 321 layer_tree_host_src_->GetLayerTree()->inputs_.overscroll_elasticity_layer =
319 layer_tree_host_src_->overscroll_elasticity_layer_); 322 overscroll_elasticity_layer;
323 root_layer_src->AddChild(overscroll_elasticity_layer);
320 324
321 VerifySerializationAndDeserialization(); 325 VerifySerializationAndDeserialization();
322 } 326 }
323 327
324 void RunLayersChangedMultipleSerializations() { 328 void RunLayersChangedMultipleSerializations() {
325 // Just fake setup a layer for both source and dest. 329 // Just fake setup a layer for both source and dest.
326 scoped_refptr<Layer> root_layer_src = Layer::Create(); 330 scoped_refptr<Layer> root_layer_src = Layer::Create();
327 layer_tree_host_src_->SetRootLayer(root_layer_src); 331 layer_tree_host_src_->SetRootLayer(root_layer_src);
328 layer_tree_host_dst_->SetRootLayer(Layer::Create()); 332 layer_tree_host_dst_->SetRootLayer(Layer::Create());
329 root_layer_src->SetDoubleSided(!root_layer_src->double_sided()); 333 root_layer_src->SetDoubleSided(!root_layer_src->double_sided());
330 334
331 // Ensure that all the layers work correctly for multiple rounds of 335 // Ensure that all the layers work correctly for multiple rounds of
332 // serialization and deserialization. 336 // serialization and deserialization.
333 layer_tree_host_src_->hud_layer_ = HeadsUpDisplayLayer::Create(); 337 layer_tree_host_src_->hud_layer_ = HeadsUpDisplayLayer::Create();
334 root_layer_src->AddChild(layer_tree_host_src_->hud_layer_); 338 root_layer_src->AddChild(layer_tree_host_src_->hud_layer_);
335 layer_tree_host_src_->overscroll_elasticity_layer_ = Layer::Create(); 339
336 root_layer_src->AddChild( 340 scoped_refptr<Layer> overscroll_elasticity_layer = Layer::Create();
337 layer_tree_host_src_->overscroll_elasticity_layer_); 341 scoped_refptr<Layer> page_scale_layer = Layer::Create();
338 layer_tree_host_src_->page_scale_layer_ = Layer::Create(); 342 scoped_refptr<Layer> inner_viewport_scroll_layer = Layer::Create();
339 root_layer_src->AddChild(layer_tree_host_src_->page_scale_layer_); 343 scoped_refptr<Layer> outer_viewport_scroll_layer = Layer::Create();
340 layer_tree_host_src_->inner_viewport_scroll_layer_ = Layer::Create(); 344
341 root_layer_src->AddChild( 345 root_layer_src->AddChild(overscroll_elasticity_layer);
342 layer_tree_host_src_->inner_viewport_scroll_layer_); 346 root_layer_src->AddChild(page_scale_layer);
343 layer_tree_host_src_->outer_viewport_scroll_layer_ = Layer::Create(); 347 root_layer_src->AddChild(inner_viewport_scroll_layer);
344 root_layer_src->AddChild( 348 root_layer_src->AddChild(outer_viewport_scroll_layer);
345 layer_tree_host_src_->outer_viewport_scroll_layer_); 349 layer_tree_host_src_->GetLayerTree()->RegisterViewportLayers(
350 overscroll_elasticity_layer, page_scale_layer,
351 inner_viewport_scroll_layer, outer_viewport_scroll_layer);
346 352
347 VerifySerializationAndDeserialization(); 353 VerifySerializationAndDeserialization();
348 VerifySerializationAndDeserialization(); 354 VerifySerializationAndDeserialization();
349 355
350 layer_tree_host_src_->hud_layer_ = nullptr; 356 layer_tree_host_src_->hud_layer_ = nullptr;
351 VerifySerializationAndDeserialization(); 357 VerifySerializationAndDeserialization();
352 layer_tree_host_src_->overscroll_elasticity_layer_ = nullptr; 358 layer_tree_host_src_->GetLayerTree()->inputs_.overscroll_elasticity_layer =
359 nullptr;
353 VerifySerializationAndDeserialization(); 360 VerifySerializationAndDeserialization();
354 layer_tree_host_src_->page_scale_layer_ = nullptr; 361 layer_tree_host_src_->GetLayerTree()->inputs_.page_scale_layer = nullptr;
355 VerifySerializationAndDeserialization(); 362 VerifySerializationAndDeserialization();
356 layer_tree_host_src_->inner_viewport_scroll_layer_ = nullptr; 363 layer_tree_host_src_->GetLayerTree()->inputs_.inner_viewport_scroll_layer =
364 nullptr;
357 VerifySerializationAndDeserialization(); 365 VerifySerializationAndDeserialization();
358 layer_tree_host_src_->outer_viewport_scroll_layer_ = nullptr; 366 layer_tree_host_src_->GetLayerTree()->inputs_.outer_viewport_scroll_layer =
367 nullptr;
359 VerifySerializationAndDeserialization(); 368 VerifySerializationAndDeserialization();
360 } 369 }
361 370
362 void RunPictureLayerMultipleSerializationsTest() { 371 void RunPictureLayerMultipleSerializationsTest() {
363 // Just fake setup a layer for both source and dest. 372 // Just fake setup a layer for both source and dest.
364 scoped_refptr<Layer> root_layer_src = Layer::Create(); 373 scoped_refptr<Layer> root_layer_src = Layer::Create();
365 layer_tree_host_src_->SetRootLayer(root_layer_src); 374 layer_tree_host_src_->SetRootLayer(root_layer_src);
366 layer_tree_host_dst_->SetRootLayer(Layer::Create()); 375 layer_tree_host_dst_->SetRootLayer(Layer::Create());
367 376
368 // Ensure that a PictureLayer work correctly for multiple rounds of 377 // Ensure that a PictureLayer work correctly for multiple rounds of
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 460
452 TEST_F(LayerTreeHostSerializationTest, AddAndRemoveNodeFromLayerTree) { 461 TEST_F(LayerTreeHostSerializationTest, AddAndRemoveNodeFromLayerTree) {
453 RunAddAndRemoveNodeFromLayerTree(); 462 RunAddAndRemoveNodeFromLayerTree();
454 } 463 }
455 464
456 TEST_F(LayerTreeHostSerializationTest, PictureLayerMultipleSerializations) { 465 TEST_F(LayerTreeHostSerializationTest, PictureLayerMultipleSerializations) {
457 RunPictureLayerMultipleSerializationsTest(); 466 RunPictureLayerMultipleSerializationsTest();
458 } 467 }
459 468
460 } // namespace cc 469 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698