Chromium Code Reviews| 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 { | |
| 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, | 191 void OnImageDecodeTaskCompleted(int layer_id, |
| 212 SkPixelRef* pixel_ref, | 192 SkPixelRef* pixel_ref, |
| 213 bool was_canceled); | 193 bool was_canceled); |
| 214 void OnRasterTaskCompleted(Tile::Id tile, | 194 void OnRasterTaskCompleted(Tile::Id tile, |
| 215 scoped_ptr<ScopedResource> resource, | 195 scoped_ptr<ScopedResource> resource, |
| 216 const PicturePileImpl::Analysis& analysis, | 196 const PicturePileImpl::Analysis& analysis, |
| 217 bool was_canceled); | 197 bool was_canceled); |
| 218 | 198 |
| 219 void FreeResourcesForTile(Tile* tile); | 199 void FreeResourcesForTile(Tile* tile); |
| 220 void FreeResourcesForTileAndNotifyClientIfTileWasReadyToDraw(Tile* tile); | 200 void FreeResourcesForTileAndNotifyClientIfTileWasReadyToDraw(Tile* tile); |
| 221 scoped_refptr<ImageDecodeTask> CreateImageDecodeTask(Tile* tile, | 201 scoped_refptr<ImageDecodeTask> CreateImageDecodeTask(Tile* tile, |
| 222 SkPixelRef* pixel_ref); | 202 SkPixelRef* pixel_ref); |
| 223 scoped_refptr<RasterTask> CreateRasterTask(Tile* tile); | 203 scoped_refptr<RasterTask> CreateRasterTask(Tile* tile); |
| 224 | 204 |
| 225 void RebuildEvictionQueueIfNeeded(); | 205 void RebuildEvictionQueueIfNeeded(); |
| 226 bool FreeTileResourcesUntilUsageIsWithinLimit(const MemoryUsage& limit, | 206 bool FreeTileResourcesUntilUsageIsWithinLimit(int64 limit, int64* usage); |
| 227 MemoryUsage* usage); | |
| 228 bool FreeTileResourcesWithLowerPriorityUntilUsageIsWithinLimit( | 207 bool FreeTileResourcesWithLowerPriorityUntilUsageIsWithinLimit( |
| 229 const MemoryUsage& limit, | 208 int64 limit, |
| 230 const TilePriority& oother_priority, | 209 const TilePriority& oother_priority, |
| 231 MemoryUsage* usage); | 210 int64* usage); |
| 232 bool TilePriorityViolatesMemoryPolicy(const TilePriority& priority); | 211 bool TilePriorityViolatesMemoryPolicy(const TilePriority& priority); |
| 233 bool IsReadyToActivate() const; | 212 bool IsReadyToActivate() const; |
| 234 void CheckIfReadyToActivate(); | 213 void CheckIfReadyToActivate(); |
| 214 int64 BytesLimitFromConfig(const gfx::Size& size, ResourceFormat format); | |
|
reveman
2014/10/27 13:39:00
MemoryUsageFromConfig?
boliu
2014/10/27 15:35:57
Done.
| |
| 215 int64 BytesLimitFromTile(const Tile* tile); | |
|
reveman
2014/10/27 13:39:00
MemoryUsageFromTile?
boliu
2014/10/27 15:35:57
Done.
| |
| 235 | 216 |
| 236 TileManagerClient* client_; | 217 TileManagerClient* client_; |
| 237 scoped_refptr<base::SequencedTaskRunner> task_runner_; | 218 scoped_refptr<base::SequencedTaskRunner> task_runner_; |
| 238 ResourcePool* resource_pool_; | 219 ResourcePool* resource_pool_; |
| 239 Rasterizer* rasterizer_; | 220 Rasterizer* rasterizer_; |
| 240 GlobalStateThatImpactsTilePriority global_state_; | 221 GlobalStateThatImpactsTilePriority global_state_; |
| 241 const size_t scheduled_raster_task_limit_; | 222 const size_t scheduled_raster_task_limit_; |
| 242 | 223 |
| 243 typedef base::hash_map<Tile::Id, Tile*> TileMap; | 224 typedef base::hash_map<Tile::Id, Tile*> TileMap; |
| 244 TileMap tiles_; | 225 TileMap tiles_; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 276 RasterTilePriorityQueue raster_priority_queue_; | 257 RasterTilePriorityQueue raster_priority_queue_; |
| 277 EvictionTilePriorityQueue eviction_priority_queue_; | 258 EvictionTilePriorityQueue eviction_priority_queue_; |
| 278 bool eviction_priority_queue_is_up_to_date_; | 259 bool eviction_priority_queue_is_up_to_date_; |
| 279 | 260 |
| 280 DISALLOW_COPY_AND_ASSIGN(TileManager); | 261 DISALLOW_COPY_AND_ASSIGN(TileManager); |
| 281 }; | 262 }; |
| 282 | 263 |
| 283 } // namespace cc | 264 } // namespace cc |
| 284 | 265 |
| 285 #endif // CC_RESOURCES_TILE_MANAGER_H_ | 266 #endif // CC_RESOURCES_TILE_MANAGER_H_ |
| OLD | NEW |