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