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_TILE_MANAGER_H_ | 5 #ifndef CC_TILE_MANAGER_H_ |
6 #define CC_TILE_MANAGER_H_ | 6 #define CC_TILE_MANAGER_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <queue> | 9 #include <queue> |
10 #include <set> | 10 #include <set> |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 | 96 |
97 // This class manages tiles, deciding which should get rasterized and which | 97 // This class manages tiles, deciding which should get rasterized and which |
98 // should no longer have any memory assigned to them. Tile objects are "owned" | 98 // should no longer have any memory assigned to them. Tile objects are "owned" |
99 // by layers; they automatically register with the manager when they are | 99 // by layers; they automatically register with the manager when they are |
100 // created, and unregister from the manager when they are deleted. | 100 // created, and unregister from the manager when they are deleted. |
101 class CC_EXPORT TileManager : public WorkerPoolClient { | 101 class CC_EXPORT TileManager : public WorkerPoolClient { |
102 public: | 102 public: |
103 TileManager(TileManagerClient* client, | 103 TileManager(TileManagerClient* client, |
104 ResourceProvider *resource_provider, | 104 ResourceProvider *resource_provider, |
105 size_t num_raster_threads, | 105 size_t num_raster_threads, |
106 bool use_cheapess_estimator); | 106 bool use_cheapess_estimator, |
| 107 bool use_color_estimator, |
| 108 bool prediction_benchmarking); |
107 virtual ~TileManager(); | 109 virtual ~TileManager(); |
108 | 110 |
109 const GlobalStateThatImpactsTilePriority& GlobalState() const { | 111 const GlobalStateThatImpactsTilePriority& GlobalState() const { |
110 return global_state_; | 112 return global_state_; |
111 } | 113 } |
112 void SetGlobalState(const GlobalStateThatImpactsTilePriority& state); | 114 void SetGlobalState(const GlobalStateThatImpactsTilePriority& state); |
113 | 115 |
114 void ManageTiles(); | 116 void ManageTiles(); |
115 void CheckForCompletedTileUploads(); | 117 void CheckForCompletedTileUploads(); |
116 void AbortPendingTileUploads(); | 118 void AbortPendingTileUploads(); |
(...skipping 24 matching lines...) Expand all Loading... |
141 Tile* tile, WhichTree tree, const TilePriority& new_priority) { | 143 Tile* tile, WhichTree tree, const TilePriority& new_priority) { |
142 // TODO(nduca): Do something smarter if reprioritization turns out to be | 144 // TODO(nduca): Do something smarter if reprioritization turns out to be |
143 // costly. | 145 // costly. |
144 ScheduleManageTiles(); | 146 ScheduleManageTiles(); |
145 } | 147 } |
146 | 148 |
147 private: | 149 private: |
148 | 150 |
149 // Data that is passed to raster tasks. | 151 // Data that is passed to raster tasks. |
150 struct RasterTaskMetadata { | 152 struct RasterTaskMetadata { |
151 bool use_cheapness_estimator; | 153 bool prediction_benchmarking; |
152 bool is_tile_in_pending_tree_now_bin; | 154 bool is_tile_in_pending_tree_now_bin; |
153 TileResolution tile_resolution; | 155 TileResolution tile_resolution; |
154 int layer_id; | 156 int layer_id; |
155 }; | 157 }; |
156 | 158 |
157 RasterTaskMetadata GetRasterTaskMetadata(const Tile& tile) const; | 159 RasterTaskMetadata GetRasterTaskMetadata(const Tile& tile) const; |
| 160 |
158 void SortTiles(); | 161 void SortTiles(); |
159 void AssignGpuMemoryToTiles(); | 162 void AssignGpuMemoryToTiles(); |
160 void FreeResourcesForTile(Tile* tile); | 163 void FreeResourcesForTile(Tile* tile); |
161 void ScheduleManageTiles() { | 164 void ScheduleManageTiles() { |
162 if (manage_tiles_pending_) | 165 if (manage_tiles_pending_) |
163 return; | 166 return; |
164 client_->ScheduleManageTiles(); | 167 client_->ScheduleManageTiles(); |
165 manage_tiles_pending_ = true; | 168 manage_tiles_pending_ = true; |
166 } | 169 } |
167 void DispatchMoreTasks(); | 170 void DispatchMoreTasks(); |
(...skipping 22 matching lines...) Expand all Loading... |
190 const gfx::Rect& rect, | 193 const gfx::Rect& rect, |
191 float contents_scale, | 194 float contents_scale, |
192 const RasterTaskMetadata& metadata, | 195 const RasterTaskMetadata& metadata, |
193 PicturePileImpl* picture_pile, | 196 PicturePileImpl* picture_pile, |
194 RenderingStats* stats); | 197 RenderingStats* stats); |
195 static void RunImageDecodeTask(skia::LazyPixelRef* pixel_ref, | 198 static void RunImageDecodeTask(skia::LazyPixelRef* pixel_ref, |
196 RenderingStats* stats); | 199 RenderingStats* stats); |
197 | 200 |
198 static void RecordCheapnessPredictorResults(bool is_predicted_cheap, | 201 static void RecordCheapnessPredictorResults(bool is_predicted_cheap, |
199 bool is_actually_cheap); | 202 bool is_actually_cheap); |
| 203 static void RecordSolidColorPredictorResults(const SkColor* actual_colors, |
| 204 size_t color_count, |
| 205 bool is_predicted_solid, |
| 206 SkColor predicted_color, |
| 207 bool is_predicted_transparent); |
200 | 208 |
201 TileManagerClient* client_; | 209 TileManagerClient* client_; |
202 scoped_ptr<ResourcePool> resource_pool_; | 210 scoped_ptr<ResourcePool> resource_pool_; |
203 scoped_ptr<RasterWorkerPool> raster_worker_pool_; | 211 scoped_ptr<RasterWorkerPool> raster_worker_pool_; |
204 bool manage_tiles_pending_; | 212 bool manage_tiles_pending_; |
205 int manage_tiles_call_count_; | 213 int manage_tiles_call_count_; |
206 | 214 |
207 GlobalStateThatImpactsTilePriority global_state_; | 215 GlobalStateThatImpactsTilePriority global_state_; |
208 | 216 |
209 typedef std::vector<Tile*> TileVector; | 217 typedef std::vector<Tile*> TileVector; |
(...skipping 14 matching lines...) Expand all Loading... |
224 TileQueue tiles_with_pending_upload_; | 232 TileQueue tiles_with_pending_upload_; |
225 size_t bytes_pending_upload_; | 233 size_t bytes_pending_upload_; |
226 bool has_performed_uploads_since_last_flush_; | 234 bool has_performed_uploads_since_last_flush_; |
227 bool ever_exceeded_memory_budget_; | 235 bool ever_exceeded_memory_budget_; |
228 MemoryHistory::Entry memory_stats_from_last_assign_; | 236 MemoryHistory::Entry memory_stats_from_last_assign_; |
229 | 237 |
230 bool record_rendering_stats_; | 238 bool record_rendering_stats_; |
231 RenderingStats rendering_stats_; | 239 RenderingStats rendering_stats_; |
232 | 240 |
233 bool use_cheapness_estimator_; | 241 bool use_cheapness_estimator_; |
| 242 bool use_color_estimator_; |
234 bool did_schedule_cheap_tasks_; | 243 bool did_schedule_cheap_tasks_; |
235 bool allow_cheap_tasks_; | 244 bool allow_cheap_tasks_; |
236 int raster_state_count_[NUM_STATES][NUM_TREES][NUM_BINS]; | 245 int raster_state_count_[NUM_STATES][NUM_TREES][NUM_BINS]; |
| 246 bool prediction_benchmarking_; |
237 | 247 |
238 DISALLOW_COPY_AND_ASSIGN(TileManager); | 248 DISALLOW_COPY_AND_ASSIGN(TileManager); |
239 }; | 249 }; |
240 | 250 |
241 } // namespace cc | 251 } // namespace cc |
242 | 252 |
243 #endif // CC_TILE_MANAGER_H_ | 253 #endif // CC_TILE_MANAGER_H_ |
OLD | NEW |