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 #ifndef CC_RESOURCES_RASTER_WORKER_POOL_H_ | 5 #ifndef CC_RESOURCES_RASTER_WORKER_POOL_H_ |
6 #define CC_RESOURCES_RASTER_WORKER_POOL_H_ | 6 #define CC_RESOURCES_RASTER_WORKER_POOL_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
(...skipping 170 matching lines...) Loading... |
181 // Once scheduled, reply callbacks are guaranteed to run for all tasks | 181 // Once scheduled, reply callbacks are guaranteed to run for all tasks |
182 // even if they later get canceled by another call to ScheduleTasks(). | 182 // even if they later get canceled by another call to ScheduleTasks(). |
183 virtual void ScheduleTasks(RasterTask::Queue* queue) = 0; | 183 virtual void ScheduleTasks(RasterTask::Queue* queue) = 0; |
184 | 184 |
185 // Returns the target that needs to be used for raster task resources. | 185 // Returns the target that needs to be used for raster task resources. |
186 virtual GLenum GetResourceTarget() const = 0; | 186 virtual GLenum GetResourceTarget() const = 0; |
187 | 187 |
188 // Returns the format that needs to be used for raster task resources. | 188 // Returns the format that needs to be used for raster task resources. |
189 virtual ResourceFormat GetResourceFormat() const = 0; | 189 virtual ResourceFormat GetResourceFormat() const = 0; |
190 | 190 |
| 191 // Sets the number of threads to use for running raster tasks. |
| 192 // Can only be called once prior to GetNumRasterThreads(). |
| 193 // Caller is responsible for correct ordering. |
| 194 static void SetNumRasterThreads(int num_threads); |
| 195 |
191 // TODO(vmpstr): Figure out an elegant way to not pass this many parameters. | 196 // TODO(vmpstr): Figure out an elegant way to not pass this many parameters. |
192 static RasterTask CreateRasterTask( | 197 static RasterTask CreateRasterTask( |
193 const Resource* resource, | 198 const Resource* resource, |
194 PicturePileImpl* picture_pile, | 199 PicturePileImpl* picture_pile, |
195 gfx::Rect content_rect, | 200 gfx::Rect content_rect, |
196 float contents_scale, | 201 float contents_scale, |
197 RasterMode raster_mode, | 202 RasterMode raster_mode, |
198 TileResolution tile_resolution, | 203 TileResolution tile_resolution, |
199 int layer_id, | 204 int layer_id, |
200 const void* tile_id, | 205 const void* tile_id, |
(...skipping 10 matching lines...) Loading... |
211 | 216 |
212 protected: | 217 protected: |
213 typedef std::vector<scoped_refptr<internal::WorkerPoolTask> > TaskVector; | 218 typedef std::vector<scoped_refptr<internal::WorkerPoolTask> > TaskVector; |
214 typedef std::vector<scoped_refptr<internal::RasterWorkerPoolTask> > | 219 typedef std::vector<scoped_refptr<internal::RasterWorkerPoolTask> > |
215 RasterTaskVector; | 220 RasterTaskVector; |
216 typedef base::hash_set<internal::RasterWorkerPoolTask*> RasterTaskSet; | 221 typedef base::hash_set<internal::RasterWorkerPoolTask*> RasterTaskSet; |
217 typedef internal::RasterWorkerPoolTask* TaskMapKey; | 222 typedef internal::RasterWorkerPoolTask* TaskMapKey; |
218 typedef base::hash_map<TaskMapKey, | 223 typedef base::hash_map<TaskMapKey, |
219 scoped_refptr<internal::WorkerPoolTask> > TaskMap; | 224 scoped_refptr<internal::WorkerPoolTask> > TaskMap; |
220 | 225 |
221 RasterWorkerPool(ResourceProvider* resource_provider, size_t num_threads); | 226 explicit RasterWorkerPool(ResourceProvider* resource_provider); |
222 | 227 |
223 virtual void OnRasterTasksFinished() = 0; | 228 virtual void OnRasterTasksFinished() = 0; |
224 virtual void OnRasterTasksRequiredForActivationFinished() = 0; | 229 virtual void OnRasterTasksRequiredForActivationFinished() = 0; |
225 | 230 |
226 void SetRasterTasks(RasterTask::Queue* queue); | 231 void SetRasterTasks(RasterTask::Queue* queue); |
227 bool IsRasterTaskRequiredForActivation( | 232 bool IsRasterTaskRequiredForActivation( |
228 internal::RasterWorkerPoolTask* task) const; | 233 internal::RasterWorkerPoolTask* task) const; |
229 | 234 |
230 RasterWorkerPoolClient* client() const { return client_; } | 235 RasterWorkerPoolClient* client() const { return client_; } |
231 ResourceProvider* resource_provider() const { return resource_provider_; } | 236 ResourceProvider* resource_provider() const { return resource_provider_; } |
(...skipping 41 matching lines...) Loading... |
273 | 278 |
274 scoped_refptr<internal::WorkerPoolTask> raster_finished_task_; | 279 scoped_refptr<internal::WorkerPoolTask> raster_finished_task_; |
275 scoped_refptr<internal::WorkerPoolTask> | 280 scoped_refptr<internal::WorkerPoolTask> |
276 raster_required_for_activation_finished_task_; | 281 raster_required_for_activation_finished_task_; |
277 base::WeakPtrFactory<RasterWorkerPool> weak_ptr_factory_; | 282 base::WeakPtrFactory<RasterWorkerPool> weak_ptr_factory_; |
278 }; | 283 }; |
279 | 284 |
280 } // namespace cc | 285 } // namespace cc |
281 | 286 |
282 #endif // CC_RESOURCES_RASTER_WORKER_POOL_H_ | 287 #endif // CC_RESOURCES_RASTER_WORKER_POOL_H_ |
OLD | NEW |