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_TILES_TILE_MANAGER_H_ | 5 #ifndef CC_TILES_TILE_MANAGER_H_ |
6 #define CC_TILES_TILE_MANAGER_H_ | 6 #define CC_TILES_TILE_MANAGER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 BasicStateAsValue() const; | 157 BasicStateAsValue() const; |
158 void BasicStateAsValueInto(base::trace_event::TracedValue* dict) const; | 158 void BasicStateAsValueInto(base::trace_event::TracedValue* dict) const; |
159 const MemoryHistory::Entry& memory_stats_from_last_assign() const { | 159 const MemoryHistory::Entry& memory_stats_from_last_assign() const { |
160 return memory_stats_from_last_assign_; | 160 return memory_stats_from_last_assign_; |
161 } | 161 } |
162 | 162 |
163 // Public methods for testing. | 163 // Public methods for testing. |
164 void InitializeTilesWithResourcesForTesting(const std::vector<Tile*>& tiles) { | 164 void InitializeTilesWithResourcesForTesting(const std::vector<Tile*>& tiles) { |
165 for (size_t i = 0; i < tiles.size(); ++i) { | 165 for (size_t i = 0; i < tiles.size(); ++i) { |
166 TileDrawInfo& draw_info = tiles[i]->draw_info(); | 166 TileDrawInfo& draw_info = tiles[i]->draw_info(); |
167 draw_info.set_resource(resource_pool_->AcquireResource( | 167 draw_info.set_resource( |
168 tiles[i]->desired_texture_size(), | 168 resource_pool_->AcquireResource( |
169 raster_buffer_provider_->GetResourceFormat(false), | 169 tiles[i]->desired_texture_size(), |
170 client_->GetRasterColorSpace())); | 170 raster_buffer_provider_->GetResourceFormat(false), |
| 171 client_->GetRasterColorSpace()), |
| 172 false); |
171 draw_info.set_resource_ready_for_draw(); | 173 draw_info.set_resource_ready_for_draw(); |
172 } | 174 } |
173 } | 175 } |
174 | 176 |
175 void ReleaseTileResourcesForTesting(const std::vector<Tile*>& tiles) { | 177 void ReleaseTileResourcesForTesting(const std::vector<Tile*>& tiles) { |
176 for (size_t i = 0; i < tiles.size(); ++i) { | 178 for (size_t i = 0; i < tiles.size(); ++i) { |
177 Tile* tile = tiles[i]; | 179 Tile* tile = tiles[i]; |
178 FreeResourcesForTile(tile); | 180 FreeResourcesForTile(tile); |
179 } | 181 } |
180 } | 182 } |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 void SetDecodedImageTracker(DecodedImageTracker* decoded_image_tracker); | 229 void SetDecodedImageTracker(DecodedImageTracker* decoded_image_tracker); |
228 | 230 |
229 // CheckerImageTrackerClient implementation. | 231 // CheckerImageTrackerClient implementation. |
230 void NeedsInvalidationForCheckerImagedTiles() override; | 232 void NeedsInvalidationForCheckerImagedTiles() override; |
231 | 233 |
232 // This method can only be used for debugging information, since it performs a | 234 // This method can only be used for debugging information, since it performs a |
233 // non trivial amount of work. | 235 // non trivial amount of work. |
234 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> | 236 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> |
235 ActivationStateAsValue(); | 237 ActivationStateAsValue(); |
236 | 238 |
| 239 int num_of_tiles_with_checker_images() const { |
| 240 return num_of_tiles_with_checker_images_; |
| 241 } |
| 242 |
237 protected: | 243 protected: |
238 friend class Tile; | 244 friend class Tile; |
239 // Must be called by tile during destruction. | 245 // Must be called by tile during destruction. |
240 void Release(Tile* tile); | 246 void Release(Tile* tile); |
241 Tile::Id GetUniqueTileId() { return ++next_tile_id_; } | 247 Tile::Id GetUniqueTileId() { return ++next_tile_id_; } |
242 | 248 |
243 private: | 249 private: |
244 class MemoryUsage { | 250 class MemoryUsage { |
245 public: | 251 public: |
246 MemoryUsage(); | 252 MemoryUsage(); |
(...skipping 27 matching lines...) Expand all Loading... |
274 bool did_notify_all_tile_tasks_completed; | 280 bool did_notify_all_tile_tasks_completed; |
275 }; | 281 }; |
276 | 282 |
277 struct PrioritizedWorkToSchedule { | 283 struct PrioritizedWorkToSchedule { |
278 PrioritizedWorkToSchedule(); | 284 PrioritizedWorkToSchedule(); |
279 PrioritizedWorkToSchedule(PrioritizedWorkToSchedule&& other); | 285 PrioritizedWorkToSchedule(PrioritizedWorkToSchedule&& other); |
280 ~PrioritizedWorkToSchedule(); | 286 ~PrioritizedWorkToSchedule(); |
281 | 287 |
282 std::vector<PrioritizedTile> tiles_to_raster; | 288 std::vector<PrioritizedTile> tiles_to_raster; |
283 std::vector<PrioritizedTile> tiles_to_process_for_images; | 289 std::vector<PrioritizedTile> tiles_to_process_for_images; |
| 290 CheckerImageTracker::ImageDecodeQueue checker_image_decode_queue; |
284 }; | 291 }; |
285 | 292 |
286 void FreeResourcesForTile(Tile* tile); | 293 void FreeResourcesForTile(Tile* tile); |
287 void FreeResourcesForTileAndNotifyClientIfTileWasReadyToDraw(Tile* tile); | 294 void FreeResourcesForTileAndNotifyClientIfTileWasReadyToDraw(Tile* tile); |
288 scoped_refptr<TileTask> CreateRasterTask( | 295 scoped_refptr<TileTask> CreateRasterTask( |
289 const PrioritizedTile& prioritized_tile, | 296 const PrioritizedTile& prioritized_tile, |
290 const gfx::ColorSpace& color_space); | 297 const gfx::ColorSpace& color_space, |
| 298 CheckerImageTracker::ImageDecodeQueue* checker_image_decode_queue); |
291 | 299 |
292 std::unique_ptr<EvictionTilePriorityQueue> | 300 std::unique_ptr<EvictionTilePriorityQueue> |
293 FreeTileResourcesUntilUsageIsWithinLimit( | 301 FreeTileResourcesUntilUsageIsWithinLimit( |
294 std::unique_ptr<EvictionTilePriorityQueue> eviction_priority_queue, | 302 std::unique_ptr<EvictionTilePriorityQueue> eviction_priority_queue, |
295 const MemoryUsage& limit, | 303 const MemoryUsage& limit, |
296 MemoryUsage* usage); | 304 MemoryUsage* usage); |
297 std::unique_ptr<EvictionTilePriorityQueue> | 305 std::unique_ptr<EvictionTilePriorityQueue> |
298 FreeTileResourcesWithLowerPriorityUntilUsageIsWithinLimit( | 306 FreeTileResourcesWithLowerPriorityUntilUsageIsWithinLimit( |
299 std::unique_ptr<EvictionTilePriorityQueue> eviction_priority_queue, | 307 std::unique_ptr<EvictionTilePriorityQueue> eviction_priority_queue, |
300 const MemoryUsage& limit, | 308 const MemoryUsage& limit, |
(...skipping 11 matching lines...) Expand all Loading... |
312 | 320 |
313 void DidFinishRunningTileTasksRequiredForActivation(); | 321 void DidFinishRunningTileTasksRequiredForActivation(); |
314 void DidFinishRunningTileTasksRequiredForDraw(); | 322 void DidFinishRunningTileTasksRequiredForDraw(); |
315 void DidFinishRunningAllTileTasks(); | 323 void DidFinishRunningAllTileTasks(); |
316 | 324 |
317 scoped_refptr<TileTask> CreateTaskSetFinishedTask( | 325 scoped_refptr<TileTask> CreateTaskSetFinishedTask( |
318 void (TileManager::*callback)()); | 326 void (TileManager::*callback)()); |
319 PrioritizedWorkToSchedule AssignGpuMemoryToTiles(); | 327 PrioritizedWorkToSchedule AssignGpuMemoryToTiles(); |
320 void ScheduleTasks(const PrioritizedWorkToSchedule& work_to_schedule); | 328 void ScheduleTasks(const PrioritizedWorkToSchedule& work_to_schedule); |
321 | 329 |
| 330 void PartitionImagesForCheckering( |
| 331 const PrioritizedTile& prioritized_tile, |
| 332 const gfx::ColorSpace& raster_color_space, |
| 333 std::vector<DrawImage>* sync_decoded_images, |
| 334 std::vector<sk_sp<const SkImage>>* checkered_images); |
| 335 void AddCheckeredImagesToDecodeQueue( |
| 336 const PrioritizedTile& prioritized_tile, |
| 337 const gfx::ColorSpace& raster_color_space, |
| 338 CheckerImageTracker::ImageDecodeQueue* image_decode_queue); |
| 339 |
322 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> | 340 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> |
323 ScheduledTasksStateAsValue() const; | 341 ScheduledTasksStateAsValue() const; |
324 | 342 |
325 bool UsePartialRaster() const; | 343 bool UsePartialRaster() const; |
326 | 344 |
327 void CheckPendingGpuWorkTiles(bool issue_signals); | 345 void CheckPendingGpuWorkTiles(bool issue_signals); |
328 | 346 |
329 TileManagerClient* client_; | 347 TileManagerClient* client_; |
330 base::SequencedTaskRunner* task_runner_; | 348 base::SequencedTaskRunner* task_runner_; |
331 ResourcePool* resource_pool_; | 349 ResourcePool* resource_pool_; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 std::unordered_set<Tile*> pending_gpu_work_tiles_; | 384 std::unordered_set<Tile*> pending_gpu_work_tiles_; |
367 uint64_t pending_required_for_activation_callback_id_ = 0; | 385 uint64_t pending_required_for_activation_callback_id_ = 0; |
368 uint64_t pending_required_for_draw_callback_id_ = 0; | 386 uint64_t pending_required_for_draw_callback_id_ = 0; |
369 // If true, we should re-compute tile requirements in | 387 // If true, we should re-compute tile requirements in |
370 // CheckPendingGpuWorkTiles. | 388 // CheckPendingGpuWorkTiles. |
371 bool pending_tile_requirements_dirty_ = false; | 389 bool pending_tile_requirements_dirty_ = false; |
372 | 390 |
373 std::unordered_map<Tile::Id, std::vector<DrawImage>> scheduled_draw_images_; | 391 std::unordered_map<Tile::Id, std::vector<DrawImage>> scheduled_draw_images_; |
374 std::vector<scoped_refptr<TileTask>> locked_image_tasks_; | 392 std::vector<scoped_refptr<TileTask>> locked_image_tasks_; |
375 | 393 |
| 394 // Number of tiles with a checker-imaged resource or active raster tasks which |
| 395 // will create a checker-imaged resource. |
| 396 int num_of_tiles_with_checker_images_ = 0; |
| 397 |
376 // We need two WeakPtrFactory objects as the invalidation pattern of each is | 398 // We need two WeakPtrFactory objects as the invalidation pattern of each is |
377 // different. The |task_set_finished_weak_ptr_factory_| is invalidated any | 399 // different. The |task_set_finished_weak_ptr_factory_| is invalidated any |
378 // time new tasks are scheduled, preventing a race when the callback has | 400 // time new tasks are scheduled, preventing a race when the callback has |
379 // been scheduled but not yet executed. | 401 // been scheduled but not yet executed. |
380 base::WeakPtrFactory<TileManager> task_set_finished_weak_ptr_factory_; | 402 base::WeakPtrFactory<TileManager> task_set_finished_weak_ptr_factory_; |
381 // The |ready_to_draw_callback_weak_ptr_factory_| is never invalidated. | 403 // The |ready_to_draw_callback_weak_ptr_factory_| is never invalidated. |
382 base::WeakPtrFactory<TileManager> ready_to_draw_callback_weak_ptr_factory_; | 404 base::WeakPtrFactory<TileManager> ready_to_draw_callback_weak_ptr_factory_; |
383 | 405 |
384 DISALLOW_COPY_AND_ASSIGN(TileManager); | 406 DISALLOW_COPY_AND_ASSIGN(TileManager); |
385 }; | 407 }; |
386 | 408 |
387 } // namespace cc | 409 } // namespace cc |
388 | 410 |
389 #endif // CC_TILES_TILE_MANAGER_H_ | 411 #endif // CC_TILES_TILE_MANAGER_H_ |
OLD | NEW |