| Index: cc/raster/task_graph_work_queue.cc
|
| diff --git a/cc/raster/task_graph_work_queue.cc b/cc/raster/task_graph_work_queue.cc
|
| index 98413eee1a668a196f137dd9f4ce0ffbfe59bdff..aa7565473aec4c35e08d9c007db6d9c8c6d38499 100644
|
| --- a/cc/raster/task_graph_work_queue.cc
|
| +++ b/cc/raster/task_graph_work_queue.cc
|
| @@ -43,6 +43,62 @@ class CompareTaskNamespacePriority {
|
| private:
|
| uint16_t category_;
|
| };
|
| +
|
| +// Helper class for iterating over all dependents of a task.
|
| +class DependentIterator {
|
| + public:
|
| + DependentIterator(TaskGraph* graph, const Task* task)
|
| + : graph_(graph),
|
| + task_(task),
|
| + current_index_(static_cast<size_t>(-1)),
|
| + current_node_(NULL) {
|
| + ++(*this);
|
| + }
|
| +
|
| + TaskGraph::Node& operator->() const {
|
| + DCHECK_LT(current_index_, graph_->edges.size());
|
| + DCHECK_EQ(graph_->edges[current_index_].task, task_);
|
| + DCHECK(current_node_);
|
| + return *current_node_;
|
| + }
|
| +
|
| + TaskGraph::Node& operator*() const {
|
| + DCHECK_LT(current_index_, graph_->edges.size());
|
| + DCHECK_EQ(graph_->edges[current_index_].task, task_);
|
| + DCHECK(current_node_);
|
| + return *current_node_;
|
| + }
|
| +
|
| + // Note: Performance can be improved by keeping edges sorted.
|
| + DependentIterator& operator++() {
|
| + // Find next dependency edge for |task_|.
|
| + do {
|
| + ++current_index_;
|
| + if (current_index_ == graph_->edges.size())
|
| + return *this;
|
| + } while (graph_->edges[current_index_].task != task_);
|
| +
|
| + // Now find the node for the dependent of this edge.
|
| + TaskGraph::Node::Vector::iterator it = std::find_if(
|
| + graph_->nodes.begin(), graph_->nodes.end(),
|
| + [this](const TaskGraph::Node& node) {
|
| + return node.task == graph_->edges[current_index_].dependent;
|
| + });
|
| + DCHECK(it != graph_->nodes.end());
|
| + current_node_ = &(*it);
|
| +
|
| + return *this;
|
| + }
|
| +
|
| + operator bool() const { return current_index_ < graph_->edges.size(); }
|
| +
|
| + private:
|
| + TaskGraph* graph_;
|
| + const Task* task_;
|
| + size_t current_index_;
|
| + TaskGraph::Node* current_node_;
|
| +};
|
| +
|
| } // namespace
|
|
|
| TaskGraphWorkQueue::TaskNamespace::TaskNamespace() {}
|
|
|