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 <queue> | 8 #include <queue> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 81 void GetMemoryStats(size_t* memory_required_bytes, | 81 void GetMemoryStats(size_t* memory_required_bytes, |
| 82 size_t* memory_nice_to_have_bytes, | 82 size_t* memory_nice_to_have_bytes, |
| 83 size_t* memory_used_bytes) const; | 83 size_t* memory_used_bytes) const; |
| 84 | 84 |
| 85 const MemoryHistory::Entry& memory_stats_from_last_assign() const { | 85 const MemoryHistory::Entry& memory_stats_from_last_assign() const { |
| 86 return memory_stats_from_last_assign_; | 86 return memory_stats_from_last_assign_; |
| 87 } | 87 } |
| 88 | 88 |
| 89 bool AreTilesRequiredForActivationReady() const { | 89 bool AreTilesRequiredForActivationReady() const { |
| 90 return tiles_that_need_to_be_initialized_for_activation_.empty() && | 90 return tiles_that_need_to_be_initialized_for_activation_.empty() && |
| 91 oom_tiles_that_need_to_be_initialized_for_activation_.empty(); | 91 all_tiles_required_for_activation_have_memory_; |
| 92 } | 92 } |
| 93 | 93 |
| 94 protected: | 94 protected: |
| 95 TileManager(TileManagerClient* client, | 95 TileManager(TileManagerClient* client, |
| 96 ResourceProvider* resource_provider, | 96 ResourceProvider* resource_provider, |
| 97 scoped_ptr<RasterWorkerPool> raster_worker_pool, | 97 scoped_ptr<RasterWorkerPool> raster_worker_pool, |
| 98 size_t num_raster_threads, | 98 size_t num_raster_threads, |
| 99 RenderingStatsInstrumentation* rendering_stats_instrumentation, | 99 RenderingStatsInstrumentation* rendering_stats_instrumentation, |
| 100 GLenum texture_format); | 100 GLenum texture_format); |
| 101 | 101 |
| 102 // Methods called by Tile | 102 // Methods called by Tile |
| 103 friend class Tile; | 103 friend class Tile; |
| 104 void RegisterTile(Tile* tile); | 104 void RegisterTile(Tile* tile); |
| 105 void UnregisterTile(Tile* tile); | 105 void UnregisterTile(Tile* tile); |
| 106 | 106 |
| 107 // Overriden from RasterWorkerPoolClient: | 107 // Overriden from RasterWorkerPoolClient: |
| 108 virtual bool ShouldForceTasksRequiredForActivationToComplete() const | 108 virtual bool ShouldForceTasksRequiredForActivationToComplete() const |
| 109 OVERRIDE; | 109 OVERRIDE; |
| 110 virtual void DidFinishedRunningTasks() OVERRIDE; | 110 virtual void DidFinishedRunningTasks() OVERRIDE; |
| 111 virtual void DidFinishedRunningTasksRequiredForActivation() OVERRIDE; | 111 virtual void DidFinishedRunningTasksRequiredForActivation() OVERRIDE; |
| 112 | 112 |
| 113 typedef std::vector<Tile*> TileVector; | |
| 114 typedef std::set<Tile*> TileSet; | |
| 115 | |
| 113 // Virtual for test | 116 // Virtual for test |
| 114 virtual void ScheduleTasks(); | 117 virtual void ScheduleTasks( |
| 118 const TileVector& tiles_that_need_to_be_rasterized); | |
| 115 | 119 |
| 116 const std::vector<Tile*>& tiles_that_need_to_be_rasterized() const { | 120 void ReassignGpuMemoryToOOMTilesRequiredForActivation( |
| 117 return tiles_that_need_to_be_rasterized_; | 121 TileVector* tiles_that_need_to_be_rasterized, |
| 122 TileSet* oom_tiles_required_for_activation); | |
| 123 void AssignGpuMemoryToTiles( | |
| 124 TileVector* tiles_that_need_to_be_rasterized, | |
| 125 TileSet* oom_tiles_required_for_activation); | |
| 126 void AssignBinsToTiles(TileVector* tiles); | |
| 127 void SortTiles(TileVector* tiles); | |
| 128 | |
| 129 // Testing function. | |
| 130 void UpdateSortedTilesForTest() { | |
| 131 sorted_tiles_need_update_ = true; | |
| 132 UpdateSortedTilesIfNeeded(); | |
| 118 } | 133 } |
| 119 | 134 |
| 120 void ReassignGpuMemoryToOOMTilesRequiredForActivation(); | |
| 121 | |
| 122 private: | 135 private: |
| 136 // TODO(vmpstr): Make this be Tile::Id once crbug.com/253972 is fixed. | |
| 137 typedef uint64 ManagedTileId; | |
| 123 void OnImageDecodeTaskCompleted( | 138 void OnImageDecodeTaskCompleted( |
| 124 int layer_id, | 139 int layer_id, |
| 125 skia::LazyPixelRef* pixel_ref, | 140 skia::LazyPixelRef* pixel_ref, |
| 126 bool was_canceled); | 141 bool was_canceled); |
| 127 void OnRasterTaskCompleted( | 142 void OnRasterTaskCompleted( |
| 128 scoped_refptr<Tile> tile, | 143 ManagedTileId tile, |
| 129 scoped_ptr<ResourcePool::Resource> resource, | 144 scoped_ptr<ResourcePool::Resource> resource, |
| 130 RasterMode raster_mode, | 145 RasterMode raster_mode, |
| 131 const PicturePileImpl::Analysis& analysis, | 146 const PicturePileImpl::Analysis& analysis, |
| 132 bool was_canceled); | 147 bool was_canceled); |
| 133 | 148 |
| 134 void AssignBinsToTiles(); | |
| 135 void SortTiles(); | |
| 136 RasterMode DetermineRasterMode(const Tile* tile) const; | 149 RasterMode DetermineRasterMode(const Tile* tile) const; |
| 150 void UpdateSortedTilesIfNeeded(); | |
| 137 void CleanUpUnusedImageDecodeTasks(); | 151 void CleanUpUnusedImageDecodeTasks(); |
| 138 void AssignGpuMemoryToTiles(); | |
| 139 void FreeResourceForTile(Tile* tile, RasterMode mode); | 152 void FreeResourceForTile(Tile* tile, RasterMode mode); |
| 140 void FreeResourcesForTile(Tile* tile); | 153 void FreeResourcesForTile(Tile* tile); |
| 141 void FreeUnusedResourcesForTile(Tile* tile); | 154 void FreeUnusedResourcesForTile(Tile* tile); |
| 142 RasterWorkerPool::Task CreateImageDecodeTask( | 155 RasterWorkerPool::Task CreateImageDecodeTask( |
| 143 Tile* tile, skia::LazyPixelRef* pixel_ref); | 156 Tile* tile, skia::LazyPixelRef* pixel_ref); |
| 144 RasterTaskMetadata GetRasterTaskMetadata(const Tile& tile) const; | 157 RasterTaskMetadata GetRasterTaskMetadata(const Tile& tile) const; |
| 145 RasterWorkerPool::RasterTask CreateRasterTask(Tile* tile); | 158 RasterWorkerPool::RasterTask CreateRasterTask(Tile* tile); |
| 146 void DidFinishTileInitialization(Tile* tile); | 159 void DidFinishTileInitialization(Tile* tile); |
| 147 void DidTileTreeBinChange(Tile* tile, | 160 void DidTileTreeBinChange(Tile* tile, |
| 148 TileManagerBin new_tree_bin, | 161 TileManagerBin new_tree_bin, |
| 149 WhichTree tree); | 162 WhichTree tree); |
| 150 scoped_ptr<base::Value> GetMemoryRequirementsAsValue() const; | 163 scoped_ptr<base::Value> GetMemoryRequirementsAsValue() const; |
| 151 void AddRequiredTileForActivation(Tile* tile); | 164 void AddRequiredTileForActivation(Tile* tile); |
| 152 | 165 |
| 153 TileManagerClient* client_; | 166 TileManagerClient* client_; |
| 154 scoped_ptr<ResourcePool> resource_pool_; | 167 scoped_ptr<ResourcePool> resource_pool_; |
| 155 scoped_ptr<RasterWorkerPool> raster_worker_pool_; | 168 scoped_ptr<RasterWorkerPool> raster_worker_pool_; |
| 156 GlobalStateThatImpactsTilePriority global_state_; | 169 GlobalStateThatImpactsTilePriority global_state_; |
| 157 | 170 |
| 158 typedef std::vector<Tile*> TileVector; | 171 typedef base::hash_map<ManagedTileId, Tile*> TileMap; |
| 159 TileVector tiles_; | 172 TileMap tiles_; |
| 160 TileVector tiles_that_need_to_be_rasterized_; | 173 |
| 161 typedef std::set<Tile*> TileSet; | 174 TileVector sorted_tiles_; |
| 175 bool sorted_tiles_need_update_; | |
| 176 | |
| 162 TileSet tiles_that_need_to_be_initialized_for_activation_; | 177 TileSet tiles_that_need_to_be_initialized_for_activation_; |
|
reveman
2013/07/04 00:46:11
I don't think we need this set.
bool all_tiles_req
vmpstr
2013/07/08 17:28:30
Done.
| |
| 163 TileSet oom_tiles_that_need_to_be_initialized_for_activation_; | 178 bool all_tiles_required_for_activation_have_memory_; |
| 164 | 179 |
| 165 bool ever_exceeded_memory_budget_; | 180 bool ever_exceeded_memory_budget_; |
| 166 MemoryHistory::Entry memory_stats_from_last_assign_; | 181 MemoryHistory::Entry memory_stats_from_last_assign_; |
| 167 | 182 |
| 168 RenderingStatsInstrumentation* rendering_stats_instrumentation_; | 183 RenderingStatsInstrumentation* rendering_stats_instrumentation_; |
| 169 | 184 |
| 170 bool did_initialize_visible_tile_; | 185 bool did_initialize_visible_tile_; |
| 171 | 186 |
| 172 GLenum texture_format_; | 187 GLenum texture_format_; |
| 173 | 188 |
| 174 typedef base::hash_map<uint32_t, RasterWorkerPool::Task> PixelRefTaskMap; | 189 typedef base::hash_map<uint32_t, RasterWorkerPool::Task> PixelRefTaskMap; |
| 175 typedef base::hash_map<int, PixelRefTaskMap> LayerPixelRefTaskMap; | 190 typedef base::hash_map<int, PixelRefTaskMap> LayerPixelRefTaskMap; |
| 176 LayerPixelRefTaskMap image_decode_tasks_; | 191 LayerPixelRefTaskMap image_decode_tasks_; |
| 177 | 192 |
| 178 DISALLOW_COPY_AND_ASSIGN(TileManager); | 193 DISALLOW_COPY_AND_ASSIGN(TileManager); |
| 179 }; | 194 }; |
| 180 | 195 |
| 181 } // namespace cc | 196 } // namespace cc |
| 182 | 197 |
| 183 #endif // CC_RESOURCES_TILE_MANAGER_H_ | 198 #endif // CC_RESOURCES_TILE_MANAGER_H_ |
| OLD | NEW |