OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/pixel_buffer_raster_worker_pool.h" | 5 #include "cc/resources/pixel_buffer_raster_worker_pool.h" |
6 | 6 |
7 #include "base/containers/stack_container.h" | 7 #include "base/containers/stack_container.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "cc/debug/traced_value.h" | 10 #include "cc/debug/traced_value.h" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
84 | 84 |
85 // Only used as std::find_if predicate for DCHECKs. | 85 // Only used as std::find_if predicate for DCHECKs. |
86 bool WasCanceled(const internal::RasterWorkerPoolTask* task) { | 86 bool WasCanceled(const internal::RasterWorkerPoolTask* task) { |
87 return task->WasCanceled(); | 87 return task->WasCanceled(); |
88 } | 88 } |
89 | 89 |
90 } // namespace | 90 } // namespace |
91 | 91 |
92 PixelBufferRasterWorkerPool::PixelBufferRasterWorkerPool( | 92 PixelBufferRasterWorkerPool::PixelBufferRasterWorkerPool( |
93 ResourceProvider* resource_provider, | 93 ResourceProvider* resource_provider, |
94 ContextProvider* context_provider, | |
94 size_t num_threads, | 95 size_t num_threads, |
95 size_t max_transfer_buffer_usage_bytes) | 96 size_t max_transfer_buffer_usage_bytes) |
96 : RasterWorkerPool(resource_provider, num_threads), | 97 : RasterWorkerPool(resource_provider, context_provider, num_threads), |
97 shutdown_(false), | 98 shutdown_(false), |
98 scheduled_raster_task_count_(0), | 99 scheduled_raster_task_count_(0), |
99 bytes_pending_upload_(0), | 100 bytes_pending_upload_(0), |
100 max_bytes_pending_upload_(max_transfer_buffer_usage_bytes), | 101 max_bytes_pending_upload_(max_transfer_buffer_usage_bytes), |
101 has_performed_uploads_since_last_flush_(false), | 102 has_performed_uploads_since_last_flush_(false), |
102 check_for_completed_raster_tasks_pending_(false), | 103 check_for_completed_raster_tasks_pending_(false), |
103 should_notify_client_if_no_tasks_are_pending_(false), | 104 should_notify_client_if_no_tasks_are_pending_(false), |
104 should_notify_client_if_no_tasks_required_for_activation_are_pending_( | 105 should_notify_client_if_no_tasks_required_for_activation_are_pending_( |
105 false) { | 106 false) { |
106 } | 107 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
142 if (!should_notify_client_if_no_tasks_are_pending_) | 143 if (!should_notify_client_if_no_tasks_are_pending_) |
143 TRACE_EVENT_ASYNC_BEGIN0("cc", "ScheduledTasks", this); | 144 TRACE_EVENT_ASYNC_BEGIN0("cc", "ScheduledTasks", this); |
144 | 145 |
145 should_notify_client_if_no_tasks_are_pending_ = true; | 146 should_notify_client_if_no_tasks_are_pending_ = true; |
146 should_notify_client_if_no_tasks_required_for_activation_are_pending_ = true; | 147 should_notify_client_if_no_tasks_required_for_activation_are_pending_ = true; |
147 | 148 |
148 tasks_required_for_activation_.clear(); | 149 tasks_required_for_activation_.clear(); |
149 | 150 |
150 // Build new pixel buffer task set. | 151 // Build new pixel buffer task set. |
151 TaskMap new_pixel_buffer_tasks; | 152 TaskMap new_pixel_buffer_tasks; |
153 RasterTaskVector gpu_rasterization_tasks; | |
152 for (RasterTaskVector::const_iterator it = raster_tasks().begin(); | 154 for (RasterTaskVector::const_iterator it = raster_tasks().begin(); |
153 it != raster_tasks().end(); ++it) { | 155 it != raster_tasks().end(); ++it) { |
154 internal::RasterWorkerPoolTask* task = it->get(); | 156 internal::RasterWorkerPoolTask* task = it->get(); |
155 DCHECK(new_pixel_buffer_tasks.find(task) == new_pixel_buffer_tasks.end()); | 157 DCHECK(new_pixel_buffer_tasks.find(task) == new_pixel_buffer_tasks.end()); |
156 DCHECK(!task->HasCompleted()); | 158 DCHECK(!task->HasCompleted()); |
157 DCHECK(!task->WasCanceled()); | 159 DCHECK(!task->WasCanceled()); |
158 | 160 |
161 if (task->use_gpu_rasterization()) { | |
162 gpu_rasterization_tasks.push_back(task); | |
163 continue; | |
164 } | |
165 | |
159 new_pixel_buffer_tasks[task] = pixel_buffer_tasks_[task]; | 166 new_pixel_buffer_tasks[task] = pixel_buffer_tasks_[task]; |
160 pixel_buffer_tasks_.erase(task); | 167 pixel_buffer_tasks_.erase(task); |
161 | 168 |
162 if (IsRasterTaskRequiredForActivation(task)) | 169 if (IsRasterTaskRequiredForActivation(task)) |
163 tasks_required_for_activation_.insert(task); | 170 tasks_required_for_activation_.insert(task); |
164 } | 171 } |
165 | 172 |
166 // Transfer remaining pixel buffer tasks to |new_pixel_buffer_tasks| | 173 // Transfer remaining pixel buffer tasks to |new_pixel_buffer_tasks| |
167 // and cancel all remaining inactive tasks. | 174 // and cancel all remaining inactive tasks. |
168 for (TaskMap::iterator it = pixel_buffer_tasks_.begin(); | 175 for (TaskMap::iterator it = pixel_buffer_tasks_.begin(); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
205 | 212 |
206 // Schedule new tasks. | 213 // Schedule new tasks. |
207 ScheduleMoreTasks(); | 214 ScheduleMoreTasks(); |
208 | 215 |
209 // Cancel any pending check for completed raster tasks and schedule | 216 // Cancel any pending check for completed raster tasks and schedule |
210 // another check. | 217 // another check. |
211 check_for_completed_raster_tasks_callback_.Cancel(); | 218 check_for_completed_raster_tasks_callback_.Cancel(); |
212 check_for_completed_raster_tasks_pending_ = false; | 219 check_for_completed_raster_tasks_pending_ = false; |
213 ScheduleCheckForCompletedRasterTasks(); | 220 ScheduleCheckForCompletedRasterTasks(); |
214 | 221 |
222 // Run raster tasks that use GPU on impl thread. | |
223 RasterWorkerPool::RunGpuRasterizationTasks(gpu_rasterization_tasks); | |
224 for (RasterTaskVector::iterator it = gpu_rasterization_tasks.begin(); | |
225 it != gpu_rasterization_tasks.end(); ++it) { | |
226 internal::RasterWorkerPoolTask* task = it->get(); | |
227 task->DidRun(false); | |
vmpstr
2013/12/17 22:52:45
In ImageRasterWorkerPool, similar block does a OnR
reveman
2013/12/17 23:03:16
Should this be done by RasterWorkerPool::RunGpuRas
alokp
2013/12/17 23:26:08
Yes. It can be. I was just following the pattern u
| |
228 task->WillComplete(); | |
229 task->CompleteOnOriginThread(); | |
230 task->DidComplete(); | |
reveman
2013/12/17 23:03:16
I think these 3 lines need to be moved to ::CheckF
alokp
2013/12/17 23:26:08
Are you suggesting implementing RasterWorkerPool::
reveman
2013/12/18 00:09:51
You already have an impl of this function below:
P
alokp
2013/12/18 22:49:22
I added an implementation of RWP::CheckForComplete
| |
231 } | |
232 | |
215 TRACE_EVENT_ASYNC_STEP_INTO1( | 233 TRACE_EVENT_ASYNC_STEP_INTO1( |
216 "cc", "ScheduledTasks", this, StateName(), | 234 "cc", "ScheduledTasks", this, StateName(), |
217 "state", TracedValue::FromValue(StateAsValue().release())); | 235 "state", TracedValue::FromValue(StateAsValue().release())); |
218 } | 236 } |
219 | 237 |
220 GLenum PixelBufferRasterWorkerPool::GetResourceTarget() const { | 238 GLenum PixelBufferRasterWorkerPool::GetResourceTarget() const { |
221 return GL_TEXTURE_2D; | 239 return GL_TEXTURE_2D; |
222 } | 240 } |
223 | 241 |
224 ResourceFormat PixelBufferRasterWorkerPool::GetResourceFormat() const { | 242 ResourceFormat PixelBufferRasterWorkerPool::GetResourceFormat() const { |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
668 | 686 |
669 throttle_state->SetInteger("bytes_available_for_upload", | 687 throttle_state->SetInteger("bytes_available_for_upload", |
670 max_bytes_pending_upload_ - bytes_pending_upload_); | 688 max_bytes_pending_upload_ - bytes_pending_upload_); |
671 throttle_state->SetInteger("bytes_pending_upload", bytes_pending_upload_); | 689 throttle_state->SetInteger("bytes_pending_upload", bytes_pending_upload_); |
672 throttle_state->SetInteger("scheduled_raster_task_count", | 690 throttle_state->SetInteger("scheduled_raster_task_count", |
673 scheduled_raster_task_count_); | 691 scheduled_raster_task_count_); |
674 return throttle_state.PassAs<base::Value>(); | 692 return throttle_state.PassAs<base::Value>(); |
675 } | 693 } |
676 | 694 |
677 } // namespace cc | 695 } // namespace cc |
OLD | NEW |