Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(557)

Side by Side Diff: cc/raster/task_graph_work_queue.cc

Issue 1890903002: cc: Simplify Task and its derived classes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remove_tile_task_runner
Patch Set: feedback Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/raster/task_graph_work_queue.h" 5 #include "cc/raster/task_graph_work_queue.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 25 matching lines...) Expand all
36 // Compare based on task priority of the ready_to_run_tasks heap .front() 36 // Compare based on task priority of the ready_to_run_tasks heap .front()
37 // will hold the max element of the heap, except after pop_heap, when max 37 // will hold the max element of the heap, except after pop_heap, when max
38 // element is moved to .back(). 38 // element is moved to .back().
39 return CompareTaskPriority(a->ready_to_run_tasks.at(category_).front(), 39 return CompareTaskPriority(a->ready_to_run_tasks.at(category_).front(),
40 b->ready_to_run_tasks.at(category_).front()); 40 b->ready_to_run_tasks.at(category_).front());
41 } 41 }
42 42
43 private: 43 private:
44 uint16_t category_; 44 uint16_t category_;
45 }; 45 };
46
47 // Helper class for iterating over all dependents of a task.
48 class DependentIterator {
49 public:
50 DependentIterator(TaskGraph* graph, const Task* task)
51 : graph_(graph),
52 task_(task),
53 current_index_(static_cast<size_t>(-1)),
54 current_node_(NULL) {
55 ++(*this);
56 }
57
58 TaskGraph::Node& operator->() const {
59 DCHECK_LT(current_index_, graph_->edges.size());
60 DCHECK_EQ(graph_->edges[current_index_].task, task_);
61 DCHECK(current_node_);
62 return *current_node_;
63 }
64
65 TaskGraph::Node& operator*() const {
66 DCHECK_LT(current_index_, graph_->edges.size());
67 DCHECK_EQ(graph_->edges[current_index_].task, task_);
68 DCHECK(current_node_);
69 return *current_node_;
70 }
71
72 // Note: Performance can be improved by keeping edges sorted.
73 DependentIterator& operator++() {
74 // Find next dependency edge for |task_|.
75 do {
76 ++current_index_;
77 if (current_index_ == graph_->edges.size())
78 return *this;
79 } while (graph_->edges[current_index_].task != task_);
80
81 // Now find the node for the dependent of this edge.
82 TaskGraph::Node::Vector::iterator it = std::find_if(
83 graph_->nodes.begin(), graph_->nodes.end(),
84 [this](const TaskGraph::Node& node) {
85 return node.task == graph_->edges[current_index_].dependent;
86 });
87 DCHECK(it != graph_->nodes.end());
88 current_node_ = &(*it);
89
90 return *this;
91 }
92
93 operator bool() const { return current_index_ < graph_->edges.size(); }
94
95 private:
96 TaskGraph* graph_;
97 const Task* task_;
98 size_t current_index_;
99 TaskGraph::Node* current_node_;
100 };
101
46 } // namespace 102 } // namespace
47 103
48 TaskGraphWorkQueue::TaskNamespace::TaskNamespace() {} 104 TaskGraphWorkQueue::TaskNamespace::TaskNamespace() {}
49 105
50 TaskGraphWorkQueue::TaskNamespace::TaskNamespace(const TaskNamespace& other) = 106 TaskGraphWorkQueue::TaskNamespace::TaskNamespace(const TaskNamespace& other) =
51 default; 107 default;
52 108
53 TaskGraphWorkQueue::TaskNamespace::~TaskNamespace() {} 109 TaskGraphWorkQueue::TaskNamespace::~TaskNamespace() {}
54 110
55 TaskGraphWorkQueue::TaskGraphWorkQueue() : next_namespace_id_(1) {} 111 TaskGraphWorkQueue::TaskGraphWorkQueue() : next_namespace_id_(1) {}
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 357
302 for (const TaskGraph::Node& node : graph->nodes) { 358 for (const TaskGraph::Node& node : graph->nodes) {
303 if (dependents[node.task] != node.dependencies) 359 if (dependents[node.task] != node.dependencies)
304 return true; 360 return true;
305 } 361 }
306 362
307 return false; 363 return false;
308 } 364 }
309 365
310 } // namespace cc 366 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698