| 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 scoped_refptr<base::debug::ConvertableToTraceFormat> BasicStateAsValue() | 118 scoped_refptr<base::debug::ConvertableToTraceFormat> BasicStateAsValue() |
| 119 const; | 119 const; |
| 120 void BasicStateAsValueInto(base::debug::TracedValue* dict) const; | 120 void BasicStateAsValueInto(base::debug::TracedValue* dict) const; |
| 121 const MemoryHistory::Entry& memory_stats_from_last_assign() const { | 121 const MemoryHistory::Entry& memory_stats_from_last_assign() const { |
| 122 return memory_stats_from_last_assign_; | 122 return memory_stats_from_last_assign_; |
| 123 } | 123 } |
| 124 | 124 |
| 125 void InitializeTilesWithResourcesForTesting(const std::vector<Tile*>& tiles) { | 125 void InitializeTilesWithResourcesForTesting(const std::vector<Tile*>& tiles) { |
| 126 for (size_t i = 0; i < tiles.size(); ++i) { | 126 for (size_t i = 0; i < tiles.size(); ++i) { |
| 127 ManagedTileState& mts = tiles[i]->managed_state(); | 127 ManagedTileState& mts = tiles[i]->managed_state(); |
| 128 ManagedTileState::TileVersion& tile_version = | |
| 129 mts.tile_versions[HIGH_QUALITY_RASTER_MODE]; | |
| 130 | 128 |
| 131 tile_version.resource_ = | 129 mts.draw_info.resource_ = |
| 132 resource_pool_->AcquireResource(tiles[i]->size()); | 130 resource_pool_->AcquireResource(tiles[i]->size()); |
| 133 | 131 |
| 134 bytes_releasable_ += BytesConsumedIfAllocated(tiles[i]); | 132 bytes_releasable_ += BytesConsumedIfAllocated(tiles[i]); |
| 135 ++resources_releasable_; | 133 ++resources_releasable_; |
| 136 } | 134 } |
| 137 } | 135 } |
| 138 | 136 |
| 139 void ReleaseTileResourcesForTesting(const std::vector<Tile*>& tiles) { | 137 void ReleaseTileResourcesForTesting(const std::vector<Tile*>& tiles) { |
| 140 for (size_t i = 0; i < tiles.size(); ++i) { | 138 for (size_t i = 0; i < tiles.size(); ++i) { |
| 141 Tile* tile = tiles[i]; | 139 Tile* tile = tiles[i]; |
| 142 for (int mode = 0; mode < NUM_RASTER_MODES; ++mode) { | 140 FreeResourcesForTile(tile); |
| 143 FreeResourceForTile(tile, static_cast<RasterMode>(mode)); | |
| 144 } | |
| 145 } | 141 } |
| 146 } | 142 } |
| 147 | 143 |
| 148 void SetGlobalStateForTesting( | 144 void SetGlobalStateForTesting( |
| 149 const GlobalStateThatImpactsTilePriority& state) { | 145 const GlobalStateThatImpactsTilePriority& state) { |
| 150 // Soft limit is used for resource pool such that | 146 // Soft limit is used for resource pool such that |
| 151 // memory returns to soft limit after going over. | 147 // memory returns to soft limit after going over. |
| 152 if (state != global_state_) { | 148 if (state != global_state_) { |
| 153 global_state_ = state; | 149 global_state_ = state; |
| 154 prioritized_tiles_dirty_ = true; | 150 prioritized_tiles_dirty_ = true; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 void AssignGpuMemoryToTiles(PrioritizedTileSet* tiles, | 199 void AssignGpuMemoryToTiles(PrioritizedTileSet* tiles, |
| 204 TileVector* tiles_that_need_to_be_rasterized); | 200 TileVector* tiles_that_need_to_be_rasterized); |
| 205 void GetTilesWithAssignedBins(PrioritizedTileSet* tiles); | 201 void GetTilesWithAssignedBins(PrioritizedTileSet* tiles); |
| 206 | 202 |
| 207 private: | 203 private: |
| 208 void OnImageDecodeTaskCompleted(int layer_id, | 204 void OnImageDecodeTaskCompleted(int layer_id, |
| 209 SkPixelRef* pixel_ref, | 205 SkPixelRef* pixel_ref, |
| 210 bool was_canceled); | 206 bool was_canceled); |
| 211 void OnRasterTaskCompleted(Tile::Id tile, | 207 void OnRasterTaskCompleted(Tile::Id tile, |
| 212 scoped_ptr<ScopedResource> resource, | 208 scoped_ptr<ScopedResource> resource, |
| 213 RasterMode raster_mode, | |
| 214 const PicturePileImpl::Analysis& analysis, | 209 const PicturePileImpl::Analysis& analysis, |
| 215 bool was_canceled); | 210 bool was_canceled); |
| 216 | 211 |
| 217 inline size_t BytesConsumedIfAllocated(const Tile* tile) const { | 212 inline size_t BytesConsumedIfAllocated(const Tile* tile) const { |
| 218 return Resource::MemorySizeBytes(tile->size(), | 213 return Resource::MemorySizeBytes(tile->size(), |
| 219 resource_pool_->resource_format()); | 214 resource_pool_->resource_format()); |
| 220 } | 215 } |
| 221 | 216 |
| 222 void FreeResourceForTile(Tile* tile, RasterMode mode); | |
| 223 void FreeResourcesForTile(Tile* tile); | 217 void FreeResourcesForTile(Tile* tile); |
| 224 void FreeUnusedResourcesForTile(Tile* tile); | |
| 225 void FreeResourcesForTileAndNotifyClientIfTileWasReadyToDraw(Tile* tile); | 218 void FreeResourcesForTileAndNotifyClientIfTileWasReadyToDraw(Tile* tile); |
| 226 scoped_refptr<ImageDecodeTask> CreateImageDecodeTask(Tile* tile, | 219 scoped_refptr<ImageDecodeTask> CreateImageDecodeTask(Tile* tile, |
| 227 SkPixelRef* pixel_ref); | 220 SkPixelRef* pixel_ref); |
| 228 scoped_refptr<RasterTask> CreateRasterTask(Tile* tile); | 221 scoped_refptr<RasterTask> CreateRasterTask(Tile* tile); |
| 229 void UpdatePrioritizedTileSetIfNeeded(); | 222 void UpdatePrioritizedTileSetIfNeeded(); |
| 230 | 223 |
| 231 bool IsReadyToActivate() const; | 224 bool IsReadyToActivate() const; |
| 232 void CheckIfReadyToActivate(); | 225 void CheckIfReadyToActivate(); |
| 233 | 226 |
| 234 TileManagerClient* client_; | 227 TileManagerClient* client_; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 std::vector<scoped_refptr<RasterTask> > orphan_raster_tasks_; | 271 std::vector<scoped_refptr<RasterTask> > orphan_raster_tasks_; |
| 279 | 272 |
| 280 UniqueNotifier ready_to_activate_check_notifier_; | 273 UniqueNotifier ready_to_activate_check_notifier_; |
| 281 | 274 |
| 282 DISALLOW_COPY_AND_ASSIGN(TileManager); | 275 DISALLOW_COPY_AND_ASSIGN(TileManager); |
| 283 }; | 276 }; |
| 284 | 277 |
| 285 } // namespace cc | 278 } // namespace cc |
| 286 | 279 |
| 287 #endif // CC_RESOURCES_TILE_MANAGER_H_ | 280 #endif // CC_RESOURCES_TILE_MANAGER_H_ |
| OLD | NEW |