Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: cc/resources/pixel_buffer_raster_worker_pool.cc

Issue 165603002: cc: Move GPU raster to DirectRasterWorkerPool. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove rastertaskqueue changes and refactor worker pool delegate Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 12 matching lines...) Expand all
23 // Only used as std::find_if predicate for DCHECKs. 23 // Only used as std::find_if predicate for DCHECKs.
24 bool WasCanceled(const internal::RasterWorkerPoolTask* task) { 24 bool WasCanceled(const internal::RasterWorkerPoolTask* task) {
25 return !task->HasFinishedRunning(); 25 return !task->HasFinishedRunning();
26 } 26 }
27 27
28 } // namespace 28 } // namespace
29 29
30 // static 30 // static
31 scoped_ptr<RasterWorkerPool> PixelBufferRasterWorkerPool::Create( 31 scoped_ptr<RasterWorkerPool> PixelBufferRasterWorkerPool::Create(
32 ResourceProvider* resource_provider, 32 ResourceProvider* resource_provider,
33 ContextProvider* context_provider,
34 size_t max_transfer_buffer_usage_bytes) { 33 size_t max_transfer_buffer_usage_bytes) {
35 return make_scoped_ptr<RasterWorkerPool>( 34 return make_scoped_ptr<RasterWorkerPool>(
36 new PixelBufferRasterWorkerPool(GetTaskGraphRunner(), 35 new PixelBufferRasterWorkerPool(GetTaskGraphRunner(),
37 resource_provider, 36 resource_provider,
38 context_provider,
39 max_transfer_buffer_usage_bytes)); 37 max_transfer_buffer_usage_bytes));
40 } 38 }
41 39
42 PixelBufferRasterWorkerPool::PixelBufferRasterWorkerPool( 40 PixelBufferRasterWorkerPool::PixelBufferRasterWorkerPool(
43 internal::TaskGraphRunner* task_graph_runner, 41 internal::TaskGraphRunner* task_graph_runner,
44 ResourceProvider* resource_provider, 42 ResourceProvider* resource_provider,
45 ContextProvider* context_provider,
46 size_t max_transfer_buffer_usage_bytes) 43 size_t max_transfer_buffer_usage_bytes)
47 : RasterWorkerPool(task_graph_runner, resource_provider, context_provider), 44 : RasterWorkerPool(task_graph_runner, resource_provider),
48 shutdown_(false), 45 shutdown_(false),
49 scheduled_raster_task_count_(0), 46 scheduled_raster_task_count_(0),
50 bytes_pending_upload_(0), 47 bytes_pending_upload_(0),
51 max_bytes_pending_upload_(max_transfer_buffer_usage_bytes), 48 max_bytes_pending_upload_(max_transfer_buffer_usage_bytes),
52 has_performed_uploads_since_last_flush_(false), 49 has_performed_uploads_since_last_flush_(false),
53 check_for_completed_raster_tasks_pending_(false), 50 check_for_completed_raster_tasks_pending_(false),
54 should_notify_client_if_no_tasks_are_pending_(false), 51 should_notify_client_if_no_tasks_are_pending_(false),
55 should_notify_client_if_no_tasks_required_for_activation_are_pending_( 52 should_notify_client_if_no_tasks_required_for_activation_are_pending_(
56 false), 53 false),
57 raster_finished_task_pending_(false), 54 raster_finished_task_pending_(false),
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 if (!should_notify_client_if_no_tasks_are_pending_) 94 if (!should_notify_client_if_no_tasks_are_pending_)
98 TRACE_EVENT_ASYNC_BEGIN0("cc", "ScheduledTasks", this); 95 TRACE_EVENT_ASYNC_BEGIN0("cc", "ScheduledTasks", this);
99 96
100 should_notify_client_if_no_tasks_are_pending_ = true; 97 should_notify_client_if_no_tasks_are_pending_ = true;
101 should_notify_client_if_no_tasks_required_for_activation_are_pending_ = true; 98 should_notify_client_if_no_tasks_required_for_activation_are_pending_ = true;
102 99
103 raster_tasks_required_for_activation_.clear(); 100 raster_tasks_required_for_activation_.clear();
104 101
105 // Build new raster task state map. 102 // Build new raster task state map.
106 RasterTaskStateMap new_raster_task_states; 103 RasterTaskStateMap new_raster_task_states;
107 RasterTaskVector gpu_raster_tasks;
108 for (RasterTaskQueueIterator it(queue); it; ++it) { 104 for (RasterTaskQueueIterator it(queue); it; ++it) {
109 internal::RasterWorkerPoolTask* task = *it; 105 internal::RasterWorkerPoolTask* task = *it;
110 DCHECK(new_raster_task_states.find(task) == new_raster_task_states.end()); 106 DCHECK(new_raster_task_states.find(task) == new_raster_task_states.end());
111 107
112 if (task->use_gpu_rasterization()) {
113 gpu_raster_tasks.push_back(task);
114 continue;
115 }
116
117 RasterTaskStateMap::iterator state_it = raster_task_states_.find(task); 108 RasterTaskStateMap::iterator state_it = raster_task_states_.find(task);
118 if (state_it != raster_task_states_.end()) { 109 if (state_it != raster_task_states_.end()) {
119 RasterTaskState state = state_it->second; 110 RasterTaskState state = state_it->second;
120 111
121 new_raster_task_states[task] = state; 112 new_raster_task_states[task] = state;
122 // |raster_tasks_required_for_activation_| contains all tasks that need to 113 // |raster_tasks_required_for_activation_| contains all tasks that need to
123 // complete before we can send a "ready to activate" signal. Tasks that 114 // complete before we can send a "ready to activate" signal. Tasks that
124 // have already completed should not be part of this set. 115 // have already completed should not be part of this set.
125 if (state != COMPLETED && it.required_for_activation()) 116 if (state != COMPLETED && it.required_for_activation())
126 raster_tasks_required_for_activation_.insert(task); 117 raster_tasks_required_for_activation_.insert(task);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 FlushUploads(); 159 FlushUploads();
169 160
170 // Schedule new tasks. 161 // Schedule new tasks.
171 ScheduleMoreTasks(); 162 ScheduleMoreTasks();
172 163
173 // Cancel any pending check for completed raster tasks and schedule 164 // Cancel any pending check for completed raster tasks and schedule
174 // another check. 165 // another check.
175 check_for_completed_raster_tasks_time_ = base::TimeTicks(); 166 check_for_completed_raster_tasks_time_ = base::TimeTicks();
176 ScheduleCheckForCompletedRasterTasks(); 167 ScheduleCheckForCompletedRasterTasks();
177 168
178 if (!gpu_raster_tasks.empty())
179 RunGpuRasterTasks(gpu_raster_tasks);
180
181 TRACE_EVENT_ASYNC_STEP_INTO1( 169 TRACE_EVENT_ASYNC_STEP_INTO1(
182 "cc", 170 "cc",
183 "ScheduledTasks", 171 "ScheduledTasks",
184 this, 172 this,
185 StateName(), 173 StateName(),
186 "state", 174 "state",
187 TracedValue::FromValue(StateAsValue().release())); 175 TracedValue::FromValue(StateAsValue().release()));
188 } 176 }
189 177
190 unsigned PixelBufferRasterWorkerPool::GetResourceTarget() const { 178 unsigned PixelBufferRasterWorkerPool::GetResourceTarget() const {
(...skipping 25 matching lines...) Expand all
216 completed_raster_tasks_.front().get(); 204 completed_raster_tasks_.front().get();
217 DCHECK(raster_task_states_.find(task) != raster_task_states_.end()); 205 DCHECK(raster_task_states_.find(task) != raster_task_states_.end());
218 DCHECK_EQ(COMPLETED, raster_task_states_[task]); 206 DCHECK_EQ(COMPLETED, raster_task_states_[task]);
219 207
220 raster_task_states_.erase(task); 208 raster_task_states_.erase(task);
221 209
222 task->RunReplyOnOriginThread(); 210 task->RunReplyOnOriginThread();
223 211
224 completed_raster_tasks_.pop_front(); 212 completed_raster_tasks_.pop_front();
225 } 213 }
226
227 CheckForCompletedGpuRasterTasks();
228 } 214 }
229 215
230 SkCanvas* PixelBufferRasterWorkerPool::AcquireCanvasForRaster( 216 SkCanvas* PixelBufferRasterWorkerPool::AcquireCanvasForRaster(
231 internal::RasterWorkerPoolTask* task) { 217 internal::RasterWorkerPoolTask* task) {
232 if (task->use_gpu_rasterization())
233 return resource_provider()->MapDirectRasterBuffer(task->resource()->id());
234
235 resource_provider()->AcquirePixelRasterBuffer(task->resource()->id()); 218 resource_provider()->AcquirePixelRasterBuffer(task->resource()->id());
236 return resource_provider()->MapPixelRasterBuffer(task->resource()->id()); 219 return resource_provider()->MapPixelRasterBuffer(task->resource()->id());
237 } 220 }
238 221
239 void PixelBufferRasterWorkerPool::OnRasterCompleted( 222 void PixelBufferRasterWorkerPool::OnRasterCompleted(
240 internal::RasterWorkerPoolTask* task, 223 internal::RasterWorkerPoolTask* task,
241 const PicturePileImpl::Analysis& analysis) { 224 const PicturePileImpl::Analysis& analysis) {
242 if (task->use_gpu_rasterization()) {
243 resource_provider()->UnmapDirectRasterBuffer(task->resource()->id());
244 return;
245 }
246
247 TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("cc"), 225 TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("cc"),
248 "PixelBufferRasterWorkerPool::OnRasterCompleted", 226 "PixelBufferRasterWorkerPool::OnRasterCompleted",
249 "was_canceled", 227 "was_canceled",
250 !task->HasFinishedRunning(), 228 !task->HasFinishedRunning(),
251 "needs_upload", 229 "needs_upload",
252 task->HasFinishedRunning() && !analysis.is_solid_color); 230 task->HasFinishedRunning() && !analysis.is_solid_color);
253 231
254 DCHECK(raster_task_states_.find(task) != raster_task_states_.end()); 232 DCHECK(raster_task_states_.find(task) != raster_task_states_.end());
255 DCHECK_EQ(SCHEDULED, raster_task_states_[task]); 233 DCHECK_EQ(SCHEDULED, raster_task_states_[task]);
256 234
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 678
701 throttle_state->SetInteger("bytes_available_for_upload", 679 throttle_state->SetInteger("bytes_available_for_upload",
702 max_bytes_pending_upload_ - bytes_pending_upload_); 680 max_bytes_pending_upload_ - bytes_pending_upload_);
703 throttle_state->SetInteger("bytes_pending_upload", bytes_pending_upload_); 681 throttle_state->SetInteger("bytes_pending_upload", bytes_pending_upload_);
704 throttle_state->SetInteger("scheduled_raster_task_count", 682 throttle_state->SetInteger("scheduled_raster_task_count",
705 scheduled_raster_task_count_); 683 scheduled_raster_task_count_);
706 return throttle_state.PassAs<base::Value>(); 684 return throttle_state.PassAs<base::Value>();
707 } 685 }
708 686
709 } // namespace cc 687 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698