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_raster_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_raster_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 RunGpuRasterTasks(&gpu_raster_tasks); |
| 223 |
215 TRACE_EVENT_ASYNC_STEP_INTO1( | 224 TRACE_EVENT_ASYNC_STEP_INTO1( |
216 "cc", "ScheduledTasks", this, StateName(), | 225 "cc", "ScheduledTasks", this, StateName(), |
217 "state", TracedValue::FromValue(StateAsValue().release())); | 226 "state", TracedValue::FromValue(StateAsValue().release())); |
218 } | 227 } |
219 | 228 |
220 GLenum PixelBufferRasterWorkerPool::GetResourceTarget() const { | 229 GLenum PixelBufferRasterWorkerPool::GetResourceTarget() const { |
221 return GL_TEXTURE_2D; | 230 return GL_TEXTURE_2D; |
222 } | 231 } |
223 | 232 |
224 ResourceFormat PixelBufferRasterWorkerPool::GetResourceFormat() const { | 233 ResourceFormat PixelBufferRasterWorkerPool::GetResourceFormat() const { |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
577 | 586 |
578 void PixelBufferRasterWorkerPool::OnRasterTaskCompleted( | 587 void PixelBufferRasterWorkerPool::OnRasterTaskCompleted( |
579 scoped_refptr<internal::RasterWorkerPoolTask> task, | 588 scoped_refptr<internal::RasterWorkerPoolTask> task, |
580 bool was_canceled, | 589 bool was_canceled, |
581 bool needs_upload) { | 590 bool needs_upload) { |
582 TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("cc"), | 591 TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("cc"), |
583 "PixelBufferRasterWorkerPool::OnRasterTaskCompleted", | 592 "PixelBufferRasterWorkerPool::OnRasterTaskCompleted", |
584 "was_canceled", was_canceled, | 593 "was_canceled", was_canceled, |
585 "needs_upload", needs_upload); | 594 "needs_upload", needs_upload); |
586 | 595 |
| 596 DCHECK(!task->use_gpu_rasterization()); |
587 DCHECK(pixel_buffer_tasks_.find(task.get()) != pixel_buffer_tasks_.end()); | 597 DCHECK(pixel_buffer_tasks_.find(task.get()) != pixel_buffer_tasks_.end()); |
588 | 598 |
589 // Balanced with MapPixelBuffer() call in ScheduleMoreTasks(). | 599 // Balanced with MapPixelBuffer() call in ScheduleMoreTasks(). |
590 resource_provider()->UnmapPixelBuffer(task->resource()->id()); | 600 resource_provider()->UnmapPixelBuffer(task->resource()->id()); |
591 | 601 |
592 if (!needs_upload) { | 602 if (!needs_upload) { |
593 resource_provider()->ReleasePixelBuffer(task->resource()->id()); | 603 resource_provider()->ReleasePixelBuffer(task->resource()->id()); |
594 | 604 |
595 if (was_canceled) { | 605 if (was_canceled) { |
596 // When priorites change, a raster task can be canceled as a result of | 606 // When priorites change, a raster task can be canceled as a result of |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 | 678 |
669 throttle_state->SetInteger("bytes_available_for_upload", | 679 throttle_state->SetInteger("bytes_available_for_upload", |
670 max_bytes_pending_upload_ - bytes_pending_upload_); | 680 max_bytes_pending_upload_ - bytes_pending_upload_); |
671 throttle_state->SetInteger("bytes_pending_upload", bytes_pending_upload_); | 681 throttle_state->SetInteger("bytes_pending_upload", bytes_pending_upload_); |
672 throttle_state->SetInteger("scheduled_raster_task_count", | 682 throttle_state->SetInteger("scheduled_raster_task_count", |
673 scheduled_raster_task_count_); | 683 scheduled_raster_task_count_); |
674 return throttle_state.PassAs<base::Value>(); | 684 return throttle_state.PassAs<base::Value>(); |
675 } | 685 } |
676 | 686 |
677 } // namespace cc | 687 } // namespace cc |
OLD | NEW |