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

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: add-test-case 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 <cmath> 7 #include <cmath>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 7425 matching lines...) Expand 10 before | Expand all | Expand 10 after
7436 host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(250)); 7436 host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(250));
7437 host_impl_->UpdateAnimationState(true); 7437 host_impl_->UpdateAnimationState(true);
7438 7438
7439 EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100), 7439 EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100),
7440 scrolling_layer->TotalScrollOffset()); 7440 scrolling_layer->TotalScrollOffset());
7441 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); 7441 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer());
7442 } 7442 }
7443 7443
7444 TEST_F(LayerTreeHostImplTest, GetPictureLayerImplPairs) { 7444 TEST_F(LayerTreeHostImplTest, GetPictureLayerImplPairs) {
7445 host_impl_->CreatePendingTree(); 7445 host_impl_->CreatePendingTree();
7446 host_impl_->ActivateSyncTree(); 7446 host_impl_->pending_tree()->SetRootLayer(
7447 host_impl_->CreatePendingTree(); 7447 PictureLayerImpl::Create(host_impl_->pending_tree(), 10));
7448 7448
7449 LayerTreeImpl* active_tree = host_impl_->active_tree();
7450 LayerTreeImpl* pending_tree = host_impl_->pending_tree(); 7449 LayerTreeImpl* pending_tree = host_impl_->pending_tree();
7451 EXPECT_NE(active_tree, pending_tree); 7450 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 7451
7458 std::vector<PictureLayerImpl::Pair> layer_pairs; 7452 std::vector<PictureLayerImpl::Pair> layer_pairs;
7459 host_impl_->GetPictureLayerImplPairs(&layer_pairs); 7453 host_impl_->GetPictureLayerImplPairs(&layer_pairs);
7454 EXPECT_EQ(1u, layer_pairs.size());
7455 EXPECT_EQ(pending_layer, layer_pairs[0].pending);
7456 EXPECT_EQ(nullptr, layer_pairs[0].active);
7460 7457
7461 EXPECT_EQ(2u, layer_pairs.size()); 7458 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 7459
7470 if (layer_pairs[1].active) { 7460 LayerTreeImpl* active_tree = host_impl_->active_tree();
7471 EXPECT_EQ(active_layer.get(), layer_pairs[1].active); 7461 LayerImpl* active_layer = active_tree->root_layer();
7472 EXPECT_EQ(NULL, layer_pairs[1].pending); 7462 EXPECT_NE(active_tree, pending_tree);
7473 } else { 7463 EXPECT_NE(active_layer, pending_layer);
7474 EXPECT_EQ(pending_layer.get(), layer_pairs[1].pending); 7464 EXPECT_NE(nullptr, active_tree);
7475 EXPECT_EQ(NULL, layer_pairs[1].active); 7465 EXPECT_NE(nullptr, active_layer);
7476 }
7477 7466
7478 active_layer->set_twin_layer(pending_layer.get()); 7467 host_impl_->CreatePendingTree();
7479 pending_layer->set_twin_layer(active_layer.get());
7480 7468
7481 layer_pairs.clear(); 7469 layer_pairs.clear();
7482 host_impl_->GetPictureLayerImplPairs(&layer_pairs); 7470 host_impl_->GetPictureLayerImplPairs(&layer_pairs);
7483 EXPECT_EQ(1u, layer_pairs.size()); 7471 EXPECT_EQ(1u, layer_pairs.size());
7472 EXPECT_EQ(active_layer, layer_pairs[0].active);
7473 EXPECT_EQ(pending_layer, layer_pairs[0].pending);
7484 7474
7485 EXPECT_EQ(active_layer.get(), layer_pairs[0].active); 7475 // Activate, the active layer has no twin now.
7486 EXPECT_EQ(pending_layer.get(), layer_pairs[0].pending); 7476 host_impl_->ActivateSyncTree();
7477
7478 layer_pairs.clear();
7479 host_impl_->GetPictureLayerImplPairs(&layer_pairs);
7480 EXPECT_EQ(1u, layer_pairs.size());
7481 EXPECT_EQ(active_layer, layer_pairs[0].active);
7482 EXPECT_EQ(nullptr, layer_pairs[0].pending);
7483
7484 // Create another layer in the pending tree that's not in the active tree. We
7485 // should get two pairs.
7486 host_impl_->CreatePendingTree();
7487 host_impl_->pending_tree()->root_layer()->AddChild(
7488 PictureLayerImpl::Create(host_impl_->pending_tree(), 11));
7489
7490 LayerImpl* new_pending_layer = pending_tree->root_layer()->children()[0];
7491
7492 layer_pairs.clear();
7493 host_impl_->GetPictureLayerImplPairs(&layer_pairs);
7494 EXPECT_EQ(2u, layer_pairs.size());
7495
7496 // The pair ordering is flaky, so make it consistent.
7497 if (layer_pairs[0].active != active_layer) {
7498 PictureLayerImpl::Pair p = layer_pairs[1];
vmpstr 2014/10/24 17:20:10 std::swap!
danakj 2014/10/24 18:00:24 ooh
7499 layer_pairs[1] = layer_pairs[0];
7500 layer_pairs[0] = p;
7501 }
7502
7503 EXPECT_EQ(active_layer, layer_pairs[0].active);
7504 EXPECT_EQ(pending_layer, layer_pairs[0].pending);
7505 EXPECT_EQ(new_pending_layer, layer_pairs[1].pending);
7506 EXPECT_EQ(nullptr, layer_pairs[1].active);
7487 } 7507 }
7488 7508
7489 TEST_F(LayerTreeHostImplTest, DidBecomeActive) { 7509 TEST_F(LayerTreeHostImplTest, DidBecomeActive) {
7490 host_impl_->CreatePendingTree(); 7510 host_impl_->CreatePendingTree();
7491 host_impl_->ActivateSyncTree(); 7511 host_impl_->ActivateSyncTree();
7492 host_impl_->CreatePendingTree(); 7512 host_impl_->CreatePendingTree();
7493 7513
7494 LayerTreeImpl* pending_tree = host_impl_->pending_tree(); 7514 LayerTreeImpl* pending_tree = host_impl_->pending_tree();
7495 7515
7496 scoped_ptr<FakePictureLayerImpl> pending_layer = 7516 scoped_ptr<FakePictureLayerImpl> pending_layer =
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
7552 // surface. 7572 // surface.
7553 EXPECT_EQ(0, num_lost_surfaces_); 7573 EXPECT_EQ(0, num_lost_surfaces_);
7554 host_impl_->DidLoseOutputSurface(); 7574 host_impl_->DidLoseOutputSurface();
7555 EXPECT_EQ(1, num_lost_surfaces_); 7575 EXPECT_EQ(1, num_lost_surfaces_);
7556 host_impl_->DidLoseOutputSurface(); 7576 host_impl_->DidLoseOutputSurface();
7557 EXPECT_LE(1, num_lost_surfaces_); 7577 EXPECT_LE(1, num_lost_surfaces_);
7558 } 7578 }
7559 7579
7560 } // namespace 7580 } // namespace
7561 } // namespace cc 7581 } // 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