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 15 matching lines...) Expand all Loading... |
26 #include "cc/resources/resource_pool.h" | 26 #include "cc/resources/resource_pool.h" |
27 #include "cc/resources/tile.h" | 27 #include "cc/resources/tile.h" |
28 | 28 |
29 namespace cc { | 29 namespace cc { |
30 class RasterizerDelegate; | 30 class RasterizerDelegate; |
31 class ResourceProvider; | 31 class ResourceProvider; |
32 | 32 |
33 class CC_EXPORT TileManagerClient { | 33 class CC_EXPORT TileManagerClient { |
34 public: | 34 public: |
35 virtual void NotifyReadyToActivate() = 0; | 35 virtual void NotifyReadyToActivate() = 0; |
36 virtual void NotifyTileInitialized(const Tile* tile) = 0; | 36 virtual void NotifyTileStateChanged(const Tile* tile) = 0; |
37 | 37 |
38 protected: | 38 protected: |
39 virtual ~TileManagerClient() {} | 39 virtual ~TileManagerClient() {} |
40 }; | 40 }; |
41 | 41 |
42 struct RasterTaskCompletionStats { | 42 struct RasterTaskCompletionStats { |
43 RasterTaskCompletionStats(); | 43 RasterTaskCompletionStats(); |
44 | 44 |
45 size_t completed_count; | 45 size_t completed_count; |
46 size_t canceled_count; | 46 size_t canceled_count; |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 std::vector<PairedPictureLayerIterator> paired_iterators_; | 149 std::vector<PairedPictureLayerIterator> paired_iterators_; |
150 std::vector<PairedPictureLayerIterator*> iterator_heap_; | 150 std::vector<PairedPictureLayerIterator*> iterator_heap_; |
151 TreePriority tree_priority_; | 151 TreePriority tree_priority_; |
152 EvictionOrderComparator comparator_; | 152 EvictionOrderComparator comparator_; |
153 | 153 |
154 DISALLOW_COPY_AND_ASSIGN(EvictionTileIterator); | 154 DISALLOW_COPY_AND_ASSIGN(EvictionTileIterator); |
155 }; | 155 }; |
156 | 156 |
157 static scoped_ptr<TileManager> Create( | 157 static scoped_ptr<TileManager> Create( |
158 TileManagerClient* client, | 158 TileManagerClient* client, |
| 159 base::SequencedTaskRunner* task_runner, |
159 ResourcePool* resource_pool, | 160 ResourcePool* resource_pool, |
160 Rasterizer* rasterizer, | 161 Rasterizer* rasterizer, |
161 Rasterizer* gpu_rasterizer, | 162 Rasterizer* gpu_rasterizer, |
162 bool use_rasterize_on_demand, | |
163 RenderingStatsInstrumentation* rendering_stats_instrumentation); | 163 RenderingStatsInstrumentation* rendering_stats_instrumentation); |
164 virtual ~TileManager(); | 164 virtual ~TileManager(); |
165 | 165 |
166 void ManageTiles(const GlobalStateThatImpactsTilePriority& state); | 166 void ManageTiles(const GlobalStateThatImpactsTilePriority& state); |
167 | 167 |
168 // Returns true when visible tiles have been initialized. | 168 // Returns true when visible tiles have been initialized. |
169 bool UpdateVisibleTiles(); | 169 bool UpdateVisibleTiles(); |
170 | 170 |
171 scoped_refptr<Tile> CreateTile(PicturePileImpl* picture_pile, | 171 scoped_refptr<Tile> CreateTile(PicturePileImpl* picture_pile, |
172 const gfx::Size& tile_size, | 172 const gfx::Size& tile_size, |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 } | 225 } |
226 } | 226 } |
227 | 227 |
228 void SetRasterizersForTesting(Rasterizer* rasterizer, | 228 void SetRasterizersForTesting(Rasterizer* rasterizer, |
229 Rasterizer* gpu_rasterizer); | 229 Rasterizer* gpu_rasterizer); |
230 | 230 |
231 void CleanUpReleasedTilesForTesting() { CleanUpReleasedTiles(); } | 231 void CleanUpReleasedTilesForTesting() { CleanUpReleasedTiles(); } |
232 | 232 |
233 protected: | 233 protected: |
234 TileManager(TileManagerClient* client, | 234 TileManager(TileManagerClient* client, |
| 235 base::SequencedTaskRunner* task_runner, |
235 ResourcePool* resource_pool, | 236 ResourcePool* resource_pool, |
236 Rasterizer* rasterizer, | 237 Rasterizer* rasterizer, |
237 Rasterizer* gpu_rasterizer, | 238 Rasterizer* gpu_rasterizer, |
238 bool use_rasterize_on_demand, | |
239 RenderingStatsInstrumentation* rendering_stats_instrumentation); | 239 RenderingStatsInstrumentation* rendering_stats_instrumentation); |
240 | 240 |
241 // Methods called by Tile | 241 // Methods called by Tile |
242 friend class Tile; | 242 friend class Tile; |
243 void DidChangeTilePriority(Tile* tile); | 243 void DidChangeTilePriority(Tile* tile); |
244 | 244 |
245 void CleanUpReleasedTiles(); | 245 void CleanUpReleasedTiles(); |
246 | 246 |
247 // Overriden from RefCountedManager<Tile>: | 247 // Overriden from RefCountedManager<Tile>: |
248 virtual void Release(Tile* tile) OVERRIDE; | 248 virtual void Release(Tile* tile) OVERRIDE; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 bool was_canceled); | 280 bool was_canceled); |
281 | 281 |
282 inline size_t BytesConsumedIfAllocated(const Tile* tile) const { | 282 inline size_t BytesConsumedIfAllocated(const Tile* tile) const { |
283 return Resource::MemorySizeBytes(tile->size(), | 283 return Resource::MemorySizeBytes(tile->size(), |
284 resource_pool_->resource_format()); | 284 resource_pool_->resource_format()); |
285 } | 285 } |
286 | 286 |
287 void FreeResourceForTile(Tile* tile, RasterMode mode); | 287 void FreeResourceForTile(Tile* tile, RasterMode mode); |
288 void FreeResourcesForTile(Tile* tile); | 288 void FreeResourcesForTile(Tile* tile); |
289 void FreeUnusedResourcesForTile(Tile* tile); | 289 void FreeUnusedResourcesForTile(Tile* tile); |
| 290 void FreeResourcesForTileAndNotifyClientIfTileWasReadyToDraw(Tile* tile); |
290 scoped_refptr<ImageDecodeTask> CreateImageDecodeTask(Tile* tile, | 291 scoped_refptr<ImageDecodeTask> CreateImageDecodeTask(Tile* tile, |
291 SkPixelRef* pixel_ref); | 292 SkPixelRef* pixel_ref); |
292 scoped_refptr<RasterTask> CreateRasterTask(Tile* tile); | 293 scoped_refptr<RasterTask> CreateRasterTask(Tile* tile); |
293 scoped_ptr<base::Value> GetMemoryRequirementsAsValue() const; | 294 scoped_ptr<base::Value> GetMemoryRequirementsAsValue() const; |
294 void UpdatePrioritizedTileSetIfNeeded(); | 295 void UpdatePrioritizedTileSetIfNeeded(); |
295 | 296 |
| 297 bool IsReadyToActivate() const; |
| 298 void ScheduleCheckIfReadyToActivate(); |
| 299 void CheckIfReadyToActivate(); |
| 300 |
296 TileManagerClient* client_; | 301 TileManagerClient* client_; |
| 302 scoped_refptr<base::SequencedTaskRunner> task_runner_; |
297 ResourcePool* resource_pool_; | 303 ResourcePool* resource_pool_; |
298 scoped_ptr<RasterizerDelegate> rasterizer_delegate_; | 304 scoped_ptr<RasterizerDelegate> rasterizer_delegate_; |
299 GlobalStateThatImpactsTilePriority global_state_; | 305 GlobalStateThatImpactsTilePriority global_state_; |
300 | 306 |
301 typedef base::hash_map<Tile::Id, Tile*> TileMap; | 307 typedef base::hash_map<Tile::Id, Tile*> TileMap; |
302 TileMap tiles_; | 308 TileMap tiles_; |
303 | 309 |
304 PrioritizedTileSet prioritized_tiles_; | 310 PrioritizedTileSet prioritized_tiles_; |
305 bool prioritized_tiles_dirty_; | 311 bool prioritized_tiles_dirty_; |
306 | 312 |
(...skipping 19 matching lines...) Expand all Loading... |
326 typedef base::hash_map<int, PixelRefTaskMap> LayerPixelRefTaskMap; | 332 typedef base::hash_map<int, PixelRefTaskMap> LayerPixelRefTaskMap; |
327 LayerPixelRefTaskMap image_decode_tasks_; | 333 LayerPixelRefTaskMap image_decode_tasks_; |
328 | 334 |
329 typedef base::hash_map<int, int> LayerCountMap; | 335 typedef base::hash_map<int, int> LayerCountMap; |
330 LayerCountMap used_layer_counts_; | 336 LayerCountMap used_layer_counts_; |
331 | 337 |
332 RasterTaskCompletionStats update_visible_tiles_stats_; | 338 RasterTaskCompletionStats update_visible_tiles_stats_; |
333 | 339 |
334 std::vector<Tile*> released_tiles_; | 340 std::vector<Tile*> released_tiles_; |
335 | 341 |
336 bool use_rasterize_on_demand_; | |
337 | |
338 ResourceFormat resource_format_; | 342 ResourceFormat resource_format_; |
339 | 343 |
340 // Queues used when scheduling raster tasks. | 344 // Queues used when scheduling raster tasks. |
341 RasterTaskQueue raster_queue_[NUM_RASTERIZER_TYPES]; | 345 RasterTaskQueue raster_queue_[NUM_RASTERIZER_TYPES]; |
342 | 346 |
343 std::vector<scoped_refptr<RasterTask> > orphan_raster_tasks_; | 347 std::vector<scoped_refptr<RasterTask> > orphan_raster_tasks_; |
344 | 348 |
345 std::vector<PictureLayerImpl*> layers_; | 349 std::vector<PictureLayerImpl*> layers_; |
346 | 350 |
| 351 bool check_if_ready_to_activate_pending_; |
| 352 |
| 353 base::WeakPtrFactory<TileManager> weak_ptr_factory_; |
| 354 |
347 DISALLOW_COPY_AND_ASSIGN(TileManager); | 355 DISALLOW_COPY_AND_ASSIGN(TileManager); |
348 }; | 356 }; |
349 | 357 |
350 } // namespace cc | 358 } // namespace cc |
351 | 359 |
352 #endif // CC_RESOURCES_TILE_MANAGER_H_ | 360 #endif // CC_RESOURCES_TILE_MANAGER_H_ |
OLD | NEW |