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 (RasterTaskQueue::Item::Vector::const_iterator it = |
56 internal::RasterWorkerPoolTask* task = *it; | 62 raster_tasks_.items.begin(); |
| 63 it != raster_tasks_.items.end(); |
| 64 ++it) { |
| 65 internal::RasterWorkerPoolTask* task = it->task; |
57 | 66 |
58 if (std::find_if(queue->tasks_.begin(), | 67 if (std::find_if(queue->items.begin(), |
59 queue->tasks_.end(), | 68 queue->items.end(), |
60 RasterTask::Queue::QueuedTask::TaskComparator(task)) == | 69 RasterTaskQueue::Item::TaskComparator(task)) == |
61 queue->tasks_.end()) | 70 queue->items.end()) |
62 completed_tasks_.push_back(task); | 71 completed_tasks_.push_back(task); |
63 } | 72 } |
64 } | 73 } |
65 | 74 |
66 ScheduleRunTasksOnOriginThread(); | 75 ScheduleRunTasksOnOriginThread(); |
67 | 76 |
68 raster_tasks_.Swap(queue); | 77 raster_tasks_.Swap(queue); |
69 | 78 |
70 set_raster_finished_task(new_raster_finished_task); | 79 set_raster_finished_task(new_raster_finished_task); |
71 set_raster_required_for_activation_finished_task( | 80 set_raster_required_for_activation_finished_task( |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 FROM_HERE, | 134 FROM_HERE, |
126 base::Bind(&DirectRasterWorkerPool::RunTasksOnOriginThread, | 135 base::Bind(&DirectRasterWorkerPool::RunTasksOnOriginThread, |
127 weak_factory_.GetWeakPtr())); | 136 weak_factory_.GetWeakPtr())); |
128 run_tasks_on_origin_thread_pending_ = true; | 137 run_tasks_on_origin_thread_pending_ = true; |
129 } | 138 } |
130 | 139 |
131 void DirectRasterWorkerPool::RunTasksOnOriginThread() { | 140 void DirectRasterWorkerPool::RunTasksOnOriginThread() { |
132 DCHECK(run_tasks_on_origin_thread_pending_); | 141 DCHECK(run_tasks_on_origin_thread_pending_); |
133 run_tasks_on_origin_thread_pending_ = false; | 142 run_tasks_on_origin_thread_pending_ = false; |
134 | 143 |
135 if (!raster_tasks_.tasks_.empty()) { | 144 if (!raster_tasks_.items.empty()) { |
136 GrContext* gr_context = context_provider_->GrContext(); | 145 GrContext* gr_context = context_provider_->GrContext(); |
137 // TODO(alokp): Implement TestContextProvider::GrContext(). | 146 // TODO(alokp): Implement TestContextProvider::GrContext(). |
138 if (gr_context) | 147 if (gr_context) |
139 gr_context->resetContext(); | 148 gr_context->resetContext(); |
140 | 149 |
141 for (RasterTaskQueueIterator it(&raster_tasks_); it; ++it) { | 150 for (RasterTaskQueue::Item::Vector::const_iterator it = |
142 internal::RasterWorkerPoolTask* task = *it; | 151 raster_tasks_.items.begin(); |
| 152 it != raster_tasks_.items.end(); |
| 153 ++it) { |
| 154 internal::RasterWorkerPoolTask* task = it->task; |
143 DCHECK(!task->HasCompleted()); | 155 DCHECK(!task->HasCompleted()); |
144 | 156 |
145 // First need to run all dependencies. | 157 // First need to run all dependencies. |
146 for (internal::WorkerPoolTask::Vector::const_iterator it = | 158 for (internal::WorkerPoolTask::Vector::const_iterator it = |
147 task->dependencies().begin(); | 159 task->dependencies().begin(); |
148 it != task->dependencies().end(); | 160 it != task->dependencies().end(); |
149 ++it) { | 161 ++it) { |
150 internal::WorkerPoolTask* dependency = it->get(); | 162 internal::WorkerPoolTask* dependency = it->get(); |
151 | 163 |
152 if (dependency->HasCompleted()) | 164 if (dependency->HasCompleted()) |
(...skipping 12 matching lines...) Expand all Loading... |
165 // TODO(alokp): Implement TestContextProvider::GrContext(). | 177 // TODO(alokp): Implement TestContextProvider::GrContext(). |
166 if (gr_context) | 178 if (gr_context) |
167 gr_context->flush(); | 179 gr_context->flush(); |
168 } | 180 } |
169 | 181 |
170 RunTaskOnOriginThread(raster_required_for_activation_finished_task()); | 182 RunTaskOnOriginThread(raster_required_for_activation_finished_task()); |
171 RunTaskOnOriginThread(raster_finished_task()); | 183 RunTaskOnOriginThread(raster_finished_task()); |
172 } | 184 } |
173 | 185 |
174 } // namespace cc | 186 } // namespace cc |
OLD | NEW |