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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 // much resources as possible. Also, prevents any future work until a | 113 // much resources as possible. Also, prevents any future work until a |
114 // SetResources call. | 114 // SetResources call. |
115 void FinishTasksAndCleanUp(); | 115 void FinishTasksAndCleanUp(); |
116 | 116 |
117 // Set the new given resource pool and tile task runner. Note that | 117 // Set the new given resource pool and tile task runner. Note that |
118 // FinishTasksAndCleanUp must be called in between consecutive calls to | 118 // FinishTasksAndCleanUp must be called in between consecutive calls to |
119 // SetResources. | 119 // SetResources. |
120 void SetResources(ResourcePool* resource_pool, | 120 void SetResources(ResourcePool* resource_pool, |
121 ImageDecodeController* image_decode_controller, | 121 ImageDecodeController* image_decode_controller, |
122 TileTaskManager* tile_task_manager, | 122 TileTaskManager* tile_task_manager, |
| 123 RasterBufferProvider* raster_buffer_provider, |
123 size_t scheduled_raster_task_limit, | 124 size_t scheduled_raster_task_limit, |
124 bool use_gpu_rasterization); | 125 bool use_gpu_rasterization); |
125 | 126 |
126 // This causes any completed raster work to finalize, so that tiles get up to | 127 // This causes any completed raster work to finalize, so that tiles get up to |
127 // date draw information. | 128 // date draw information. |
128 void Flush(); | 129 void Flush(); |
129 | 130 |
130 ScopedTilePtr CreateTile(const Tile::CreateInfo& info, | 131 ScopedTilePtr CreateTile(const Tile::CreateInfo& info, |
131 int layer_id, | 132 int layer_id, |
132 int source_frame_number, | 133 int source_frame_number, |
133 int flags); | 134 int flags); |
134 | 135 |
135 bool IsReadyToActivate() const; | 136 bool IsReadyToActivate() const; |
136 bool IsReadyToDraw() const; | 137 bool IsReadyToDraw() const; |
137 | 138 |
138 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> | 139 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> |
139 BasicStateAsValue() const; | 140 BasicStateAsValue() const; |
140 void BasicStateAsValueInto(base::trace_event::TracedValue* dict) const; | 141 void BasicStateAsValueInto(base::trace_event::TracedValue* dict) const; |
141 const MemoryHistory::Entry& memory_stats_from_last_assign() const { | 142 const MemoryHistory::Entry& memory_stats_from_last_assign() const { |
142 return memory_stats_from_last_assign_; | 143 return memory_stats_from_last_assign_; |
143 } | 144 } |
144 | 145 |
145 // Public methods for testing. | 146 // Public methods for testing. |
146 void InitializeTilesWithResourcesForTesting(const std::vector<Tile*>& tiles) { | 147 void InitializeTilesWithResourcesForTesting(const std::vector<Tile*>& tiles) { |
147 for (size_t i = 0; i < tiles.size(); ++i) { | 148 for (size_t i = 0; i < tiles.size(); ++i) { |
148 TileDrawInfo& draw_info = tiles[i]->draw_info(); | 149 TileDrawInfo& draw_info = tiles[i]->draw_info(); |
149 draw_info.resource_ = resource_pool_->AcquireResource( | 150 draw_info.resource_ = resource_pool_->AcquireResource( |
150 tiles[i]->desired_texture_size(), | 151 tiles[i]->desired_texture_size(), |
151 tile_task_manager_->GetRasterBufferProvider()->GetResourceFormat( | 152 raster_buffer_provider_->GetResourceFormat(false)); |
152 false)); | |
153 } | 153 } |
154 } | 154 } |
155 | 155 |
156 void ReleaseTileResourcesForTesting(const std::vector<Tile*>& tiles) { | 156 void ReleaseTileResourcesForTesting(const std::vector<Tile*>& tiles) { |
157 for (size_t i = 0; i < tiles.size(); ++i) { | 157 for (size_t i = 0; i < tiles.size(); ++i) { |
158 Tile* tile = tiles[i]; | 158 Tile* tile = tiles[i]; |
159 FreeResourcesForTile(tile); | 159 FreeResourcesForTile(tile); |
160 } | 160 } |
161 } | 161 } |
162 | 162 |
163 void SetGlobalStateForTesting( | 163 void SetGlobalStateForTesting( |
164 const GlobalStateThatImpactsTilePriority& state) { | 164 const GlobalStateThatImpactsTilePriority& state) { |
165 global_state_ = state; | 165 global_state_ = state; |
166 } | 166 } |
167 | 167 |
168 void SetTileTaskManagerForTesting(TileTaskManager* tile_task_manager); | 168 void SetTileTaskManagerForTesting(TileTaskManager* tile_task_manager); |
169 | 169 |
| 170 void SetRasterBufferProviderForTesting( |
| 171 RasterBufferProvider* raster_buffer_provider); |
| 172 |
170 void FreeResourcesAndCleanUpReleasedTilesForTesting() { | 173 void FreeResourcesAndCleanUpReleasedTilesForTesting() { |
171 FreeResourcesForReleasedTiles(); | 174 FreeResourcesForReleasedTiles(); |
172 CleanUpReleasedTiles(); | 175 CleanUpReleasedTiles(); |
173 } | 176 } |
174 | 177 |
175 std::vector<Tile*> AllTilesForTesting() const { | 178 std::vector<Tile*> AllTilesForTesting() const { |
176 std::vector<Tile*> tiles; | 179 std::vector<Tile*> tiles; |
177 for (auto& tile_pair : tiles_) | 180 for (auto& tile_pair : tiles_) |
178 tiles.push_back(tile_pair.second); | 181 tiles.push_back(tile_pair.second); |
179 return tiles; | 182 return tiles; |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 PrioritizedWorkToSchedule AssignGpuMemoryToTiles(); | 290 PrioritizedWorkToSchedule AssignGpuMemoryToTiles(); |
288 void ScheduleTasks(const PrioritizedWorkToSchedule& work_to_schedule); | 291 void ScheduleTasks(const PrioritizedWorkToSchedule& work_to_schedule); |
289 | 292 |
290 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> | 293 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> |
291 ScheduledTasksStateAsValue() const; | 294 ScheduledTasksStateAsValue() const; |
292 | 295 |
293 TileManagerClient* client_; | 296 TileManagerClient* client_; |
294 base::SequencedTaskRunner* task_runner_; | 297 base::SequencedTaskRunner* task_runner_; |
295 ResourcePool* resource_pool_; | 298 ResourcePool* resource_pool_; |
296 TileTaskManager* tile_task_manager_; | 299 TileTaskManager* tile_task_manager_; |
| 300 RasterBufferProvider* raster_buffer_provider_; |
297 GlobalStateThatImpactsTilePriority global_state_; | 301 GlobalStateThatImpactsTilePriority global_state_; |
298 size_t scheduled_raster_task_limit_; | 302 size_t scheduled_raster_task_limit_; |
299 const bool use_partial_raster_; | 303 const bool use_partial_raster_; |
300 bool use_gpu_rasterization_; | 304 bool use_gpu_rasterization_; |
301 | 305 |
302 std::unordered_map<Tile::Id, Tile*> tiles_; | 306 std::unordered_map<Tile::Id, Tile*> tiles_; |
303 | 307 |
304 bool all_tiles_that_need_to_be_rasterized_are_scheduled_; | 308 bool all_tiles_that_need_to_be_rasterized_are_scheduled_; |
305 MemoryHistory::Entry memory_stats_from_last_assign_; | 309 MemoryHistory::Entry memory_stats_from_last_assign_; |
306 | 310 |
(...skipping 29 matching lines...) Expand all Loading... |
336 std::vector<std::pair<DrawImage, scoped_refptr<TileTask>>> locked_images_; | 340 std::vector<std::pair<DrawImage, scoped_refptr<TileTask>>> locked_images_; |
337 | 341 |
338 base::WeakPtrFactory<TileManager> task_set_finished_weak_ptr_factory_; | 342 base::WeakPtrFactory<TileManager> task_set_finished_weak_ptr_factory_; |
339 | 343 |
340 DISALLOW_COPY_AND_ASSIGN(TileManager); | 344 DISALLOW_COPY_AND_ASSIGN(TileManager); |
341 }; | 345 }; |
342 | 346 |
343 } // namespace cc | 347 } // namespace cc |
344 | 348 |
345 #endif // CC_TILES_TILE_MANAGER_H_ | 349 #endif // CC_TILES_TILE_MANAGER_H_ |
OLD | NEW |