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