| OLD | NEW |
| 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 #ifndef CC_RASTER_TASK_GRAPH_RUNNER_H_ | 5 #ifndef CC_RASTER_TASK_GRAPH_RUNNER_H_ |
| 6 #define CC_RASTER_TASK_GRAPH_RUNNER_H_ | 6 #define CC_RASTER_TASK_GRAPH_RUNNER_H_ |
| 7 | 7 |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 | 39 |
| 40 Task(); | 40 Task(); |
| 41 virtual ~Task(); | 41 virtual ~Task(); |
| 42 | 42 |
| 43 bool will_run_; | 43 bool will_run_; |
| 44 bool did_run_; | 44 bool did_run_; |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 // A task dependency graph describes the order in which to execute a set | 47 // A task dependency graph describes the order in which to execute a set |
| 48 // of tasks. Dependencies are represented as edges. Each node is assigned | 48 // of tasks. Dependencies are represented as edges. Each node is assigned |
| 49 // a category, a priority and a run count that matches the number of | 49 // a priority and a run count that matches the number of dependencies. |
| 50 // dependencies. Priority range from 0 (most favorable scheduling) to UINT16_MAX | 50 // Priority range from 0 (most favorable scheduling) to UINT_MAX |
| 51 // (least favorable). Categories range from 0 to UINT16_MAX. It is up to the | 51 // (least favorable). |
| 52 // implementation and its consumer to determine the meaning (if any) of a | |
| 53 // category. A TaskGraphRunner implementation may chose to prioritize certain | |
| 54 // categories over others, regardless of the individual priorities of tasks. | |
| 55 struct CC_EXPORT TaskGraph { | 52 struct CC_EXPORT TaskGraph { |
| 56 struct Node { | 53 struct Node { |
| 57 typedef std::vector<Node> Vector; | 54 typedef std::vector<Node> Vector; |
| 58 | 55 |
| 59 Node(Task* task, | 56 Node(Task* task, size_t priority, size_t dependencies) |
| 60 uint16_t category, | 57 : task(task), priority(priority), dependencies(dependencies) {} |
| 61 uint16_t priority, | |
| 62 uint32_t dependencies) | |
| 63 : task(task), | |
| 64 category(category), | |
| 65 priority(priority), | |
| 66 dependencies(dependencies) {} | |
| 67 | 58 |
| 68 Task* task; | 59 Task* task; |
| 69 uint16_t category; | 60 size_t priority; |
| 70 uint16_t priority; | 61 size_t dependencies; |
| 71 uint32_t dependencies; | |
| 72 }; | 62 }; |
| 73 | 63 |
| 74 struct Edge { | 64 struct Edge { |
| 75 typedef std::vector<Edge> Vector; | 65 typedef std::vector<Edge> Vector; |
| 76 | 66 |
| 77 Edge(const Task* task, Task* dependent) | 67 Edge(const Task* task, Task* dependent) |
| 78 : task(task), dependent(dependent) {} | 68 : task(task), dependent(dependent) {} |
| 79 | 69 |
| 80 const Task* task; | 70 const Task* task; |
| 81 Task* dependent; | 71 Task* dependent; |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 private: | 203 private: |
| 214 TaskGraph* graph_; | 204 TaskGraph* graph_; |
| 215 const Task* task_; | 205 const Task* task_; |
| 216 size_t current_index_; | 206 size_t current_index_; |
| 217 TaskGraph::Node* current_node_; | 207 TaskGraph::Node* current_node_; |
| 218 }; | 208 }; |
| 219 | 209 |
| 220 } // namespace cc | 210 } // namespace cc |
| 221 | 211 |
| 222 #endif // CC_RASTER_TASK_GRAPH_RUNNER_H_ | 212 #endif // CC_RASTER_TASK_GRAPH_RUNNER_H_ |
| OLD | NEW |