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, |
109 size_t scheduled_raster_task_limit); | 111 size_t scheduled_raster_task_limit); |
110 ~TileManager() override; | 112 ~TileManager() override; |
111 | 113 |
112 // Assigns tile memory and schedules work to prepare tiles for drawing. | 114 // Assigns tile memory and schedules work to prepare tiles for drawing. |
113 // - Runs client_->NotifyReadyToActivate() when all tiles required for | 115 // - Runs client_->NotifyReadyToActivate() when all tiles required for |
114 // activation are prepared, or failed to prepare due to OOM. | 116 // activation are prepared, or failed to prepare due to OOM. |
115 // - Runs client_->NotifyReadyToDraw() when all tiles required draw are | 117 // - Runs client_->NotifyReadyToDraw() when all tiles required draw are |
116 // prepared, or failed to prepare due to OOM. | 118 // prepared, or failed to prepare due to OOM. |
117 bool PrepareTiles(const GlobalStateThatImpactsTilePriority& state); | 119 void 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); | |
130 | 120 |
131 // This causes any completed raster work to finalize, so that tiles get up to | 121 // This causes any completed raster work to finalize, so that tiles get up to |
132 // date draw information. | 122 // date draw information. |
133 void Flush(); | 123 void Flush(); |
134 | 124 |
135 ScopedTilePtr CreateTile(const gfx::Size& desired_texture_size, | 125 ScopedTilePtr CreateTile(const gfx::Size& desired_texture_size, |
136 const gfx::Rect& content_rect, | 126 const gfx::Rect& content_rect, |
137 float contents_scale, | 127 float contents_scale, |
138 int layer_id, | 128 int layer_id, |
139 int source_frame_number, | 129 int source_frame_number, |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 all_tiles_that_need_to_be_rasterized_are_scheduled_ = false; | 189 all_tiles_that_need_to_be_rasterized_are_scheduled_ = false; |
200 } | 190 } |
201 | 191 |
202 bool HasScheduledTileTasksForTesting() const { | 192 bool HasScheduledTileTasksForTesting() const { |
203 return has_scheduled_tile_tasks_; | 193 return has_scheduled_tile_tasks_; |
204 } | 194 } |
205 | 195 |
206 protected: | 196 protected: |
207 TileManager(TileManagerClient* client, | 197 TileManager(TileManagerClient* client, |
208 const scoped_refptr<base::SequencedTaskRunner>& task_runner, | 198 const scoped_refptr<base::SequencedTaskRunner>& task_runner, |
| 199 ResourcePool* resource_pool, |
| 200 TileTaskRunner* tile_task_runner, |
209 size_t scheduled_raster_task_limit); | 201 size_t scheduled_raster_task_limit); |
210 | 202 |
211 void FreeResourcesForReleasedTiles(); | 203 void FreeResourcesForReleasedTiles(); |
212 void CleanUpReleasedTiles(); | 204 void CleanUpReleasedTiles(); |
213 | 205 |
214 friend class Tile; | 206 friend class Tile; |
215 // Virtual for testing. | 207 // Virtual for testing. |
216 virtual void Release(Tile* tile); | 208 virtual void Release(Tile* tile); |
217 | 209 |
218 // Overriden from TileTaskRunnerClient: | 210 // Overriden from TileTaskRunnerClient: |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 bool has_scheduled_tile_tasks_; | 331 bool has_scheduled_tile_tasks_; |
340 | 332 |
341 uint64_t prepare_tiles_count_; | 333 uint64_t prepare_tiles_count_; |
342 | 334 |
343 DISALLOW_COPY_AND_ASSIGN(TileManager); | 335 DISALLOW_COPY_AND_ASSIGN(TileManager); |
344 }; | 336 }; |
345 | 337 |
346 } // namespace cc | 338 } // namespace cc |
347 | 339 |
348 #endif // CC_TILES_TILE_MANAGER_H_ | 340 #endif // CC_TILES_TILE_MANAGER_H_ |
OLD | NEW |