| 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 #include "cc/resources/direct_raster_worker_pool.h" | 5 #include "cc/resources/direct_raster_worker_pool.h" |
| 6 | 6 |
| 7 #include "cc/output/context_provider.h" | 7 #include "cc/output/context_provider.h" |
| 8 #include "cc/resources/resource.h" | 8 #include "cc/resources/resource.h" |
| 9 #include "cc/resources/resource_provider.h" | 9 #include "cc/resources/resource_provider.h" |
| 10 #include "gpu/command_buffer/client/gles2_interface.h" | 10 #include "gpu/command_buffer/client/gles2_interface.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 context_provider_(context_provider), | 27 context_provider_(context_provider), |
| 28 run_tasks_on_origin_thread_pending_(false), | 28 run_tasks_on_origin_thread_pending_(false), |
| 29 raster_tasks_pending_(false), | 29 raster_tasks_pending_(false), |
| 30 raster_tasks_required_for_activation_pending_(false), | 30 raster_tasks_required_for_activation_pending_(false), |
| 31 weak_factory_(this) {} | 31 weak_factory_(this) {} |
| 32 | 32 |
| 33 DirectRasterWorkerPool::~DirectRasterWorkerPool() { | 33 DirectRasterWorkerPool::~DirectRasterWorkerPool() { |
| 34 DCHECK_EQ(0u, completed_tasks_.size()); | 34 DCHECK_EQ(0u, completed_tasks_.size()); |
| 35 } | 35 } |
| 36 | 36 |
| 37 void DirectRasterWorkerPool::ScheduleTasks(RasterTask::Queue* queue) { | 37 void DirectRasterWorkerPool::ScheduleTasks(RasterTaskQueue* queue) { |
| 38 TRACE_EVENT0("cc", "DirectRasterWorkerPool::ScheduleTasks"); | 38 TRACE_EVENT0("cc", "DirectRasterWorkerPool::ScheduleTasks"); |
| 39 | 39 |
| 40 DCHECK_EQ(queue->required_for_activation_count, |
| 41 static_cast<size_t>( |
| 42 std::count_if(queue->items.begin(), |
| 43 queue->items.end(), |
| 44 RasterTaskQueue::Item::IsRequiredForActivation))); |
| 45 |
| 40 raster_tasks_pending_ = true; | 46 raster_tasks_pending_ = true; |
| 41 raster_tasks_required_for_activation_pending_ = true; | 47 raster_tasks_required_for_activation_pending_ = true; |
| 42 | 48 |
| 43 scoped_refptr<internal::WorkerPoolTask> | 49 scoped_refptr<internal::WorkerPoolTask> |
| 44 new_raster_required_for_activation_finished_task( | 50 new_raster_required_for_activation_finished_task( |
| 45 CreateRasterRequiredForActivationFinishedTask( | 51 CreateRasterRequiredForActivationFinishedTask( |
| 46 queue->required_for_activation_count())); | 52 queue->required_for_activation_count)); |
| 47 scoped_refptr<internal::WorkerPoolTask> new_raster_finished_task( | 53 scoped_refptr<internal::WorkerPoolTask> new_raster_finished_task( |
| 48 CreateRasterFinishedTask()); | 54 CreateRasterFinishedTask()); |
| 49 | 55 |
| 50 // Need to cancel tasks not present in new queue if we haven't had a | 56 // Need to cancel tasks not present in new queue if we haven't had a |
| 51 // chance to run the previous set of tasks yet. | 57 // chance to run the previous set of tasks yet. |
| 52 // TODO(reveman): Remove this once only tasks for which | 58 // TODO(reveman): Remove this once only tasks for which |
| 53 // ::ScheduleOnOriginThread has been called need to be canceled. | 59 // ::ScheduleOnOriginThread has been called need to be canceled. |
| 54 if (run_tasks_on_origin_thread_pending_) { | 60 if (run_tasks_on_origin_thread_pending_) { |
| 55 for (RasterTaskQueueIterator it(&raster_tasks_); it; ++it) { | 61 for (RasterTaskQueueIterator it(&raster_tasks_); it; ++it) { |
| 56 internal::RasterWorkerPoolTask* task = *it; | 62 internal::RasterWorkerPoolTask* task = *it; |
| 57 | 63 |
| 58 if (std::find_if(queue->tasks_.begin(), | 64 if (std::find_if(queue->items.begin(), |
| 59 queue->tasks_.end(), | 65 queue->items.end(), |
| 60 RasterTask::Queue::QueuedTask::TaskComparator(task)) == | 66 RasterTaskQueue::Item::TaskComparator(task)) == |
| 61 queue->tasks_.end()) | 67 queue->items.end()) |
| 62 completed_tasks_.push_back(task); | 68 completed_tasks_.push_back(task); |
| 63 } | 69 } |
| 64 } | 70 } |
| 65 | 71 |
| 66 ScheduleRunTasksOnOriginThread(); | 72 ScheduleRunTasksOnOriginThread(); |
| 67 | 73 |
| 68 raster_tasks_.Swap(queue); | 74 raster_tasks_.Swap(queue); |
| 69 | 75 |
| 70 set_raster_finished_task(new_raster_finished_task); | 76 set_raster_finished_task(new_raster_finished_task); |
| 71 set_raster_required_for_activation_finished_task( | 77 set_raster_required_for_activation_finished_task( |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 FROM_HERE, | 131 FROM_HERE, |
| 126 base::Bind(&DirectRasterWorkerPool::RunTasksOnOriginThread, | 132 base::Bind(&DirectRasterWorkerPool::RunTasksOnOriginThread, |
| 127 weak_factory_.GetWeakPtr())); | 133 weak_factory_.GetWeakPtr())); |
| 128 run_tasks_on_origin_thread_pending_ = true; | 134 run_tasks_on_origin_thread_pending_ = true; |
| 129 } | 135 } |
| 130 | 136 |
| 131 void DirectRasterWorkerPool::RunTasksOnOriginThread() { | 137 void DirectRasterWorkerPool::RunTasksOnOriginThread() { |
| 132 DCHECK(run_tasks_on_origin_thread_pending_); | 138 DCHECK(run_tasks_on_origin_thread_pending_); |
| 133 run_tasks_on_origin_thread_pending_ = false; | 139 run_tasks_on_origin_thread_pending_ = false; |
| 134 | 140 |
| 135 if (!raster_tasks_.tasks_.empty()) { | 141 if (!raster_tasks_.items.empty()) { |
| 136 GrContext* gr_context = context_provider_->GrContext(); | 142 GrContext* gr_context = context_provider_->GrContext(); |
| 137 // TODO(alokp): Implement TestContextProvider::GrContext(). | 143 // TODO(alokp): Implement TestContextProvider::GrContext(). |
| 138 if (gr_context) | 144 if (gr_context) |
| 139 gr_context->resetContext(); | 145 gr_context->resetContext(); |
| 140 | 146 |
| 141 for (RasterTaskQueueIterator it(&raster_tasks_); it; ++it) { | 147 for (RasterTaskQueueIterator it(&raster_tasks_); it; ++it) { |
| 142 internal::RasterWorkerPoolTask* task = *it; | 148 internal::RasterWorkerPoolTask* task = *it; |
| 143 DCHECK(!task->HasCompleted()); | 149 DCHECK(!task->HasCompleted()); |
| 144 | 150 |
| 145 // First need to run all dependencies. | 151 // First need to run all dependencies. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 165 // TODO(alokp): Implement TestContextProvider::GrContext(). | 171 // TODO(alokp): Implement TestContextProvider::GrContext(). |
| 166 if (gr_context) | 172 if (gr_context) |
| 167 gr_context->flush(); | 173 gr_context->flush(); |
| 168 } | 174 } |
| 169 | 175 |
| 170 RunTaskOnOriginThread(raster_required_for_activation_finished_task()); | 176 RunTaskOnOriginThread(raster_required_for_activation_finished_task()); |
| 171 RunTaskOnOriginThread(raster_finished_task()); | 177 RunTaskOnOriginThread(raster_finished_task()); |
| 172 } | 178 } |
| 173 | 179 |
| 174 } // namespace cc | 180 } // namespace cc |
| OLD | NEW |