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 <list> | 8 #include <list> |
9 #include <queue> | 9 #include <queue> |
10 #include <set> | 10 #include <set> |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 void RegisterTile(Tile* tile); | 98 void RegisterTile(Tile* tile); |
99 void UnregisterTile(Tile* tile); | 99 void UnregisterTile(Tile* tile); |
100 void WillModifyTilePriority( | 100 void WillModifyTilePriority( |
101 Tile* tile, WhichTree tree, const TilePriority& new_priority) { | 101 Tile* tile, WhichTree tree, const TilePriority& new_priority) { |
102 // TODO(nduca): Do something smarter if reprioritization turns out to be | 102 // TODO(nduca): Do something smarter if reprioritization turns out to be |
103 // costly. | 103 // costly. |
104 ScheduleManageTiles(); | 104 ScheduleManageTiles(); |
105 } | 105 } |
106 | 106 |
107 // Virtual for test | 107 // Virtual for test |
108 virtual void DispatchMoreTasks(); | 108 virtual void ScheduleTasks(); |
109 | 109 |
110 private: | 110 private: |
111 // Data that is passed to raster tasks. | 111 // Data that is passed to raster tasks. |
112 struct RasterTaskMetadata { | 112 struct RasterTaskMetadata { |
113 bool prediction_benchmarking; | 113 bool prediction_benchmarking; |
114 bool is_tile_in_pending_tree_now_bin; | 114 bool is_tile_in_pending_tree_now_bin; |
115 TileResolution tile_resolution; | 115 TileResolution tile_resolution; |
116 int layer_id; | 116 int layer_id; |
117 }; | 117 }; |
118 | 118 |
119 RasterTaskMetadata GetRasterTaskMetadata(const Tile& tile) const; | 119 RasterTaskMetadata GetRasterTaskMetadata(const Tile& tile) const; |
120 | 120 |
121 void AssignBinsToTiles(); | 121 void AssignBinsToTiles(); |
122 void SortTiles(); | 122 void SortTiles(); |
123 void AssignGpuMemoryToTiles(); | 123 void AssignGpuMemoryToTiles(); |
124 void FreeResourcesForTile(Tile* tile); | 124 void FreeResourcesForTile(Tile* tile); |
125 void ScheduleManageTiles() { | 125 void ScheduleManageTiles() { |
126 if (manage_tiles_pending_) | 126 if (manage_tiles_pending_) |
127 return; | 127 return; |
128 client_->ScheduleManageTiles(); | 128 client_->ScheduleManageTiles(); |
129 manage_tiles_pending_ = true; | 129 manage_tiles_pending_ = true; |
130 } | 130 } |
131 bool DispatchImageDecodeTasksForTile(Tile* tile); | 131 RasterWorkerPool::Task CreateImageDecodeTask( |
132 void DispatchOneImageDecodeTask( | 132 Tile* tile, skia::LazyPixelRef* pixel_ref); |
133 scoped_refptr<Tile> tile, skia::LazyPixelRef* pixel_ref); | |
134 void OnImageDecodeTaskCompleted( | 133 void OnImageDecodeTaskCompleted( |
135 scoped_refptr<Tile> tile, | 134 scoped_refptr<Tile> tile, |
136 uint32_t pixel_ref_id); | 135 uint32_t pixel_ref_id, |
137 bool CanDispatchRasterTask(Tile* tile) const; | 136 bool was_cancelled); |
138 scoped_ptr<ResourcePool::Resource> PrepareTileForRaster(Tile* tile); | 137 RasterWorkerPool::Task CreateRasterTask(Tile* tile); |
139 void DispatchOneRasterTask(scoped_refptr<Tile> tile); | |
140 void OnRasterTaskCompleted( | 138 void OnRasterTaskCompleted( |
141 scoped_refptr<Tile> tile, | 139 scoped_refptr<Tile> tile, |
142 scoped_ptr<ResourcePool::Resource> resource, | 140 scoped_ptr<ResourcePool::Resource> resource, |
143 PicturePileImpl::Analysis* analysis, | 141 PicturePileImpl::Analysis* analysis, |
144 int manage_tiles_call_count_when_dispatched); | 142 bool was_cancelled); |
145 void DidFinishTileInitialization(Tile* tile); | 143 void DidFinishTileInitialization(Tile* tile); |
146 void DidTileTreeBinChange(Tile* tile, | 144 void DidTileTreeBinChange(Tile* tile, |
147 TileManagerBin new_tree_bin, | 145 TileManagerBin new_tree_bin, |
148 WhichTree tree); | 146 WhichTree tree); |
149 scoped_ptr<Value> GetMemoryRequirementsAsValue() const; | 147 scoped_ptr<Value> GetMemoryRequirementsAsValue() const; |
150 | 148 |
| 149 static void RunImageDecodeTask( |
| 150 skia::LazyPixelRef* pixel_ref, |
| 151 RenderingStatsInstrumentation* stats_instrumentation); |
151 static void RunAnalyzeAndRasterTask( | 152 static void RunAnalyzeAndRasterTask( |
152 const RasterWorkerPool::RasterCallback& analyze_task, | 153 const RasterWorkerPool::PictureTask::Callback& analyze_task, |
153 const RasterWorkerPool::RasterCallback& raster_task, | 154 const RasterWorkerPool::PictureTask::Callback& raster_task, |
154 PicturePileImpl* picture_pile); | 155 PicturePileImpl* picture_pile); |
155 static void RunAnalyzeTask( | 156 static void RunAnalyzeTask( |
156 PicturePileImpl::Analysis* analysis, | 157 PicturePileImpl::Analysis* analysis, |
157 gfx::Rect rect, | 158 gfx::Rect rect, |
158 float contents_scale, | 159 float contents_scale, |
159 bool use_color_estimator, | 160 bool use_color_estimator, |
160 const RasterTaskMetadata& metadata, | 161 const RasterTaskMetadata& metadata, |
161 RenderingStatsInstrumentation* stats_instrumentation, | 162 RenderingStatsInstrumentation* stats_instrumentation, |
162 PicturePileImpl* picture_pile); | 163 PicturePileImpl* picture_pile); |
163 static void RunRasterTask( | 164 static void RunRasterTask( |
164 uint8* buffer, | 165 uint8* buffer, |
165 PicturePileImpl::Analysis* analysis, | 166 PicturePileImpl::Analysis* analysis, |
166 gfx::Rect rect, | 167 gfx::Rect rect, |
167 float contents_scale, | 168 float contents_scale, |
168 const RasterTaskMetadata& metadata, | 169 const RasterTaskMetadata& metadata, |
169 RenderingStatsInstrumentation* stats_instrumentation, | 170 RenderingStatsInstrumentation* stats_instrumentation, |
170 PicturePileImpl* picture_pile); | 171 PicturePileImpl* picture_pile); |
171 static void RunImageDecodeTask( | |
172 skia::LazyPixelRef* pixel_ref, | |
173 RenderingStatsInstrumentation* stats_instrumentation); | |
174 | 172 |
175 static void RecordSolidColorPredictorResults(const SkPMColor* actual_colors, | 173 static void RecordSolidColorPredictorResults(const SkPMColor* actual_colors, |
176 size_t color_count, | 174 size_t color_count, |
177 bool is_predicted_solid, | 175 bool is_predicted_solid, |
178 SkPMColor predicted_color); | 176 SkPMColor predicted_color); |
179 | 177 |
180 TileManagerClient* client_; | 178 TileManagerClient* client_; |
181 scoped_ptr<ResourcePool> resource_pool_; | 179 scoped_ptr<ResourcePool> resource_pool_; |
182 scoped_ptr<RasterWorkerPool> raster_worker_pool_; | 180 scoped_ptr<RasterWorkerPool> raster_worker_pool_; |
183 bool manage_tiles_pending_; | 181 bool manage_tiles_pending_; |
184 int manage_tiles_call_count_; | |
185 | 182 |
186 GlobalStateThatImpactsTilePriority global_state_; | 183 GlobalStateThatImpactsTilePriority global_state_; |
187 | 184 |
188 typedef std::vector<Tile*> TileVector; | 185 typedef std::vector<Tile*> TileVector; |
189 TileVector tiles_; | 186 TileVector tiles_; |
190 TileVector tiles_that_need_to_be_rasterized_; | 187 TileVector tiles_that_need_to_be_rasterized_; |
191 | 188 |
192 typedef base::hash_set<uint32_t> PixelRefSet; | 189 typedef base::hash_map<uint32_t, RasterWorkerPool::Task> PixelRefMap; |
193 PixelRefSet pending_decode_tasks_; | 190 PixelRefMap pending_decode_tasks_; |
194 | 191 |
195 typedef std::queue<scoped_refptr<Tile> > TileQueue; | 192 typedef std::queue<scoped_refptr<Tile> > TileQueue; |
196 TileQueue tiles_with_pending_upload_; | 193 TileQueue tiles_with_pending_upload_; |
197 size_t bytes_pending_upload_; | 194 size_t bytes_pending_upload_; |
198 bool has_performed_uploads_since_last_flush_; | 195 bool has_performed_uploads_since_last_flush_; |
199 bool ever_exceeded_memory_budget_; | 196 bool ever_exceeded_memory_budget_; |
200 MemoryHistory::Entry memory_stats_from_last_assign_; | 197 MemoryHistory::Entry memory_stats_from_last_assign_; |
201 | 198 |
202 RenderingStatsInstrumentation* rendering_stats_instrumentation_; | 199 RenderingStatsInstrumentation* rendering_stats_instrumentation_; |
203 | 200 |
204 bool use_color_estimator_; | 201 bool use_color_estimator_; |
205 bool prediction_benchmarking_; | 202 bool prediction_benchmarking_; |
206 bool did_initialize_visible_tile_; | 203 bool did_initialize_visible_tile_; |
207 | 204 |
208 size_t pending_tasks_; | |
209 size_t max_pending_tasks_; | 205 size_t max_pending_tasks_; |
210 | 206 |
211 DISALLOW_COPY_AND_ASSIGN(TileManager); | 207 DISALLOW_COPY_AND_ASSIGN(TileManager); |
212 }; | 208 }; |
213 | 209 |
214 } // namespace cc | 210 } // namespace cc |
215 | 211 |
216 #endif // CC_RESOURCES_TILE_MANAGER_H_ | 212 #endif // CC_RESOURCES_TILE_MANAGER_H_ |
OLD | NEW |