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, | |
123 size_t scheduled_raster_task_limit, | 122 size_t scheduled_raster_task_limit, |
124 bool use_gpu_rasterization); | 123 bool use_gpu_rasterization); |
125 | 124 |
126 // This causes any completed raster work to finalize, so that tiles get up to | 125 // This causes any completed raster work to finalize, so that tiles get up to |
127 // date draw information. | 126 // date draw information. |
128 void Flush(); | 127 void Flush(); |
129 | 128 |
130 ScopedTilePtr CreateTile(const Tile::CreateInfo& info, | 129 ScopedTilePtr CreateTile(const Tile::CreateInfo& info, |
131 int layer_id, | 130 int layer_id, |
132 int source_frame_number, | 131 int source_frame_number, |
133 int flags); | 132 int flags); |
134 | 133 |
135 bool IsReadyToActivate() const; | 134 bool IsReadyToActivate() const; |
136 bool IsReadyToDraw() const; | 135 bool IsReadyToDraw() const; |
137 | 136 |
138 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> | 137 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> |
139 BasicStateAsValue() const; | 138 BasicStateAsValue() const; |
140 void BasicStateAsValueInto(base::trace_event::TracedValue* dict) const; | 139 void BasicStateAsValueInto(base::trace_event::TracedValue* dict) const; |
141 const MemoryHistory::Entry& memory_stats_from_last_assign() const { | 140 const MemoryHistory::Entry& memory_stats_from_last_assign() const { |
142 return memory_stats_from_last_assign_; | 141 return memory_stats_from_last_assign_; |
143 } | 142 } |
144 | 143 |
145 // Public methods for testing. | 144 // Public methods for testing. |
146 void InitializeTilesWithResourcesForTesting(const std::vector<Tile*>& tiles) { | 145 void InitializeTilesWithResourcesForTesting(const std::vector<Tile*>& tiles) { |
147 for (size_t i = 0; i < tiles.size(); ++i) { | 146 for (size_t i = 0; i < tiles.size(); ++i) { |
148 TileDrawInfo& draw_info = tiles[i]->draw_info(); | 147 TileDrawInfo& draw_info = tiles[i]->draw_info(); |
149 draw_info.resource_ = resource_pool_->AcquireResource( | 148 draw_info.resource_ = resource_pool_->AcquireResource( |
150 tiles[i]->desired_texture_size(), | 149 tiles[i]->desired_texture_size(), |
151 raster_buffer_provider_->GetResourceFormat(false)); | 150 tile_task_manager_->GetRasterBufferProvider()->GetResourceFormat( |
| 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 | |
172 void FreeResourcesAndCleanUpReleasedTilesForTesting() { | 169 void FreeResourcesAndCleanUpReleasedTilesForTesting() { |
173 FreeResourcesForReleasedTiles(); | 170 FreeResourcesForReleasedTiles(); |
174 CleanUpReleasedTiles(); | 171 CleanUpReleasedTiles(); |
175 } | 172 } |
176 | 173 |
177 std::vector<Tile*> AllTilesForTesting() const { | 174 std::vector<Tile*> AllTilesForTesting() const { |
178 std::vector<Tile*> tiles; | 175 std::vector<Tile*> tiles; |
179 for (auto& tile_pair : tiles_) | 176 for (auto& tile_pair : tiles_) |
180 tiles.push_back(tile_pair.second); | 177 tiles.push_back(tile_pair.second); |
181 return tiles; | 178 return tiles; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 void (TileManager::*callback)()); | 267 void (TileManager::*callback)()); |
271 std::vector<PrioritizedTile> AssignGpuMemoryToTiles(); | 268 std::vector<PrioritizedTile> AssignGpuMemoryToTiles(); |
272 | 269 |
273 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> | 270 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> |
274 ScheduledTasksStateAsValue() const; | 271 ScheduledTasksStateAsValue() const; |
275 | 272 |
276 TileManagerClient* client_; | 273 TileManagerClient* client_; |
277 base::SequencedTaskRunner* task_runner_; | 274 base::SequencedTaskRunner* task_runner_; |
278 ResourcePool* resource_pool_; | 275 ResourcePool* resource_pool_; |
279 TileTaskManager* tile_task_manager_; | 276 TileTaskManager* tile_task_manager_; |
280 RasterBufferProvider* raster_buffer_provider_; | |
281 GlobalStateThatImpactsTilePriority global_state_; | 277 GlobalStateThatImpactsTilePriority global_state_; |
282 size_t scheduled_raster_task_limit_; | 278 size_t scheduled_raster_task_limit_; |
283 const bool use_partial_raster_; | 279 const bool use_partial_raster_; |
284 bool use_gpu_rasterization_; | 280 bool use_gpu_rasterization_; |
285 | 281 |
286 std::unordered_map<Tile::Id, Tile*> tiles_; | 282 std::unordered_map<Tile::Id, Tile*> tiles_; |
287 | 283 |
288 bool all_tiles_that_need_to_be_rasterized_are_scheduled_; | 284 bool all_tiles_that_need_to_be_rasterized_are_scheduled_; |
289 MemoryHistory::Entry memory_stats_from_last_assign_; | 285 MemoryHistory::Entry memory_stats_from_last_assign_; |
290 | 286 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 std::unordered_map<Tile::Id, std::vector<DrawImage>> scheduled_draw_images_; | 325 std::unordered_map<Tile::Id, std::vector<DrawImage>> scheduled_draw_images_; |
330 | 326 |
331 base::WeakPtrFactory<TileManager> task_set_finished_weak_ptr_factory_; | 327 base::WeakPtrFactory<TileManager> task_set_finished_weak_ptr_factory_; |
332 | 328 |
333 DISALLOW_COPY_AND_ASSIGN(TileManager); | 329 DISALLOW_COPY_AND_ASSIGN(TileManager); |
334 }; | 330 }; |
335 | 331 |
336 } // namespace cc | 332 } // namespace cc |
337 | 333 |
338 #endif // CC_TILES_TILE_MANAGER_H_ | 334 #endif // CC_TILES_TILE_MANAGER_H_ |
OLD | NEW |