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 }; | 156 }; |
155 | 157 |
156 RasterTaskMetadata GetRasterTaskMetadata(const Tile& tile) const; | 158 RasterTaskMetadata GetRasterTaskMetadata(const Tile& tile) const; |
| 159 |
157 void SortTiles(); | 160 void SortTiles(); |
158 void AssignGpuMemoryToTiles(); | 161 void AssignGpuMemoryToTiles(); |
159 void FreeResourcesForTile(Tile* tile); | 162 void FreeResourcesForTile(Tile* tile); |
160 void ScheduleManageTiles() { | 163 void ScheduleManageTiles() { |
161 if (manage_tiles_pending_) | 164 if (manage_tiles_pending_) |
162 return; | 165 return; |
163 client_->ScheduleManageTiles(); | 166 client_->ScheduleManageTiles(); |
164 manage_tiles_pending_ = true; | 167 manage_tiles_pending_ = true; |
165 } | 168 } |
166 void DispatchMoreTasks(); | 169 void DispatchMoreTasks(); |
(...skipping 22 matching lines...) Expand all Loading... |
189 const gfx::Rect& rect, | 192 const gfx::Rect& rect, |
190 float contents_scale, | 193 float contents_scale, |
191 const RasterTaskMetadata& metadata, | 194 const RasterTaskMetadata& metadata, |
192 PicturePileImpl* picture_pile, | 195 PicturePileImpl* picture_pile, |
193 RenderingStats* stats); | 196 RenderingStats* stats); |
194 static void RunImageDecodeTask(skia::LazyPixelRef* pixel_ref, | 197 static void RunImageDecodeTask(skia::LazyPixelRef* pixel_ref, |
195 RenderingStats* stats); | 198 RenderingStats* stats); |
196 | 199 |
197 static void RecordCheapnessPredictorResults(bool is_predicted_cheap, | 200 static void RecordCheapnessPredictorResults(bool is_predicted_cheap, |
198 bool is_actually_cheap); | 201 bool is_actually_cheap); |
| 202 static void RecordSolidColorPredictorResults(const SkColor* actual_colors, |
| 203 size_t color_count, |
| 204 bool is_predicted_solid, |
| 205 SkColor predicted_color, |
| 206 bool is_predicted_transparent); |
199 | 207 |
200 TileManagerClient* client_; | 208 TileManagerClient* client_; |
201 scoped_ptr<ResourcePool> resource_pool_; | 209 scoped_ptr<ResourcePool> resource_pool_; |
202 scoped_ptr<RasterWorkerPool> raster_worker_pool_; | 210 scoped_ptr<RasterWorkerPool> raster_worker_pool_; |
203 bool manage_tiles_pending_; | 211 bool manage_tiles_pending_; |
204 int manage_tiles_call_count_; | 212 int manage_tiles_call_count_; |
205 | 213 |
206 GlobalStateThatImpactsTilePriority global_state_; | 214 GlobalStateThatImpactsTilePriority global_state_; |
207 | 215 |
208 typedef std::vector<Tile*> TileVector; | 216 typedef std::vector<Tile*> TileVector; |
(...skipping 14 matching lines...) Expand all Loading... |
223 TileQueue tiles_with_pending_upload_; | 231 TileQueue tiles_with_pending_upload_; |
224 size_t bytes_pending_upload_; | 232 size_t bytes_pending_upload_; |
225 bool has_performed_uploads_since_last_flush_; | 233 bool has_performed_uploads_since_last_flush_; |
226 bool ever_exceeded_memory_budget_; | 234 bool ever_exceeded_memory_budget_; |
227 MemoryHistory::Entry memory_stats_from_last_assign_; | 235 MemoryHistory::Entry memory_stats_from_last_assign_; |
228 | 236 |
229 bool record_rendering_stats_; | 237 bool record_rendering_stats_; |
230 RenderingStats rendering_stats_; | 238 RenderingStats rendering_stats_; |
231 | 239 |
232 bool use_cheapness_estimator_; | 240 bool use_cheapness_estimator_; |
| 241 bool use_color_estimator_; |
233 bool did_schedule_cheap_tasks_; | 242 bool did_schedule_cheap_tasks_; |
234 bool allow_cheap_tasks_; | 243 bool allow_cheap_tasks_; |
235 int raster_state_count_[NUM_STATES][NUM_TREES][NUM_BINS]; | 244 int raster_state_count_[NUM_STATES][NUM_TREES][NUM_BINS]; |
| 245 bool prediction_benchmarking_; |
236 | 246 |
237 DISALLOW_COPY_AND_ASSIGN(TileManager); | 247 DISALLOW_COPY_AND_ASSIGN(TileManager); |
238 }; | 248 }; |
239 | 249 |
240 } // namespace cc | 250 } // namespace cc |
241 | 251 |
242 #endif // CC_TILE_MANAGER_H_ | 252 #endif // CC_TILE_MANAGER_H_ |
OLD | NEW |