| 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_RESOURCES_TILE_MANAGER_H_ | 5 #ifndef CC_RESOURCES_TILE_MANAGER_H_ |
| 6 #define CC_RESOURCES_TILE_MANAGER_H_ | 6 #define CC_RESOURCES_TILE_MANAGER_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <queue> | 9 #include <queue> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 REQUIRED_FOR_DRAW | 95 REQUIRED_FOR_DRAW |
| 96 // Adding additional values requires increasing kNumberOfTaskSets in | 96 // Adding additional values requires increasing kNumberOfTaskSets in |
| 97 // rasterizer.h | 97 // rasterizer.h |
| 98 }; | 98 }; |
| 99 | 99 |
| 100 static scoped_ptr<TileManager> Create( | 100 static scoped_ptr<TileManager> Create( |
| 101 TileManagerClient* client, | 101 TileManagerClient* client, |
| 102 base::SequencedTaskRunner* task_runner, | 102 base::SequencedTaskRunner* task_runner, |
| 103 ResourcePool* resource_pool, | 103 ResourcePool* resource_pool, |
| 104 TileTaskRunner* tile_task_runner, | 104 TileTaskRunner* tile_task_runner, |
| 105 int compression_threshold, |
| 105 RenderingStatsInstrumentation* rendering_stats_instrumentation, | 106 RenderingStatsInstrumentation* rendering_stats_instrumentation, |
| 106 size_t scheduled_raster_task_limit); | 107 size_t scheduled_raster_task_limit); |
| 107 ~TileManager() override; | 108 ~TileManager() override; |
| 108 | 109 |
| 109 // Assigns tile memory and schedules work to prepare tiles for drawing. | 110 // Assigns tile memory and schedules work to prepare tiles for drawing. |
| 110 // - Runs client_->NotifyReadyToActivate() when all tiles required for | 111 // - Runs client_->NotifyReadyToActivate() when all tiles required for |
| 111 // activation are prepared, or failed to prepare due to OOM. | 112 // activation are prepared, or failed to prepare due to OOM. |
| 112 // - Runs client_->NotifyReadyToDraw() when all tiles required draw are | 113 // - Runs client_->NotifyReadyToDraw() when all tiles required draw are |
| 113 // prepared, or failed to prepare due to OOM. | 114 // prepared, or failed to prepare due to OOM. |
| 114 void PrepareTiles(const GlobalStateThatImpactsTilePriority& state); | 115 void PrepareTiles(const GlobalStateThatImpactsTilePriority& state); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 127 const; | 128 const; |
| 128 void BasicStateAsValueInto(base::debug::TracedValue* dict) const; | 129 void BasicStateAsValueInto(base::debug::TracedValue* dict) const; |
| 129 const MemoryHistory::Entry& memory_stats_from_last_assign() const { | 130 const MemoryHistory::Entry& memory_stats_from_last_assign() const { |
| 130 return memory_stats_from_last_assign_; | 131 return memory_stats_from_last_assign_; |
| 131 } | 132 } |
| 132 | 133 |
| 133 void InitializeTilesWithResourcesForTesting(const std::vector<Tile*>& tiles) { | 134 void InitializeTilesWithResourcesForTesting(const std::vector<Tile*>& tiles) { |
| 134 for (size_t i = 0; i < tiles.size(); ++i) { | 135 for (size_t i = 0; i < tiles.size(); ++i) { |
| 135 ManagedTileState& mts = tiles[i]->managed_state(); | 136 ManagedTileState& mts = tiles[i]->managed_state(); |
| 136 | 137 |
| 137 mts.draw_info.resource_ = | 138 mts.draw_info.resource_ = resource_pool_->AcquireResource( |
| 138 resource_pool_->AcquireResource(tiles[i]->size()); | 139 tiles[i]->size(), FORMAT_USAGE_NATIVE); |
| 139 } | 140 } |
| 140 } | 141 } |
| 141 | 142 |
| 142 void ReleaseTileResourcesForTesting(const std::vector<Tile*>& tiles) { | 143 void ReleaseTileResourcesForTesting(const std::vector<Tile*>& tiles) { |
| 143 for (size_t i = 0; i < tiles.size(); ++i) { | 144 for (size_t i = 0; i < tiles.size(); ++i) { |
| 144 Tile* tile = tiles[i]; | 145 Tile* tile = tiles[i]; |
| 145 FreeResourcesForTile(tile); | 146 FreeResourcesForTile(tile); |
| 146 } | 147 } |
| 147 } | 148 } |
| 148 | 149 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 169 | 170 |
| 170 void SetScheduledRasterTaskLimitForTesting(size_t limit) { | 171 void SetScheduledRasterTaskLimitForTesting(size_t limit) { |
| 171 scheduled_raster_task_limit_ = limit; | 172 scheduled_raster_task_limit_ = limit; |
| 172 } | 173 } |
| 173 | 174 |
| 174 protected: | 175 protected: |
| 175 TileManager(TileManagerClient* client, | 176 TileManager(TileManagerClient* client, |
| 176 const scoped_refptr<base::SequencedTaskRunner>& task_runner, | 177 const scoped_refptr<base::SequencedTaskRunner>& task_runner, |
| 177 ResourcePool* resource_pool, | 178 ResourcePool* resource_pool, |
| 178 TileTaskRunner* tile_task_runner, | 179 TileTaskRunner* tile_task_runner, |
| 180 int compression_threshold, |
| 179 RenderingStatsInstrumentation* rendering_stats_instrumentation, | 181 RenderingStatsInstrumentation* rendering_stats_instrumentation, |
| 180 size_t scheduled_raster_task_limit); | 182 size_t scheduled_raster_task_limit); |
| 181 | 183 |
| 182 void FreeResourcesForReleasedTiles(); | 184 void FreeResourcesForReleasedTiles(); |
| 183 void CleanUpReleasedTiles(); | 185 void CleanUpReleasedTiles(); |
| 184 | 186 |
| 185 // Overriden from RefCountedManager<Tile>: | 187 // Overriden from RefCountedManager<Tile>: |
| 186 friend class Tile; | 188 friend class Tile; |
| 187 void Release(Tile* tile) override; | 189 void Release(Tile* tile) override; |
| 188 | 190 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 }; | 223 }; |
| 222 | 224 |
| 223 void OnImageDecodeTaskCompleted(int layer_id, | 225 void OnImageDecodeTaskCompleted(int layer_id, |
| 224 SkPixelRef* pixel_ref, | 226 SkPixelRef* pixel_ref, |
| 225 bool was_canceled); | 227 bool was_canceled); |
| 226 void OnRasterTaskCompleted(Tile::Id tile, | 228 void OnRasterTaskCompleted(Tile::Id tile, |
| 227 scoped_ptr<ScopedResource> resource, | 229 scoped_ptr<ScopedResource> resource, |
| 228 const RasterSource::SolidColorAnalysis& analysis, | 230 const RasterSource::SolidColorAnalysis& analysis, |
| 229 bool was_canceled); | 231 bool was_canceled); |
| 230 | 232 |
| 233 ResourceFormatUsage DetermineResourceFormatUsage(const Tile* tile) const; |
| 231 void FreeResourcesForTile(Tile* tile); | 234 void FreeResourcesForTile(Tile* tile); |
| 232 void FreeResourcesForTileAndNotifyClientIfTileWasReadyToDraw(Tile* tile); | 235 void FreeResourcesForTileAndNotifyClientIfTileWasReadyToDraw(Tile* tile); |
| 233 scoped_refptr<ImageDecodeTask> CreateImageDecodeTask(Tile* tile, | 236 scoped_refptr<ImageDecodeTask> CreateImageDecodeTask(Tile* tile, |
| 234 SkPixelRef* pixel_ref); | 237 SkPixelRef* pixel_ref); |
| 235 scoped_refptr<RasterTask> CreateRasterTask(Tile* tile); | 238 scoped_refptr<RasterTask> CreateRasterTask(Tile* tile); |
| 236 | 239 |
| 237 void RebuildEvictionQueueIfNeeded(); | 240 void RebuildEvictionQueueIfNeeded(); |
| 238 bool FreeTileResourcesUntilUsageIsWithinLimit(const MemoryUsage& limit, | 241 bool FreeTileResourcesUntilUsageIsWithinLimit(const MemoryUsage& limit, |
| 239 MemoryUsage* usage); | 242 MemoryUsage* usage); |
| 240 bool FreeTileResourcesWithLowerPriorityUntilUsageIsWithinLimit( | 243 bool FreeTileResourcesWithLowerPriorityUntilUsageIsWithinLimit( |
| (...skipping 29 matching lines...) Expand all Loading... |
| 270 typedef base::hash_map<int, PixelRefTaskMap> LayerPixelRefTaskMap; | 273 typedef base::hash_map<int, PixelRefTaskMap> LayerPixelRefTaskMap; |
| 271 LayerPixelRefTaskMap image_decode_tasks_; | 274 LayerPixelRefTaskMap image_decode_tasks_; |
| 272 | 275 |
| 273 typedef base::hash_map<int, int> LayerCountMap; | 276 typedef base::hash_map<int, int> LayerCountMap; |
| 274 LayerCountMap used_layer_counts_; | 277 LayerCountMap used_layer_counts_; |
| 275 | 278 |
| 276 RasterTaskCompletionStats update_visible_tiles_stats_; | 279 RasterTaskCompletionStats update_visible_tiles_stats_; |
| 277 | 280 |
| 278 std::vector<Tile*> released_tiles_; | 281 std::vector<Tile*> released_tiles_; |
| 279 | 282 |
| 283 int compression_threshold_; |
| 284 |
| 280 ResourceFormat resource_format_; | 285 ResourceFormat resource_format_; |
| 281 | 286 |
| 282 // Queue used when scheduling raster tasks. | 287 // Queue used when scheduling raster tasks. |
| 283 TileTaskQueue raster_queue_; | 288 TileTaskQueue raster_queue_; |
| 284 | 289 |
| 285 std::vector<scoped_refptr<RasterTask>> orphan_raster_tasks_; | 290 std::vector<scoped_refptr<RasterTask>> orphan_raster_tasks_; |
| 286 | 291 |
| 287 UniqueNotifier ready_to_activate_check_notifier_; | 292 UniqueNotifier ready_to_activate_check_notifier_; |
| 288 UniqueNotifier ready_to_draw_check_notifier_; | 293 UniqueNotifier ready_to_draw_check_notifier_; |
| 289 | 294 |
| 290 RasterTilePriorityQueue raster_priority_queue_; | 295 RasterTilePriorityQueue raster_priority_queue_; |
| 291 EvictionTilePriorityQueue eviction_priority_queue_; | 296 EvictionTilePriorityQueue eviction_priority_queue_; |
| 292 bool eviction_priority_queue_is_up_to_date_; | 297 bool eviction_priority_queue_is_up_to_date_; |
| 293 | 298 |
| 294 bool did_notify_ready_to_activate_; | 299 bool did_notify_ready_to_activate_; |
| 295 bool did_notify_ready_to_draw_; | 300 bool did_notify_ready_to_draw_; |
| 296 | 301 |
| 297 DISALLOW_COPY_AND_ASSIGN(TileManager); | 302 DISALLOW_COPY_AND_ASSIGN(TileManager); |
| 298 }; | 303 }; |
| 299 | 304 |
| 300 } // namespace cc | 305 } // namespace cc |
| 301 | 306 |
| 302 #endif // CC_RESOURCES_TILE_MANAGER_H_ | 307 #endif // CC_RESOURCES_TILE_MANAGER_H_ |
| OLD | NEW |