Chromium Code Reviews| 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 18 matching lines...) Expand all Loading... | |
| 29 public: | 29 public: |
| 30 typedef std::vector<scoped_refptr<WorkerPoolTask> > TaskVector; | 30 typedef std::vector<scoped_refptr<WorkerPoolTask> > TaskVector; |
| 31 | 31 |
| 32 // Returns true if |buffer| was written to. False indicate that | 32 // Returns true if |buffer| was written to. False indicate that |
| 33 // the content of |buffer| is undefined and the resource doesn't | 33 // the content of |buffer| is undefined and the resource doesn't |
| 34 // need to be initialized. | 34 // need to be initialized. |
| 35 virtual bool RunOnWorkerThread(unsigned thread_index, | 35 virtual bool RunOnWorkerThread(unsigned thread_index, |
| 36 void* buffer, | 36 void* buffer, |
| 37 gfx::Size size, | 37 gfx::Size size, |
| 38 int stride) = 0; | 38 int stride) = 0; |
| 39 virtual void RunOnOriginThread(ResourceProvider* resource_provider, | |
| 40 ContextProvider* context_provider) = 0; | |
| 39 virtual void CompleteOnOriginThread() = 0; | 41 virtual void CompleteOnOriginThread() = 0; |
| 40 | 42 |
| 41 void DidRun(bool was_canceled); | 43 void DidRun(bool was_canceled); |
| 42 bool HasFinishedRunning() const; | 44 bool HasFinishedRunning() const; |
| 43 bool WasCanceled() const; | 45 bool WasCanceled() const; |
| 44 void WillComplete(); | 46 void WillComplete(); |
| 45 void DidComplete(); | 47 void DidComplete(); |
| 46 bool HasCompleted() const; | 48 bool HasCompleted() const; |
| 47 | 49 |
| 48 const Resource* resource() const { return resource_; } | 50 const Resource* resource() const { return resource_; } |
| 49 const TaskVector& dependencies() const { return dependencies_; } | 51 const TaskVector& dependencies() const { return dependencies_; } |
| 52 bool use_gpu_rasterization() const { return use_gpu_rasterization_; } | |
| 50 | 53 |
| 51 protected: | 54 protected: |
| 52 friend class base::RefCounted<RasterWorkerPoolTask>; | 55 friend class base::RefCounted<RasterWorkerPoolTask>; |
| 53 | 56 |
| 54 RasterWorkerPoolTask(const Resource* resource, TaskVector* dependencies); | 57 RasterWorkerPoolTask(const Resource* resource, |
| 58 TaskVector* dependencies, | |
| 59 bool use_gpu_rasterization); | |
| 55 virtual ~RasterWorkerPoolTask(); | 60 virtual ~RasterWorkerPoolTask(); |
| 56 | 61 |
| 57 private: | 62 private: |
| 58 bool did_run_; | 63 bool did_run_; |
| 59 bool did_complete_; | 64 bool did_complete_; |
| 60 bool was_canceled_; | 65 bool was_canceled_; |
| 61 const Resource* resource_; | 66 const Resource* resource_; |
| 62 TaskVector dependencies_; | 67 TaskVector dependencies_; |
| 68 bool use_gpu_rasterization_; | |
| 63 }; | 69 }; |
| 64 | 70 |
| 65 } // namespace internal | 71 } // namespace internal |
| 66 } // namespace cc | 72 } // namespace cc |
| 67 | 73 |
| 68 #if defined(COMPILER_GCC) | 74 #if defined(COMPILER_GCC) |
| 69 namespace BASE_HASH_NAMESPACE { | 75 namespace BASE_HASH_NAMESPACE { |
| 70 template <> struct hash<cc::internal::RasterWorkerPoolTask*> { | 76 template <> struct hash<cc::internal::RasterWorkerPoolTask*> { |
| 71 size_t operator()(cc::internal::RasterWorkerPoolTask* ptr) const { | 77 size_t operator()(cc::internal::RasterWorkerPoolTask* ptr) const { |
| 72 return hash<size_t>()(reinterpret_cast<size_t>(ptr)); | 78 return hash<size_t>()(reinterpret_cast<size_t>(ptr)); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 192 static RasterTask CreateRasterTask( | 198 static RasterTask CreateRasterTask( |
| 193 const Resource* resource, | 199 const Resource* resource, |
| 194 PicturePileImpl* picture_pile, | 200 PicturePileImpl* picture_pile, |
| 195 gfx::Rect content_rect, | 201 gfx::Rect content_rect, |
| 196 float contents_scale, | 202 float contents_scale, |
| 197 RasterMode raster_mode, | 203 RasterMode raster_mode, |
| 198 TileResolution tile_resolution, | 204 TileResolution tile_resolution, |
| 199 int layer_id, | 205 int layer_id, |
| 200 const void* tile_id, | 206 const void* tile_id, |
| 201 int source_frame_number, | 207 int source_frame_number, |
| 208 bool use_gpu_rasterization, | |
| 202 RenderingStatsInstrumentation* rendering_stats, | 209 RenderingStatsInstrumentation* rendering_stats, |
| 203 const RasterTask::Reply& reply, | 210 const RasterTask::Reply& reply, |
| 204 Task::Set* dependencies); | 211 Task::Set* dependencies); |
| 205 | 212 |
| 206 static Task CreateImageDecodeTask( | 213 static Task CreateImageDecodeTask( |
| 207 skia::LazyPixelRef* pixel_ref, | 214 skia::LazyPixelRef* pixel_ref, |
| 208 int layer_id, | 215 int layer_id, |
| 209 RenderingStatsInstrumentation* stats_instrumentation, | 216 RenderingStatsInstrumentation* stats_instrumentation, |
| 210 const Task::Reply& reply); | 217 const Task::Reply& reply); |
| 211 | 218 |
| 212 protected: | 219 protected: |
| 213 typedef std::vector<scoped_refptr<internal::WorkerPoolTask> > TaskVector; | 220 typedef std::vector<scoped_refptr<internal::WorkerPoolTask> > TaskVector; |
| 214 typedef std::vector<scoped_refptr<internal::RasterWorkerPoolTask> > | 221 typedef std::vector<scoped_refptr<internal::RasterWorkerPoolTask> > |
| 215 RasterTaskVector; | 222 RasterTaskVector; |
| 216 typedef base::hash_set<internal::RasterWorkerPoolTask*> RasterTaskSet; | 223 typedef base::hash_set<internal::RasterWorkerPoolTask*> RasterTaskSet; |
| 217 typedef internal::RasterWorkerPoolTask* TaskMapKey; | 224 typedef internal::RasterWorkerPoolTask* TaskMapKey; |
| 218 typedef base::hash_map<TaskMapKey, | 225 typedef base::hash_map<TaskMapKey, |
| 219 scoped_refptr<internal::WorkerPoolTask> > TaskMap; | 226 scoped_refptr<internal::WorkerPoolTask> > TaskMap; |
| 220 | 227 |
| 221 RasterWorkerPool(ResourceProvider* resource_provider, size_t num_threads); | 228 RasterWorkerPool(ResourceProvider* resource_provider, |
| 229 ContextProvider* context_provider, | |
| 230 size_t num_threads); | |
| 222 | 231 |
| 223 virtual void OnRasterTasksFinished() = 0; | 232 virtual void OnRasterTasksFinished() = 0; |
| 224 virtual void OnRasterTasksRequiredForActivationFinished() = 0; | 233 virtual void OnRasterTasksRequiredForActivationFinished() = 0; |
| 225 | 234 |
| 226 void SetRasterTasks(RasterTask::Queue* queue); | 235 void SetRasterTasks(RasterTask::Queue* queue); |
| 227 bool IsRasterTaskRequiredForActivation( | 236 bool IsRasterTaskRequiredForActivation( |
| 228 internal::RasterWorkerPoolTask* task) const; | 237 internal::RasterWorkerPoolTask* task) const; |
| 238 void RunGpuRasterizationTasks(RasterTaskVector& tasks); | |
|
reveman
2013/12/17 23:03:16
can this be "const RasterTaskVector&"? otherwise "
alokp
2013/12/18 22:49:22
Done.
| |
| 229 | 239 |
| 230 RasterWorkerPoolClient* client() const { return client_; } | 240 RasterWorkerPoolClient* client() const { return client_; } |
| 231 ResourceProvider* resource_provider() const { return resource_provider_; } | 241 ResourceProvider* resource_provider() const { return resource_provider_; } |
| 242 ContextProvider* context_provider() const { return context_provider_; } | |
| 232 const RasterTaskVector& raster_tasks() const { return raster_tasks_; } | 243 const RasterTaskVector& raster_tasks() const { return raster_tasks_; } |
| 233 const RasterTaskSet& raster_tasks_required_for_activation() const { | 244 const RasterTaskSet& raster_tasks_required_for_activation() const { |
| 234 return raster_tasks_required_for_activation_; | 245 return raster_tasks_required_for_activation_; |
| 235 } | 246 } |
| 236 void set_raster_finished_task( | 247 void set_raster_finished_task( |
| 237 scoped_refptr<internal::WorkerPoolTask> raster_finished_task) { | 248 scoped_refptr<internal::WorkerPoolTask> raster_finished_task) { |
| 238 raster_finished_task_ = raster_finished_task; | 249 raster_finished_task_ = raster_finished_task; |
| 239 } | 250 } |
| 240 void set_raster_required_for_activation_finished_task( | 251 void set_raster_required_for_activation_finished_task( |
| 241 scoped_refptr<internal::WorkerPoolTask> | 252 scoped_refptr<internal::WorkerPoolTask> |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 261 unsigned priority, | 272 unsigned priority, |
| 262 TaskGraph* graph); | 273 TaskGraph* graph); |
| 263 | 274 |
| 264 private: | 275 private: |
| 265 void OnRasterFinished(const internal::WorkerPoolTask* source); | 276 void OnRasterFinished(const internal::WorkerPoolTask* source); |
| 266 void OnRasterRequiredForActivationFinished( | 277 void OnRasterRequiredForActivationFinished( |
| 267 const internal::WorkerPoolTask* source); | 278 const internal::WorkerPoolTask* source); |
| 268 | 279 |
| 269 RasterWorkerPoolClient* client_; | 280 RasterWorkerPoolClient* client_; |
| 270 ResourceProvider* resource_provider_; | 281 ResourceProvider* resource_provider_; |
| 282 ContextProvider* context_provider_; | |
| 271 RasterTask::Queue::TaskVector raster_tasks_; | 283 RasterTask::Queue::TaskVector raster_tasks_; |
| 272 RasterTask::Queue::TaskSet raster_tasks_required_for_activation_; | 284 RasterTask::Queue::TaskSet raster_tasks_required_for_activation_; |
| 273 | 285 |
| 274 scoped_refptr<internal::WorkerPoolTask> raster_finished_task_; | 286 scoped_refptr<internal::WorkerPoolTask> raster_finished_task_; |
| 275 scoped_refptr<internal::WorkerPoolTask> | 287 scoped_refptr<internal::WorkerPoolTask> |
| 276 raster_required_for_activation_finished_task_; | 288 raster_required_for_activation_finished_task_; |
| 277 base::WeakPtrFactory<RasterWorkerPool> weak_ptr_factory_; | 289 base::WeakPtrFactory<RasterWorkerPool> weak_ptr_factory_; |
| 278 }; | 290 }; |
| 279 | 291 |
| 280 } // namespace cc | 292 } // namespace cc |
| 281 | 293 |
| 282 #endif // CC_RESOURCES_RASTER_WORKER_POOL_H_ | 294 #endif // CC_RESOURCES_RASTER_WORKER_POOL_H_ |
| OLD | NEW |