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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 165 explicit RasterTask(internal::RasterWorkerPoolTask* internal); | 171 explicit RasterTask(internal::RasterWorkerPoolTask* internal); |
| 166 | 172 |
| 167 scoped_refptr<internal::RasterWorkerPoolTask> internal_; | 173 scoped_refptr<internal::RasterWorkerPoolTask> internal_; |
| 168 }; | 174 }; |
| 169 | 175 |
| 170 virtual ~RasterWorkerPool(); | 176 virtual ~RasterWorkerPool(); |
| 171 | 177 |
| 172 void SetClient(RasterWorkerPoolClient* client); | 178 void SetClient(RasterWorkerPoolClient* client); |
| 173 | 179 |
| 174 // Tells the worker pool to shutdown after canceling all previously | 180 // Tells the worker pool to shutdown after canceling all previously |
| 175 // scheduled tasks. Reply callbacks are still guaranteed to run. | 181 // scheduled tasks. Reply callbacks are still guaranteed to run. |
|
reveman
2013/12/19 01:36:47
Do you mind replacing this comment with "// Overri
alokp
2013/12/19 06:25:42
Done.
| |
| 176 virtual void Shutdown() OVERRIDE; | 182 virtual void Shutdown() OVERRIDE; |
| 177 | 183 |
| 184 // Force a check for completed tasks. | |
| 185 // Runs reply callbacks for completed tasks. | |
| 186 virtual void CheckForCompletedTasks() OVERRIDE; | |
|
reveman
2013/12/19 01:36:47
Hm, this will still result in raster task completi
alokp
2013/12/19 06:25:42
Hm. It does not sound like the right thing to do.
reveman
2013/12/19 17:52:03
This doesn't have to be overridden by RWP implemen
alokp
2013/12/19 21:37:51
Good Idea! With this change we are moving away fro
reveman
2013/12/19 22:05:26
Yes, I think we'll do that but I like to first lan
| |
| 187 | |
| 178 // Schedule running of raster tasks in |queue| and all dependencies. | 188 // Schedule running of raster tasks in |queue| and all dependencies. |
| 179 // Previously scheduled tasks that are no longer needed to run | 189 // Previously scheduled tasks that are no longer needed to run |
| 180 // raster tasks in |queue| will be canceled unless already running. | 190 // raster tasks in |queue| will be canceled unless already running. |
| 181 // Once scheduled, reply callbacks are guaranteed to run for all tasks | 191 // Once scheduled, reply callbacks are guaranteed to run for all tasks |
| 182 // even if they later get canceled by another call to ScheduleTasks(). | 192 // even if they later get canceled by another call to ScheduleTasks(). |
| 183 virtual void ScheduleTasks(RasterTask::Queue* queue) = 0; | 193 virtual void ScheduleTasks(RasterTask::Queue* queue) = 0; |
| 184 | 194 |
| 185 // Returns the target that needs to be used for raster task resources. | 195 // Returns the target that needs to be used for raster task resources. |
| 186 virtual GLenum GetResourceTarget() const = 0; | 196 virtual GLenum GetResourceTarget() const = 0; |
| 187 | 197 |
| 188 // Returns the format that needs to be used for raster task resources. | 198 // Returns the format that needs to be used for raster task resources. |
| 189 virtual ResourceFormat GetResourceFormat() const = 0; | 199 virtual ResourceFormat GetResourceFormat() const = 0; |
| 190 | 200 |
| 191 // TODO(vmpstr): Figure out an elegant way to not pass this many parameters. | 201 // TODO(vmpstr): Figure out an elegant way to not pass this many parameters. |
| 192 static RasterTask CreateRasterTask( | 202 static RasterTask CreateRasterTask( |
| 193 const Resource* resource, | 203 const Resource* resource, |
| 194 PicturePileImpl* picture_pile, | 204 PicturePileImpl* picture_pile, |
| 195 gfx::Rect content_rect, | 205 gfx::Rect content_rect, |
| 196 float contents_scale, | 206 float contents_scale, |
| 197 RasterMode raster_mode, | 207 RasterMode raster_mode, |
| 198 TileResolution tile_resolution, | 208 TileResolution tile_resolution, |
| 199 int layer_id, | 209 int layer_id, |
| 200 const void* tile_id, | 210 const void* tile_id, |
| 201 int source_frame_number, | 211 int source_frame_number, |
| 212 bool use_gpu_rasterization, | |
| 202 RenderingStatsInstrumentation* rendering_stats, | 213 RenderingStatsInstrumentation* rendering_stats, |
| 203 const RasterTask::Reply& reply, | 214 const RasterTask::Reply& reply, |
| 204 Task::Set* dependencies); | 215 Task::Set* dependencies); |
| 205 | 216 |
| 206 static Task CreateImageDecodeTask( | 217 static Task CreateImageDecodeTask( |
| 207 skia::LazyPixelRef* pixel_ref, | 218 skia::LazyPixelRef* pixel_ref, |
| 208 int layer_id, | 219 int layer_id, |
| 209 RenderingStatsInstrumentation* stats_instrumentation, | 220 RenderingStatsInstrumentation* stats_instrumentation, |
| 210 const Task::Reply& reply); | 221 const Task::Reply& reply); |
| 211 | 222 |
| 212 protected: | 223 protected: |
| 213 typedef std::vector<scoped_refptr<internal::WorkerPoolTask> > TaskVector; | 224 typedef std::vector<scoped_refptr<internal::WorkerPoolTask> > TaskVector; |
| 214 typedef std::vector<scoped_refptr<internal::RasterWorkerPoolTask> > | 225 typedef std::vector<scoped_refptr<internal::RasterWorkerPoolTask> > |
| 215 RasterTaskVector; | 226 RasterTaskVector; |
| 216 typedef base::hash_set<internal::RasterWorkerPoolTask*> RasterTaskSet; | 227 typedef base::hash_set<internal::RasterWorkerPoolTask*> RasterTaskSet; |
| 217 typedef internal::RasterWorkerPoolTask* TaskMapKey; | 228 typedef internal::RasterWorkerPoolTask* TaskMapKey; |
| 218 typedef base::hash_map<TaskMapKey, | 229 typedef base::hash_map<TaskMapKey, |
| 219 scoped_refptr<internal::WorkerPoolTask> > TaskMap; | 230 scoped_refptr<internal::WorkerPoolTask> > TaskMap; |
| 220 | 231 |
| 221 RasterWorkerPool(ResourceProvider* resource_provider, size_t num_threads); | 232 RasterWorkerPool(ResourceProvider* resource_provider, |
| 233 ContextProvider* context_provider, | |
| 234 size_t num_threads); | |
| 222 | 235 |
| 223 virtual void OnRasterTasksFinished() = 0; | 236 virtual void OnRasterTasksFinished() = 0; |
| 224 virtual void OnRasterTasksRequiredForActivationFinished() = 0; | 237 virtual void OnRasterTasksRequiredForActivationFinished() = 0; |
| 225 | 238 |
| 226 void SetRasterTasks(RasterTask::Queue* queue); | 239 void SetRasterTasks(RasterTask::Queue* queue); |
| 227 bool IsRasterTaskRequiredForActivation( | 240 bool IsRasterTaskRequiredForActivation( |
| 228 internal::RasterWorkerPoolTask* task) const; | 241 internal::RasterWorkerPoolTask* task) const; |
| 242 // Run raster tasks that use GPU on impl thread. | |
|
reveman
2013/12/19 01:36:47
nit: s/impl/current/
alokp
2013/12/19 06:25:42
Done.
| |
| 243 void RunGpuRasterTasks(RasterTaskVector* tasks); | |
| 229 | 244 |
| 230 RasterWorkerPoolClient* client() const { return client_; } | 245 RasterWorkerPoolClient* client() const { return client_; } |
| 231 ResourceProvider* resource_provider() const { return resource_provider_; } | 246 ResourceProvider* resource_provider() const { return resource_provider_; } |
| 247 ContextProvider* context_provider() const { return context_provider_; } | |
| 232 const RasterTaskVector& raster_tasks() const { return raster_tasks_; } | 248 const RasterTaskVector& raster_tasks() const { return raster_tasks_; } |
| 233 const RasterTaskSet& raster_tasks_required_for_activation() const { | 249 const RasterTaskSet& raster_tasks_required_for_activation() const { |
| 234 return raster_tasks_required_for_activation_; | 250 return raster_tasks_required_for_activation_; |
| 235 } | 251 } |
| 236 void set_raster_finished_task( | 252 void set_raster_finished_task( |
| 237 scoped_refptr<internal::WorkerPoolTask> raster_finished_task) { | 253 scoped_refptr<internal::WorkerPoolTask> raster_finished_task) { |
| 238 raster_finished_task_ = raster_finished_task; | 254 raster_finished_task_ = raster_finished_task; |
| 239 } | 255 } |
| 240 void set_raster_required_for_activation_finished_task( | 256 void set_raster_required_for_activation_finished_task( |
| 241 scoped_refptr<internal::WorkerPoolTask> | 257 scoped_refptr<internal::WorkerPoolTask> |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 261 unsigned priority, | 277 unsigned priority, |
| 262 TaskGraph* graph); | 278 TaskGraph* graph); |
| 263 | 279 |
| 264 private: | 280 private: |
| 265 void OnRasterFinished(const internal::WorkerPoolTask* source); | 281 void OnRasterFinished(const internal::WorkerPoolTask* source); |
| 266 void OnRasterRequiredForActivationFinished( | 282 void OnRasterRequiredForActivationFinished( |
| 267 const internal::WorkerPoolTask* source); | 283 const internal::WorkerPoolTask* source); |
| 268 | 284 |
| 269 RasterWorkerPoolClient* client_; | 285 RasterWorkerPoolClient* client_; |
| 270 ResourceProvider* resource_provider_; | 286 ResourceProvider* resource_provider_; |
| 287 ContextProvider* context_provider_; | |
| 271 RasterTask::Queue::TaskVector raster_tasks_; | 288 RasterTask::Queue::TaskVector raster_tasks_; |
| 272 RasterTask::Queue::TaskSet raster_tasks_required_for_activation_; | 289 RasterTask::Queue::TaskSet raster_tasks_required_for_activation_; |
| 290 RasterTaskVector gpu_raster_tasks_; | |
| 273 | 291 |
| 274 scoped_refptr<internal::WorkerPoolTask> raster_finished_task_; | 292 scoped_refptr<internal::WorkerPoolTask> raster_finished_task_; |
| 275 scoped_refptr<internal::WorkerPoolTask> | 293 scoped_refptr<internal::WorkerPoolTask> |
| 276 raster_required_for_activation_finished_task_; | 294 raster_required_for_activation_finished_task_; |
| 277 base::WeakPtrFactory<RasterWorkerPool> weak_ptr_factory_; | 295 base::WeakPtrFactory<RasterWorkerPool> weak_ptr_factory_; |
| 278 }; | 296 }; |
| 279 | 297 |
| 280 } // namespace cc | 298 } // namespace cc |
| 281 | 299 |
| 282 #endif // CC_RESOURCES_RASTER_WORKER_POOL_H_ | 300 #endif // CC_RESOURCES_RASTER_WORKER_POOL_H_ |
| OLD | NEW |