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

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

Issue 328263005: cc: Rename DirectRasterWorkerPool to GpuRasterWorkerPool (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updated build.gn file Created 6 years, 5 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
« no previous file with comments | « cc/resources/gpu_raster_worker_pool.h ('k') | cc/resources/raster_worker_pool_perftest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/gpu_raster_worker_pool.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "cc/output/context_provider.h" 8 #include "cc/output/context_provider.h"
9 #include "cc/resources/resource.h" 9 #include "cc/resources/resource.h"
10 #include "cc/resources/resource_provider.h" 10 #include "cc/resources/resource_provider.h"
11 #include "gpu/command_buffer/client/gles2_interface.h" 11 #include "gpu/command_buffer/client/gles2_interface.h"
12 #include "third_party/skia/include/gpu/GrContext.h" 12 #include "third_party/skia/include/gpu/GrContext.h"
13 13
14 namespace cc { 14 namespace cc {
15 15
16 // static 16 // static
17 scoped_ptr<RasterWorkerPool> DirectRasterWorkerPool::Create( 17 scoped_ptr<RasterWorkerPool> GpuRasterWorkerPool::Create(
18 base::SequencedTaskRunner* task_runner, 18 base::SequencedTaskRunner* task_runner,
19 ResourceProvider* resource_provider, 19 ResourceProvider* resource_provider,
20 ContextProvider* context_provider) { 20 ContextProvider* context_provider) {
21 return make_scoped_ptr<RasterWorkerPool>(new DirectRasterWorkerPool( 21 return make_scoped_ptr<RasterWorkerPool>(new GpuRasterWorkerPool(
22 task_runner, resource_provider, context_provider)); 22 task_runner, resource_provider, context_provider));
23 } 23 }
24 24
25 DirectRasterWorkerPool::DirectRasterWorkerPool( 25 GpuRasterWorkerPool::GpuRasterWorkerPool(base::SequencedTaskRunner* task_runner,
26 base::SequencedTaskRunner* task_runner, 26 ResourceProvider* resource_provider,
27 ResourceProvider* resource_provider, 27 ContextProvider* context_provider)
28 ContextProvider* context_provider)
29 : task_runner_(task_runner), 28 : task_runner_(task_runner),
30 task_graph_runner_(new TaskGraphRunner), 29 task_graph_runner_(new TaskGraphRunner),
31 namespace_token_(task_graph_runner_->GetNamespaceToken()), 30 namespace_token_(task_graph_runner_->GetNamespaceToken()),
32 resource_provider_(resource_provider), 31 resource_provider_(resource_provider),
33 context_provider_(context_provider), 32 context_provider_(context_provider),
34 run_tasks_on_origin_thread_pending_(false), 33 run_tasks_on_origin_thread_pending_(false),
35 raster_tasks_pending_(false), 34 raster_tasks_pending_(false),
36 raster_tasks_required_for_activation_pending_(false), 35 raster_tasks_required_for_activation_pending_(false),
37 raster_finished_weak_ptr_factory_(this), 36 raster_finished_weak_ptr_factory_(this),
38 weak_ptr_factory_(this) {} 37 weak_ptr_factory_(this) {
38 DCHECK(context_provider_);
39 }
39 40
40 DirectRasterWorkerPool::~DirectRasterWorkerPool() { 41 GpuRasterWorkerPool::~GpuRasterWorkerPool() {
41 DCHECK_EQ(0u, completed_tasks_.size()); 42 DCHECK_EQ(0u, completed_tasks_.size());
42 } 43 }
43 44
44 Rasterizer* DirectRasterWorkerPool::AsRasterizer() { return this; } 45 Rasterizer* GpuRasterWorkerPool::AsRasterizer() {
46 return this;
47 }
45 48
46 void DirectRasterWorkerPool::SetClient(RasterizerClient* client) { 49 void GpuRasterWorkerPool::SetClient(RasterizerClient* client) {
47 client_ = client; 50 client_ = client;
48 } 51 }
49 52
50 void DirectRasterWorkerPool::Shutdown() { 53 void GpuRasterWorkerPool::Shutdown() {
51 TRACE_EVENT0("cc", "DirectRasterWorkerPool::Shutdown"); 54 TRACE_EVENT0("cc", "GpuRasterWorkerPool::Shutdown");
52 55
53 TaskGraph empty; 56 TaskGraph empty;
54 task_graph_runner_->ScheduleTasks(namespace_token_, &empty); 57 task_graph_runner_->ScheduleTasks(namespace_token_, &empty);
55 task_graph_runner_->WaitForTasksToFinishRunning(namespace_token_); 58 task_graph_runner_->WaitForTasksToFinishRunning(namespace_token_);
56 } 59 }
57 60
58 void DirectRasterWorkerPool::ScheduleTasks(RasterTaskQueue* queue) { 61 void GpuRasterWorkerPool::ScheduleTasks(RasterTaskQueue* queue) {
59 TRACE_EVENT0("cc", "DirectRasterWorkerPool::ScheduleTasks"); 62 TRACE_EVENT0("cc", "GpuRasterWorkerPool::ScheduleTasks");
60 63
61 DCHECK_EQ(queue->required_for_activation_count, 64 DCHECK_EQ(queue->required_for_activation_count,
62 static_cast<size_t>( 65 static_cast<size_t>(
63 std::count_if(queue->items.begin(), 66 std::count_if(queue->items.begin(),
64 queue->items.end(), 67 queue->items.end(),
65 RasterTaskQueue::Item::IsRequiredForActivation))); 68 RasterTaskQueue::Item::IsRequiredForActivation)));
66 69
67 raster_tasks_pending_ = true; 70 raster_tasks_pending_ = true;
68 raster_tasks_required_for_activation_pending_ = true; 71 raster_tasks_required_for_activation_pending_ = true;
69 72
70 unsigned priority = kRasterTaskPriorityBase; 73 unsigned priority = kRasterTaskPriorityBase;
71 74
72 graph_.Reset(); 75 graph_.Reset();
73 76
74 // Cancel existing OnRasterFinished callbacks. 77 // Cancel existing OnRasterFinished callbacks.
75 raster_finished_weak_ptr_factory_.InvalidateWeakPtrs(); 78 raster_finished_weak_ptr_factory_.InvalidateWeakPtrs();
76 79
77 scoped_refptr<RasterizerTask> 80 scoped_refptr<RasterizerTask>
78 new_raster_required_for_activation_finished_task( 81 new_raster_required_for_activation_finished_task(
79 CreateRasterRequiredForActivationFinishedTask( 82 CreateRasterRequiredForActivationFinishedTask(
80 queue->required_for_activation_count, 83 queue->required_for_activation_count,
81 task_runner_.get(), 84 task_runner_.get(),
82 base::Bind(&DirectRasterWorkerPool:: 85 base::Bind(
83 OnRasterRequiredForActivationFinished, 86 &GpuRasterWorkerPool::OnRasterRequiredForActivationFinished,
84 raster_finished_weak_ptr_factory_.GetWeakPtr()))); 87 raster_finished_weak_ptr_factory_.GetWeakPtr())));
85 scoped_refptr<RasterizerTask> new_raster_finished_task( 88 scoped_refptr<RasterizerTask> new_raster_finished_task(
86 CreateRasterFinishedTask( 89 CreateRasterFinishedTask(
87 task_runner_.get(), 90 task_runner_.get(),
88 base::Bind(&DirectRasterWorkerPool::OnRasterFinished, 91 base::Bind(&GpuRasterWorkerPool::OnRasterFinished,
89 raster_finished_weak_ptr_factory_.GetWeakPtr()))); 92 raster_finished_weak_ptr_factory_.GetWeakPtr())));
90 93
91 for (RasterTaskQueue::Item::Vector::const_iterator it = queue->items.begin(); 94 for (RasterTaskQueue::Item::Vector::const_iterator it = queue->items.begin();
92 it != queue->items.end(); 95 it != queue->items.end();
93 ++it) { 96 ++it) {
94 const RasterTaskQueue::Item& item = *it; 97 const RasterTaskQueue::Item& item = *it;
95 RasterTask* task = item.task; 98 RasterTask* task = item.task;
96 DCHECK(!task->HasCompleted()); 99 DCHECK(!task->HasCompleted());
97 100
98 if (item.required_for_activation) { 101 if (item.required_for_activation) {
(...skipping 19 matching lines...) Expand all
118 ScheduleTasksOnOriginThread(this, &graph_); 121 ScheduleTasksOnOriginThread(this, &graph_);
119 task_graph_runner_->ScheduleTasks(namespace_token_, &graph_); 122 task_graph_runner_->ScheduleTasks(namespace_token_, &graph_);
120 123
121 ScheduleRunTasksOnOriginThread(); 124 ScheduleRunTasksOnOriginThread();
122 125
123 raster_finished_task_ = new_raster_finished_task; 126 raster_finished_task_ = new_raster_finished_task;
124 raster_required_for_activation_finished_task_ = 127 raster_required_for_activation_finished_task_ =
125 new_raster_required_for_activation_finished_task; 128 new_raster_required_for_activation_finished_task;
126 } 129 }
127 130
128 void DirectRasterWorkerPool::CheckForCompletedTasks() { 131 void GpuRasterWorkerPool::CheckForCompletedTasks() {
129 TRACE_EVENT0("cc", "DirectRasterWorkerPool::CheckForCompletedTasks"); 132 TRACE_EVENT0("cc", "GpuRasterWorkerPool::CheckForCompletedTasks");
130 133
131 task_graph_runner_->CollectCompletedTasks(namespace_token_, 134 task_graph_runner_->CollectCompletedTasks(namespace_token_,
132 &completed_tasks_); 135 &completed_tasks_);
133 for (Task::Vector::const_iterator it = completed_tasks_.begin(); 136 for (Task::Vector::const_iterator it = completed_tasks_.begin();
134 it != completed_tasks_.end(); 137 it != completed_tasks_.end();
135 ++it) { 138 ++it) {
136 RasterizerTask* task = static_cast<RasterizerTask*>(it->get()); 139 RasterizerTask* task = static_cast<RasterizerTask*>(it->get());
137 140
138 task->WillComplete(); 141 task->WillComplete();
139 task->CompleteOnOriginThread(this); 142 task->CompleteOnOriginThread(this);
140 task->DidComplete(); 143 task->DidComplete();
141 144
142 task->RunReplyOnOriginThread(); 145 task->RunReplyOnOriginThread();
143 } 146 }
144 completed_tasks_.clear(); 147 completed_tasks_.clear();
145 } 148 }
146 149
147 SkCanvas* DirectRasterWorkerPool::AcquireCanvasForRaster(RasterTask* task) { 150 SkCanvas* GpuRasterWorkerPool::AcquireCanvasForRaster(RasterTask* task) {
148 return resource_provider_->MapDirectRasterBuffer(task->resource()->id()); 151 return resource_provider_->MapGpuRasterBuffer(task->resource()->id());
149 } 152 }
150 153
151 void DirectRasterWorkerPool::ReleaseCanvasForRaster(RasterTask* task) { 154 void GpuRasterWorkerPool::ReleaseCanvasForRaster(RasterTask* task) {
152 resource_provider_->UnmapDirectRasterBuffer(task->resource()->id()); 155 resource_provider_->UnmapGpuRasterBuffer(task->resource()->id());
153 } 156 }
154 157
155 void DirectRasterWorkerPool::OnRasterFinished() { 158 void GpuRasterWorkerPool::OnRasterFinished() {
156 TRACE_EVENT0("cc", "DirectRasterWorkerPool::OnRasterFinished"); 159 TRACE_EVENT0("cc", "GpuRasterWorkerPool::OnRasterFinished");
157 160
158 DCHECK(raster_tasks_pending_); 161 DCHECK(raster_tasks_pending_);
159 raster_tasks_pending_ = false; 162 raster_tasks_pending_ = false;
160 client_->DidFinishRunningTasks(); 163 client_->DidFinishRunningTasks();
161 } 164 }
162 165
163 void DirectRasterWorkerPool::OnRasterRequiredForActivationFinished() { 166 void GpuRasterWorkerPool::OnRasterRequiredForActivationFinished() {
164 TRACE_EVENT0("cc", 167 TRACE_EVENT0("cc",
165 "DirectRasterWorkerPool::OnRasterRequiredForActivationFinished"); 168 "GpuRasterWorkerPool::OnRasterRequiredForActivationFinished");
166 169
167 DCHECK(raster_tasks_required_for_activation_pending_); 170 DCHECK(raster_tasks_required_for_activation_pending_);
168 raster_tasks_required_for_activation_pending_ = false; 171 raster_tasks_required_for_activation_pending_ = false;
169 client_->DidFinishRunningTasksRequiredForActivation(); 172 client_->DidFinishRunningTasksRequiredForActivation();
170 } 173 }
171 174
172 void DirectRasterWorkerPool::ScheduleRunTasksOnOriginThread() { 175 void GpuRasterWorkerPool::ScheduleRunTasksOnOriginThread() {
173 if (run_tasks_on_origin_thread_pending_) 176 if (run_tasks_on_origin_thread_pending_)
174 return; 177 return;
175 178
176 task_runner_->PostTask( 179 task_runner_->PostTask(
177 FROM_HERE, 180 FROM_HERE,
178 base::Bind(&DirectRasterWorkerPool::RunTasksOnOriginThread, 181 base::Bind(&GpuRasterWorkerPool::RunTasksOnOriginThread,
179 weak_ptr_factory_.GetWeakPtr())); 182 weak_ptr_factory_.GetWeakPtr()));
180 run_tasks_on_origin_thread_pending_ = true; 183 run_tasks_on_origin_thread_pending_ = true;
181 } 184 }
182 185
183 void DirectRasterWorkerPool::RunTasksOnOriginThread() { 186 void GpuRasterWorkerPool::RunTasksOnOriginThread() {
184 TRACE_EVENT0("cc", "DirectRasterWorkerPool::RunTasksOnOriginThread"); 187 TRACE_EVENT0("cc", "GpuRasterWorkerPool::RunTasksOnOriginThread");
185 188
186 DCHECK(run_tasks_on_origin_thread_pending_); 189 DCHECK(run_tasks_on_origin_thread_pending_);
187 run_tasks_on_origin_thread_pending_ = false; 190 run_tasks_on_origin_thread_pending_ = false;
188 191
189 if (context_provider_) { 192 DCHECK(context_provider_->ContextGL());
190 DCHECK(context_provider_->ContextGL()); 193 // TODO(alokp): Use a trace macro to push/pop markers.
191 // TODO(alokp): Use a trace macro to push/pop markers. 194 // Using push/pop functions directly incurs cost to evaluate function
192 // Using push/pop functions directly incurs cost to evaluate function 195 // arguments even when tracing is disabled.
193 // arguments even when tracing is disabled. 196 context_provider_->ContextGL()->PushGroupMarkerEXT(
194 context_provider_->ContextGL()->PushGroupMarkerEXT( 197 0, "GpuRasterWorkerPool::RunTasksOnOriginThread");
195 0, "DirectRasterWorkerPool::RunTasksOnOriginThread");
196 198
197 GrContext* gr_context = context_provider_->GrContext(); 199 GrContext* gr_context = context_provider_->GrContext();
198 // TODO(alokp): Implement TestContextProvider::GrContext(). 200 // TODO(alokp): Implement TestContextProvider::GrContext().
199 if (gr_context) 201 if (gr_context)
200 gr_context->resetContext(); 202 gr_context->resetContext();
201 }
202 203
203 task_graph_runner_->RunUntilIdle(); 204 task_graph_runner_->RunUntilIdle();
204 205
205 if (context_provider_) { 206 // TODO(alokp): Implement TestContextProvider::GrContext().
206 GrContext* gr_context = context_provider_->GrContext(); 207 if (gr_context)
207 // TODO(alokp): Implement TestContextProvider::GrContext(). 208 gr_context->flush();
208 if (gr_context)
209 gr_context->flush();
210 209
211 context_provider_->ContextGL()->PopGroupMarkerEXT(); 210 context_provider_->ContextGL()->PopGroupMarkerEXT();
212 }
213 } 211 }
214 212
215 } // namespace cc 213 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/gpu_raster_worker_pool.h ('k') | cc/resources/raster_worker_pool_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698