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 #include "cc/tiles/tile_manager.h" | 5 #include "cc/tiles/tile_manager.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 base::saturated_cast<int>(stats.canceled_count)); | 341 base::saturated_cast<int>(stats.canceled_count)); |
342 return std::move(state); | 342 return std::move(state); |
343 } | 343 } |
344 | 344 |
345 TileManager::TileManager( | 345 TileManager::TileManager( |
346 TileManagerClient* client, | 346 TileManagerClient* client, |
347 base::SequencedTaskRunner* origin_task_runner, | 347 base::SequencedTaskRunner* origin_task_runner, |
348 scoped_refptr<base::SequencedTaskRunner> image_worker_task_runner, | 348 scoped_refptr<base::SequencedTaskRunner> image_worker_task_runner, |
349 size_t scheduled_raster_task_limit, | 349 size_t scheduled_raster_task_limit, |
350 bool use_partial_raster, | 350 bool use_partial_raster, |
351 bool check_tile_priority_inversion) | 351 bool check_tile_priority_inversion, |
| 352 bool enable_checker_imaging) |
352 : client_(client), | 353 : client_(client), |
353 task_runner_(origin_task_runner), | 354 task_runner_(origin_task_runner), |
354 resource_pool_(nullptr), | 355 resource_pool_(nullptr), |
355 tile_task_manager_(nullptr), | 356 tile_task_manager_(nullptr), |
356 scheduled_raster_task_limit_(scheduled_raster_task_limit), | 357 scheduled_raster_task_limit_(scheduled_raster_task_limit), |
357 use_partial_raster_(use_partial_raster), | 358 use_partial_raster_(use_partial_raster), |
358 use_gpu_rasterization_(false), | 359 use_gpu_rasterization_(false), |
359 all_tiles_that_need_to_be_rasterized_are_scheduled_(true), | 360 all_tiles_that_need_to_be_rasterized_are_scheduled_(true), |
360 did_check_for_completed_tasks_since_last_schedule_tasks_(true), | 361 did_check_for_completed_tasks_since_last_schedule_tasks_(true), |
361 did_oom_on_last_assign_(false), | 362 did_oom_on_last_assign_(false), |
362 image_controller_(origin_task_runner, | 363 image_controller_(origin_task_runner, |
363 std::move(image_worker_task_runner)), | 364 std::move(image_worker_task_runner)), |
| 365 checker_image_tracker_(&image_controller_, this, enable_checker_imaging), |
364 more_tiles_need_prepare_check_notifier_( | 366 more_tiles_need_prepare_check_notifier_( |
365 task_runner_, | 367 task_runner_, |
366 base::Bind(&TileManager::CheckIfMoreTilesNeedToBePrepared, | 368 base::Bind(&TileManager::CheckIfMoreTilesNeedToBePrepared, |
367 base::Unretained(this))), | 369 base::Unretained(this))), |
368 signals_check_notifier_(task_runner_, | 370 signals_check_notifier_(task_runner_, |
369 base::Bind(&TileManager::CheckAndIssueSignals, | 371 base::Bind(&TileManager::CheckAndIssueSignals, |
370 base::Unretained(this))), | 372 base::Unretained(this))), |
371 has_scheduled_tile_tasks_(false), | 373 has_scheduled_tile_tasks_(false), |
372 prepare_tiles_count_(0u), | 374 prepare_tiles_count_(0u), |
373 next_tile_id_(0u), | 375 next_tile_id_(0u), |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
890 InsertNodesForRasterTask(&graph_, task, task->dependencies(), priority++, | 892 InsertNodesForRasterTask(&graph_, task, task->dependencies(), priority++, |
891 use_foreground_category); | 893 use_foreground_category); |
892 } | 894 } |
893 | 895 |
894 const std::vector<PrioritizedTile>& tiles_to_process_for_images = | 896 const std::vector<PrioritizedTile>& tiles_to_process_for_images = |
895 work_to_schedule.tiles_to_process_for_images; | 897 work_to_schedule.tiles_to_process_for_images; |
896 std::vector<DrawImage> new_locked_images; | 898 std::vector<DrawImage> new_locked_images; |
897 for (const PrioritizedTile& prioritized_tile : tiles_to_process_for_images) { | 899 for (const PrioritizedTile& prioritized_tile : tiles_to_process_for_images) { |
898 Tile* tile = prioritized_tile.tile(); | 900 Tile* tile = prioritized_tile.tile(); |
899 | 901 |
| 902 // TODO(khushalsagar): Send these images to the ImageDecodeService, through |
| 903 // the CheckerImageTracker as well. See crbug.com/686267. |
900 std::vector<DrawImage> images; | 904 std::vector<DrawImage> images; |
901 prioritized_tile.raster_source()->GetDiscardableImagesInRect( | 905 prioritized_tile.raster_source()->GetDiscardableImagesInRect( |
902 tile->enclosing_layer_rect(), tile->contents_scale(), &images); | 906 tile->enclosing_layer_rect(), tile->contents_scale(), &images); |
903 new_locked_images.insert(new_locked_images.end(), images.begin(), | 907 new_locked_images.insert(new_locked_images.end(), images.begin(), |
904 images.end()); | 908 images.end()); |
905 } | 909 } |
906 | 910 |
907 // TODO(vmpstr): SOON is misleading here, but these images can come from | 911 // TODO(vmpstr): SOON is misleading here, but these images can come from |
908 // several diffent tiles. Rethink what we actually want to trace here. Note | 912 // several diffent tiles. Rethink what we actually want to trace here. Note |
909 // that I'm using SOON, since it can't be NOW (these are prepaint). | 913 // that I'm using SOON, since it can't be NOW (these are prepaint). |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
992 } | 996 } |
993 | 997 |
994 // For LOW_RESOLUTION tiles, we don't draw or predecode images. | 998 // For LOW_RESOLUTION tiles, we don't draw or predecode images. |
995 RasterSource::PlaybackSettings playback_settings; | 999 RasterSource::PlaybackSettings playback_settings; |
996 playback_settings.skip_images = | 1000 playback_settings.skip_images = |
997 prioritized_tile.priority().resolution == LOW_RESOLUTION; | 1001 prioritized_tile.priority().resolution == LOW_RESOLUTION; |
998 | 1002 |
999 // Create and queue all image decode tasks that this tile depends on. | 1003 // Create and queue all image decode tasks that this tile depends on. |
1000 TileTask::Vector decode_tasks; | 1004 TileTask::Vector decode_tasks; |
1001 std::vector<DrawImage>& images = scheduled_draw_images_[tile->id()]; | 1005 std::vector<DrawImage>& images = scheduled_draw_images_[tile->id()]; |
| 1006 std::unordered_set<ImageId>& images_to_skip = |
| 1007 playback_settings.images_to_skip; |
| 1008 images_to_skip.clear(); |
1002 images.clear(); | 1009 images.clear(); |
1003 if (!playback_settings.skip_images) { | 1010 if (!playback_settings.skip_images) { |
1004 prioritized_tile.raster_source()->GetDiscardableImagesInRect( | 1011 checker_image_tracker_.FilterImagesForCheckeringForTile( |
1005 tile->enclosing_layer_rect(), tile->contents_scale(), &images); | 1012 prioritized_tile, &images, &images_to_skip); |
1006 } | 1013 } |
1007 | 1014 |
1008 // We can skip the image hijack canvas if we have no images. | 1015 // We can skip the image hijack canvas if we have no images, or no images to |
1009 playback_settings.use_image_hijack_canvas = !images.empty(); | 1016 // skip during raster. |
| 1017 playback_settings.use_image_hijack_canvas = |
| 1018 !images.empty() || !images_to_skip.empty(); |
1010 | 1019 |
1011 // Get the tasks for the required images. | 1020 // Get the tasks for the required images. |
1012 ImageDecodeCache::TracingInfo tracing_info( | 1021 ImageDecodeCache::TracingInfo tracing_info( |
1013 prepare_tiles_count_, prioritized_tile.priority().priority_bin); | 1022 prepare_tiles_count_, prioritized_tile.priority().priority_bin); |
1014 image_controller_.GetTasksForImagesAndRef(&images, &decode_tasks, | 1023 image_controller_.GetTasksForImagesAndRef(&images, &decode_tasks, |
1015 tracing_info); | 1024 tracing_info); |
1016 | 1025 |
1017 std::unique_ptr<RasterBuffer> raster_buffer = | 1026 std::unique_ptr<RasterBuffer> raster_buffer = |
1018 raster_buffer_provider_->AcquireBufferForRaster( | 1027 raster_buffer_provider_->AcquireBufferForRaster( |
1019 resource, resource_content_id, tile->invalidated_id()); | 1028 resource, resource_content_id, tile->invalidated_id()); |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1256 // Mark required tiles as OOM so that we can activate/draw without them. | 1265 // Mark required tiles as OOM so that we can activate/draw without them. |
1257 for (; !queue->IsEmpty(); queue->Pop()) { | 1266 for (; !queue->IsEmpty(); queue->Pop()) { |
1258 Tile* tile = queue->Top().tile(); | 1267 Tile* tile = queue->Top().tile(); |
1259 if (tile->draw_info().IsReadyToDraw()) | 1268 if (tile->draw_info().IsReadyToDraw()) |
1260 continue; | 1269 continue; |
1261 tile->draw_info().set_oom(); | 1270 tile->draw_info().set_oom(); |
1262 client_->NotifyTileStateChanged(tile); | 1271 client_->NotifyTileStateChanged(tile); |
1263 } | 1272 } |
1264 } | 1273 } |
1265 | 1274 |
| 1275 void TileManager::AddImplSideInvalidations(LayerTreeImpl* pending_tree) { |
| 1276 checker_image_tracker_.AddInvalidationForCheckerImages(pending_tree); |
| 1277 } |
| 1278 |
| 1279 void TileManager::DidActivateSyncTree() { |
| 1280 checker_image_tracker_.DidActivateSyncTree(); |
| 1281 } |
| 1282 |
| 1283 void TileManager::NeedsInvalidationForCheckerImagedTiles() { |
| 1284 client_->RequestImplSideInvalidation(); |
| 1285 } |
| 1286 |
1266 ResourceFormat TileManager::DetermineResourceFormat(const Tile* tile) const { | 1287 ResourceFormat TileManager::DetermineResourceFormat(const Tile* tile) const { |
1267 return raster_buffer_provider_->GetResourceFormat(!tile->is_opaque()); | 1288 return raster_buffer_provider_->GetResourceFormat(!tile->is_opaque()); |
1268 } | 1289 } |
1269 | 1290 |
1270 bool TileManager::DetermineResourceRequiresSwizzle(const Tile* tile) const { | 1291 bool TileManager::DetermineResourceRequiresSwizzle(const Tile* tile) const { |
1271 return raster_buffer_provider_->IsResourceSwizzleRequired(!tile->is_opaque()); | 1292 return raster_buffer_provider_->IsResourceSwizzleRequired(!tile->is_opaque()); |
1272 } | 1293 } |
1273 | 1294 |
1274 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> | 1295 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> |
1275 TileManager::ScheduledTasksStateAsValue() const { | 1296 TileManager::ScheduledTasksStateAsValue() const { |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1373 all_tile_tasks_completed = false; | 1394 all_tile_tasks_completed = false; |
1374 did_notify_all_tile_tasks_completed = false; | 1395 did_notify_all_tile_tasks_completed = false; |
1375 } | 1396 } |
1376 | 1397 |
1377 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule() = default; | 1398 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule() = default; |
1378 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule( | 1399 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule( |
1379 PrioritizedWorkToSchedule&& other) = default; | 1400 PrioritizedWorkToSchedule&& other) = default; |
1380 TileManager::PrioritizedWorkToSchedule::~PrioritizedWorkToSchedule() = default; | 1401 TileManager::PrioritizedWorkToSchedule::~PrioritizedWorkToSchedule() = default; |
1381 | 1402 |
1382 } // namespace cc | 1403 } // namespace cc |
OLD | NEW |