Index: content/renderer/raster_worker_pool.cc |
diff --git a/content/renderer/raster_worker_pool.cc b/content/renderer/raster_worker_pool.cc |
index e8ed13bf8cad0012e91abc13f9b2d6d3b23b117a..90406fc7549f9130bb7e39ff37d5104fbc3fe80c 100644 |
--- a/content/renderer/raster_worker_pool.cc |
+++ b/content/renderer/raster_worker_pool.cc |
@@ -19,19 +19,22 @@ namespace { |
// A thread which forwards to RasterWorkerPool::Run with the runnable |
// categories. |
-class RasterWorkerPoolThread : public base::SimpleThread { |
+class RasterWorkerPoolThread : public base::TestSimpleThread { |
public: |
- RasterWorkerPoolThread(const std::string& name_prefix, |
+ RasterWorkerPoolThread(const TestSimpleThread::PrioritySet& priorities, |
+ const std::string& name_prefix, |
const Options& options, |
RasterWorkerPool* pool, |
std::vector<cc::TaskCategory> categories, |
base::ConditionVariable* has_ready_to_run_tasks_cv) |
- : SimpleThread(name_prefix, options), |
+ : TestSimpleThread(priorities, name_prefix, options), |
pool_(pool), |
categories_(categories), |
has_ready_to_run_tasks_cv_(has_ready_to_run_tasks_cv) {} |
- void Run() override { pool_->Run(categories_, has_ready_to_run_tasks_cv_); } |
+ void Run() override { |
+ pool_->Run(this, categories_, has_ready_to_run_tasks_cv_); |
+ } |
private: |
RasterWorkerPool* const pool_; |
@@ -133,8 +136,18 @@ void RasterWorkerPool::Start(int num_threads) { |
foreground_categories.push_back(cc::TASK_CATEGORY_NONCONCURRENT_FOREGROUND); |
foreground_categories.push_back(cc::TASK_CATEGORY_FOREGROUND); |
+ base::TestSimpleThread::PrioritySet only_foreground( |
+ base::ThreadPriority::NORMAL, base::ThreadPriority::NORMAL, |
+ base::ThreadPriority::NORMAL); |
+ |
+ base::TestSimpleThread::PrioritySet dynamic_background( |
+ base::ThreadPriority::BACKGROUND, base::ThreadPriority::BACKGROUND, |
+ base::ThreadPriority::NORMAL); |
+ |
+ // Create N normal priority threads and 1 background priority dynamic thread. |
for (int i = 0; i < num_threads; i++) { |
scoped_ptr<base::SimpleThread> thread(new RasterWorkerPoolThread( |
+ only_foreground, |
base::StringPrintf("CompositorTileWorker%u", |
static_cast<unsigned>(threads_.size() + 1)) |
.c_str(), |
@@ -155,6 +168,7 @@ void RasterWorkerPool::Start(int num_threads) { |
#endif |
scoped_ptr<base::SimpleThread> thread(new RasterWorkerPoolThread( |
+ dynamic_background, |
base::StringPrintf("CompositorTileWorker%u", |
static_cast<unsigned>(threads_.size() + 1)) |
.c_str(), |
@@ -225,12 +239,13 @@ bool RasterWorkerPool::RunsTasksOnCurrentThread() const { |
return true; |
} |
-void RasterWorkerPool::Run(const std::vector<cc::TaskCategory>& categories, |
+void RasterWorkerPool::Run(base::TestSimpleThread* runner, |
+ const std::vector<cc::TaskCategory>& categories, |
base::ConditionVariable* has_ready_to_run_tasks_cv) { |
base::AutoLock lock(lock_); |
while (true) { |
- if (!RunTaskWithLockAcquired(categories)) { |
+ if (!RunTaskWithLockAcquired(runner, categories)) { |
// We are no longer running tasks, which may allow another category to |
// start running. Signal other worker threads. |
SignalHasReadyToRunTasksWithLockAcquired(); |
@@ -318,7 +333,6 @@ void RasterWorkerPool::CollectCompletedTasks( |
cc::Task::Vector* completed_tasks) { |
TRACE_EVENT0("disabled-by-default-cc.debug", |
"RasterWorkerPool::CollectCompletedTasks"); |
- |
{ |
base::AutoLock lock(lock_); |
CollectCompletedTasksWithLockAcquired(token, completed_tasks); |
@@ -333,10 +347,11 @@ void RasterWorkerPool::CollectCompletedTasksWithLockAcquired( |
} |
bool RasterWorkerPool::RunTaskWithLockAcquired( |
+ base::TestSimpleThread* runner, |
const std::vector<cc::TaskCategory>& categories) { |
for (const auto& category : categories) { |
if (ShouldRunTaskForCategoryWithLockAcquired(category)) { |
- RunTaskInCategoryWithLockAcquired(category); |
+ RunTaskInCategoryWithLockAcquired(runner, category); |
return true; |
} |
} |
@@ -344,6 +359,7 @@ bool RasterWorkerPool::RunTaskWithLockAcquired( |
} |
void RasterWorkerPool::RunTaskInCategoryWithLockAcquired( |
+ base::TestSimpleThread* runner, |
cc::TaskCategory category) { |
TRACE_EVENT0("toplevel", "TaskGraphRunner::RunTask"); |
@@ -355,6 +371,7 @@ void RasterWorkerPool::RunTaskInCategoryWithLockAcquired( |
// There may be more work available, so wake up another worker thread. |
SignalHasReadyToRunTasksWithLockAcquired(); |
+ task->SetRunner(runner); |
// Call WillRun() before releasing |lock_| and running task. |
task->WillRun(); |
@@ -369,6 +386,11 @@ void RasterWorkerPool::RunTaskInCategoryWithLockAcquired( |
work_queue_.CompleteTask(prioritized_task); |
+ if (task->IsRasterTask()) |
+ runner->Restore(); |
+ |
+ task->SetRunner(nullptr); |
+ |
// If namespace has finished running all tasks, wake up origin threads. |
if (work_queue_.HasFinishedRunningTasksInNamespace( |
prioritized_task.task_namespace)) |