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 marked as required for draw are ready to draw. |
| 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 ALL, |
91 ALL = 1, | 94 REQUIRED_FOR_ACTIVATION, |
| 95 REQUIRED_FOR_DRAW |
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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 | 228 |
225 void RebuildEvictionQueueIfNeeded(); | 229 void RebuildEvictionQueueIfNeeded(); |
226 bool FreeTileResourcesUntilUsageIsWithinLimit(const MemoryUsage& limit, | 230 bool FreeTileResourcesUntilUsageIsWithinLimit(const MemoryUsage& limit, |
227 MemoryUsage* usage); | 231 MemoryUsage* usage); |
228 bool FreeTileResourcesWithLowerPriorityUntilUsageIsWithinLimit( | 232 bool FreeTileResourcesWithLowerPriorityUntilUsageIsWithinLimit( |
229 const MemoryUsage& limit, | 233 const MemoryUsage& limit, |
230 const TilePriority& oother_priority, | 234 const TilePriority& oother_priority, |
231 MemoryUsage* usage); | 235 MemoryUsage* usage); |
232 bool TilePriorityViolatesMemoryPolicy(const TilePriority& priority); | 236 bool TilePriorityViolatesMemoryPolicy(const TilePriority& priority); |
233 bool IsReadyToActivate() const; | 237 bool IsReadyToActivate() const; |
| 238 bool IsReadyToDraw() const; |
234 void CheckIfReadyToActivate(); | 239 void CheckIfReadyToActivate(); |
| 240 void CheckIfReadyToDraw(); |
235 | 241 |
236 TileManagerClient* client_; | 242 TileManagerClient* client_; |
237 scoped_refptr<base::SequencedTaskRunner> task_runner_; | 243 scoped_refptr<base::SequencedTaskRunner> task_runner_; |
238 ResourcePool* resource_pool_; | 244 ResourcePool* resource_pool_; |
239 Rasterizer* rasterizer_; | 245 Rasterizer* rasterizer_; |
240 GlobalStateThatImpactsTilePriority global_state_; | 246 GlobalStateThatImpactsTilePriority global_state_; |
241 const size_t scheduled_raster_task_limit_; | 247 const size_t scheduled_raster_task_limit_; |
242 | 248 |
243 typedef base::hash_map<Tile::Id, Tile*> TileMap; | 249 typedef base::hash_map<Tile::Id, Tile*> TileMap; |
244 TileMap tiles_; | 250 TileMap tiles_; |
(...skipping 20 matching lines...) Expand all Loading... |
265 std::vector<Tile*> released_tiles_; | 271 std::vector<Tile*> released_tiles_; |
266 | 272 |
267 ResourceFormat resource_format_; | 273 ResourceFormat resource_format_; |
268 | 274 |
269 // Queue used when scheduling raster tasks. | 275 // Queue used when scheduling raster tasks. |
270 RasterTaskQueue raster_queue_; | 276 RasterTaskQueue raster_queue_; |
271 | 277 |
272 std::vector<scoped_refptr<RasterTask>> orphan_raster_tasks_; | 278 std::vector<scoped_refptr<RasterTask>> orphan_raster_tasks_; |
273 | 279 |
274 UniqueNotifier ready_to_activate_check_notifier_; | 280 UniqueNotifier ready_to_activate_check_notifier_; |
| 281 UniqueNotifier ready_to_draw_check_notifier_; |
275 | 282 |
276 RasterTilePriorityQueue raster_priority_queue_; | 283 RasterTilePriorityQueue raster_priority_queue_; |
277 EvictionTilePriorityQueue eviction_priority_queue_; | 284 EvictionTilePriorityQueue eviction_priority_queue_; |
278 bool eviction_priority_queue_is_up_to_date_; | 285 bool eviction_priority_queue_is_up_to_date_; |
279 | 286 |
280 DISALLOW_COPY_AND_ASSIGN(TileManager); | 287 DISALLOW_COPY_AND_ASSIGN(TileManager); |
281 }; | 288 }; |
282 | 289 |
283 } // namespace cc | 290 } // namespace cc |
284 | 291 |
285 #endif // CC_RESOURCES_TILE_MANAGER_H_ | 292 #endif // CC_RESOURCES_TILE_MANAGER_H_ |
OLD | NEW |