| OLD | NEW |
| 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 <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 7410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7421 | 7421 |
| 7422 TEST_F(LayerTreeHostImplTest, GetPictureLayerImplPairs) { | 7422 TEST_F(LayerTreeHostImplTest, GetPictureLayerImplPairs) { |
| 7423 host_impl_->CreatePendingTree(); | 7423 host_impl_->CreatePendingTree(); |
| 7424 host_impl_->pending_tree()->SetRootLayer( | 7424 host_impl_->pending_tree()->SetRootLayer( |
| 7425 PictureLayerImpl::Create(host_impl_->pending_tree(), 10)); | 7425 PictureLayerImpl::Create(host_impl_->pending_tree(), 10)); |
| 7426 | 7426 |
| 7427 LayerTreeImpl* pending_tree = host_impl_->pending_tree(); | 7427 LayerTreeImpl* pending_tree = host_impl_->pending_tree(); |
| 7428 LayerImpl* pending_layer = pending_tree->root_layer(); | 7428 LayerImpl* pending_layer = pending_tree->root_layer(); |
| 7429 | 7429 |
| 7430 std::vector<PictureLayerImpl::Pair> layer_pairs; | 7430 std::vector<PictureLayerImpl::Pair> layer_pairs; |
| 7431 host_impl_->GetPictureLayerImplPairs(&layer_pairs); | 7431 host_impl_->GetPictureLayerImplPairs(&layer_pairs, true); |
| 7432 EXPECT_EQ(1u, layer_pairs.size()); | 7432 EXPECT_EQ(1u, layer_pairs.size()); |
| 7433 EXPECT_EQ(pending_layer, layer_pairs[0].pending); | 7433 EXPECT_EQ(pending_layer, layer_pairs[0].pending); |
| 7434 EXPECT_EQ(nullptr, layer_pairs[0].active); | 7434 EXPECT_EQ(nullptr, layer_pairs[0].active); |
| 7435 | 7435 |
| 7436 host_impl_->ActivateSyncTree(); | 7436 host_impl_->ActivateSyncTree(); |
| 7437 | 7437 |
| 7438 LayerTreeImpl* active_tree = host_impl_->active_tree(); | 7438 LayerTreeImpl* active_tree = host_impl_->active_tree(); |
| 7439 LayerImpl* active_layer = active_tree->root_layer(); | 7439 LayerImpl* active_layer = active_tree->root_layer(); |
| 7440 EXPECT_NE(active_tree, pending_tree); | 7440 EXPECT_NE(active_tree, pending_tree); |
| 7441 EXPECT_NE(active_layer, pending_layer); | 7441 EXPECT_NE(active_layer, pending_layer); |
| 7442 EXPECT_NE(nullptr, active_tree); | 7442 EXPECT_NE(nullptr, active_tree); |
| 7443 EXPECT_NE(nullptr, active_layer); | 7443 EXPECT_NE(nullptr, active_layer); |
| 7444 | 7444 |
| 7445 host_impl_->CreatePendingTree(); | 7445 host_impl_->CreatePendingTree(); |
| 7446 | 7446 |
| 7447 layer_pairs.clear(); | 7447 layer_pairs.clear(); |
| 7448 host_impl_->GetPictureLayerImplPairs(&layer_pairs); | 7448 host_impl_->GetPictureLayerImplPairs(&layer_pairs, true); |
| 7449 EXPECT_EQ(1u, layer_pairs.size()); | 7449 EXPECT_EQ(1u, layer_pairs.size()); |
| 7450 EXPECT_EQ(active_layer, layer_pairs[0].active); | 7450 EXPECT_EQ(active_layer, layer_pairs[0].active); |
| 7451 EXPECT_EQ(pending_layer, layer_pairs[0].pending); | 7451 EXPECT_EQ(pending_layer, layer_pairs[0].pending); |
| 7452 | 7452 |
| 7453 // Activate, the active layer has no twin now. | 7453 // Activate, the active layer has no twin now. |
| 7454 host_impl_->ActivateSyncTree(); | 7454 host_impl_->ActivateSyncTree(); |
| 7455 | 7455 |
| 7456 layer_pairs.clear(); | 7456 layer_pairs.clear(); |
| 7457 host_impl_->GetPictureLayerImplPairs(&layer_pairs); | 7457 host_impl_->GetPictureLayerImplPairs(&layer_pairs, true); |
| 7458 EXPECT_EQ(1u, layer_pairs.size()); | 7458 EXPECT_EQ(1u, layer_pairs.size()); |
| 7459 EXPECT_EQ(active_layer, layer_pairs[0].active); | 7459 EXPECT_EQ(active_layer, layer_pairs[0].active); |
| 7460 EXPECT_EQ(nullptr, layer_pairs[0].pending); | 7460 EXPECT_EQ(nullptr, layer_pairs[0].pending); |
| 7461 | 7461 |
| 7462 // Create another layer in the pending tree that's not in the active tree. We | 7462 // Create another layer in the pending tree that's not in the active tree. We |
| 7463 // should get two pairs. | 7463 // should get two pairs. |
| 7464 host_impl_->CreatePendingTree(); | 7464 host_impl_->CreatePendingTree(); |
| 7465 host_impl_->pending_tree()->root_layer()->AddChild( | 7465 host_impl_->pending_tree()->root_layer()->AddChild( |
| 7466 PictureLayerImpl::Create(host_impl_->pending_tree(), 11)); | 7466 PictureLayerImpl::Create(host_impl_->pending_tree(), 11)); |
| 7467 | 7467 |
| 7468 LayerImpl* new_pending_layer = pending_tree->root_layer()->children()[0]; | 7468 LayerImpl* new_pending_layer = pending_tree->root_layer()->children()[0]; |
| 7469 | 7469 |
| 7470 layer_pairs.clear(); | 7470 layer_pairs.clear(); |
| 7471 host_impl_->GetPictureLayerImplPairs(&layer_pairs); | 7471 host_impl_->GetPictureLayerImplPairs(&layer_pairs, true); |
| 7472 EXPECT_EQ(2u, layer_pairs.size()); | 7472 EXPECT_EQ(2u, layer_pairs.size()); |
| 7473 | 7473 |
| 7474 // The pair ordering is flaky, so make it consistent. | 7474 // The pair ordering is flaky, so make it consistent. |
| 7475 if (layer_pairs[0].active != active_layer) | 7475 if (layer_pairs[0].active != active_layer) |
| 7476 std::swap(layer_pairs[0], layer_pairs[1]); | 7476 std::swap(layer_pairs[0], layer_pairs[1]); |
| 7477 | 7477 |
| 7478 EXPECT_EQ(active_layer, layer_pairs[0].active); | 7478 EXPECT_EQ(active_layer, layer_pairs[0].active); |
| 7479 EXPECT_EQ(pending_layer, layer_pairs[0].pending); | 7479 EXPECT_EQ(pending_layer, layer_pairs[0].pending); |
| 7480 EXPECT_EQ(new_pending_layer, layer_pairs[1].pending); | 7480 EXPECT_EQ(new_pending_layer, layer_pairs[1].pending); |
| 7481 EXPECT_EQ(nullptr, layer_pairs[1].active); | 7481 EXPECT_EQ(nullptr, layer_pairs[1].active); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7547 // surface. | 7547 // surface. |
| 7548 EXPECT_EQ(0, num_lost_surfaces_); | 7548 EXPECT_EQ(0, num_lost_surfaces_); |
| 7549 host_impl_->DidLoseOutputSurface(); | 7549 host_impl_->DidLoseOutputSurface(); |
| 7550 EXPECT_EQ(1, num_lost_surfaces_); | 7550 EXPECT_EQ(1, num_lost_surfaces_); |
| 7551 host_impl_->DidLoseOutputSurface(); | 7551 host_impl_->DidLoseOutputSurface(); |
| 7552 EXPECT_LE(1, num_lost_surfaces_); | 7552 EXPECT_LE(1, num_lost_surfaces_); |
| 7553 } | 7553 } |
| 7554 | 7554 |
| 7555 } // namespace | 7555 } // namespace |
| 7556 } // namespace cc | 7556 } // namespace cc |
| OLD | NEW |