| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 // Adding additional values requires increasing kNumberOfTaskSets in | 99 // Adding additional values requires increasing kNumberOfTaskSets in |
| 100 // tile_task_runner.h | 100 // tile_task_runner.h |
| 101 }; | 101 }; |
| 102 | 102 |
| 103 static_assert(NamedTaskSet::ALL == (kNumberOfTaskSets - 1), | 103 static_assert(NamedTaskSet::ALL == (kNumberOfTaskSets - 1), |
| 104 "NamedTaskSet::ALL should be equal to kNumberOfTaskSets" | 104 "NamedTaskSet::ALL should be equal to kNumberOfTaskSets" |
| 105 "minus 1"); | 105 "minus 1"); |
| 106 | 106 |
| 107 static scoped_ptr<TileManager> Create(TileManagerClient* client, | 107 static scoped_ptr<TileManager> Create(TileManagerClient* client, |
| 108 base::SequencedTaskRunner* task_runner, | 108 base::SequencedTaskRunner* task_runner, |
| 109 ResourcePool* resource_pool, | |
| 110 TileTaskRunner* tile_task_runner, | |
| 111 size_t scheduled_raster_task_limit); | 109 size_t scheduled_raster_task_limit); |
| 112 ~TileManager() override; | 110 ~TileManager() override; |
| 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 void PrepareTiles(const GlobalStateThatImpactsTilePriority& state); | 117 bool PrepareTiles(const GlobalStateThatImpactsTilePriority& state); |
| 118 |
| 119 // Synchronously finish any in progress work, cancel the rest, and clean up as |
| 120 // much resources as possible. Also, prevents any future work until a |
| 121 // SetResources call. |
| 122 void FinishTasksAndCleanUp(); |
| 123 |
| 124 // Set the new given resource pool and tile task runner. Note that |
| 125 // FinishTasksAndCleanUp must be called in between consecutive calls to |
| 126 // SetResources. |
| 127 void SetResources(ResourcePool* resource_pool, |
| 128 TileTaskRunner* tile_task_runner, |
| 129 size_t scheduled_raster_task_limit); |
| 120 | 130 |
| 121 // This causes any completed raster work to finalize, so that tiles get up to | 131 // This causes any completed raster work to finalize, so that tiles get up to |
| 122 // date draw information. | 132 // date draw information. |
| 123 void Flush(); | 133 void Flush(); |
| 124 | 134 |
| 125 ScopedTilePtr CreateTile(const gfx::Size& desired_texture_size, | 135 ScopedTilePtr CreateTile(const gfx::Size& desired_texture_size, |
| 126 const gfx::Rect& content_rect, | 136 const gfx::Rect& content_rect, |
| 127 float contents_scale, | 137 float contents_scale, |
| 128 int layer_id, | 138 int layer_id, |
| 129 int source_frame_number, | 139 int source_frame_number, |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 all_tiles_that_need_to_be_rasterized_are_scheduled_ = false; | 199 all_tiles_that_need_to_be_rasterized_are_scheduled_ = false; |
| 190 } | 200 } |
| 191 | 201 |
| 192 bool HasScheduledTileTasksForTesting() const { | 202 bool HasScheduledTileTasksForTesting() const { |
| 193 return has_scheduled_tile_tasks_; | 203 return has_scheduled_tile_tasks_; |
| 194 } | 204 } |
| 195 | 205 |
| 196 protected: | 206 protected: |
| 197 TileManager(TileManagerClient* client, | 207 TileManager(TileManagerClient* client, |
| 198 const scoped_refptr<base::SequencedTaskRunner>& task_runner, | 208 const scoped_refptr<base::SequencedTaskRunner>& task_runner, |
| 199 ResourcePool* resource_pool, | |
| 200 TileTaskRunner* tile_task_runner, | |
| 201 size_t scheduled_raster_task_limit); | 209 size_t scheduled_raster_task_limit); |
| 202 | 210 |
| 203 void FreeResourcesForReleasedTiles(); | 211 void FreeResourcesForReleasedTiles(); |
| 204 void CleanUpReleasedTiles(); | 212 void CleanUpReleasedTiles(); |
| 205 | 213 |
| 206 friend class Tile; | 214 friend class Tile; |
| 207 // Virtual for testing. | 215 // Virtual for testing. |
| 208 virtual void Release(Tile* tile); | 216 virtual void Release(Tile* tile); |
| 209 | 217 |
| 210 // Overriden from TileTaskRunnerClient: | 218 // Overriden from TileTaskRunnerClient: |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 bool has_scheduled_tile_tasks_; | 339 bool has_scheduled_tile_tasks_; |
| 332 | 340 |
| 333 uint64_t prepare_tiles_count_; | 341 uint64_t prepare_tiles_count_; |
| 334 | 342 |
| 335 DISALLOW_COPY_AND_ASSIGN(TileManager); | 343 DISALLOW_COPY_AND_ASSIGN(TileManager); |
| 336 }; | 344 }; |
| 337 | 345 |
| 338 } // namespace cc | 346 } // namespace cc |
| 339 | 347 |
| 340 #endif // CC_TILES_TILE_MANAGER_H_ | 348 #endif // CC_TILES_TILE_MANAGER_H_ |
| OLD | NEW |