Index: cc/trees/layer_tree_host_impl_unittest.cc |
diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc |
index 4deb8e430a2c9c51ba6a1536a6f51052d6a8eb79..afea2d284831654385aee2fedb9facc336ccb995 100644 |
--- a/cc/trees/layer_tree_host_impl_unittest.cc |
+++ b/cc/trees/layer_tree_host_impl_unittest.cc |
@@ -8070,17 +8070,26 @@ TEST_F(LayerTreeHostImplTest, GetPictureLayerImplPairs) { |
scoped_ptr<PictureLayerImpl> layer = |
FakePictureLayerImpl::Create(host_impl_->pending_tree(), 10); |
layer->SetBounds(gfx::Size(10, 10)); |
+ scoped_ptr<FakePictureLayerImpl> nondraw_layer = |
+ FakePictureLayerImpl::Create(host_impl_->pending_tree(), 12); |
+ nondraw_layer->SetBounds(gfx::Size(10, 10)); |
scoped_refptr<RasterSource> pile(FakePicturePileImpl::CreateEmptyPile( |
gfx::Size(10, 10), gfx::Size(10, 10))); |
Region empty_invalidation; |
const PictureLayerTilingSet* null_tiling_set = nullptr; |
layer->UpdateRasterSource(pile, &empty_invalidation, null_tiling_set); |
+ nondraw_layer->UpdateRasterSource(pile, &empty_invalidation, null_tiling_set); |
+ layer->AddChild(nondraw_layer.Pass()); |
host_impl_->pending_tree()->SetRootLayer(layer.Pass()); |
LayerTreeImpl* pending_tree = host_impl_->pending_tree(); |
LayerImpl* pending_layer = pending_tree->root_layer(); |
+ FakePictureLayerImpl* pending_nondraw_layer = |
+ static_cast<FakePictureLayerImpl*>(pending_layer->children()[0]); |
+ |
+ pending_nondraw_layer->SetIsDrawnRenderSurfaceLayerListMember(false); |
std::vector<PictureLayerImpl::Pair> layer_pairs; |
host_impl_->GetPictureLayerImplPairs(&layer_pairs, true); |
@@ -8092,10 +8101,16 @@ TEST_F(LayerTreeHostImplTest, GetPictureLayerImplPairs) { |
LayerTreeImpl* active_tree = host_impl_->active_tree(); |
LayerImpl* active_layer = active_tree->root_layer(); |
+ FakePictureLayerImpl* active_nondraw_layer = |
+ static_cast<FakePictureLayerImpl*>(active_layer->children()[0]); |
EXPECT_NE(active_tree, pending_tree); |
EXPECT_NE(active_layer, pending_layer); |
+ EXPECT_NE(active_nondraw_layer, pending_nondraw_layer); |
EXPECT_NE(nullptr, active_tree); |
EXPECT_NE(nullptr, active_layer); |
+ EXPECT_NE(nullptr, active_nondraw_layer); |
+ |
+ active_nondraw_layer->SetIsDrawnRenderSurfaceLayerListMember(false); |
host_impl_->CreatePendingTree(); |
@@ -8120,20 +8135,192 @@ TEST_F(LayerTreeHostImplTest, GetPictureLayerImplPairs) { |
host_impl_->pending_tree()->root_layer()->AddChild( |
FakePictureLayerImpl::Create(host_impl_->pending_tree(), 11)); |
- LayerImpl* new_pending_layer = pending_tree->root_layer()->children()[0]; |
+ LayerImpl* new_pending_layer = pending_tree->root_layer()->children()[1]; |
layer_pairs.clear(); |
host_impl_->GetPictureLayerImplPairs(&layer_pairs, true); |
EXPECT_EQ(2u, layer_pairs.size()); |
+ // The pair ordering is flaky, so make it consistent. |
+ if (layer_pairs[0].active != active_layer) |
+ std::swap(layer_pairs[0], layer_pairs[1]); |
+ EXPECT_EQ(active_layer, layer_pairs[0].active); |
+ EXPECT_EQ(pending_layer, layer_pairs[0].pending); |
+ EXPECT_EQ(new_pending_layer, layer_pairs[1].pending); |
+ EXPECT_EQ(nullptr, layer_pairs[1].active); |
+ |
+ host_impl_->pending_tree()->root_layer()->RemoveChild(new_pending_layer); |
+ // Have the pending layer be part of the RSLL now. It should appear in the |
+ // list without an active twin. |
+ pending_nondraw_layer->SetIsDrawnRenderSurfaceLayerListMember(true); |
+ |
+ layer_pairs.clear(); |
+ host_impl_->GetPictureLayerImplPairs(&layer_pairs, true); |
+ EXPECT_EQ(2u, layer_pairs.size()); |
// The pair ordering is flaky, so make it consistent. |
if (layer_pairs[0].active != active_layer) |
std::swap(layer_pairs[0], layer_pairs[1]); |
+ EXPECT_EQ(active_layer, layer_pairs[0].active); |
+ EXPECT_EQ(pending_layer, layer_pairs[0].pending); |
+ EXPECT_EQ(pending_nondraw_layer, layer_pairs[1].pending); |
+ EXPECT_EQ(nullptr, layer_pairs[1].active); |
+ // Have the active layer be part of the RSLL now instead. It should appear in |
+ // the list without a pending twin. |
+ pending_nondraw_layer->SetIsDrawnRenderSurfaceLayerListMember(false); |
+ active_nondraw_layer->SetIsDrawnRenderSurfaceLayerListMember(true); |
+ |
+ layer_pairs.clear(); |
+ host_impl_->GetPictureLayerImplPairs(&layer_pairs, true); |
+ EXPECT_EQ(2u, layer_pairs.size()); |
+ // The pair ordering is flaky, so make it consistent. |
+ if (layer_pairs[0].active != active_layer) |
+ std::swap(layer_pairs[0], layer_pairs[1]); |
+ EXPECT_EQ(active_layer, layer_pairs[0].active); |
+ EXPECT_EQ(pending_layer, layer_pairs[0].pending); |
+ EXPECT_EQ(nullptr, layer_pairs[1].pending); |
+ EXPECT_EQ(active_nondraw_layer, layer_pairs[1].active); |
+} |
+ |
+TEST_F(LayerTreeHostImplTest, GetPictureLayerImplPairsWithNonRSLLMembers) { |
+ host_impl_->CreatePendingTree(); |
+ |
+ scoped_ptr<PictureLayerImpl> layer = |
+ FakePictureLayerImpl::Create(host_impl_->pending_tree(), 10); |
+ layer->SetBounds(gfx::Size(10, 10)); |
+ scoped_ptr<FakePictureLayerImpl> nondraw_layer = |
+ FakePictureLayerImpl::Create(host_impl_->pending_tree(), 12); |
+ nondraw_layer->SetBounds(gfx::Size(10, 10)); |
+ |
+ scoped_refptr<RasterSource> pile(FakePicturePileImpl::CreateEmptyPile( |
+ gfx::Size(10, 10), gfx::Size(10, 10))); |
+ Region empty_invalidation; |
+ const PictureLayerTilingSet* null_tiling_set = nullptr; |
+ layer->UpdateRasterSource(pile, &empty_invalidation, null_tiling_set); |
+ nondraw_layer->UpdateRasterSource(pile, &empty_invalidation, null_tiling_set); |
+ |
+ layer->AddChild(nondraw_layer.Pass()); |
+ host_impl_->pending_tree()->SetRootLayer(layer.Pass()); |
+ |
+ LayerTreeImpl* pending_tree = host_impl_->pending_tree(); |
+ LayerImpl* pending_layer = pending_tree->root_layer(); |
+ FakePictureLayerImpl* pending_nondraw_layer = |
+ static_cast<FakePictureLayerImpl*>(pending_layer->children()[0]); |
+ |
+ pending_nondraw_layer->SetIsDrawnRenderSurfaceLayerListMember(false); |
+ |
+ std::vector<PictureLayerImpl::Pair> layer_pairs; |
+ host_impl_->GetPictureLayerImplPairs(&layer_pairs, false); |
+ EXPECT_EQ(2u, layer_pairs.size()); |
+ // The pair ordering is flaky, so make it consistent. |
+ if (layer_pairs[0].pending != pending_layer) |
+ std::swap(layer_pairs[0], layer_pairs[1]); |
+ EXPECT_EQ(pending_layer, layer_pairs[0].pending); |
+ EXPECT_EQ(nullptr, layer_pairs[0].active); |
+ EXPECT_EQ(pending_nondraw_layer, layer_pairs[1].pending); |
+ EXPECT_EQ(nullptr, layer_pairs[1].active); |
+ |
+ host_impl_->ActivateSyncTree(); |
+ |
+ LayerTreeImpl* active_tree = host_impl_->active_tree(); |
+ LayerImpl* active_layer = active_tree->root_layer(); |
+ FakePictureLayerImpl* active_nondraw_layer = |
+ static_cast<FakePictureLayerImpl*>(active_layer->children()[0]); |
+ EXPECT_NE(active_tree, pending_tree); |
+ EXPECT_NE(active_layer, pending_layer); |
+ EXPECT_NE(active_nondraw_layer, pending_nondraw_layer); |
+ EXPECT_NE(nullptr, active_tree); |
+ EXPECT_NE(nullptr, active_layer); |
+ EXPECT_NE(nullptr, active_nondraw_layer); |
+ |
+ active_nondraw_layer->SetIsDrawnRenderSurfaceLayerListMember(false); |
+ |
+ host_impl_->CreatePendingTree(); |
+ |
+ layer_pairs.clear(); |
+ host_impl_->GetPictureLayerImplPairs(&layer_pairs, false); |
+ EXPECT_EQ(2u, layer_pairs.size()); |
+ // The pair ordering is flaky, so make it consistent. |
+ if (layer_pairs[0].active != active_layer) |
+ std::swap(layer_pairs[0], layer_pairs[1]); |
+ EXPECT_EQ(active_layer, layer_pairs[0].active); |
+ EXPECT_EQ(pending_layer, layer_pairs[0].pending); |
+ EXPECT_EQ(pending_nondraw_layer, layer_pairs[1].pending); |
+ EXPECT_EQ(active_nondraw_layer, layer_pairs[1].active); |
+ |
+ // Activate, the active layer has no twin now. |
+ host_impl_->ActivateSyncTree(); |
+ |
+ layer_pairs.clear(); |
+ host_impl_->GetPictureLayerImplPairs(&layer_pairs, false); |
+ EXPECT_EQ(2u, layer_pairs.size()); |
+ // The pair ordering is flaky, so make it consistent. |
+ if (layer_pairs[0].active != active_layer) |
+ std::swap(layer_pairs[0], layer_pairs[1]); |
+ EXPECT_EQ(active_layer, layer_pairs[0].active); |
+ EXPECT_EQ(nullptr, layer_pairs[0].pending); |
+ EXPECT_EQ(active_nondraw_layer, layer_pairs[1].active); |
+ EXPECT_EQ(nullptr, layer_pairs[1].pending); |
+ |
+ // Create another layer in the pending tree that's not in the active tree. We |
+ // should get three pairs including the nondraw layers. |
+ host_impl_->CreatePendingTree(); |
+ host_impl_->pending_tree()->root_layer()->AddChild( |
+ FakePictureLayerImpl::Create(host_impl_->pending_tree(), 11)); |
+ |
+ LayerImpl* new_pending_layer = pending_tree->root_layer()->children()[1]; |
+ |
+ layer_pairs.clear(); |
+ host_impl_->GetPictureLayerImplPairs(&layer_pairs, false); |
+ EXPECT_EQ(3u, layer_pairs.size()); |
+ // The pair ordering is flaky, so make it consistent. |
+ if (layer_pairs[0].active != active_layer) |
+ std::swap(layer_pairs[0], layer_pairs[1]); |
+ if (layer_pairs[0].active != active_layer) |
+ std::swap(layer_pairs[0], layer_pairs[2]); |
+ if (layer_pairs[1].pending != new_pending_layer) |
+ std::swap(layer_pairs[1], layer_pairs[2]); |
EXPECT_EQ(active_layer, layer_pairs[0].active); |
EXPECT_EQ(pending_layer, layer_pairs[0].pending); |
EXPECT_EQ(new_pending_layer, layer_pairs[1].pending); |
EXPECT_EQ(nullptr, layer_pairs[1].active); |
+ EXPECT_EQ(active_nondraw_layer, layer_pairs[2].active); |
+ EXPECT_EQ(pending_nondraw_layer, layer_pairs[2].pending); |
+ |
+ host_impl_->pending_tree()->root_layer()->RemoveChild(new_pending_layer); |
+ |
+ // Have the pending layer be part of the RSLL now. It should appear in the |
+ // list, as should its active twin since we don't request only layers with |
+ // valid draw properties. |
+ pending_nondraw_layer->SetIsDrawnRenderSurfaceLayerListMember(true); |
+ |
+ layer_pairs.clear(); |
+ host_impl_->GetPictureLayerImplPairs(&layer_pairs, false); |
+ EXPECT_EQ(2u, layer_pairs.size()); |
+ // The pair ordering is flaky, so make it consistent. |
+ if (layer_pairs[0].active != active_layer) |
+ std::swap(layer_pairs[0], layer_pairs[1]); |
+ EXPECT_EQ(active_layer, layer_pairs[0].active); |
+ EXPECT_EQ(pending_layer, layer_pairs[0].pending); |
+ EXPECT_EQ(pending_nondraw_layer, layer_pairs[1].pending); |
+ EXPECT_EQ(active_nondraw_layer, layer_pairs[1].active); |
+ |
+ // Have the active layer be part of the RSLL now instead. It should appear in |
+ // the list, as should its pending twin since we don't request only layers |
+ // with valid draw properties. |
+ pending_nondraw_layer->SetIsDrawnRenderSurfaceLayerListMember(false); |
+ active_nondraw_layer->SetIsDrawnRenderSurfaceLayerListMember(true); |
+ |
+ layer_pairs.clear(); |
+ host_impl_->GetPictureLayerImplPairs(&layer_pairs, false); |
+ EXPECT_EQ(2u, layer_pairs.size()); |
+ // The pair ordering is flaky, so make it consistent. |
+ if (layer_pairs[0].active != active_layer) |
+ std::swap(layer_pairs[0], layer_pairs[1]); |
+ EXPECT_EQ(active_layer, layer_pairs[0].active); |
+ EXPECT_EQ(pending_layer, layer_pairs[0].pending); |
+ EXPECT_EQ(active_nondraw_layer, layer_pairs[1].active); |
+ EXPECT_EQ(pending_nondraw_layer, layer_pairs[1].pending); |
} |
TEST_F(LayerTreeHostImplTest, DidBecomeActive) { |