| 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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 typedef std::vector<Tile*> TileVector; | 181 typedef std::vector<Tile*> TileVector; |
| 182 typedef std::set<Tile*> TileSet; | 182 typedef std::set<Tile*> TileSet; |
| 183 | 183 |
| 184 // Virtual for test | 184 // Virtual for test |
| 185 virtual void ScheduleTasks( | 185 virtual void ScheduleTasks( |
| 186 const TileVector& tiles_that_need_to_be_rasterized); | 186 const TileVector& tiles_that_need_to_be_rasterized); |
| 187 | 187 |
| 188 void AssignGpuMemoryToTiles(TileVector* tiles_that_need_to_be_rasterized); | 188 void AssignGpuMemoryToTiles(TileVector* tiles_that_need_to_be_rasterized); |
| 189 | 189 |
| 190 private: | 190 private: |
| 191 class MemoryUsage { | 191 using MemoryUsage = int64_t; |
| 192 public: | |
| 193 MemoryUsage(); | |
| 194 MemoryUsage(int64 memory_bytes, int resource_count); | |
| 195 | |
| 196 static MemoryUsage FromConfig(const gfx::Size& size, ResourceFormat format); | |
| 197 static MemoryUsage FromTile(const Tile* tile); | |
| 198 | |
| 199 MemoryUsage& operator+=(const MemoryUsage& other); | |
| 200 MemoryUsage& operator-=(const MemoryUsage& other); | |
| 201 MemoryUsage operator-(const MemoryUsage& other); | |
| 202 | |
| 203 bool Exceeds(const MemoryUsage& limit) const; | |
| 204 int64 memory_bytes() const { return memory_bytes_; } | |
| 205 | |
| 206 private: | |
| 207 int64 memory_bytes_; | |
| 208 int resource_count_; | |
| 209 }; | |
| 210 | |
| 211 void OnImageDecodeTaskCompleted(int layer_id, | 192 void OnImageDecodeTaskCompleted(int layer_id, |
| 212 SkPixelRef* pixel_ref, | 193 SkPixelRef* pixel_ref, |
| 213 bool was_canceled); | 194 bool was_canceled); |
| 214 void OnRasterTaskCompleted(Tile::Id tile, | 195 void OnRasterTaskCompleted(Tile::Id tile, |
| 215 scoped_ptr<ScopedResource> resource, | 196 scoped_ptr<ScopedResource> resource, |
| 216 const PicturePileImpl::Analysis& analysis, | 197 const PicturePileImpl::Analysis& analysis, |
| 217 bool was_canceled); | 198 bool was_canceled); |
| 218 | 199 |
| 219 void FreeResourcesForTile(Tile* tile); | 200 void FreeResourcesForTile(Tile* tile); |
| 220 void FreeResourcesForTileAndNotifyClientIfTileWasReadyToDraw(Tile* tile); | 201 void FreeResourcesForTileAndNotifyClientIfTileWasReadyToDraw(Tile* tile); |
| 221 scoped_refptr<ImageDecodeTask> CreateImageDecodeTask(Tile* tile, | 202 scoped_refptr<ImageDecodeTask> CreateImageDecodeTask(Tile* tile, |
| 222 SkPixelRef* pixel_ref); | 203 SkPixelRef* pixel_ref); |
| 223 scoped_refptr<RasterTask> CreateRasterTask(Tile* tile); | 204 scoped_refptr<RasterTask> CreateRasterTask(Tile* tile); |
| 224 | 205 |
| 225 void RebuildEvictionQueueIfNeeded(); | 206 void RebuildEvictionQueueIfNeeded(); |
| 226 bool FreeTileResourcesUntilUsageIsWithinLimit(const MemoryUsage& limit, | 207 bool FreeTileResourcesUntilUsageIsWithinLimit(MemoryUsage limit, |
| 227 MemoryUsage* usage); | 208 MemoryUsage* usage); |
| 228 bool FreeTileResourcesWithLowerPriorityUntilUsageIsWithinLimit( | 209 bool FreeTileResourcesWithLowerPriorityUntilUsageIsWithinLimit( |
| 229 const MemoryUsage& limit, | 210 MemoryUsage limit, |
| 230 const TilePriority& oother_priority, | 211 const TilePriority& oother_priority, |
| 231 MemoryUsage* usage); | 212 MemoryUsage* usage); |
| 232 bool TilePriorityViolatesMemoryPolicy(const TilePriority& priority); | 213 bool TilePriorityViolatesMemoryPolicy(const TilePriority& priority); |
| 233 bool IsReadyToActivate() const; | 214 bool IsReadyToActivate() const; |
| 234 void CheckIfReadyToActivate(); | 215 void CheckIfReadyToActivate(); |
| 216 MemoryUsage MemoryUsageFromConfig(const gfx::Size& size, |
| 217 ResourceFormat format); |
| 218 MemoryUsage MemoryUsageFromTile(const Tile* tile); |
| 235 | 219 |
| 236 TileManagerClient* client_; | 220 TileManagerClient* client_; |
| 237 scoped_refptr<base::SequencedTaskRunner> task_runner_; | 221 scoped_refptr<base::SequencedTaskRunner> task_runner_; |
| 238 ResourcePool* resource_pool_; | 222 ResourcePool* resource_pool_; |
| 239 Rasterizer* rasterizer_; | 223 Rasterizer* rasterizer_; |
| 240 GlobalStateThatImpactsTilePriority global_state_; | 224 GlobalStateThatImpactsTilePriority global_state_; |
| 241 const size_t scheduled_raster_task_limit_; | 225 const size_t scheduled_raster_task_limit_; |
| 242 | 226 |
| 243 typedef base::hash_map<Tile::Id, Tile*> TileMap; | 227 typedef base::hash_map<Tile::Id, Tile*> TileMap; |
| 244 TileMap tiles_; | 228 TileMap tiles_; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 RasterTilePriorityQueue raster_priority_queue_; | 260 RasterTilePriorityQueue raster_priority_queue_; |
| 277 EvictionTilePriorityQueue eviction_priority_queue_; | 261 EvictionTilePriorityQueue eviction_priority_queue_; |
| 278 bool eviction_priority_queue_is_up_to_date_; | 262 bool eviction_priority_queue_is_up_to_date_; |
| 279 | 263 |
| 280 DISALLOW_COPY_AND_ASSIGN(TileManager); | 264 DISALLOW_COPY_AND_ASSIGN(TileManager); |
| 281 }; | 265 }; |
| 282 | 266 |
| 283 } // namespace cc | 267 } // namespace cc |
| 284 | 268 |
| 285 #endif // CC_RESOURCES_TILE_MANAGER_H_ | 269 #endif // CC_RESOURCES_TILE_MANAGER_H_ |
| OLD | NEW |