Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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_TILES_TILE_MANAGER_H_ | 5 #ifndef CC_TILES_TILE_MANAGER_H_ |
| 6 #define CC_TILES_TILE_MANAGER_H_ | 6 #define CC_TILES_TILE_MANAGER_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <queue> | 9 #include <queue> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 83 size_t completed_count; | 83 size_t completed_count; |
| 84 size_t canceled_count; | 84 size_t canceled_count; |
| 85 }; | 85 }; |
| 86 scoped_refptr<base::trace_event::ConvertableToTraceFormat> | 86 scoped_refptr<base::trace_event::ConvertableToTraceFormat> |
| 87 RasterTaskCompletionStatsAsValue(const RasterTaskCompletionStats& stats); | 87 RasterTaskCompletionStatsAsValue(const RasterTaskCompletionStats& stats); |
| 88 | 88 |
| 89 // This class manages tiles, deciding which should get rasterized and which | 89 // This class manages tiles, deciding which should get rasterized and which |
| 90 // should no longer have any memory assigned to them. Tile objects are "owned" | 90 // should no longer have any memory assigned to them. Tile objects are "owned" |
| 91 // by layers; they automatically register with the manager when they are | 91 // by layers; they automatically register with the manager when they are |
| 92 // created, and unregister from the manager when they are deleted. | 92 // created, and unregister from the manager when they are deleted. |
| 93 class CC_EXPORT TileManager : public TileTaskRunnerClient { | 93 class CC_EXPORT TileManager { |
| 94 public: | 94 public: |
| 95 enum NamedTaskSet { | 95 enum TaskSet : int { |
| 96 REQUIRED_FOR_ACTIVATION, | 96 REQUIRED_FOR_ACTIVATION, |
| 97 REQUIRED_FOR_DRAW, | 97 REQUIRED_FOR_DRAW, |
| 98 // PixelBufferTileTaskWorkerPool depends on ALL being last. | 98 // PixelBufferTileTaskWorkerPool depends on ALL being last. |
|
reveman
2015/12/02 05:22:55
not sure we need this enum still but we should at
ericrk
2015/12/02 21:28:09
removed.
| |
| 99 ALL | 99 ALL |
| 100 // Adding additional values requires increasing kNumberOfTaskSets in | 100 // Adding additional values requires increasing kNumberOfTaskSets in |
| 101 // tile_task_runner.h | 101 // tile_task_runner.h |
|
reveman
2015/12/02 05:22:55
and this one
ericrk
2015/12/02 21:28:09
Done.
| |
| 102 }; | 102 }; |
| 103 | 103 |
| 104 static_assert(NamedTaskSet::ALL == (kNumberOfTaskSets - 1), | 104 enum : int { kNumberOfTaskSets = TaskSet::ALL + 1 }; |
| 105 "NamedTaskSet::ALL should be equal to kNumberOfTaskSets" | |
| 106 "minus 1"); | |
| 107 | 105 |
| 108 static scoped_ptr<TileManager> Create(TileManagerClient* client, | 106 static scoped_ptr<TileManager> Create(TileManagerClient* client, |
| 109 base::SequencedTaskRunner* task_runner, | 107 base::SequencedTaskRunner* task_runner, |
| 110 size_t scheduled_raster_task_limit, | 108 size_t scheduled_raster_task_limit, |
| 111 bool use_partial_raster); | 109 bool use_partial_raster); |
| 112 ~TileManager() override; | 110 virtual ~TileManager(); |
| 113 | 111 |
| 114 // Assigns tile memory and schedules work to prepare tiles for drawing. | 112 // Assigns tile memory and schedules work to prepare tiles for drawing. |
| 115 // - Runs client_->NotifyReadyToActivate() when all tiles required for | 113 // - Runs client_->NotifyReadyToActivate() when all tiles required for |
| 116 // activation are prepared, or failed to prepare due to OOM. | 114 // activation are prepared, or failed to prepare due to OOM. |
| 117 // - Runs client_->NotifyReadyToDraw() when all tiles required draw are | 115 // - Runs client_->NotifyReadyToDraw() when all tiles required draw are |
| 118 // prepared, or failed to prepare due to OOM. | 116 // prepared, or failed to prepare due to OOM. |
| 119 bool PrepareTiles(const GlobalStateThatImpactsTilePriority& state); | 117 bool PrepareTiles(const GlobalStateThatImpactsTilePriority& state); |
| 120 | 118 |
| 121 // Synchronously finish any in progress work, cancel the rest, and clean up as | 119 // Synchronously finish any in progress work, cancel the rest, and clean up as |
| 122 // much resources as possible. Also, prevents any future work until a | 120 // much resources as possible. Also, prevents any future work until a |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 210 bool use_partial_raster); | 208 bool use_partial_raster); |
| 211 | 209 |
| 212 void FreeResourcesForReleasedTiles(); | 210 void FreeResourcesForReleasedTiles(); |
| 213 void CleanUpReleasedTiles(); | 211 void CleanUpReleasedTiles(); |
| 214 | 212 |
| 215 friend class Tile; | 213 friend class Tile; |
| 216 // Virtual for testing. | 214 // Virtual for testing. |
| 217 virtual void Release(Tile* tile); | 215 virtual void Release(Tile* tile); |
| 218 Tile::Id GetUniqueTileId() { return ++next_tile_id_; } | 216 Tile::Id GetUniqueTileId() { return ++next_tile_id_; } |
| 219 | 217 |
| 220 // Overriden from TileTaskRunnerClient: | |
| 221 void DidFinishRunningTileTasks(TaskSet task_set) override; | |
| 222 | |
| 223 typedef std::vector<PrioritizedTile> PrioritizedTileVector; | 218 typedef std::vector<PrioritizedTile> PrioritizedTileVector; |
| 224 typedef std::set<Tile*> TileSet; | 219 typedef std::set<Tile*> TileSet; |
| 225 | 220 |
| 226 // Virtual for test | 221 // Virtual for test |
| 227 virtual void ScheduleTasks( | 222 virtual void ScheduleTasks( |
| 228 const PrioritizedTileVector& tiles_that_need_to_be_rasterized); | 223 const PrioritizedTileVector& tiles_that_need_to_be_rasterized); |
| 229 | 224 |
| 230 void AssignGpuMemoryToTiles( | 225 void AssignGpuMemoryToTiles( |
| 231 RasterTilePriorityQueue* raster_priority_queue, | 226 RasterTilePriorityQueue* raster_priority_queue, |
| 232 size_t scheduled_raser_task_limit, | 227 size_t scheduled_raser_task_limit, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 281 MemoryUsage* usage); | 276 MemoryUsage* usage); |
| 282 bool TilePriorityViolatesMemoryPolicy(const TilePriority& priority); | 277 bool TilePriorityViolatesMemoryPolicy(const TilePriority& priority); |
| 283 bool AreRequiredTilesReadyToDraw(RasterTilePriorityQueue::Type type) const; | 278 bool AreRequiredTilesReadyToDraw(RasterTilePriorityQueue::Type type) const; |
| 284 void CheckIfMoreTilesNeedToBePrepared(); | 279 void CheckIfMoreTilesNeedToBePrepared(); |
| 285 void CheckAndIssueSignals(); | 280 void CheckAndIssueSignals(); |
| 286 bool MarkTilesOutOfMemory(scoped_ptr<RasterTilePriorityQueue> queue) const; | 281 bool MarkTilesOutOfMemory(scoped_ptr<RasterTilePriorityQueue> queue) const; |
| 287 | 282 |
| 288 ResourceFormat DetermineResourceFormat(const Tile* tile) const; | 283 ResourceFormat DetermineResourceFormat(const Tile* tile) const; |
| 289 bool DetermineResourceRequiresSwizzle(const Tile* tile) const; | 284 bool DetermineResourceRequiresSwizzle(const Tile* tile) const; |
| 290 | 285 |
| 286 void DidFinishRunningTileTasks(TaskSet task_set); | |
| 287 | |
| 288 void BuildTaskGraph( | |
| 289 const PrioritizedTileVector& tiles_that_need_to_be_rasterized, | |
| 290 TaskGraph* graph, | |
| 291 std::array<scoped_refptr<TileTask>, kNumberOfTaskSets>* | |
|
reveman
2015/12/02 05:22:55
The code that had to deal with task sets in the pa
ericrk
2015/12/02 21:28:09
std::array is now allowed.
Re structured this - t
| |
| 292 new_task_set_finished_tasks); | |
| 293 | |
| 294 scoped_refptr<base::trace_event::ConvertableToTraceFormat> | |
| 295 ScheduledTasksStateAsValue() const; | |
| 296 | |
| 291 TileManagerClient* client_; | 297 TileManagerClient* client_; |
| 292 scoped_refptr<base::SequencedTaskRunner> task_runner_; | 298 scoped_refptr<base::SequencedTaskRunner> task_runner_; |
| 293 ResourcePool* resource_pool_; | 299 ResourcePool* resource_pool_; |
| 294 TileTaskRunner* tile_task_runner_; | 300 TileTaskRunner* tile_task_runner_; |
| 295 GlobalStateThatImpactsTilePriority global_state_; | 301 GlobalStateThatImpactsTilePriority global_state_; |
| 296 size_t scheduled_raster_task_limit_; | 302 size_t scheduled_raster_task_limit_; |
| 297 const bool use_partial_raster_; | 303 const bool use_partial_raster_; |
| 298 | 304 |
| 299 typedef base::hash_map<Tile::Id, Tile*> TileMap; | 305 typedef base::hash_map<Tile::Id, Tile*> TileMap; |
| 300 TileMap tiles_; | 306 TileMap tiles_; |
| 301 | 307 |
| 302 bool all_tiles_that_need_to_be_rasterized_are_scheduled_; | 308 bool all_tiles_that_need_to_be_rasterized_are_scheduled_; |
| 303 MemoryHistory::Entry memory_stats_from_last_assign_; | 309 MemoryHistory::Entry memory_stats_from_last_assign_; |
| 304 | 310 |
| 305 bool did_check_for_completed_tasks_since_last_schedule_tasks_; | 311 bool did_check_for_completed_tasks_since_last_schedule_tasks_; |
| 306 bool did_oom_on_last_assign_; | 312 bool did_oom_on_last_assign_; |
| 307 | 313 |
| 308 ImageDecodeController image_decode_controller_; | 314 ImageDecodeController image_decode_controller_; |
| 309 | 315 |
| 310 RasterTaskCompletionStats flush_stats_; | 316 RasterTaskCompletionStats flush_stats_; |
| 311 | 317 |
| 312 std::vector<Tile*> released_tiles_; | 318 std::vector<Tile*> released_tiles_; |
| 313 | 319 |
| 314 // Queue used when scheduling raster tasks. | 320 std::vector<scoped_refptr<TileTask>> orphan_tasks_; |
| 315 TileTaskQueue raster_queue_; | |
|
reveman
2015/12/02 05:22:55
Keep this as "TaskGraph task_graph_"? See my other
| |
| 316 | 321 |
| 317 std::vector<scoped_refptr<RasterTask>> orphan_raster_tasks_; | 322 using TaskSetCollection = std::bitset<kNumberOfTaskSets>; |
| 323 TaskSetCollection tasks_pending_; | |
| 318 | 324 |
| 319 UniqueNotifier more_tiles_need_prepare_check_notifier_; | 325 UniqueNotifier more_tiles_need_prepare_check_notifier_; |
| 320 | 326 |
| 321 struct Signals { | 327 struct Signals { |
| 322 Signals(); | 328 Signals(); |
| 323 | 329 |
| 324 void reset(); | 330 void reset(); |
| 325 | 331 |
| 326 bool ready_to_activate; | 332 bool ready_to_activate; |
| 327 bool did_notify_ready_to_activate; | 333 bool did_notify_ready_to_activate; |
| 328 bool ready_to_draw; | 334 bool ready_to_draw; |
| 329 bool did_notify_ready_to_draw; | 335 bool did_notify_ready_to_draw; |
| 330 bool all_tile_tasks_completed; | 336 bool all_tile_tasks_completed; |
| 331 bool did_notify_all_tile_tasks_completed; | 337 bool did_notify_all_tile_tasks_completed; |
| 332 } signals_; | 338 } signals_; |
| 333 | 339 |
| 334 UniqueNotifier signals_check_notifier_; | 340 UniqueNotifier signals_check_notifier_; |
| 335 | 341 |
| 336 bool has_scheduled_tile_tasks_; | 342 bool has_scheduled_tile_tasks_; |
| 337 | 343 |
| 338 uint64_t prepare_tiles_count_; | 344 uint64_t prepare_tiles_count_; |
| 339 uint64_t next_tile_id_; | 345 uint64_t next_tile_id_; |
| 340 | 346 |
| 347 base::WeakPtrFactory<TileManager> task_set_finished_weak_ptr_factory_; | |
| 348 | |
| 341 DISALLOW_COPY_AND_ASSIGN(TileManager); | 349 DISALLOW_COPY_AND_ASSIGN(TileManager); |
| 342 }; | 350 }; |
| 343 | 351 |
| 344 } // namespace cc | 352 } // namespace cc |
| 345 | 353 |
| 346 #endif // CC_TILES_TILE_MANAGER_H_ | 354 #endif // CC_TILES_TILE_MANAGER_H_ |
| OLD | NEW |