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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 scoped_ptr<base::Value> AllTilesAsValue() const; | 83 scoped_ptr<base::Value> AllTilesAsValue() const; |
84 void GetMemoryStats(size_t* memory_required_bytes, | 84 void GetMemoryStats(size_t* memory_required_bytes, |
85 size_t* memory_nice_to_have_bytes, | 85 size_t* memory_nice_to_have_bytes, |
86 size_t* memory_used_bytes) const; | 86 size_t* memory_used_bytes) const; |
87 | 87 |
88 const MemoryHistory::Entry& memory_stats_from_last_assign() const { | 88 const MemoryHistory::Entry& memory_stats_from_last_assign() const { |
89 return memory_stats_from_last_assign_; | 89 return memory_stats_from_last_assign_; |
90 } | 90 } |
91 | 91 |
92 bool AreTilesRequiredForActivationReady() const { | 92 bool AreTilesRequiredForActivationReady() const { |
93 return tiles_that_need_to_be_initialized_for_activation_.empty(); | 93 return tiles_that_need_to_be_initialized_for_activation_.empty() && |
| 94 oom_tiles_that_need_to_be_initialized_for_activation_.empty(); |
94 } | 95 } |
95 | 96 |
96 protected: | 97 protected: |
97 TileManager(TileManagerClient* client, | 98 TileManager(TileManagerClient* client, |
98 ResourceProvider* resource_provider, | 99 ResourceProvider* resource_provider, |
99 scoped_ptr<RasterWorkerPool> raster_worker_pool, | 100 scoped_ptr<RasterWorkerPool> raster_worker_pool, |
100 size_t num_raster_threads, | 101 size_t num_raster_threads, |
101 bool use_color_estimator, | 102 bool use_color_estimator, |
102 RenderingStatsInstrumentation* rendering_stats_instrumentation, | 103 RenderingStatsInstrumentation* rendering_stats_instrumentation, |
103 GLenum texture_format); | 104 GLenum texture_format); |
104 | 105 |
105 // Methods called by Tile | 106 // Methods called by Tile |
106 friend class Tile; | 107 friend class Tile; |
107 void RegisterTile(Tile* tile); | 108 void RegisterTile(Tile* tile); |
108 void UnregisterTile(Tile* tile); | 109 void UnregisterTile(Tile* tile); |
109 | 110 |
110 // Overriden from RasterWorkerPoolClient: | 111 // Overriden from RasterWorkerPoolClient: |
111 virtual bool ShouldForceTasksRequiredForActivationToComplete() const | 112 virtual bool ShouldForceTasksRequiredForActivationToComplete() const |
112 OVERRIDE; | 113 OVERRIDE; |
| 114 virtual void DidFinishedRunningTasks() OVERRIDE; |
| 115 virtual void DidFinishedRunningTasksRequiredForActivation() OVERRIDE; |
113 | 116 |
114 // Virtual for test | 117 // Virtual for test |
115 virtual void ScheduleTasks(); | 118 virtual void ScheduleTasks(); |
116 | 119 |
117 private: | 120 private: |
118 void OnImageDecodeTaskCompleted( | 121 void OnImageDecodeTaskCompleted( |
119 int layer_id, | 122 int layer_id, |
120 skia::LazyPixelRef* pixel_ref, | 123 skia::LazyPixelRef* pixel_ref, |
121 bool was_canceled); | 124 bool was_canceled); |
122 void OnRasterTaskCompleted( | 125 void OnRasterTaskCompleted( |
123 scoped_refptr<Tile> tile, | 126 scoped_refptr<Tile> tile, |
124 scoped_ptr<ResourcePool::Resource> resource, | 127 scoped_ptr<ResourcePool::Resource> resource, |
125 RasterMode raster_mode, | 128 RasterMode raster_mode, |
126 const PicturePileImpl::Analysis& analysis, | 129 const PicturePileImpl::Analysis& analysis, |
127 bool was_canceled); | 130 bool was_canceled); |
128 | 131 |
129 void AssignBinsToTiles(); | 132 void AssignBinsToTiles(); |
130 void SortTiles(); | 133 void SortTiles(); |
131 RasterMode DetermineRasterMode(const Tile* tile) const; | 134 RasterMode DetermineRasterMode(const Tile* tile) const; |
132 void CleanUpUnusedImageDecodeTasks(); | 135 void CleanUpUnusedImageDecodeTasks(); |
133 void AssignGpuMemoryToTiles(); | 136 void AssignGpuMemoryToTiles(); |
| 137 void ReassignGpuMemoryToOOMTiles(); |
134 void FreeResourceForTile(Tile* tile, RasterMode mode); | 138 void FreeResourceForTile(Tile* tile, RasterMode mode); |
135 void FreeResourcesForTile(Tile* tile); | 139 void FreeResourcesForTile(Tile* tile); |
136 void FreeUnusedResourcesForTile(Tile* tile); | 140 void FreeUnusedResourcesForTile(Tile* tile); |
137 RasterWorkerPool::Task CreateImageDecodeTask( | 141 RasterWorkerPool::Task CreateImageDecodeTask( |
138 Tile* tile, skia::LazyPixelRef* pixel_ref); | 142 Tile* tile, skia::LazyPixelRef* pixel_ref); |
139 RasterTaskMetadata GetRasterTaskMetadata(const Tile& tile) const; | 143 RasterTaskMetadata GetRasterTaskMetadata(const Tile& tile) const; |
140 RasterWorkerPool::RasterTask CreateRasterTask(Tile* tile); | 144 RasterWorkerPool::RasterTask CreateRasterTask(Tile* tile); |
141 void DidFinishTileInitialization(Tile* tile); | 145 void DidFinishTileInitialization(Tile* tile); |
142 void DidTileTreeBinChange(Tile* tile, | 146 void DidTileTreeBinChange(Tile* tile, |
143 TileManagerBin new_tree_bin, | 147 TileManagerBin new_tree_bin, |
144 WhichTree tree); | 148 WhichTree tree); |
145 scoped_ptr<Value> GetMemoryRequirementsAsValue() const; | 149 scoped_ptr<Value> GetMemoryRequirementsAsValue() const; |
146 void AddRequiredTileForActivation(Tile* tile); | 150 void AddRequiredTileForActivation(Tile* tile); |
147 | 151 |
148 TileManagerClient* client_; | 152 TileManagerClient* client_; |
149 scoped_ptr<ResourcePool> resource_pool_; | 153 scoped_ptr<ResourcePool> resource_pool_; |
150 scoped_ptr<RasterWorkerPool> raster_worker_pool_; | 154 scoped_ptr<RasterWorkerPool> raster_worker_pool_; |
151 GlobalStateThatImpactsTilePriority global_state_; | 155 GlobalStateThatImpactsTilePriority global_state_; |
152 | 156 |
153 typedef std::vector<Tile*> TileVector; | 157 typedef std::vector<Tile*> TileVector; |
154 TileVector tiles_; | 158 TileVector tiles_; |
155 TileVector tiles_that_need_to_be_rasterized_; | 159 TileVector tiles_that_need_to_be_rasterized_; |
156 typedef std::set<Tile*> TileSet; | 160 typedef std::set<Tile*> TileSet; |
157 TileSet tiles_that_need_to_be_initialized_for_activation_; | 161 TileSet tiles_that_need_to_be_initialized_for_activation_; |
| 162 TileSet oom_tiles_that_need_to_be_initialized_for_activation_; |
158 | 163 |
159 bool ever_exceeded_memory_budget_; | 164 bool ever_exceeded_memory_budget_; |
160 MemoryHistory::Entry memory_stats_from_last_assign_; | 165 MemoryHistory::Entry memory_stats_from_last_assign_; |
161 | 166 |
162 RenderingStatsInstrumentation* rendering_stats_instrumentation_; | 167 RenderingStatsInstrumentation* rendering_stats_instrumentation_; |
163 | 168 |
164 bool use_color_estimator_; | 169 bool use_color_estimator_; |
165 bool did_initialize_visible_tile_; | 170 bool did_initialize_visible_tile_; |
166 | 171 |
167 GLenum texture_format_; | 172 GLenum texture_format_; |
168 | 173 |
169 typedef base::hash_map<uint32_t, RasterWorkerPool::Task> PixelRefTaskMap; | 174 typedef base::hash_map<uint32_t, RasterWorkerPool::Task> PixelRefTaskMap; |
170 typedef base::hash_map<int, PixelRefTaskMap> LayerPixelRefTaskMap; | 175 typedef base::hash_map<int, PixelRefTaskMap> LayerPixelRefTaskMap; |
171 LayerPixelRefTaskMap image_decode_tasks_; | 176 LayerPixelRefTaskMap image_decode_tasks_; |
172 | 177 |
173 DISALLOW_COPY_AND_ASSIGN(TileManager); | 178 DISALLOW_COPY_AND_ASSIGN(TileManager); |
174 }; | 179 }; |
175 | 180 |
176 } // namespace cc | 181 } // namespace cc |
177 | 182 |
178 #endif // CC_RESOURCES_TILE_MANAGER_H_ | 183 #endif // CC_RESOURCES_TILE_MANAGER_H_ |
OLD | NEW |