Chromium Code Reviews| Index: cc/trees/layer_tree_host_impl.cc |
| diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc |
| index c3ea50005021f8a1dd963afa3e169da0fa834971..3f8d8e1aa2892c8cbfc5bff369924537643f41ba 100644 |
| --- a/cc/trees/layer_tree_host_impl.cc |
| +++ b/cc/trees/layer_tree_host_impl.cc |
| @@ -216,6 +216,7 @@ LayerTreeHostImpl::LayerTreeHostImpl( |
| : client_(client), |
| proxy_(proxy), |
| use_gpu_rasterization_(false), |
| + on_demand_task_graph_runner_(NULL), |
| input_handler_client_(NULL), |
| did_lock_scrolling_layer_(false), |
| should_bubble_scrolls_(false), |
| @@ -1872,6 +1873,7 @@ void LayerTreeHostImpl::CreateAndSetTileManager() { |
| ContextProvider* context_provider = output_surface_->context_provider(); |
| transfer_buffer_memory_limit_ = |
| GetMaxTransferBufferUsageBytes(context_provider); |
| + on_demand_task_graph_runner_ = NULL; |
|
reveman
2014/06/20 03:56:30
nit: doesn't look like you need this line
|
| if (use_gpu_rasterization_ && context_provider) { |
| resource_pool_ = |
| @@ -1883,6 +1885,11 @@ void LayerTreeHostImpl::CreateAndSetTileManager() { |
| DirectRasterWorkerPool::Create(proxy_->ImplThreadTaskRunner(), |
| resource_provider_.get(), |
| context_provider); |
| + |
| + if (!synchronous_on_demand_task_graph_runner_) |
| + synchronous_on_demand_task_graph_runner_.reset(new TaskGraphRunner); |
|
reveman
2014/06/20 03:56:30
A TaskGraphRunner instance is relatively lightweig
boliu
2014/06/20 04:21:06
Then don't need scoped_ptr either. Just embed the
|
| + on_demand_task_graph_runner_ = |
| + synchronous_on_demand_task_graph_runner_.get(); |
| } else if (UseZeroCopyTextureUpload()) { |
| resource_pool_ = |
| ResourcePool::Create(resource_provider_.get(), |
| @@ -1893,6 +1900,7 @@ void LayerTreeHostImpl::CreateAndSetTileManager() { |
| ImageRasterWorkerPool::Create(proxy_->ImplThreadTaskRunner(), |
| RasterWorkerPool::GetTaskGraphRunner(), |
| resource_provider_.get()); |
| + on_demand_task_graph_runner_ = RasterWorkerPool::GetTaskGraphRunner(); |
| } else if (UseOneCopyTextureUpload()) { |
| // We need to create a staging resource pool when using copy rasterizer. |
| staging_resource_pool_ = |
| @@ -1909,6 +1917,7 @@ void LayerTreeHostImpl::CreateAndSetTileManager() { |
| RasterWorkerPool::GetTaskGraphRunner(), |
| resource_provider_.get(), |
| staging_resource_pool_.get()); |
| + on_demand_task_graph_runner_ = RasterWorkerPool::GetTaskGraphRunner(); |
| } else { |
| resource_pool_ = ResourcePool::Create( |
| resource_provider_.get(), |
| @@ -1920,6 +1929,7 @@ void LayerTreeHostImpl::CreateAndSetTileManager() { |
| RasterWorkerPool::GetTaskGraphRunner(), |
| resource_provider_.get(), |
| transfer_buffer_memory_limit_); |
| + on_demand_task_graph_runner_ = RasterWorkerPool::GetTaskGraphRunner(); |
| } |
| tile_manager_ = |
| @@ -1931,6 +1941,7 @@ void LayerTreeHostImpl::CreateAndSetTileManager() { |
| UpdateTileManagerMemoryPolicy(ActualManagedMemoryPolicy()); |
| need_to_update_visible_tiles_before_draw_ = false; |
| + on_demand_task_namespace_ = on_demand_task_graph_runner_->GetNamespaceToken(); |
| } |
| void LayerTreeHostImpl::DestroyTileManager() { |
| @@ -2761,6 +2772,36 @@ void LayerTreeHostImpl::SetFullRootLayerDamage() { |
| SetViewportDamage(gfx::Rect(DrawViewportSize())); |
| } |
| +void LayerTreeHostImpl::RunOnDemandRasterTask(Task* on_demand_raster_task) { |
| + DCHECK(on_demand_task_graph_runner_); |
| + |
| + // Construct a task graph that contains this single raster task. |
| + TaskGraph graph; |
| + graph.nodes.push_back( |
| + TaskGraph::Node(on_demand_raster_task, |
| + RasterWorkerPool::kOnDemandRasterTaskPriority, |
| + 0u)); |
| + |
| + // Schedule task and wait for task graph runner to finish running it. |
| + on_demand_task_graph_runner_->ScheduleTasks(on_demand_task_namespace_, |
| + &graph); |
| + |
| + if (synchronous_on_demand_task_graph_runner_.get() == |
| + on_demand_task_graph_runner_) { |
| + on_demand_task_graph_runner_->RunUntilIdle(); |
| + } else { |
|
reveman
2014/06/20 03:56:30
can you remove this "else" and always call WaitFor
|
| + on_demand_task_graph_runner_->WaitForTasksToFinishRunning( |
| + on_demand_task_namespace_); |
| + } |
| + |
| + // Collect task now that it has finished running. |
| + Task::Vector completed_tasks; |
| + on_demand_task_graph_runner_->CollectCompletedTasks(on_demand_task_namespace_, |
| + &completed_tasks); |
| + DCHECK_EQ(1u, completed_tasks.size()); |
| + DCHECK_EQ(completed_tasks[0], on_demand_raster_task); |
| +} |
| + |
| void LayerTreeHostImpl::ScrollViewportBy(gfx::Vector2dF scroll_delta) { |
| DCHECK(InnerViewportScrollLayer()); |
| LayerImpl* scroll_layer = OuterViewportScrollLayer() |