OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/synchronous_task_graph_runner.h" | 5 #include "cc/raster/synchronous_task_graph_runner.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <utility> | 10 #include <utility> |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 return; | 47 return; |
48 | 48 |
49 while (!work_queue_.HasFinishedRunningTasksInNamespace(task_namespace)) { | 49 while (!work_queue_.HasFinishedRunningTasksInNamespace(task_namespace)) { |
50 bool succeeded = RunTask(); | 50 bool succeeded = RunTask(); |
51 DCHECK(succeeded); | 51 DCHECK(succeeded); |
52 } | 52 } |
53 } | 53 } |
54 | 54 |
55 void SynchronousTaskGraphRunner::CollectCompletedTasks( | 55 void SynchronousTaskGraphRunner::CollectCompletedTasks( |
56 NamespaceToken token, | 56 NamespaceToken token, |
57 Task::Vector* completed_tasks) { | 57 DependencyTask::Vector* completed_tasks) { |
58 TRACE_EVENT0("cc", "SynchronousTaskGraphRunner::CollectCompletedTasks"); | 58 TRACE_EVENT0("cc", "SynchronousTaskGraphRunner::CollectCompletedTasks"); |
59 | 59 |
60 DCHECK(token.IsValid()); | 60 DCHECK(token.IsValid()); |
61 work_queue_.CollectCompletedTasks(token, completed_tasks); | 61 work_queue_.CollectCompletedTasks(token, completed_tasks); |
62 } | 62 } |
63 | 63 |
64 void SynchronousTaskGraphRunner::RunUntilIdle() { | 64 void SynchronousTaskGraphRunner::RunUntilIdle() { |
65 while (RunTask()) { | 65 while (RunTask()) { |
66 } | 66 } |
67 } | 67 } |
68 | 68 |
69 bool SynchronousTaskGraphRunner::RunTask() { | 69 bool SynchronousTaskGraphRunner::RunTask() { |
70 TRACE_EVENT0("toplevel", "SynchronousTaskGraphRunner::RunTask"); | 70 TRACE_EVENT0("toplevel", "SynchronousTaskGraphRunner::RunTask"); |
71 | 71 |
72 // Find the first category with any tasks to run. This task graph runner | 72 // Find the first category with any tasks to run. This task graph runner |
73 // treats categories as an additional priority. | 73 // treats categories as an additional priority. |
74 const auto& ready_to_run_namespaces = work_queue_.ready_to_run_namespaces(); | 74 const auto& ready_to_run_namespaces = work_queue_.ready_to_run_namespaces(); |
75 auto found = std::find_if( | 75 auto found = std::find_if( |
76 ready_to_run_namespaces.cbegin(), ready_to_run_namespaces.cend(), | 76 ready_to_run_namespaces.cbegin(), ready_to_run_namespaces.cend(), |
77 [](const std::pair<uint16_t, TaskGraphWorkQueue::TaskNamespace::Vector>& | 77 [](const std::pair<uint16_t, TaskGraphWorkQueue::TaskNamespace::Vector>& |
78 pair) { return !pair.second.empty(); }); | 78 pair) { return !pair.second.empty(); }); |
79 | 79 |
80 if (found == ready_to_run_namespaces.cend()) { | 80 if (found == ready_to_run_namespaces.cend()) { |
81 return false; | 81 return false; |
82 } | 82 } |
83 | 83 |
84 const uint16_t category = found->first; | 84 const uint16_t category = found->first; |
85 auto prioritized_task = work_queue_.GetNextTaskToRun(category); | 85 auto prioritized_task = work_queue_.GetNextTaskToRun(category); |
86 | 86 |
87 Task* task = prioritized_task.task; | 87 DependencyTask* task = prioritized_task.task; |
88 task->WillRun(); | 88 task->WillRun(); |
89 task->RunOnWorkerThread(); | 89 task->RunOnWorkerThread(); |
90 task->DidRun(); | 90 task->DidRun(); |
91 | 91 |
92 work_queue_.CompleteTask(prioritized_task); | 92 work_queue_.CompleteTask(prioritized_task); |
93 | 93 |
94 return true; | 94 return true; |
95 } | 95 } |
96 | 96 |
97 } // namespace cc | 97 } // namespace cc |
OLD | NEW |