Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "cc/tiles/tile_task_manager.h" | |
| 6 | |
| 7 #include "base/memory/ptr_util.h" | |
| 8 #include "base/trace_event/trace_event.h" | |
| 9 | |
| 10 namespace cc { | |
| 11 | |
| 12 // static | |
| 13 std::unique_ptr<TileTaskManager> TileTaskManager::Create( | |
| 14 std::unique_ptr<TileTaskWorkerPool> tile_task_worker_pool, | |
| 15 TaskGraphRunner* task_graph_runner) { | |
| 16 return base::WrapUnique<TileTaskManager>( | |
| 17 new TileTaskManager(std::move(tile_task_worker_pool), task_graph_runner)); | |
| 18 } | |
| 19 | |
| 20 TileTaskManager::TileTaskManager( | |
| 21 std::unique_ptr<TileTaskWorkerPool> tile_task_worker_pool, | |
| 22 TaskGraphRunner* task_graph_runner) | |
| 23 : tile_task_worker_pool_(std::move(tile_task_worker_pool)), | |
| 24 task_graph_runner_(task_graph_runner), | |
| 25 namespace_token_(task_graph_runner->GetNamespaceToken()) {} | |
| 26 | |
| 27 TileTaskManager::TileTaskManager( | |
| 28 std::unique_ptr<TileTaskWorkerPool> tile_task_worker_pool) | |
| 29 : tile_task_worker_pool_(std::move(tile_task_worker_pool)) {} | |
| 30 | |
| 31 TileTaskManager::~TileTaskManager() { | |
| 32 DCHECK_EQ(0u, completed_tasks_.size()); | |
| 33 } | |
| 34 | |
| 35 void TileTaskManager::ScheduleTasks(TaskGraph* graph) { | |
| 36 TRACE_EVENT0("cc", "TileTaskManager::ScheduleTasksOnOriginThread"); | |
|
ericrk
2016/04/25 20:56:07
nit: trace event should read "TileTaskManager::Sch
| |
| 37 | |
| 38 for (TaskGraph::Node::Vector::iterator it = graph->nodes.begin(); | |
| 39 it != graph->nodes.end(); ++it) { | |
| 40 TaskGraph::Node& node = *it; | |
| 41 TileTask* task = static_cast<TileTask*>(node.task); | |
| 42 | |
| 43 if (!task->HasBeenScheduled()) { | |
| 44 task->WillSchedule(); | |
| 45 task->ScheduleOnOriginThread( | |
| 46 tile_task_worker_pool_->AsRasterBufferProvider()); | |
| 47 task->DidSchedule(); | |
| 48 } | |
| 49 } | |
| 50 | |
| 51 tile_task_worker_pool_->BarrierToSyncResources(); | |
| 52 | |
| 53 task_graph_runner_->ScheduleTasks(namespace_token_, graph); | |
| 54 } | |
| 55 | |
| 56 void TileTaskManager::CheckForCompletedTasks() { | |
| 57 TRACE_EVENT0("cc", "TileTaskManager::CheckForCompletedTasks"); | |
| 58 | |
| 59 task_graph_runner_->CollectCompletedTasks(namespace_token_, | |
| 60 &completed_tasks_); | |
| 61 for (Task::Vector::const_iterator it = completed_tasks_.begin(); | |
| 62 it != completed_tasks_.end(); ++it) { | |
| 63 TileTask* task = static_cast<TileTask*>(it->get()); | |
| 64 | |
| 65 task->WillComplete(); | |
| 66 task->CompleteOnOriginThread( | |
| 67 tile_task_worker_pool_->AsRasterBufferProvider()); | |
| 68 task->DidComplete(); | |
| 69 } | |
| 70 completed_tasks_.clear(); | |
| 71 } | |
| 72 | |
| 73 void TileTaskManager::Shutdown() { | |
| 74 TRACE_EVENT0("cc", "TileTaskManager::Shutdown"); | |
| 75 | |
| 76 TaskGraph empty; | |
| 77 task_graph_runner_->ScheduleTasks(namespace_token_, &empty); | |
| 78 task_graph_runner_->WaitForTasksToFinishRunning(namespace_token_); | |
| 79 } | |
| 80 | |
| 81 TileTaskWorkerPool* TileTaskManager::GetTileTaskWorkerPool() const { | |
| 82 return tile_task_worker_pool_.get(); | |
| 83 } | |
| 84 | |
| 85 } // namespace cc | |
| OLD | NEW |