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

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

Issue 676953003: cc: Always keep the PictureLayerImpl::twin_layer_ pointer valid. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: twins: anothercheck Created 6 years, 1 month 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_impl.cc ('k') | cc/trees/layer_tree_host_unittest_picture.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 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/trees/layer_tree_host_impl.h" 5 #include "cc/trees/layer_tree_host_impl.h"
6 6
7 #include <algorithm>
7 #include <cmath> 8 #include <cmath>
8 9
9 #include "base/bind.h" 10 #include "base/bind.h"
10 #include "base/command_line.h" 11 #include "base/command_line.h"
11 #include "base/containers/hash_tables.h" 12 #include "base/containers/hash_tables.h"
12 #include "base/containers/scoped_ptr_hash_map.h" 13 #include "base/containers/scoped_ptr_hash_map.h"
13 #include "cc/animation/scrollbar_animation_controller_thinning.h" 14 #include "cc/animation/scrollbar_animation_controller_thinning.h"
14 #include "cc/base/latency_info_swap_promise.h" 15 #include "cc/base/latency_info_swap_promise.h"
15 #include "cc/base/math_util.h" 16 #include "cc/base/math_util.h"
16 #include "cc/input/page_scale_animation.h" 17 #include "cc/input/page_scale_animation.h"
(...skipping 7419 matching lines...) Expand 10 before | Expand all | Expand 10 after
7436 host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(250)); 7437 host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(250));
7437 host_impl_->UpdateAnimationState(true); 7438 host_impl_->UpdateAnimationState(true);
7438 7439
7439 EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100), 7440 EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100),
7440 scrolling_layer->TotalScrollOffset()); 7441 scrolling_layer->TotalScrollOffset());
7441 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); 7442 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer());
7442 } 7443 }
7443 7444
7444 TEST_F(LayerTreeHostImplTest, GetPictureLayerImplPairs) { 7445 TEST_F(LayerTreeHostImplTest, GetPictureLayerImplPairs) {
7445 host_impl_->CreatePendingTree(); 7446 host_impl_->CreatePendingTree();
7446 host_impl_->ActivateSyncTree(); 7447 host_impl_->pending_tree()->SetRootLayer(
7447 host_impl_->CreatePendingTree(); 7448 PictureLayerImpl::Create(host_impl_->pending_tree(), 10));
7448 7449
7449 LayerTreeImpl* active_tree = host_impl_->active_tree();
7450 LayerTreeImpl* pending_tree = host_impl_->pending_tree(); 7450 LayerTreeImpl* pending_tree = host_impl_->pending_tree();
7451 EXPECT_NE(active_tree, pending_tree); 7451 LayerImpl* pending_layer = pending_tree->root_layer();
7452
7453 scoped_ptr<FakePictureLayerImpl> active_layer =
7454 FakePictureLayerImpl::Create(active_tree, 10);
7455 scoped_ptr<FakePictureLayerImpl> pending_layer =
7456 FakePictureLayerImpl::Create(pending_tree, 10);
7457 7452
7458 std::vector<PictureLayerImpl::Pair> layer_pairs; 7453 std::vector<PictureLayerImpl::Pair> layer_pairs;
7459 host_impl_->GetPictureLayerImplPairs(&layer_pairs); 7454 host_impl_->GetPictureLayerImplPairs(&layer_pairs);
7455 EXPECT_EQ(1u, layer_pairs.size());
7456 EXPECT_EQ(pending_layer, layer_pairs[0].pending);
7457 EXPECT_EQ(nullptr, layer_pairs[0].active);
7460 7458
7461 EXPECT_EQ(2u, layer_pairs.size()); 7459 host_impl_->ActivateSyncTree();
7462 if (layer_pairs[0].active) {
7463 EXPECT_EQ(active_layer.get(), layer_pairs[0].active);
7464 EXPECT_EQ(NULL, layer_pairs[0].pending);
7465 } else {
7466 EXPECT_EQ(pending_layer.get(), layer_pairs[0].pending);
7467 EXPECT_EQ(NULL, layer_pairs[0].active);
7468 }
7469 7460
7470 if (layer_pairs[1].active) { 7461 LayerTreeImpl* active_tree = host_impl_->active_tree();
7471 EXPECT_EQ(active_layer.get(), layer_pairs[1].active); 7462 LayerImpl* active_layer = active_tree->root_layer();
7472 EXPECT_EQ(NULL, layer_pairs[1].pending); 7463 EXPECT_NE(active_tree, pending_tree);
7473 } else { 7464 EXPECT_NE(active_layer, pending_layer);
7474 EXPECT_EQ(pending_layer.get(), layer_pairs[1].pending); 7465 EXPECT_NE(nullptr, active_tree);
7475 EXPECT_EQ(NULL, layer_pairs[1].active); 7466 EXPECT_NE(nullptr, active_layer);
7476 }
7477 7467
7478 active_layer->set_twin_layer(pending_layer.get()); 7468 host_impl_->CreatePendingTree();
7479 pending_layer->set_twin_layer(active_layer.get());
7480 7469
7481 layer_pairs.clear(); 7470 layer_pairs.clear();
7482 host_impl_->GetPictureLayerImplPairs(&layer_pairs); 7471 host_impl_->GetPictureLayerImplPairs(&layer_pairs);
7483 EXPECT_EQ(1u, layer_pairs.size()); 7472 EXPECT_EQ(1u, layer_pairs.size());
7473 EXPECT_EQ(active_layer, layer_pairs[0].active);
7474 EXPECT_EQ(pending_layer, layer_pairs[0].pending);
7484 7475
7485 EXPECT_EQ(active_layer.get(), layer_pairs[0].active); 7476 // Activate, the active layer has no twin now.
7486 EXPECT_EQ(pending_layer.get(), layer_pairs[0].pending); 7477 host_impl_->ActivateSyncTree();
7478
7479 layer_pairs.clear();
7480 host_impl_->GetPictureLayerImplPairs(&layer_pairs);
7481 EXPECT_EQ(1u, layer_pairs.size());
7482 EXPECT_EQ(active_layer, layer_pairs[0].active);
7483 EXPECT_EQ(nullptr, layer_pairs[0].pending);
7484
7485 // Create another layer in the pending tree that's not in the active tree. We
7486 // should get two pairs.
7487 host_impl_->CreatePendingTree();
7488 host_impl_->pending_tree()->root_layer()->AddChild(
7489 PictureLayerImpl::Create(host_impl_->pending_tree(), 11));
7490
7491 LayerImpl* new_pending_layer = pending_tree->root_layer()->children()[0];
7492
7493 layer_pairs.clear();
7494 host_impl_->GetPictureLayerImplPairs(&layer_pairs);
7495 EXPECT_EQ(2u, layer_pairs.size());
7496
7497 // The pair ordering is flaky, so make it consistent.
7498 if (layer_pairs[0].active != active_layer)
7499 std::swap(layer_pairs[0], layer_pairs[1]);
7500
7501 EXPECT_EQ(active_layer, layer_pairs[0].active);
7502 EXPECT_EQ(pending_layer, layer_pairs[0].pending);
7503 EXPECT_EQ(new_pending_layer, layer_pairs[1].pending);
7504 EXPECT_EQ(nullptr, layer_pairs[1].active);
7487 } 7505 }
7488 7506
7489 TEST_F(LayerTreeHostImplTest, DidBecomeActive) { 7507 TEST_F(LayerTreeHostImplTest, DidBecomeActive) {
7490 host_impl_->CreatePendingTree(); 7508 host_impl_->CreatePendingTree();
7491 host_impl_->ActivateSyncTree(); 7509 host_impl_->ActivateSyncTree();
7492 host_impl_->CreatePendingTree(); 7510 host_impl_->CreatePendingTree();
7493 7511
7494 LayerTreeImpl* pending_tree = host_impl_->pending_tree(); 7512 LayerTreeImpl* pending_tree = host_impl_->pending_tree();
7495 7513
7496 scoped_ptr<FakePictureLayerImpl> pending_layer = 7514 scoped_ptr<FakePictureLayerImpl> pending_layer =
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
7552 // surface. 7570 // surface.
7553 EXPECT_EQ(0, num_lost_surfaces_); 7571 EXPECT_EQ(0, num_lost_surfaces_);
7554 host_impl_->DidLoseOutputSurface(); 7572 host_impl_->DidLoseOutputSurface();
7555 EXPECT_EQ(1, num_lost_surfaces_); 7573 EXPECT_EQ(1, num_lost_surfaces_);
7556 host_impl_->DidLoseOutputSurface(); 7574 host_impl_->DidLoseOutputSurface();
7557 EXPECT_LE(1, num_lost_surfaces_); 7575 EXPECT_LE(1, num_lost_surfaces_);
7558 } 7576 }
7559 7577
7560 } // namespace 7578 } // namespace
7561 } // namespace cc 7579 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_unittest_picture.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698