Chromium Code Reviews| Index: cc/resources/tile_manager.h |
| diff --git a/cc/resources/tile_manager.h b/cc/resources/tile_manager.h |
| index 30f4730423e9ce616c61a614c287b38897752bf9..a59fe1a17bea7f2802aa154273c16ae7018451af 100644 |
| --- a/cc/resources/tile_manager.h |
| +++ b/cc/resources/tile_manager.h |
| @@ -21,7 +21,6 @@ |
| #include "cc/resources/managed_tile_state.h" |
| #include "cc/resources/memory_history.h" |
| #include "cc/resources/picture_pile_impl.h" |
| -#include "cc/resources/prioritized_tile_set.h" |
| #include "cc/resources/rasterizer.h" |
| #include "cc/resources/resource_pool.h" |
| #include "cc/resources/tile.h" |
| @@ -204,10 +203,8 @@ class CC_EXPORT TileManager : public RasterizerClient, |
| ManagedTileState::TileVersion& tile_version = |
| mts.tile_versions[HIGH_QUALITY_RASTER_MODE]; |
| - tile_version.resource_ = resource_pool_->AcquireResource(gfx::Size(1, 1)); |
| - |
| - bytes_releasable_ += BytesConsumedIfAllocated(tiles[i]); |
| - ++resources_releasable_; |
| + tile_version.resource_ = |
| + resource_pool_->AcquireResource(tiles[i]->size()); |
| } |
| } |
| @@ -222,12 +219,7 @@ class CC_EXPORT TileManager : public RasterizerClient, |
| void SetGlobalStateForTesting( |
| const GlobalStateThatImpactsTilePriority& state) { |
| - // Soft limit is used for resource pool such that |
| - // memory returns to soft limit after going over. |
| - if (state != global_state_) { |
| - global_state_ = state; |
| - prioritized_tiles_dirty_ = true; |
| - } |
| + global_state_ = state; |
| } |
| void SetRasterizerForTesting(Rasterizer* rasterizer); |
| @@ -241,13 +233,10 @@ class CC_EXPORT TileManager : public RasterizerClient, |
| Rasterizer* rasterizer, |
| RenderingStatsInstrumentation* rendering_stats_instrumentation); |
| - // Methods called by Tile |
| - friend class Tile; |
| - void DidChangeTilePriority(Tile* tile); |
| - |
| void CleanUpReleasedTiles(); |
| // Overriden from RefCountedManager<Tile>: |
| + friend class Tile; |
| virtual void Release(Tile* tile) OVERRIDE; |
| // Overriden from RasterizerClient: |
| @@ -262,11 +251,30 @@ class CC_EXPORT TileManager : public RasterizerClient, |
| virtual void ScheduleTasks( |
| const TileVector& tiles_that_need_to_be_rasterized); |
| - void AssignGpuMemoryToTiles(PrioritizedTileSet* tiles, |
| - TileVector* tiles_that_need_to_be_rasterized); |
| - void GetTilesWithAssignedBins(PrioritizedTileSet* tiles); |
| + void AssignGpuMemoryToTiles(TileVector* tiles_that_need_to_be_rasterized); |
| private: |
| + class MemoryUsage { |
| + public: |
| + MemoryUsage(); |
| + MemoryUsage(int64 memory_bytes, int resource_count); |
| + |
| + static MemoryUsage FromConfig(const gfx::Size& size, ResourceFormat format); |
| + static MemoryUsage FromTile(const Tile* tile); |
| + |
| + MemoryUsage& operator+=(const MemoryUsage& other); |
| + MemoryUsage& operator-=(const MemoryUsage& other); |
| + MemoryUsage operator-(const MemoryUsage& other); |
| + |
| + bool Exceeds(const MemoryUsage& limit) const; |
| + |
| + int64 memory_bytes() const { return memory_bytes_; } |
| + |
| + private: |
| + int64 memory_bytes_; |
| + int resource_count_; |
| + }; |
| + |
| void OnImageDecodeTaskCompleted(int layer_id, |
| SkPixelRef* pixel_ref, |
| bool was_canceled); |
| @@ -276,11 +284,6 @@ class CC_EXPORT TileManager : public RasterizerClient, |
| const PicturePileImpl::Analysis& analysis, |
| bool was_canceled); |
| - inline size_t BytesConsumedIfAllocated(const Tile* tile) const { |
| - return Resource::MemorySizeBytes(tile->size(), |
| - resource_pool_->resource_format()); |
| - } |
| - |
| void FreeResourceForTile(Tile* tile, RasterMode mode); |
| void FreeResourcesForTile(Tile* tile); |
| void FreeUnusedResourcesForTile(Tile* tile); |
| @@ -289,8 +292,16 @@ class CC_EXPORT TileManager : public RasterizerClient, |
| SkPixelRef* pixel_ref); |
| scoped_refptr<RasterTask> CreateRasterTask(Tile* tile); |
| scoped_ptr<base::Value> GetMemoryRequirementsAsValue() const; |
| - void UpdatePrioritizedTileSetIfNeeded(); |
| + bool FreeTileResourcesUntilUsageIsWithinLimit(EvictionTileIterator* iterator, |
| + const MemoryUsage& limit, |
| + MemoryUsage* usage); |
| + bool FreeTileResourcesWithLowerPriorityUntilUsageIsWithinLimit( |
| + EvictionTileIterator* iterator, |
| + const MemoryUsage& limit, |
| + const TilePriority& max_priority, |
|
reveman
2014/06/18 03:35:43
nit: max_priority is a lie. we're not freeing tile
vmpstr
2014/06/18 06:45:01
other_priority sounds fine. Done.
|
| + MemoryUsage* usage); |
| + bool TilePriorityViolatesMemoryPolicy(const TilePriority& priority); |
| bool IsReadyToActivate() const; |
| void CheckIfReadyToActivate(); |
| @@ -303,18 +314,9 @@ class CC_EXPORT TileManager : public RasterizerClient, |
| typedef base::hash_map<Tile::Id, Tile*> TileMap; |
| TileMap tiles_; |
| - PrioritizedTileSet prioritized_tiles_; |
| - bool prioritized_tiles_dirty_; |
| - |
| bool all_tiles_that_need_to_be_rasterized_have_memory_; |
|
reveman
2014/06/18 03:35:43
I think this should be renamed to all_tiles_that_n
vmpstr
2014/06/18 06:45:01
Done.
|
| bool all_tiles_required_for_activation_have_memory_; |
|
reveman
2014/06/18 03:35:42
Is this still used?
vmpstr
2014/06/18 06:45:01
Nope, removed.
|
| - size_t memory_required_bytes_; |
| - size_t memory_nice_to_have_bytes_; |
| - |
| - size_t bytes_releasable_; |
| - size_t resources_releasable_; |
| - |
| bool ever_exceeded_memory_budget_; |
| MemoryHistory::Entry memory_stats_from_last_assign_; |