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 <vector> | 10 #include <vector> |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 | 88 |
89 // This class manages tiles, deciding which should get rasterized and which | 89 // This class manages tiles, deciding which should get rasterized and which |
90 // should no longer have any memory assigned to them. Tile objects are "owned" | 90 // should no longer have any memory assigned to them. Tile objects are "owned" |
91 // by layers; they automatically register with the manager when they are | 91 // by layers; they automatically register with the manager when they are |
92 // created, and unregister from the manager when they are deleted. | 92 // created, and unregister from the manager when they are deleted. |
93 class CC_EXPORT TileManager { | 93 class CC_EXPORT TileManager { |
94 public: | 94 public: |
95 TileManager(TileManagerClient* client, | 95 TileManager(TileManagerClient* client, |
96 ResourceProvider *resource_provider, | 96 ResourceProvider *resource_provider, |
97 size_t num_raster_threads, | 97 size_t num_raster_threads, |
98 bool record_rendering_stats); | 98 bool record_rendering_stats, |
| 99 bool use_cheapess_estimator); |
99 virtual ~TileManager(); | 100 virtual ~TileManager(); |
100 | 101 |
101 const GlobalStateThatImpactsTilePriority& GlobalState() const { | 102 const GlobalStateThatImpactsTilePriority& GlobalState() const { |
102 return global_state_; | 103 return global_state_; |
103 } | 104 } |
104 void SetGlobalState(const GlobalStateThatImpactsTilePriority& state); | 105 void SetGlobalState(const GlobalStateThatImpactsTilePriority& state); |
105 | 106 |
106 void ManageTiles(); | 107 void ManageTiles(); |
107 void CheckForCompletedTileUploads(); | 108 void CheckForCompletedTileUploads(); |
108 | 109 |
(...skipping 29 matching lines...) Expand all Loading... |
138 manage_tiles_pending_ = true; | 139 manage_tiles_pending_ = true; |
139 } | 140 } |
140 void DispatchMoreTasks(); | 141 void DispatchMoreTasks(); |
141 void GatherPixelRefsForTile(Tile* tile); | 142 void GatherPixelRefsForTile(Tile* tile); |
142 void DispatchImageDecodeTasksForTile(Tile* tile); | 143 void DispatchImageDecodeTasksForTile(Tile* tile); |
143 void DispatchOneImageDecodeTask( | 144 void DispatchOneImageDecodeTask( |
144 scoped_refptr<Tile> tile, skia::LazyPixelRef* pixel_ref); | 145 scoped_refptr<Tile> tile, skia::LazyPixelRef* pixel_ref); |
145 void OnImageDecodeTaskCompleted( | 146 void OnImageDecodeTaskCompleted( |
146 scoped_refptr<Tile> tile, uint32_t pixel_ref_id); | 147 scoped_refptr<Tile> tile, uint32_t pixel_ref_id); |
147 bool CanDispatchRasterTask(Tile* tile); | 148 bool CanDispatchRasterTask(Tile* tile); |
| 149 scoped_ptr<ResourcePool::Resource> PrepareTileForRaster(Tile* tile); |
148 void DispatchOneRasterTask(scoped_refptr<Tile> tile); | 150 void DispatchOneRasterTask(scoped_refptr<Tile> tile); |
| 151 void PerformOneRaster(Tile* tile); |
| 152 void OnRasterCompleted( |
| 153 scoped_refptr<Tile> tile, |
| 154 scoped_ptr<ResourcePool::Resource> resource, |
| 155 int manage_tiles_call_count_when_dispatched); |
149 void OnRasterTaskCompleted( | 156 void OnRasterTaskCompleted( |
150 scoped_refptr<Tile> tile, | 157 scoped_refptr<Tile> tile, |
151 scoped_ptr<ResourcePool::Resource> resource, | 158 scoped_ptr<ResourcePool::Resource> resource, |
152 int manage_tiles_call_count_when_dispatched); | 159 int manage_tiles_call_count_when_dispatched); |
153 void DidFinishTileInitialization(Tile* tile); | 160 void DidFinishTileInitialization(Tile* tile); |
154 void DidTileRasterStateChange(Tile* tile, TileRasterState state); | 161 void DidTileRasterStateChange(Tile* tile, TileRasterState state); |
155 void DidTileBinChange(Tile* tile, | 162 void DidTileBinChange(Tile* tile, |
156 TileManagerBin bin, | 163 TileManagerBin bin, |
157 WhichTree tree); | 164 WhichTree tree); |
158 scoped_ptr<Value> GetMemoryRequirementsAsValue() const; | 165 scoped_ptr<Value> GetMemoryRequirementsAsValue() const; |
159 | 166 |
160 static void RunRasterTask(uint8* buffer, | 167 static void PerformRaster(uint8* buffer, |
161 const gfx::Rect& rect, | 168 const gfx::Rect& rect, |
162 float contents_scale, | 169 float contents_scale, |
| 170 bool use_cheapness_estimator, |
163 PicturePileImpl* picture_pile, | 171 PicturePileImpl* picture_pile, |
164 RenderingStats* stats); | 172 RenderingStats* stats); |
165 static void RunImageDecodeTask(skia::LazyPixelRef* pixel_ref, | 173 static void RunImageDecodeTask(skia::LazyPixelRef* pixel_ref, |
166 RenderingStats* stats); | 174 RenderingStats* stats); |
167 | 175 |
| 176 static void RecordCheapnessPredictorResults(bool is_predicted_cheap, |
| 177 bool is_actually_cheap); |
| 178 |
168 TileManagerClient* client_; | 179 TileManagerClient* client_; |
169 scoped_ptr<ResourcePool> resource_pool_; | 180 scoped_ptr<ResourcePool> resource_pool_; |
170 scoped_ptr<RasterWorkerPool> raster_worker_pool_; | 181 scoped_ptr<RasterWorkerPool> raster_worker_pool_; |
171 bool manage_tiles_pending_; | 182 bool manage_tiles_pending_; |
172 int manage_tiles_call_count_; | 183 int manage_tiles_call_count_; |
173 | 184 |
174 GlobalStateThatImpactsTilePriority global_state_; | 185 GlobalStateThatImpactsTilePriority global_state_; |
175 | 186 |
176 typedef std::vector<Tile*> TileVector; | 187 typedef std::vector<Tile*> TileVector; |
177 TileVector tiles_; | 188 TileVector tiles_; |
178 TileVector tiles_that_need_to_be_rasterized_; | 189 TileVector tiles_that_need_to_be_rasterized_; |
179 | 190 |
180 typedef std::list<Tile*> TileList; | 191 typedef std::list<Tile*> TileList; |
181 // Tiles with image decoding tasks. These tiles need to be rasterized | 192 // Tiles with image decoding tasks. These tiles need to be rasterized |
182 // when all the image decoding tasks finish. | 193 // when all the image decoding tasks finish. |
183 TileList tiles_with_image_decoding_tasks_; | 194 TileList tiles_with_image_decoding_tasks_; |
184 | 195 |
185 typedef base::hash_map<uint32_t, skia::LazyPixelRef*> PixelRefMap; | 196 typedef base::hash_map<uint32_t, skia::LazyPixelRef*> PixelRefMap; |
186 PixelRefMap pending_decode_tasks_; | 197 PixelRefMap pending_decode_tasks_; |
187 | 198 |
188 typedef std::queue<scoped_refptr<Tile> > TileQueue; | 199 typedef std::queue<scoped_refptr<Tile> > TileQueue; |
189 TileQueue tiles_with_pending_set_pixels_; | 200 TileQueue tiles_with_pending_set_pixels_; |
190 size_t bytes_pending_set_pixels_; | 201 size_t bytes_pending_set_pixels_; |
191 bool ever_exceeded_memory_budget_; | 202 bool ever_exceeded_memory_budget_; |
192 MemoryHistory::Entry memory_stats_from_last_assign_; | 203 MemoryHistory::Entry memory_stats_from_last_assign_; |
193 | 204 |
194 bool record_rendering_stats_; | 205 bool record_rendering_stats_; |
195 RenderingStats rendering_stats_; | 206 RenderingStats rendering_stats_; |
196 | 207 |
| 208 bool use_cheapness_estimator_; |
197 int raster_state_count_[NUM_STATES][NUM_TREES][NUM_BINS]; | 209 int raster_state_count_[NUM_STATES][NUM_TREES][NUM_BINS]; |
198 | 210 |
199 DISALLOW_COPY_AND_ASSIGN(TileManager); | 211 DISALLOW_COPY_AND_ASSIGN(TileManager); |
200 }; | 212 }; |
201 | 213 |
202 } // namespace cc | 214 } // namespace cc |
203 | 215 |
204 #endif // CC_TILE_MANAGER_H_ | 216 #endif // CC_TILE_MANAGER_H_ |
OLD | NEW |