| 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 29 matching lines...) Expand all Loading... |
| 40 class CC_EXPORT TileManagerClient { | 40 class CC_EXPORT TileManagerClient { |
| 41 public: | 41 public: |
| 42 // Returns the set of layers that the tile manager should consider for raster. | 42 // Returns the set of layers that the tile manager should consider for raster. |
| 43 // TODO(vmpstr): Change the way we determine if we are ready to activate, so | 43 // TODO(vmpstr): Change the way we determine if we are ready to activate, so |
| 44 // that this can be removed. | 44 // that this can be removed. |
| 45 virtual const std::vector<PictureLayerImpl*>& GetPictureLayers() const = 0; | 45 virtual const std::vector<PictureLayerImpl*>& GetPictureLayers() const = 0; |
| 46 | 46 |
| 47 // Called when all tiles marked as required for activation are ready to draw. | 47 // Called when all tiles marked as required for activation are ready to draw. |
| 48 virtual void NotifyReadyToActivate() = 0; | 48 virtual void NotifyReadyToActivate() = 0; |
| 49 | 49 |
| 50 // Called when all tiles required to draw are ready. |
| 51 virtual void NotifyReadyToDraw() = 0; |
| 52 |
| 50 // Called when the visible representation of a tile might have changed. Some | 53 // Called when the visible representation of a tile might have changed. Some |
| 51 // examples are: | 54 // examples are: |
| 52 // - Tile version initialized. | 55 // - Tile version initialized. |
| 53 // - Tile resources freed. | 56 // - Tile resources freed. |
| 54 // - Tile marked for on-demand raster. | 57 // - Tile marked for on-demand raster. |
| 55 virtual void NotifyTileStateChanged(const Tile* tile) = 0; | 58 virtual void NotifyTileStateChanged(const Tile* tile) = 0; |
| 56 | 59 |
| 57 // Given an empty raster tile priority queue, this will build a priority queue | 60 // Given an empty raster tile priority queue, this will build a priority queue |
| 58 // that will return tiles in order in which they should be rasterized. | 61 // that will return tiles in order in which they should be rasterized. |
| 59 // Note if the queue was previous built, Reset must be called on it. | 62 // Note if the queue was previous built, Reset must be called on it. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 80 RasterTaskCompletionStatsAsValue(const RasterTaskCompletionStats& stats); | 83 RasterTaskCompletionStatsAsValue(const RasterTaskCompletionStats& stats); |
| 81 | 84 |
| 82 // This class manages tiles, deciding which should get rasterized and which | 85 // This class manages tiles, deciding which should get rasterized and which |
| 83 // should no longer have any memory assigned to them. Tile objects are "owned" | 86 // should no longer have any memory assigned to them. Tile objects are "owned" |
| 84 // by layers; they automatically register with the manager when they are | 87 // by layers; they automatically register with the manager when they are |
| 85 // created, and unregister from the manager when they are deleted. | 88 // created, and unregister from the manager when they are deleted. |
| 86 class CC_EXPORT TileManager : public RasterizerClient, | 89 class CC_EXPORT TileManager : public RasterizerClient, |
| 87 public RefCountedManager<Tile> { | 90 public RefCountedManager<Tile> { |
| 88 public: | 91 public: |
| 89 enum NamedTaskSet { | 92 enum NamedTaskSet { |
| 90 REQUIRED_FOR_ACTIVATION = 0, | 93 REQUIRED_FOR_DRAW = 0, |
| 91 ALL = 1, | 94 REQUIRED_FOR_ACTIVATION = 1, |
| 95 ALL = 2 |
| 92 // Adding additional values requires increasing kNumberOfTaskSets in | 96 // Adding additional values requires increasing kNumberOfTaskSets in |
| 93 // rasterizer.h | 97 // rasterizer.h |
| 94 }; | 98 }; |
| 95 | 99 |
| 96 static scoped_ptr<TileManager> Create( | 100 static scoped_ptr<TileManager> Create( |
| 97 TileManagerClient* client, | 101 TileManagerClient* client, |
| 98 base::SequencedTaskRunner* task_runner, | 102 base::SequencedTaskRunner* task_runner, |
| 99 ResourcePool* resource_pool, | 103 ResourcePool* resource_pool, |
| 100 Rasterizer* rasterizer, | 104 Rasterizer* rasterizer, |
| 101 RenderingStatsInstrumentation* rendering_stats_instrumentation); | 105 RenderingStatsInstrumentation* rendering_stats_instrumentation); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 | 226 |
| 223 void RebuildEvictionQueueIfNeeded(); | 227 void RebuildEvictionQueueIfNeeded(); |
| 224 bool FreeTileResourcesUntilUsageIsWithinLimit(const MemoryUsage& limit, | 228 bool FreeTileResourcesUntilUsageIsWithinLimit(const MemoryUsage& limit, |
| 225 MemoryUsage* usage); | 229 MemoryUsage* usage); |
| 226 bool FreeTileResourcesWithLowerPriorityUntilUsageIsWithinLimit( | 230 bool FreeTileResourcesWithLowerPriorityUntilUsageIsWithinLimit( |
| 227 const MemoryUsage& limit, | 231 const MemoryUsage& limit, |
| 228 const TilePriority& oother_priority, | 232 const TilePriority& oother_priority, |
| 229 MemoryUsage* usage); | 233 MemoryUsage* usage); |
| 230 bool TilePriorityViolatesMemoryPolicy(const TilePriority& priority); | 234 bool TilePriorityViolatesMemoryPolicy(const TilePriority& priority); |
| 231 bool IsReadyToActivate() const; | 235 bool IsReadyToActivate() const; |
| 236 bool IsReadyToDraw() const; |
| 232 void CheckIfReadyToActivate(); | 237 void CheckIfReadyToActivate(); |
| 238 void CheckIfReadyToDraw(); |
| 233 | 239 |
| 234 TileManagerClient* client_; | 240 TileManagerClient* client_; |
| 235 scoped_refptr<base::SequencedTaskRunner> task_runner_; | 241 scoped_refptr<base::SequencedTaskRunner> task_runner_; |
| 236 ResourcePool* resource_pool_; | 242 ResourcePool* resource_pool_; |
| 237 Rasterizer* rasterizer_; | 243 Rasterizer* rasterizer_; |
| 238 GlobalStateThatImpactsTilePriority global_state_; | 244 GlobalStateThatImpactsTilePriority global_state_; |
| 239 | 245 |
| 240 typedef base::hash_map<Tile::Id, Tile*> TileMap; | 246 typedef base::hash_map<Tile::Id, Tile*> TileMap; |
| 241 TileMap tiles_; | 247 TileMap tiles_; |
| 242 | 248 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 262 std::vector<Tile*> released_tiles_; | 268 std::vector<Tile*> released_tiles_; |
| 263 | 269 |
| 264 ResourceFormat resource_format_; | 270 ResourceFormat resource_format_; |
| 265 | 271 |
| 266 // Queue used when scheduling raster tasks. | 272 // Queue used when scheduling raster tasks. |
| 267 RasterTaskQueue raster_queue_; | 273 RasterTaskQueue raster_queue_; |
| 268 | 274 |
| 269 std::vector<scoped_refptr<RasterTask>> orphan_raster_tasks_; | 275 std::vector<scoped_refptr<RasterTask>> orphan_raster_tasks_; |
| 270 | 276 |
| 271 UniqueNotifier ready_to_activate_check_notifier_; | 277 UniqueNotifier ready_to_activate_check_notifier_; |
| 278 UniqueNotifier ready_to_draw_check_notifier_; |
| 272 | 279 |
| 273 RasterTilePriorityQueue raster_priority_queue_; | 280 RasterTilePriorityQueue raster_priority_queue_; |
| 274 EvictionTilePriorityQueue eviction_priority_queue_; | 281 EvictionTilePriorityQueue eviction_priority_queue_; |
| 275 bool eviction_priority_queue_is_up_to_date_; | 282 bool eviction_priority_queue_is_up_to_date_; |
| 276 | 283 |
| 277 DISALLOW_COPY_AND_ASSIGN(TileManager); | 284 DISALLOW_COPY_AND_ASSIGN(TileManager); |
| 278 }; | 285 }; |
| 279 | 286 |
| 280 } // namespace cc | 287 } // namespace cc |
| 281 | 288 |
| 282 #endif // CC_RESOURCES_TILE_MANAGER_H_ | 289 #endif // CC_RESOURCES_TILE_MANAGER_H_ |
| OLD | NEW |