| 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 7569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7580 | 7580 |
| 7581 TEST_F(LayerTreeHostImplTest, GetPictureLayerImplPairs) { | 7581 TEST_F(LayerTreeHostImplTest, GetPictureLayerImplPairs) { |
| 7582 host_impl_->CreatePendingTree(); | 7582 host_impl_->CreatePendingTree(); |
| 7583 host_impl_->pending_tree()->SetRootLayer( | 7583 host_impl_->pending_tree()->SetRootLayer( |
| 7584 PictureLayerImpl::Create(host_impl_->pending_tree(), 10)); | 7584 PictureLayerImpl::Create(host_impl_->pending_tree(), 10)); |
| 7585 | 7585 |
| 7586 LayerTreeImpl* pending_tree = host_impl_->pending_tree(); | 7586 LayerTreeImpl* pending_tree = host_impl_->pending_tree(); |
| 7587 LayerImpl* pending_layer = pending_tree->root_layer(); | 7587 LayerImpl* pending_layer = pending_tree->root_layer(); |
| 7588 | 7588 |
| 7589 std::vector<PictureLayerImpl::Pair> layer_pairs; | 7589 std::vector<PictureLayerImpl::Pair> layer_pairs; |
| 7590 host_impl_->GetPictureLayerImplPairs(&layer_pairs); | 7590 host_impl_->GetPictureLayerImplPairs(&layer_pairs, true); |
| 7591 EXPECT_EQ(1u, layer_pairs.size()); | 7591 EXPECT_EQ(1u, layer_pairs.size()); |
| 7592 EXPECT_EQ(pending_layer, layer_pairs[0].pending); | 7592 EXPECT_EQ(pending_layer, layer_pairs[0].pending); |
| 7593 EXPECT_EQ(nullptr, layer_pairs[0].active); | 7593 EXPECT_EQ(nullptr, layer_pairs[0].active); |
| 7594 | 7594 |
| 7595 host_impl_->ActivateSyncTree(); | 7595 host_impl_->ActivateSyncTree(); |
| 7596 | 7596 |
| 7597 LayerTreeImpl* active_tree = host_impl_->active_tree(); | 7597 LayerTreeImpl* active_tree = host_impl_->active_tree(); |
| 7598 LayerImpl* active_layer = active_tree->root_layer(); | 7598 LayerImpl* active_layer = active_tree->root_layer(); |
| 7599 EXPECT_NE(active_tree, pending_tree); | 7599 EXPECT_NE(active_tree, pending_tree); |
| 7600 EXPECT_NE(active_layer, pending_layer); | 7600 EXPECT_NE(active_layer, pending_layer); |
| 7601 EXPECT_NE(nullptr, active_tree); | 7601 EXPECT_NE(nullptr, active_tree); |
| 7602 EXPECT_NE(nullptr, active_layer); | 7602 EXPECT_NE(nullptr, active_layer); |
| 7603 | 7603 |
| 7604 host_impl_->CreatePendingTree(); | 7604 host_impl_->CreatePendingTree(); |
| 7605 | 7605 |
| 7606 layer_pairs.clear(); | 7606 layer_pairs.clear(); |
| 7607 host_impl_->GetPictureLayerImplPairs(&layer_pairs); | 7607 host_impl_->GetPictureLayerImplPairs(&layer_pairs, true); |
| 7608 EXPECT_EQ(1u, layer_pairs.size()); | 7608 EXPECT_EQ(1u, layer_pairs.size()); |
| 7609 EXPECT_EQ(active_layer, layer_pairs[0].active); | 7609 EXPECT_EQ(active_layer, layer_pairs[0].active); |
| 7610 EXPECT_EQ(pending_layer, layer_pairs[0].pending); | 7610 EXPECT_EQ(pending_layer, layer_pairs[0].pending); |
| 7611 | 7611 |
| 7612 // Activate, the active layer has no twin now. | 7612 // Activate, the active layer has no twin now. |
| 7613 host_impl_->ActivateSyncTree(); | 7613 host_impl_->ActivateSyncTree(); |
| 7614 | 7614 |
| 7615 layer_pairs.clear(); | 7615 layer_pairs.clear(); |
| 7616 host_impl_->GetPictureLayerImplPairs(&layer_pairs); | 7616 host_impl_->GetPictureLayerImplPairs(&layer_pairs, true); |
| 7617 EXPECT_EQ(1u, layer_pairs.size()); | 7617 EXPECT_EQ(1u, layer_pairs.size()); |
| 7618 EXPECT_EQ(active_layer, layer_pairs[0].active); | 7618 EXPECT_EQ(active_layer, layer_pairs[0].active); |
| 7619 EXPECT_EQ(nullptr, layer_pairs[0].pending); | 7619 EXPECT_EQ(nullptr, layer_pairs[0].pending); |
| 7620 | 7620 |
| 7621 // Create another layer in the pending tree that's not in the active tree. We | 7621 // Create another layer in the pending tree that's not in the active tree. We |
| 7622 // should get two pairs. | 7622 // should get two pairs. |
| 7623 host_impl_->CreatePendingTree(); | 7623 host_impl_->CreatePendingTree(); |
| 7624 host_impl_->pending_tree()->root_layer()->AddChild( | 7624 host_impl_->pending_tree()->root_layer()->AddChild( |
| 7625 PictureLayerImpl::Create(host_impl_->pending_tree(), 11)); | 7625 PictureLayerImpl::Create(host_impl_->pending_tree(), 11)); |
| 7626 | 7626 |
| 7627 LayerImpl* new_pending_layer = pending_tree->root_layer()->children()[0]; | 7627 LayerImpl* new_pending_layer = pending_tree->root_layer()->children()[0]; |
| 7628 | 7628 |
| 7629 layer_pairs.clear(); | 7629 layer_pairs.clear(); |
| 7630 host_impl_->GetPictureLayerImplPairs(&layer_pairs); | 7630 host_impl_->GetPictureLayerImplPairs(&layer_pairs, true); |
| 7631 EXPECT_EQ(2u, layer_pairs.size()); | 7631 EXPECT_EQ(2u, layer_pairs.size()); |
| 7632 | 7632 |
| 7633 // The pair ordering is flaky, so make it consistent. | 7633 // The pair ordering is flaky, so make it consistent. |
| 7634 if (layer_pairs[0].active != active_layer) | 7634 if (layer_pairs[0].active != active_layer) |
| 7635 std::swap(layer_pairs[0], layer_pairs[1]); | 7635 std::swap(layer_pairs[0], layer_pairs[1]); |
| 7636 | 7636 |
| 7637 EXPECT_EQ(active_layer, layer_pairs[0].active); | 7637 EXPECT_EQ(active_layer, layer_pairs[0].active); |
| 7638 EXPECT_EQ(pending_layer, layer_pairs[0].pending); | 7638 EXPECT_EQ(pending_layer, layer_pairs[0].pending); |
| 7639 EXPECT_EQ(new_pending_layer, layer_pairs[1].pending); | 7639 EXPECT_EQ(new_pending_layer, layer_pairs[1].pending); |
| 7640 EXPECT_EQ(nullptr, layer_pairs[1].active); | 7640 EXPECT_EQ(nullptr, layer_pairs[1].active); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7706 // surface. | 7706 // surface. |
| 7707 EXPECT_EQ(0, num_lost_surfaces_); | 7707 EXPECT_EQ(0, num_lost_surfaces_); |
| 7708 host_impl_->DidLoseOutputSurface(); | 7708 host_impl_->DidLoseOutputSurface(); |
| 7709 EXPECT_EQ(1, num_lost_surfaces_); | 7709 EXPECT_EQ(1, num_lost_surfaces_); |
| 7710 host_impl_->DidLoseOutputSurface(); | 7710 host_impl_->DidLoseOutputSurface(); |
| 7711 EXPECT_LE(1, num_lost_surfaces_); | 7711 EXPECT_LE(1, num_lost_surfaces_); |
| 7712 } | 7712 } |
| 7713 | 7713 |
| 7714 } // namespace | 7714 } // namespace |
| 7715 } // namespace cc | 7715 } // namespace cc |
| OLD | NEW |