diff options
author | hendrikw <hendrikw@chromium.org> | 2015-05-05 17:08:42 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-05-06 00:09:14 +0000 |
commit | 0ab2fae37182e138de686d775d578510a7b4e748 (patch) | |
tree | 1ea7da59e769844c9d2a8c97d9da62ed3d0cee1b /cc/trees | |
parent | acf8e4fa78466305b1bf7ac7da061f6b2248f58b (diff) | |
download | chromium_src-0ab2fae37182e138de686d775d578510a7b4e748.zip chromium_src-0ab2fae37182e138de686d775d578510a7b4e748.tar.gz chromium_src-0ab2fae37182e138de686d775d578510a7b4e748.tar.bz2 |
cc: Remove pairs from the raster and eviction queues
Replace the queue of layer pairs in the raster and eviction
queues with two separate queues.
BUG=483292
Review URL: https://codereview.chromium.org/1121383002
Cr-Commit-Position: refs/heads/master@{#328444}
Diffstat (limited to 'cc/trees')
-rw-r--r-- | cc/trees/layer_tree_host_impl.cc | 57 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_impl.h | 6 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_impl_unittest.cc | 265 |
3 files changed, 25 insertions, 303 deletions
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc index 3d566ba..1c602b9 100644 --- a/cc/trees/layer_tree_host_impl.cc +++ b/cc/trees/layer_tree_host_impl.cc @@ -1219,36 +1219,18 @@ void LayerTreeHostImpl::DidModifyTilePriorities() { client_->SetNeedsPrepareTilesOnImplThread(); } -void LayerTreeHostImpl::GetPictureLayerImplPairs( - std::vector<PictureLayerImpl::Pair>* layer_pairs, - bool need_valid_tile_priorities) const { - DCHECK(layer_pairs->empty()); +void LayerTreeHostImpl::GetValidTilePrioritiesPictureLayerImpls( + const LayerTreeImpl* tree, + std::vector<PictureLayerImpl*>* layers) const { + DCHECK(layers->empty()); - for (auto& layer : active_tree_->picture_layers()) { - if (need_valid_tile_priorities && !layer->HasValidTilePriorities()) - continue; - PictureLayerImpl* twin_layer = layer->GetPendingOrActiveTwinLayer(); - // Ignore the twin layer when tile priorities are invalid. - if (need_valid_tile_priorities && twin_layer && - !twin_layer->HasValidTilePriorities()) { - twin_layer = nullptr; - } - layer_pairs->push_back(PictureLayerImpl::Pair(layer, twin_layer)); - } + if (!tree) + return; - if (pending_tree_) { - for (auto& layer : pending_tree_->picture_layers()) { - if (need_valid_tile_priorities && !layer->HasValidTilePriorities()) - continue; - if (PictureLayerImpl* twin_layer = layer->GetPendingOrActiveTwinLayer()) { - if (!need_valid_tile_priorities || - twin_layer->HasValidTilePriorities()) { - // Already captured from the active tree. - continue; - } - } - layer_pairs->push_back(PictureLayerImpl::Pair(nullptr, layer)); - } + layers->reserve(tree->picture_layers().size()); + for (auto& layer : tree->picture_layers()) { + if (layer->HasValidTilePriorities()) + layers->push_back(layer); } } @@ -1256,19 +1238,24 @@ scoped_ptr<RasterTilePriorityQueue> LayerTreeHostImpl::BuildRasterQueue( TreePriority tree_priority, RasterTilePriorityQueue::Type type) { TRACE_EVENT0("cc", "LayerTreeHostImpl::BuildRasterQueue"); - picture_layer_pairs_.clear(); - GetPictureLayerImplPairs(&picture_layer_pairs_, true); - return RasterTilePriorityQueue::Create(picture_layer_pairs_, tree_priority, - type); + + std::vector<PictureLayerImpl*> active_layers; + std::vector<PictureLayerImpl*> pending_layers; + GetValidTilePrioritiesPictureLayerImpls(active_tree_.get(), &active_layers); + GetValidTilePrioritiesPictureLayerImpls(pending_tree_.get(), &pending_layers); + return RasterTilePriorityQueue::Create(active_layers, pending_layers, + tree_priority, type); } scoped_ptr<EvictionTilePriorityQueue> LayerTreeHostImpl::BuildEvictionQueue( TreePriority tree_priority) { TRACE_EVENT0("cc", "LayerTreeHostImpl::BuildEvictionQueue"); + scoped_ptr<EvictionTilePriorityQueue> queue(new EvictionTilePriorityQueue); - picture_layer_pairs_.clear(); - GetPictureLayerImplPairs(&picture_layer_pairs_, false); - queue->Build(picture_layer_pairs_, tree_priority); + queue->Build(active_tree_->picture_layers(), + pending_tree_ ? pending_tree_->picture_layers() + : std::vector<PictureLayerImpl*>(), + tree_priority); return queue; } diff --git a/cc/trees/layer_tree_host_impl.h b/cc/trees/layer_tree_host_impl.h index 720bbcd..cec3f60 100644 --- a/cc/trees/layer_tree_host_impl.h +++ b/cc/trees/layer_tree_host_impl.h @@ -496,8 +496,9 @@ class CC_EXPORT LayerTreeHostImpl void InsertSwapPromiseMonitor(SwapPromiseMonitor* monitor); void RemoveSwapPromiseMonitor(SwapPromiseMonitor* monitor); - void GetPictureLayerImplPairs(std::vector<PictureLayerImpl::Pair>* layers, - bool need_valid_tile_priorities) const; + void GetValidTilePrioritiesPictureLayerImpls( + const LayerTreeImpl* tree, + std::vector<PictureLayerImpl*>* layers) const; // TODO(weiliangc): Replace RequiresHighResToDraw with scheduler waits for // ReadyToDraw. crbug.com/469175 @@ -754,7 +755,6 @@ class CC_EXPORT LayerTreeHostImpl int id_; std::set<SwapPromiseMonitor*> swap_promise_monitor_; - std::vector<PictureLayerImpl::Pair> picture_layer_pairs_; bool requires_high_res_to_draw_; bool is_likely_to_require_a_draw_; diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc index ec519ee..5fcadfc 100644 --- a/cc/trees/layer_tree_host_impl_unittest.cc +++ b/cc/trees/layer_tree_host_impl_unittest.cc @@ -7408,271 +7408,6 @@ TEST_F(LayerTreeHostImplTest, ScrollAnimated) { EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); } -TEST_F(LayerTreeHostImplTest, GetPictureLayerImplPairs) { - 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->set_gpu_raster_max_texture_size(host_impl_->device_viewport_size()); - layer->UpdateRasterSource(pile, &empty_invalidation, null_tiling_set); - nondraw_layer->set_gpu_raster_max_texture_size( - host_impl_->device_viewport_size()); - 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); - EXPECT_EQ(1u, layer_pairs.size()); - EXPECT_EQ(pending_layer, layer_pairs[0].pending); - EXPECT_EQ(nullptr, layer_pairs[0].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, true); - EXPECT_EQ(1u, layer_pairs.size()); - EXPECT_EQ(active_layer, layer_pairs[0].active); - EXPECT_EQ(pending_layer, layer_pairs[0].pending); - - // Activate, the active layer has no twin now. - host_impl_->ActivateSyncTree(); - - layer_pairs.clear(); - host_impl_->GetPictureLayerImplPairs(&layer_pairs, true); - EXPECT_EQ(1u, layer_pairs.size()); - EXPECT_EQ(active_layer, layer_pairs[0].active); - EXPECT_EQ(nullptr, layer_pairs[0].pending); - - // Create another layer in the pending tree that's not in the active tree. We - // should get two pairs. - 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, 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->set_gpu_raster_max_texture_size(host_impl_->device_viewport_size()); - layer->UpdateRasterSource(pile, &empty_invalidation, null_tiling_set); - nondraw_layer->set_gpu_raster_max_texture_size( - host_impl_->device_viewport_size()); - 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) { host_impl_->CreatePendingTree(); host_impl_->ActivateSyncTree(); |