| Index: cc/raster/synchronous_task_graph_runner.cc
|
| diff --git a/cc/raster/synchronous_task_graph_runner.cc b/cc/raster/synchronous_task_graph_runner.cc
|
| index ed05cfb5823127277020491b4b5fbb0d6e3abbd2..156ef9acda846f0d2ef840ecee922d2aa3e69869 100644
|
| --- a/cc/raster/synchronous_task_graph_runner.cc
|
| +++ b/cc/raster/synchronous_task_graph_runner.cc
|
| @@ -4,6 +4,9 @@
|
|
|
| #include "cc/raster/synchronous_task_graph_runner.h"
|
|
|
| +#include <algorithm>
|
| +#include <utility>
|
| +
|
| #include "base/threading/simple_thread.h"
|
| #include "base/threading/thread_restrictions.h"
|
| #include "base/trace_event/trace_event.h"
|
| @@ -41,9 +44,9 @@ void SynchronousTaskGraphRunner::WaitForTasksToFinishRunning(
|
| if (!task_namespace)
|
| return;
|
|
|
| - while (
|
| - !TaskGraphWorkQueue::HasFinishedRunningTasksInNamespace(task_namespace)) {
|
| - RunTask();
|
| + while (!work_queue_.HasFinishedRunningTasksInNamespace(task_namespace)) {
|
| + bool succeeded = RunTask();
|
| + DCHECK(succeeded);
|
| }
|
| }
|
|
|
| @@ -57,14 +60,27 @@ void SynchronousTaskGraphRunner::CollectCompletedTasks(
|
| }
|
|
|
| void SynchronousTaskGraphRunner::RunUntilIdle() {
|
| - while (work_queue_.HasReadyToRunTasks())
|
| - RunTask();
|
| + while (RunTask()) {
|
| + }
|
| }
|
|
|
| -void SynchronousTaskGraphRunner::RunTask() {
|
| +bool SynchronousTaskGraphRunner::RunTask() {
|
| TRACE_EVENT0("toplevel", "SynchronousTaskGraphRunner::RunTask");
|
|
|
| - auto prioritized_task = work_queue_.GetNextTaskToRun();
|
| + // Find the first category with any tasks to run. This task graph runner
|
| + // treats categories as an additional priority.
|
| + const auto& ready_to_run_namespaces = work_queue_.ready_to_run_namespaces();
|
| + auto found = std::find_if(
|
| + ready_to_run_namespaces.cbegin(), ready_to_run_namespaces.cend(),
|
| + [](const std::pair<uint16_t, TaskGraphWorkQueue::TaskNamespace::Vector>&
|
| + pair) { return !pair.second.empty(); });
|
| +
|
| + if (found == ready_to_run_namespaces.cend()) {
|
| + return false;
|
| + }
|
| +
|
| + const uint16_t category = found->first;
|
| + auto prioritized_task = work_queue_.GetNextTaskToRun(category);
|
|
|
| Task* task = prioritized_task.task;
|
| task->WillRun();
|
| @@ -72,6 +88,8 @@ void SynchronousTaskGraphRunner::RunTask() {
|
| task->DidRun();
|
|
|
| work_queue_.CompleteTask(prioritized_task);
|
| +
|
| + return true;
|
| }
|
|
|
| } // namespace cc
|
|
|