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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 // 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 |
54 // examples are: | 54 // examples are: |
55 // - Tile version initialized. | 55 // - Tile version initialized. |
56 // - Tile resources freed. | 56 // - Tile resources freed. |
57 // - Tile marked for on-demand raster. | 57 // - Tile marked for on-demand raster. |
58 virtual void NotifyTileStateChanged(const Tile* tile) = 0; | 58 virtual void NotifyTileStateChanged(const Tile* tile) = 0; |
59 | 59 |
60 // 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 |
61 // 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. |
62 // 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. |
63 virtual void BuildRasterQueue(RasterTilePriorityQueue* queue, | 63 virtual scoped_ptr<RasterTilePriorityQueue> BuildRasterQueue( |
64 TreePriority tree_priority, | 64 TreePriority tree_priority, |
65 RasterTilePriorityQueue::Type type) = 0; | 65 RasterTilePriorityQueue::Type type) = 0; |
66 | 66 |
67 // Given an empty eviction tile priority queue, this will build a priority | 67 // Given an empty eviction tile priority queue, this will build a priority |
68 // queue that will return tiles in order in which they should be evicted. | 68 // queue that will return tiles in order in which they should be evicted. |
69 // Note if the queue was previous built, Reset must be called on it. | 69 // Note if the queue was previous built, Reset must be called on it. |
70 virtual void BuildEvictionQueue(EvictionTilePriorityQueue* queue, | 70 virtual scoped_ptr<EvictionTilePriorityQueue> BuildEvictionQueue( |
71 TreePriority tree_priority) = 0; | 71 TreePriority tree_priority) = 0; |
72 | 72 |
73 protected: | 73 protected: |
74 virtual ~TileManagerClient() {} | 74 virtual ~TileManagerClient() {} |
75 }; | 75 }; |
76 | 76 |
77 struct RasterTaskCompletionStats { | 77 struct RasterTaskCompletionStats { |
78 RasterTaskCompletionStats(); | 78 RasterTaskCompletionStats(); |
79 | 79 |
80 size_t completed_count; | 80 size_t completed_count; |
81 size_t canceled_count; | 81 size_t canceled_count; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 scoped_refptr<base::debug::ConvertableToTraceFormat> BasicStateAsValue() | 131 scoped_refptr<base::debug::ConvertableToTraceFormat> BasicStateAsValue() |
132 const; | 132 const; |
133 void BasicStateAsValueInto(base::debug::TracedValue* dict) const; | 133 void BasicStateAsValueInto(base::debug::TracedValue* dict) const; |
134 const MemoryHistory::Entry& memory_stats_from_last_assign() const { | 134 const MemoryHistory::Entry& memory_stats_from_last_assign() const { |
135 return memory_stats_from_last_assign_; | 135 return memory_stats_from_last_assign_; |
136 } | 136 } |
137 | 137 |
138 void InitializeTilesWithResourcesForTesting(const std::vector<Tile*>& tiles) { | 138 void InitializeTilesWithResourcesForTesting(const std::vector<Tile*>& tiles) { |
139 for (size_t i = 0; i < tiles.size(); ++i) { | 139 for (size_t i = 0; i < tiles.size(); ++i) { |
140 TileDrawInfo& draw_info = tiles[i]->draw_info(); | 140 TileDrawInfo& draw_info = tiles[i]->draw_info(); |
141 draw_info.resource_ = | 141 draw_info.resource_ = resource_pool_->AcquireResource( |
142 resource_pool_->AcquireResource(tiles[i]->desired_texture_size(), | 142 tiles[i]->desired_texture_size(), |
143 resource_pool_->default_format()); | 143 tile_task_runner_->GetResourceFormat()); |
144 } | 144 } |
145 } | 145 } |
146 | 146 |
147 void ReleaseTileResourcesForTesting(const std::vector<Tile*>& tiles) { | 147 void ReleaseTileResourcesForTesting(const std::vector<Tile*>& tiles) { |
148 for (size_t i = 0; i < tiles.size(); ++i) { | 148 for (size_t i = 0; i < tiles.size(); ++i) { |
149 Tile* tile = tiles[i]; | 149 Tile* tile = tiles[i]; |
150 FreeResourcesForTile(tile); | 150 FreeResourcesForTile(tile); |
151 } | 151 } |
152 } | 152 } |
153 | 153 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 void UpdateTileDrawInfo(Tile* tile, | 240 void UpdateTileDrawInfo(Tile* tile, |
241 scoped_ptr<ScopedResource> resource, | 241 scoped_ptr<ScopedResource> resource, |
242 const RasterSource::SolidColorAnalysis& analysis); | 242 const RasterSource::SolidColorAnalysis& analysis); |
243 | 243 |
244 void FreeResourcesForTile(Tile* tile); | 244 void FreeResourcesForTile(Tile* tile); |
245 void FreeResourcesForTileAndNotifyClientIfTileWasReadyToDraw(Tile* tile); | 245 void FreeResourcesForTileAndNotifyClientIfTileWasReadyToDraw(Tile* tile); |
246 scoped_refptr<ImageDecodeTask> CreateImageDecodeTask(Tile* tile, | 246 scoped_refptr<ImageDecodeTask> CreateImageDecodeTask(Tile* tile, |
247 SkPixelRef* pixel_ref); | 247 SkPixelRef* pixel_ref); |
248 scoped_refptr<RasterTask> CreateRasterTask(Tile* tile); | 248 scoped_refptr<RasterTask> CreateRasterTask(Tile* tile); |
249 | 249 |
250 void RebuildEvictionQueueIfNeeded(); | 250 scoped_ptr<EvictionTilePriorityQueue> |
251 bool FreeTileResourcesUntilUsageIsWithinLimit(const MemoryUsage& limit, | 251 FreeTileResourcesUntilUsageIsWithinLimit( |
252 MemoryUsage* usage); | 252 scoped_ptr<EvictionTilePriorityQueue> eviction_priority_queue, |
253 bool FreeTileResourcesWithLowerPriorityUntilUsageIsWithinLimit( | 253 const MemoryUsage& limit, |
| 254 MemoryUsage* usage); |
| 255 scoped_ptr<EvictionTilePriorityQueue> |
| 256 FreeTileResourcesWithLowerPriorityUntilUsageIsWithinLimit( |
| 257 scoped_ptr<EvictionTilePriorityQueue> eviction_priority_queue, |
254 const MemoryUsage& limit, | 258 const MemoryUsage& limit, |
255 const TilePriority& oother_priority, | 259 const TilePriority& oother_priority, |
256 MemoryUsage* usage); | 260 MemoryUsage* usage); |
257 bool TilePriorityViolatesMemoryPolicy(const TilePriority& priority); | 261 bool TilePriorityViolatesMemoryPolicy(const TilePriority& priority); |
258 bool IsReadyToActivate() const; | 262 bool IsReadyToActivate() const; |
259 bool IsReadyToDraw() const; | 263 bool IsReadyToDraw() const; |
260 void NotifyReadyToActivate(); | 264 void NotifyReadyToActivate(); |
261 void NotifyReadyToDraw(); | 265 void NotifyReadyToDraw(); |
262 void CheckIfReadyToActivate(); | 266 void CheckIfReadyToActivate(); |
263 void CheckIfReadyToDraw(); | 267 void CheckIfReadyToDraw(); |
(...skipping 21 matching lines...) Expand all Loading... |
285 typedef base::hash_map<int, PixelRefTaskMap> LayerPixelRefTaskMap; | 289 typedef base::hash_map<int, PixelRefTaskMap> LayerPixelRefTaskMap; |
286 LayerPixelRefTaskMap image_decode_tasks_; | 290 LayerPixelRefTaskMap image_decode_tasks_; |
287 | 291 |
288 typedef base::hash_map<int, int> LayerCountMap; | 292 typedef base::hash_map<int, int> LayerCountMap; |
289 LayerCountMap used_layer_counts_; | 293 LayerCountMap used_layer_counts_; |
290 | 294 |
291 RasterTaskCompletionStats update_visible_tiles_stats_; | 295 RasterTaskCompletionStats update_visible_tiles_stats_; |
292 | 296 |
293 std::vector<Tile*> released_tiles_; | 297 std::vector<Tile*> released_tiles_; |
294 | 298 |
295 ResourceFormat resource_format_; | |
296 | |
297 // Queue used when scheduling raster tasks. | 299 // Queue used when scheduling raster tasks. |
298 TileTaskQueue raster_queue_; | 300 TileTaskQueue raster_queue_; |
299 | 301 |
300 std::vector<scoped_refptr<RasterTask>> orphan_raster_tasks_; | 302 std::vector<scoped_refptr<RasterTask>> orphan_raster_tasks_; |
301 | 303 |
302 UniqueNotifier ready_to_activate_notifier_; | 304 UniqueNotifier ready_to_activate_notifier_; |
303 UniqueNotifier ready_to_draw_notifier_; | 305 UniqueNotifier ready_to_draw_notifier_; |
304 UniqueNotifier ready_to_activate_check_notifier_; | 306 UniqueNotifier ready_to_activate_check_notifier_; |
305 UniqueNotifier ready_to_draw_check_notifier_; | 307 UniqueNotifier ready_to_draw_check_notifier_; |
306 UniqueNotifier more_tiles_need_prepare_check_notifier_; | 308 UniqueNotifier more_tiles_need_prepare_check_notifier_; |
307 | 309 |
308 EvictionTilePriorityQueue eviction_priority_queue_; | |
309 bool eviction_priority_queue_is_up_to_date_; | |
310 | |
311 bool did_notify_ready_to_activate_; | 310 bool did_notify_ready_to_activate_; |
312 bool did_notify_ready_to_draw_; | 311 bool did_notify_ready_to_draw_; |
313 | 312 |
314 DISALLOW_COPY_AND_ASSIGN(TileManager); | 313 DISALLOW_COPY_AND_ASSIGN(TileManager); |
315 }; | 314 }; |
316 | 315 |
317 } // namespace cc | 316 } // namespace cc |
318 | 317 |
319 #endif // CC_RESOURCES_TILE_MANAGER_H_ | 318 #endif // CC_RESOURCES_TILE_MANAGER_H_ |
OLD | NEW |