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 <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 // much resources as possible. Also, prevents any future work until a | 112 // much resources as possible. Also, prevents any future work until a |
113 // SetResources call. | 113 // SetResources call. |
114 void FinishTasksAndCleanUp(); | 114 void FinishTasksAndCleanUp(); |
115 | 115 |
116 // Set the new given resource pool and tile task runner. Note that | 116 // Set the new given resource pool and tile task runner. Note that |
117 // FinishTasksAndCleanUp must be called in between consecutive calls to | 117 // FinishTasksAndCleanUp must be called in between consecutive calls to |
118 // SetResources. | 118 // SetResources. |
119 void SetResources(ResourcePool* resource_pool, | 119 void SetResources(ResourcePool* resource_pool, |
120 ImageDecodeController* image_decode_controller, | 120 ImageDecodeController* image_decode_controller, |
121 TileTaskManager* tile_task_manager, | 121 TileTaskManager* tile_task_manager, |
| 122 RasterBufferProvider* raster_buffer_provider, |
122 size_t scheduled_raster_task_limit, | 123 size_t scheduled_raster_task_limit, |
123 bool use_gpu_rasterization); | 124 bool use_gpu_rasterization); |
124 | 125 |
125 // This causes any completed raster work to finalize, so that tiles get up to | 126 // This causes any completed raster work to finalize, so that tiles get up to |
126 // date draw information. | 127 // date draw information. |
127 void Flush(); | 128 void Flush(); |
128 | 129 |
129 ScopedTilePtr CreateTile(const Tile::CreateInfo& info, | 130 ScopedTilePtr CreateTile(const Tile::CreateInfo& info, |
130 int layer_id, | 131 int layer_id, |
131 int source_frame_number, | 132 int source_frame_number, |
132 int flags); | 133 int flags); |
133 | 134 |
134 bool IsReadyToActivate() const; | 135 bool IsReadyToActivate() const; |
135 bool IsReadyToDraw() const; | 136 bool IsReadyToDraw() const; |
136 | 137 |
137 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> | 138 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> |
138 BasicStateAsValue() const; | 139 BasicStateAsValue() const; |
139 void BasicStateAsValueInto(base::trace_event::TracedValue* dict) const; | 140 void BasicStateAsValueInto(base::trace_event::TracedValue* dict) const; |
140 const MemoryHistory::Entry& memory_stats_from_last_assign() const { | 141 const MemoryHistory::Entry& memory_stats_from_last_assign() const { |
141 return memory_stats_from_last_assign_; | 142 return memory_stats_from_last_assign_; |
142 } | 143 } |
143 | 144 |
144 // Public methods for testing. | 145 // Public methods for testing. |
145 void InitializeTilesWithResourcesForTesting(const std::vector<Tile*>& tiles) { | 146 void InitializeTilesWithResourcesForTesting(const std::vector<Tile*>& tiles) { |
146 for (size_t i = 0; i < tiles.size(); ++i) { | 147 for (size_t i = 0; i < tiles.size(); ++i) { |
147 TileDrawInfo& draw_info = tiles[i]->draw_info(); | 148 TileDrawInfo& draw_info = tiles[i]->draw_info(); |
148 draw_info.resource_ = resource_pool_->AcquireResource( | 149 draw_info.resource_ = resource_pool_->AcquireResource( |
149 tiles[i]->desired_texture_size(), | 150 tiles[i]->desired_texture_size(), |
150 tile_task_manager_->GetRasterBufferProvider()->GetResourceFormat( | 151 raster_buffer_provider_->GetResourceFormat(false)); |
151 false)); | |
152 } | 152 } |
153 } | 153 } |
154 | 154 |
155 void ReleaseTileResourcesForTesting(const std::vector<Tile*>& tiles) { | 155 void ReleaseTileResourcesForTesting(const std::vector<Tile*>& tiles) { |
156 for (size_t i = 0; i < tiles.size(); ++i) { | 156 for (size_t i = 0; i < tiles.size(); ++i) { |
157 Tile* tile = tiles[i]; | 157 Tile* tile = tiles[i]; |
158 FreeResourcesForTile(tile); | 158 FreeResourcesForTile(tile); |
159 } | 159 } |
160 } | 160 } |
161 | 161 |
162 void SetGlobalStateForTesting( | 162 void SetGlobalStateForTesting( |
163 const GlobalStateThatImpactsTilePriority& state) { | 163 const GlobalStateThatImpactsTilePriority& state) { |
164 global_state_ = state; | 164 global_state_ = state; |
165 } | 165 } |
166 | 166 |
167 void SetTileTaskManagerForTesting(TileTaskManager* tile_task_manager); | 167 void SetTileTaskManagerForTesting(TileTaskManager* tile_task_manager); |
168 | 168 |
| 169 void SetRasterBufferProviderForTesting( |
| 170 RasterBufferProvider* raster_buffer_provider); |
| 171 |
169 void FreeResourcesAndCleanUpReleasedTilesForTesting() { | 172 void FreeResourcesAndCleanUpReleasedTilesForTesting() { |
170 FreeResourcesForReleasedTiles(); | 173 FreeResourcesForReleasedTiles(); |
171 CleanUpReleasedTiles(); | 174 CleanUpReleasedTiles(); |
172 } | 175 } |
173 | 176 |
174 std::vector<Tile*> AllTilesForTesting() const { | 177 std::vector<Tile*> AllTilesForTesting() const { |
175 std::vector<Tile*> tiles; | 178 std::vector<Tile*> tiles; |
176 for (auto& tile_pair : tiles_) | 179 for (auto& tile_pair : tiles_) |
177 tiles.push_back(tile_pair.second); | 180 tiles.push_back(tile_pair.second); |
178 return tiles; | 181 return tiles; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 void (TileManager::*callback)()); | 270 void (TileManager::*callback)()); |
268 std::vector<PrioritizedTile> AssignGpuMemoryToTiles(); | 271 std::vector<PrioritizedTile> AssignGpuMemoryToTiles(); |
269 | 272 |
270 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> | 273 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> |
271 ScheduledTasksStateAsValue() const; | 274 ScheduledTasksStateAsValue() const; |
272 | 275 |
273 TileManagerClient* client_; | 276 TileManagerClient* client_; |
274 base::SequencedTaskRunner* task_runner_; | 277 base::SequencedTaskRunner* task_runner_; |
275 ResourcePool* resource_pool_; | 278 ResourcePool* resource_pool_; |
276 TileTaskManager* tile_task_manager_; | 279 TileTaskManager* tile_task_manager_; |
| 280 RasterBufferProvider* raster_buffer_provider_; |
277 GlobalStateThatImpactsTilePriority global_state_; | 281 GlobalStateThatImpactsTilePriority global_state_; |
278 size_t scheduled_raster_task_limit_; | 282 size_t scheduled_raster_task_limit_; |
279 const bool use_partial_raster_; | 283 const bool use_partial_raster_; |
280 bool use_gpu_rasterization_; | 284 bool use_gpu_rasterization_; |
281 | 285 |
282 std::unordered_map<Tile::Id, Tile*> tiles_; | 286 std::unordered_map<Tile::Id, Tile*> tiles_; |
283 | 287 |
284 bool all_tiles_that_need_to_be_rasterized_are_scheduled_; | 288 bool all_tiles_that_need_to_be_rasterized_are_scheduled_; |
285 MemoryHistory::Entry memory_stats_from_last_assign_; | 289 MemoryHistory::Entry memory_stats_from_last_assign_; |
286 | 290 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 std::unordered_map<Tile::Id, std::vector<DrawImage>> scheduled_draw_images_; | 329 std::unordered_map<Tile::Id, std::vector<DrawImage>> scheduled_draw_images_; |
326 | 330 |
327 base::WeakPtrFactory<TileManager> task_set_finished_weak_ptr_factory_; | 331 base::WeakPtrFactory<TileManager> task_set_finished_weak_ptr_factory_; |
328 | 332 |
329 DISALLOW_COPY_AND_ASSIGN(TileManager); | 333 DISALLOW_COPY_AND_ASSIGN(TileManager); |
330 }; | 334 }; |
331 | 335 |
332 } // namespace cc | 336 } // namespace cc |
333 | 337 |
334 #endif // CC_TILES_TILE_MANAGER_H_ | 338 #endif // CC_TILES_TILE_MANAGER_H_ |
OLD | NEW |