| 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 bool is_tile_in_pending_tree_now_bin; | 98 bool is_tile_in_pending_tree_now_bin; |
| 99 TileResolution tile_resolution; | 99 TileResolution tile_resolution; |
| 100 int layer_id; | 100 int layer_id; |
| 101 const void* tile_id; | 101 const void* tile_id; |
| 102 int source_frame_number; | 102 int source_frame_number; |
| 103 }; | 103 }; |
| 104 | 104 |
| 105 class CC_EXPORT RasterWorkerPoolClient { | 105 class CC_EXPORT RasterWorkerPoolClient { |
| 106 public: | 106 public: |
| 107 virtual bool ShouldForceTasksRequiredForActivationToComplete() const = 0; | 107 virtual bool ShouldForceTasksRequiredForActivationToComplete() const = 0; |
| 108 virtual void DidFinishedRunningTasks() = 0; |
| 109 virtual void DidFinishedRunningTasksRequiredForActivation() = 0; |
| 108 | 110 |
| 109 protected: | 111 protected: |
| 110 virtual ~RasterWorkerPoolClient() {} | 112 virtual ~RasterWorkerPoolClient() {} |
| 111 }; | 113 }; |
| 112 | 114 |
| 113 // A worker thread pool that runs raster tasks. | 115 // A worker thread pool that runs raster tasks. |
| 114 class CC_EXPORT RasterWorkerPool : public WorkerPool { | 116 class CC_EXPORT RasterWorkerPool : public WorkerPool { |
| 115 public: | 117 public: |
| 116 class CC_EXPORT Task { | 118 class CC_EXPORT Task { |
| 117 public: | 119 public: |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 RenderingStatsInstrumentation* stats_instrumentation, | 226 RenderingStatsInstrumentation* stats_instrumentation, |
| 225 const Task::Reply& reply); | 227 const Task::Reply& reply); |
| 226 | 228 |
| 227 protected: | 229 protected: |
| 228 typedef std::vector<scoped_refptr<internal::WorkerPoolTask> > TaskVector; | 230 typedef std::vector<scoped_refptr<internal::WorkerPoolTask> > TaskVector; |
| 229 typedef std::vector<scoped_refptr<internal::RasterWorkerPoolTask> > | 231 typedef std::vector<scoped_refptr<internal::RasterWorkerPoolTask> > |
| 230 RasterTaskVector; | 232 RasterTaskVector; |
| 231 typedef internal::RasterWorkerPoolTask* TaskMapKey; | 233 typedef internal::RasterWorkerPoolTask* TaskMapKey; |
| 232 typedef base::hash_map<TaskMapKey, | 234 typedef base::hash_map<TaskMapKey, |
| 233 scoped_refptr<internal::WorkerPoolTask> > TaskMap; | 235 scoped_refptr<internal::WorkerPoolTask> > TaskMap; |
| 234 | 236 typedef std::vector<GraphNode*> NodeVector; |
| 235 class CC_EXPORT RasterTaskGraph { | |
| 236 public: | |
| 237 RasterTaskGraph(); | |
| 238 ~RasterTaskGraph(); | |
| 239 | |
| 240 void InsertRasterTask(internal::WorkerPoolTask* raster_task, | |
| 241 const TaskVector& decode_tasks); | |
| 242 | |
| 243 private: | |
| 244 friend class RasterWorkerPool; | |
| 245 | |
| 246 TaskGraph graph_; | |
| 247 scoped_refptr<internal::WorkerPoolTask> raster_finished_task_; | |
| 248 scoped_ptr<GraphNode> raster_finished_node_; | |
| 249 unsigned next_priority_; | |
| 250 | |
| 251 DISALLOW_COPY_AND_ASSIGN(RasterTaskGraph); | |
| 252 }; | |
| 253 | 237 |
| 254 RasterWorkerPool(ResourceProvider* resource_provider, size_t num_threads); | 238 RasterWorkerPool(ResourceProvider* resource_provider, size_t num_threads); |
| 255 | 239 |
| 256 virtual void OnRasterTasksFinished() {} | 240 virtual void OnRasterTasksFinished() = 0; |
| 241 virtual void OnRasterTasksRequiredForActivationFinished() = 0; |
| 257 | 242 |
| 258 void SetRasterTasks(RasterTask::Queue* queue); | 243 void SetRasterTasks(RasterTask::Queue* queue); |
| 259 void SetRasterTaskGraph(RasterTaskGraph* graph); | |
| 260 bool IsRasterTaskRequiredForActivation( | 244 bool IsRasterTaskRequiredForActivation( |
| 261 internal::RasterWorkerPoolTask* task) const; | 245 internal::RasterWorkerPoolTask* task) const; |
| 262 | 246 |
| 263 RasterWorkerPoolClient* client() const { return client_; } | 247 RasterWorkerPoolClient* client() const { return client_; } |
| 264 ResourceProvider* resource_provider() const { return resource_provider_; } | 248 ResourceProvider* resource_provider() const { return resource_provider_; } |
| 265 const RasterTask::Queue::TaskVector& raster_tasks() const { | 249 const RasterTask::Queue::TaskVector& raster_tasks() const { |
| 266 return raster_tasks_; | 250 return raster_tasks_; |
| 267 } | 251 } |
| 252 void set_raster_finished_task( |
| 253 scoped_refptr<internal::WorkerPoolTask> raster_finished_task) { |
| 254 raster_finished_task_ = raster_finished_task; |
| 255 } |
| 256 void set_raster_required_for_activation_finished_task( |
| 257 scoped_refptr<internal::WorkerPoolTask> |
| 258 raster_required_for_activation_finished_task) { |
| 259 raster_required_for_activation_finished_task_ = |
| 260 raster_required_for_activation_finished_task; |
| 261 } |
| 262 |
| 263 scoped_refptr<internal::WorkerPoolTask> CreateRasterFinishedTask(); |
| 264 scoped_refptr<internal::WorkerPoolTask> |
| 265 CreateRasterRequiredForActivationFinishedTask(); |
| 266 |
| 267 static GraphNode* CreateGraphNodeForTask( |
| 268 internal::WorkerPoolTask* task, |
| 269 unsigned priority, |
| 270 TaskGraph* graph); |
| 271 |
| 272 static GraphNode* CreateGraphNodeForRasterTask( |
| 273 internal::WorkerPoolTask* raster_task, |
| 274 const TaskVector& decode_tasks, |
| 275 unsigned priority, |
| 276 TaskGraph* graph); |
| 268 | 277 |
| 269 private: | 278 private: |
| 270 void OnRasterFinished(int64 schedule_raster_tasks_count); | 279 void OnRasterFinished(const internal::WorkerPoolTask* source); |
| 280 void OnRasterRequiredForActivationFinished( |
| 281 const internal::WorkerPoolTask* source); |
| 271 | 282 |
| 272 RasterWorkerPoolClient* client_; | 283 RasterWorkerPoolClient* client_; |
| 273 ResourceProvider* resource_provider_; | 284 ResourceProvider* resource_provider_; |
| 274 RasterTask::Queue::TaskVector raster_tasks_; | 285 RasterTask::Queue::TaskVector raster_tasks_; |
| 275 RasterTask::Queue::TaskSet raster_tasks_required_for_activation_; | 286 RasterTask::Queue::TaskSet raster_tasks_required_for_activation_; |
| 276 | 287 |
| 277 base::WeakPtrFactory<RasterWorkerPool> weak_ptr_factory_; | 288 base::WeakPtrFactory<RasterWorkerPool> weak_ptr_factory_; |
| 278 scoped_refptr<internal::WorkerPoolTask> raster_finished_task_; | 289 scoped_refptr<internal::WorkerPoolTask> raster_finished_task_; |
| 279 int64 schedule_raster_tasks_count_; | 290 scoped_refptr<internal::WorkerPoolTask> |
| 291 raster_required_for_activation_finished_task_; |
| 280 }; | 292 }; |
| 281 | 293 |
| 282 } // namespace cc | 294 } // namespace cc |
| 283 | 295 |
| 284 #endif // CC_RESOURCES_RASTER_WORKER_POOL_H_ | 296 #endif // CC_RESOURCES_RASTER_WORKER_POOL_H_ |
| OLD | NEW |