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> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/hash_tables.h" | 13 #include "base/hash_tables.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/values.h" | 15 #include "base/values.h" |
16 #include "cc/memory_history.h" | 16 #include "cc/memory_history.h" |
| 17 #include "cc/picture_pile_impl.h" |
17 #include "cc/rendering_stats.h" | 18 #include "cc/rendering_stats.h" |
18 #include "cc/resource_pool.h" | 19 #include "cc/resource_pool.h" |
19 #include "cc/tile_priority.h" | 20 #include "cc/tile_priority.h" |
20 #include "cc/worker_pool.h" | 21 #include "cc/worker_pool.h" |
21 | 22 |
22 namespace cc { | 23 namespace cc { |
23 class RasterWorkerPool; | 24 class RasterWorkerPool; |
24 class ResourceProvider; | 25 class ResourceProvider; |
25 class Tile; | 26 class Tile; |
26 class TileVersion; | 27 class TileVersion; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 | 86 |
86 // Ephemeral state, valid only during Manage. | 87 // Ephemeral state, valid only during Manage. |
87 TileManagerBin bin[NUM_BIN_PRIORITIES]; | 88 TileManagerBin bin[NUM_BIN_PRIORITIES]; |
88 TileManagerBin tree_bin[NUM_TREES]; | 89 TileManagerBin tree_bin[NUM_TREES]; |
89 // The bin that the tile would have if the GPU memory manager had a maximally
permissive policy, | 90 // The bin that the tile would have if the GPU memory manager had a maximally
permissive policy, |
90 // send to the GPU memory manager to determine policy. | 91 // send to the GPU memory manager to determine policy. |
91 TileManagerBin gpu_memmgr_stats_bin; | 92 TileManagerBin gpu_memmgr_stats_bin; |
92 TileResolution resolution; | 93 TileResolution resolution; |
93 float time_to_needed_in_seconds; | 94 float time_to_needed_in_seconds; |
94 float distance_to_visible_in_pixels; | 95 float distance_to_visible_in_pixels; |
| 96 PicturePileImpl::Analysis picture_pile_analysis; |
| 97 bool picture_pile_analyzed; |
95 }; | 98 }; |
96 | 99 |
97 // This class manages tiles, deciding which should get rasterized and which | 100 // 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" | 101 // 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 | 102 // by layers; they automatically register with the manager when they are |
100 // created, and unregister from the manager when they are deleted. | 103 // created, and unregister from the manager when they are deleted. |
101 class CC_EXPORT TileManager : public WorkerPoolClient { | 104 class CC_EXPORT TileManager : public WorkerPoolClient { |
102 public: | 105 public: |
103 TileManager(TileManagerClient* client, | 106 TileManager(TileManagerClient* client, |
104 ResourceProvider *resource_provider, | 107 ResourceProvider *resource_provider, |
105 size_t num_raster_threads, | 108 size_t num_raster_threads, |
106 bool use_cheapess_estimator); | 109 bool use_cheapess_estimator, |
| 110 bool use_color_estimator, |
| 111 bool prediction_benchmarking); |
107 virtual ~TileManager(); | 112 virtual ~TileManager(); |
108 | 113 |
109 const GlobalStateThatImpactsTilePriority& GlobalState() const { | 114 const GlobalStateThatImpactsTilePriority& GlobalState() const { |
110 return global_state_; | 115 return global_state_; |
111 } | 116 } |
112 void SetGlobalState(const GlobalStateThatImpactsTilePriority& state); | 117 void SetGlobalState(const GlobalStateThatImpactsTilePriority& state); |
113 | 118 |
114 void ManageTiles(); | 119 void ManageTiles(); |
115 void CheckForCompletedTileUploads(); | 120 void CheckForCompletedTileUploads(); |
116 void AbortPendingTileUploads(); | 121 void AbortPendingTileUploads(); |
(...skipping 24 matching lines...) Expand all Loading... |
141 Tile* tile, WhichTree tree, const TilePriority& new_priority) { | 146 Tile* tile, WhichTree tree, const TilePriority& new_priority) { |
142 // TODO(nduca): Do something smarter if reprioritization turns out to be | 147 // TODO(nduca): Do something smarter if reprioritization turns out to be |
143 // costly. | 148 // costly. |
144 ScheduleManageTiles(); | 149 ScheduleManageTiles(); |
145 } | 150 } |
146 | 151 |
147 private: | 152 private: |
148 | 153 |
149 // Data that is passed to raster tasks. | 154 // Data that is passed to raster tasks. |
150 struct RasterTaskMetadata { | 155 struct RasterTaskMetadata { |
151 bool use_cheapness_estimator; | 156 bool prediction_benchmarking; |
152 bool is_tile_in_pending_tree_now_bin; | 157 bool is_tile_in_pending_tree_now_bin; |
153 TileResolution tile_resolution; | 158 TileResolution tile_resolution; |
154 int layer_id; | 159 int layer_id; |
155 }; | 160 }; |
156 | 161 |
157 RasterTaskMetadata GetRasterTaskMetadata(const Tile& tile) const; | 162 RasterTaskMetadata GetRasterTaskMetadata(const Tile& tile) const; |
| 163 |
158 void SortTiles(); | 164 void SortTiles(); |
159 void AssignGpuMemoryToTiles(); | 165 void AssignGpuMemoryToTiles(); |
160 void FreeResourcesForTile(Tile* tile); | 166 void FreeResourcesForTile(Tile* tile); |
161 void ScheduleManageTiles() { | 167 void ScheduleManageTiles() { |
162 if (manage_tiles_pending_) | 168 if (manage_tiles_pending_) |
163 return; | 169 return; |
164 client_->ScheduleManageTiles(); | 170 client_->ScheduleManageTiles(); |
165 manage_tiles_pending_ = true; | 171 manage_tiles_pending_ = true; |
166 } | 172 } |
167 void DispatchMoreTasks(); | 173 void DispatchMoreTasks(); |
| 174 void AnalyzeTile(Tile* tile); |
168 void GatherPixelRefsForTile(Tile* tile); | 175 void GatherPixelRefsForTile(Tile* tile); |
169 void DispatchImageDecodeTasksForTile(Tile* tile); | 176 void DispatchImageDecodeTasksForTile(Tile* tile); |
170 void DispatchOneImageDecodeTask( | 177 void DispatchOneImageDecodeTask( |
171 scoped_refptr<Tile> tile, skia::LazyPixelRef* pixel_ref); | 178 scoped_refptr<Tile> tile, skia::LazyPixelRef* pixel_ref); |
172 void OnImageDecodeTaskCompleted( | 179 void OnImageDecodeTaskCompleted( |
173 scoped_refptr<Tile> tile, | 180 scoped_refptr<Tile> tile, |
174 uint32_t pixel_ref_id); | 181 uint32_t pixel_ref_id); |
175 bool CanDispatchRasterTask(Tile* tile) const; | 182 bool CanDispatchRasterTask(Tile* tile) const; |
176 scoped_ptr<ResourcePool::Resource> PrepareTileForRaster(Tile* tile); | 183 scoped_ptr<ResourcePool::Resource> PrepareTileForRaster(Tile* tile); |
177 void DispatchOneRasterTask(scoped_refptr<Tile> tile); | 184 void DispatchOneRasterTask(scoped_refptr<Tile> tile); |
(...skipping 12 matching lines...) Expand all Loading... |
190 const gfx::Rect& rect, | 197 const gfx::Rect& rect, |
191 float contents_scale, | 198 float contents_scale, |
192 const RasterTaskMetadata& metadata, | 199 const RasterTaskMetadata& metadata, |
193 PicturePileImpl* picture_pile, | 200 PicturePileImpl* picture_pile, |
194 RenderingStats* stats); | 201 RenderingStats* stats); |
195 static void RunImageDecodeTask(skia::LazyPixelRef* pixel_ref, | 202 static void RunImageDecodeTask(skia::LazyPixelRef* pixel_ref, |
196 RenderingStats* stats); | 203 RenderingStats* stats); |
197 | 204 |
198 static void RecordCheapnessPredictorResults(bool is_predicted_cheap, | 205 static void RecordCheapnessPredictorResults(bool is_predicted_cheap, |
199 bool is_actually_cheap); | 206 bool is_actually_cheap); |
| 207 static void RecordSolidColorPredictorResults(const SkColor* actual_colors, |
| 208 size_t color_count, |
| 209 bool is_predicted_solid, |
| 210 SkColor predicted_color, |
| 211 bool is_predicted_transparent); |
200 | 212 |
201 TileManagerClient* client_; | 213 TileManagerClient* client_; |
202 scoped_ptr<ResourcePool> resource_pool_; | 214 scoped_ptr<ResourcePool> resource_pool_; |
203 scoped_ptr<RasterWorkerPool> raster_worker_pool_; | 215 scoped_ptr<RasterWorkerPool> raster_worker_pool_; |
204 bool manage_tiles_pending_; | 216 bool manage_tiles_pending_; |
205 int manage_tiles_call_count_; | 217 int manage_tiles_call_count_; |
206 | 218 |
207 GlobalStateThatImpactsTilePriority global_state_; | 219 GlobalStateThatImpactsTilePriority global_state_; |
208 | 220 |
209 typedef std::vector<Tile*> TileVector; | 221 typedef std::vector<Tile*> TileVector; |
(...skipping 14 matching lines...) Expand all Loading... |
224 TileQueue tiles_with_pending_upload_; | 236 TileQueue tiles_with_pending_upload_; |
225 size_t bytes_pending_upload_; | 237 size_t bytes_pending_upload_; |
226 bool has_performed_uploads_since_last_flush_; | 238 bool has_performed_uploads_since_last_flush_; |
227 bool ever_exceeded_memory_budget_; | 239 bool ever_exceeded_memory_budget_; |
228 MemoryHistory::Entry memory_stats_from_last_assign_; | 240 MemoryHistory::Entry memory_stats_from_last_assign_; |
229 | 241 |
230 bool record_rendering_stats_; | 242 bool record_rendering_stats_; |
231 RenderingStats rendering_stats_; | 243 RenderingStats rendering_stats_; |
232 | 244 |
233 bool use_cheapness_estimator_; | 245 bool use_cheapness_estimator_; |
| 246 bool use_color_estimator_; |
234 bool did_schedule_cheap_tasks_; | 247 bool did_schedule_cheap_tasks_; |
235 bool allow_cheap_tasks_; | 248 bool allow_cheap_tasks_; |
236 int raster_state_count_[NUM_STATES][NUM_TREES][NUM_BINS]; | 249 int raster_state_count_[NUM_STATES][NUM_TREES][NUM_BINS]; |
| 250 bool prediction_benchmarking_; |
237 | 251 |
238 DISALLOW_COPY_AND_ASSIGN(TileManager); | 252 DISALLOW_COPY_AND_ASSIGN(TileManager); |
239 }; | 253 }; |
240 | 254 |
241 } // namespace cc | 255 } // namespace cc |
242 | 256 |
243 #endif // CC_TILE_MANAGER_H_ | 257 #endif // CC_TILE_MANAGER_H_ |
OLD | NEW |