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 |
11 #include <memory> | 11 #include <memory> |
12 #include <set> | 12 #include <set> |
13 #include <unordered_map> | 13 #include <unordered_map> |
14 #include <utility> | 14 #include <utility> |
15 #include <vector> | 15 #include <vector> |
16 | 16 |
17 #include "base/macros.h" | 17 #include "base/macros.h" |
18 #include "base/values.h" | 18 #include "base/values.h" |
19 #include "cc/base/unique_notifier.h" | 19 #include "cc/base/unique_notifier.h" |
20 #include "cc/playback/raster_source.h" | 20 #include "cc/playback/raster_source.h" |
21 #include "cc/raster/tile_task_runner.h" | 21 #include "cc/raster/tile_task_worker_pool.h" |
22 #include "cc/resources/memory_history.h" | 22 #include "cc/resources/memory_history.h" |
23 #include "cc/resources/resource_pool.h" | 23 #include "cc/resources/resource_pool.h" |
24 #include "cc/tiles/eviction_tile_priority_queue.h" | 24 #include "cc/tiles/eviction_tile_priority_queue.h" |
25 #include "cc/tiles/image_decode_controller.h" | 25 #include "cc/tiles/image_decode_controller.h" |
26 #include "cc/tiles/raster_tile_priority_queue.h" | 26 #include "cc/tiles/raster_tile_priority_queue.h" |
27 #include "cc/tiles/tile.h" | 27 #include "cc/tiles/tile.h" |
28 #include "cc/tiles/tile_draw_info.h" | 28 #include "cc/tiles/tile_draw_info.h" |
29 | 29 |
30 namespace base { | 30 namespace base { |
31 namespace trace_event { | 31 namespace trace_event { |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 | 110 |
111 // Synchronously finish any in progress work, cancel the rest, and clean up as | 111 // Synchronously finish any in progress work, cancel the rest, and clean up as |
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 TileTaskRunner* tile_task_runner, | 120 TileTaskWorkerPool* tile_task_worker_pool, |
121 ImageDecodeController* image_decode_controller, | 121 ImageDecodeController* image_decode_controller, |
122 size_t scheduled_raster_task_limit, | 122 size_t scheduled_raster_task_limit, |
123 bool use_gpu_rasterization); | 123 bool use_gpu_rasterization); |
124 | 124 |
125 // 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 |
126 // date draw information. | 126 // date draw information. |
127 void Flush(); | 127 void Flush(); |
128 | 128 |
129 ScopedTilePtr CreateTile(const Tile::CreateInfo& info, | 129 ScopedTilePtr CreateTile(const Tile::CreateInfo& info, |
130 int layer_id, | 130 int layer_id, |
131 int source_frame_number, | 131 int source_frame_number, |
132 int flags); | 132 int flags); |
133 | 133 |
134 bool IsReadyToActivate() const; | 134 bool IsReadyToActivate() const; |
135 bool IsReadyToDraw() const; | 135 bool IsReadyToDraw() const; |
136 | 136 |
137 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> | 137 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> |
138 BasicStateAsValue() const; | 138 BasicStateAsValue() const; |
139 void BasicStateAsValueInto(base::trace_event::TracedValue* dict) const; | 139 void BasicStateAsValueInto(base::trace_event::TracedValue* dict) const; |
140 const MemoryHistory::Entry& memory_stats_from_last_assign() const { | 140 const MemoryHistory::Entry& memory_stats_from_last_assign() const { |
141 return memory_stats_from_last_assign_; | 141 return memory_stats_from_last_assign_; |
142 } | 142 } |
143 | 143 |
144 // Public methods for testing. | 144 // Public methods for testing. |
145 void InitializeTilesWithResourcesForTesting(const std::vector<Tile*>& tiles) { | 145 void InitializeTilesWithResourcesForTesting(const std::vector<Tile*>& tiles) { |
146 for (size_t i = 0; i < tiles.size(); ++i) { | 146 for (size_t i = 0; i < tiles.size(); ++i) { |
147 TileDrawInfo& draw_info = tiles[i]->draw_info(); | 147 TileDrawInfo& draw_info = tiles[i]->draw_info(); |
148 draw_info.resource_ = resource_pool_->AcquireResource( | 148 draw_info.resource_ = resource_pool_->AcquireResource( |
149 tiles[i]->desired_texture_size(), | 149 tiles[i]->desired_texture_size(), |
150 tile_task_runner_->GetResourceFormat(false)); | 150 tile_task_worker_pool_->GetResourceFormat(false)); |
151 } | 151 } |
152 } | 152 } |
153 | 153 |
154 void ReleaseTileResourcesForTesting(const std::vector<Tile*>& tiles) { | 154 void ReleaseTileResourcesForTesting(const std::vector<Tile*>& tiles) { |
155 for (size_t i = 0; i < tiles.size(); ++i) { | 155 for (size_t i = 0; i < tiles.size(); ++i) { |
156 Tile* tile = tiles[i]; | 156 Tile* tile = tiles[i]; |
157 FreeResourcesForTile(tile); | 157 FreeResourcesForTile(tile); |
158 } | 158 } |
159 } | 159 } |
160 | 160 |
161 void SetGlobalStateForTesting( | 161 void SetGlobalStateForTesting( |
162 const GlobalStateThatImpactsTilePriority& state) { | 162 const GlobalStateThatImpactsTilePriority& state) { |
163 global_state_ = state; | 163 global_state_ = state; |
164 } | 164 } |
165 | 165 |
166 void SetTileTaskRunnerForTesting(TileTaskRunner* tile_task_runner); | 166 void SetTileTaskWorkerPoolForTesting( |
| 167 TileTaskWorkerPool* tile_task_worker_pool); |
167 | 168 |
168 void FreeResourcesAndCleanUpReleasedTilesForTesting() { | 169 void FreeResourcesAndCleanUpReleasedTilesForTesting() { |
169 FreeResourcesForReleasedTiles(); | 170 FreeResourcesForReleasedTiles(); |
170 CleanUpReleasedTiles(); | 171 CleanUpReleasedTiles(); |
171 } | 172 } |
172 | 173 |
173 std::vector<Tile*> AllTilesForTesting() const { | 174 std::vector<Tile*> AllTilesForTesting() const { |
174 std::vector<Tile*> tiles; | 175 std::vector<Tile*> tiles; |
175 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); | 176 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); |
176 ++it) { | 177 ++it) { |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 | 280 |
280 scoped_refptr<TileTask> CreateTaskSetFinishedTask( | 281 scoped_refptr<TileTask> CreateTaskSetFinishedTask( |
281 void (TileManager::*callback)()); | 282 void (TileManager::*callback)()); |
282 | 283 |
283 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> | 284 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> |
284 ScheduledTasksStateAsValue() const; | 285 ScheduledTasksStateAsValue() const; |
285 | 286 |
286 TileManagerClient* client_; | 287 TileManagerClient* client_; |
287 scoped_refptr<base::SequencedTaskRunner> task_runner_; | 288 scoped_refptr<base::SequencedTaskRunner> task_runner_; |
288 ResourcePool* resource_pool_; | 289 ResourcePool* resource_pool_; |
289 TileTaskRunner* tile_task_runner_; | 290 TileTaskWorkerPool* tile_task_worker_pool_; |
290 GlobalStateThatImpactsTilePriority global_state_; | 291 GlobalStateThatImpactsTilePriority global_state_; |
291 size_t scheduled_raster_task_limit_; | 292 size_t scheduled_raster_task_limit_; |
292 const bool use_partial_raster_; | 293 const bool use_partial_raster_; |
293 bool use_gpu_rasterization_; | 294 bool use_gpu_rasterization_; |
294 | 295 |
295 using TileMap = std::unordered_map<Tile::Id, Tile*>; | 296 using TileMap = std::unordered_map<Tile::Id, Tile*>; |
296 TileMap tiles_; | 297 TileMap tiles_; |
297 | 298 |
298 bool all_tiles_that_need_to_be_rasterized_are_scheduled_; | 299 bool all_tiles_that_need_to_be_rasterized_are_scheduled_; |
299 MemoryHistory::Entry memory_stats_from_last_assign_; | 300 MemoryHistory::Entry memory_stats_from_last_assign_; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 std::unordered_map<Tile::Id, std::vector<DrawImage>> scheduled_draw_images_; | 340 std::unordered_map<Tile::Id, std::vector<DrawImage>> scheduled_draw_images_; |
340 | 341 |
341 base::WeakPtrFactory<TileManager> task_set_finished_weak_ptr_factory_; | 342 base::WeakPtrFactory<TileManager> task_set_finished_weak_ptr_factory_; |
342 | 343 |
343 DISALLOW_COPY_AND_ASSIGN(TileManager); | 344 DISALLOW_COPY_AND_ASSIGN(TileManager); |
344 }; | 345 }; |
345 | 346 |
346 } // namespace cc | 347 } // namespace cc |
347 | 348 |
348 #endif // CC_TILES_TILE_MANAGER_H_ | 349 #endif // CC_TILES_TILE_MANAGER_H_ |
OLD | NEW |