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 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
340 state->SetInteger("canceled_count", | 340 state->SetInteger("canceled_count", |
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 const TileManagerSettings& tile_manager_settings) |
351 bool check_tile_priority_inversion) | |
352 : client_(client), | 351 : client_(client), |
353 task_runner_(origin_task_runner), | 352 task_runner_(origin_task_runner), |
354 resource_pool_(nullptr), | 353 resource_pool_(nullptr), |
355 tile_task_manager_(nullptr), | 354 tile_task_manager_(nullptr), |
356 scheduled_raster_task_limit_(scheduled_raster_task_limit), | 355 scheduled_raster_task_limit_(scheduled_raster_task_limit), |
357 use_partial_raster_(use_partial_raster), | 356 tile_manager_settings_(tile_manager_settings), |
358 use_gpu_rasterization_(false), | 357 use_gpu_rasterization_(false), |
359 all_tiles_that_need_to_be_rasterized_are_scheduled_(true), | 358 all_tiles_that_need_to_be_rasterized_are_scheduled_(true), |
360 did_check_for_completed_tasks_since_last_schedule_tasks_(true), | 359 did_check_for_completed_tasks_since_last_schedule_tasks_(true), |
361 did_oom_on_last_assign_(false), | 360 did_oom_on_last_assign_(false), |
362 image_controller_(origin_task_runner, | 361 image_controller_(origin_task_runner, |
363 std::move(image_worker_task_runner)), | 362 std::move(image_worker_task_runner)), |
363 checker_image_tracker_(&image_controller_, | |
364 this, | |
365 tile_manager_settings_.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), |
374 check_tile_priority_inversion_(check_tile_priority_inversion), | |
375 task_set_finished_weak_ptr_factory_(this), | 376 task_set_finished_weak_ptr_factory_(this), |
376 ready_to_draw_callback_weak_ptr_factory_(this) {} | 377 ready_to_draw_callback_weak_ptr_factory_(this) {} |
377 | 378 |
378 TileManager::~TileManager() { | 379 TileManager::~TileManager() { |
379 FinishTasksAndCleanUp(); | 380 FinishTasksAndCleanUp(); |
380 } | 381 } |
381 | 382 |
382 void TileManager::FinishTasksAndCleanUp() { | 383 void TileManager::FinishTasksAndCleanUp() { |
383 if (!tile_task_manager_) | 384 if (!tile_task_manager_) |
384 return; | 385 return; |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
741 | 742 |
742 // Debugging to check that remaining tiles in the priority queue are not in | 743 // Debugging to check that remaining tiles in the priority queue are not in |
743 // the NOW bin and are required for neither activation nor draw. | 744 // the NOW bin and are required for neither activation nor draw. |
744 // This runs if the following conditions hold: | 745 // This runs if the following conditions hold: |
745 // - check_tile_priority_inversion has been enabled. | 746 // - check_tile_priority_inversion has been enabled. |
746 // - the loop above has processed all tiles that would be needed for any | 747 // - the loop above has processed all tiles that would be needed for any |
747 // signals to fire (that is, | 748 // signals to fire (that is, |
748 // all_tiles_that_need_to_be_rasterized_are_scheduled_ is true) | 749 // all_tiles_that_need_to_be_rasterized_are_scheduled_ is true) |
749 // - Memory limit policy allows for any tiles to be scheduled at all (ie it's | 750 // - Memory limit policy allows for any tiles to be scheduled at all (ie it's |
750 // not ALLOW_NOTHING). | 751 // not ALLOW_NOTHING). |
751 if (check_tile_priority_inversion_ && | 752 if (tile_manager_settings_.check_tile_priority_inversion && |
752 all_tiles_that_need_to_be_rasterized_are_scheduled_ && | 753 all_tiles_that_need_to_be_rasterized_are_scheduled_ && |
753 global_state_.memory_limit_policy != ALLOW_NOTHING) { | 754 global_state_.memory_limit_policy != ALLOW_NOTHING) { |
754 TilePriority::PriorityBin highest_bin_found = TilePriority::NOW; | 755 TilePriority::PriorityBin highest_bin_found = TilePriority::NOW; |
755 for (; !raster_priority_queue->IsEmpty(); raster_priority_queue->Pop()) { | 756 for (; !raster_priority_queue->IsEmpty(); raster_priority_queue->Pop()) { |
756 const PrioritizedTile& prioritized_tile = raster_priority_queue->Top(); | 757 const PrioritizedTile& prioritized_tile = raster_priority_queue->Top(); |
757 Tile* tile = prioritized_tile.tile(); | 758 Tile* tile = prioritized_tile.tile(); |
758 TilePriority priority = prioritized_tile.priority(); | 759 TilePriority priority = prioritized_tile.priority(); |
759 | 760 |
760 if (priority.priority_bin > highest_bin_found) | 761 if (priority.priority_bin > highest_bin_found) |
761 highest_bin_found = priority.priority_bin; | 762 highest_bin_found = priority.priority_bin; |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
896 InsertNodesForRasterTask(&graph_, task, task->dependencies(), priority++, | 897 InsertNodesForRasterTask(&graph_, task, task->dependencies(), priority++, |
897 use_foreground_category); | 898 use_foreground_category); |
898 } | 899 } |
899 | 900 |
900 const std::vector<PrioritizedTile>& tiles_to_process_for_images = | 901 const std::vector<PrioritizedTile>& tiles_to_process_for_images = |
901 work_to_schedule.tiles_to_process_for_images; | 902 work_to_schedule.tiles_to_process_for_images; |
902 std::vector<DrawImage> new_locked_images; | 903 std::vector<DrawImage> new_locked_images; |
903 for (const PrioritizedTile& prioritized_tile : tiles_to_process_for_images) { | 904 for (const PrioritizedTile& prioritized_tile : tiles_to_process_for_images) { |
904 Tile* tile = prioritized_tile.tile(); | 905 Tile* tile = prioritized_tile.tile(); |
905 | 906 |
907 // TODO(khushalsagar): Send these images to the ImageDecodeService, through | |
908 // the CheckerImageTracker as well. See crbug.com/686267. | |
vmpstr
2017/02/10 19:25:43
Can you file a different crbug for this? We also n
Khushal
2017/02/10 22:09:19
Done.
| |
906 std::vector<DrawImage> images; | 909 std::vector<DrawImage> images; |
907 prioritized_tile.raster_source()->GetDiscardableImagesInRect( | 910 prioritized_tile.raster_source()->GetDiscardableImagesInRect( |
908 tile->enclosing_layer_rect(), tile->contents_scale(), &images); | 911 tile->enclosing_layer_rect(), tile->contents_scale(), &images); |
909 new_locked_images.insert(new_locked_images.end(), images.begin(), | 912 new_locked_images.insert(new_locked_images.end(), images.begin(), |
910 images.end()); | 913 images.end()); |
911 } | 914 } |
912 | 915 |
913 // TODO(vmpstr): SOON is misleading here, but these images can come from | 916 // TODO(vmpstr): SOON is misleading here, but these images can come from |
914 // several diffent tiles. Rethink what we actually want to trace here. Note | 917 // several diffent tiles. Rethink what we actually want to trace here. Note |
915 // that I'm using SOON, since it can't be NOW (these are prepaint). | 918 // 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... | |
998 } | 1001 } |
999 | 1002 |
1000 // For LOW_RESOLUTION tiles, we don't draw or predecode images. | 1003 // For LOW_RESOLUTION tiles, we don't draw or predecode images. |
1001 RasterSource::PlaybackSettings playback_settings; | 1004 RasterSource::PlaybackSettings playback_settings; |
1002 playback_settings.skip_images = | 1005 playback_settings.skip_images = |
1003 prioritized_tile.priority().resolution == LOW_RESOLUTION; | 1006 prioritized_tile.priority().resolution == LOW_RESOLUTION; |
1004 | 1007 |
1005 // Create and queue all image decode tasks that this tile depends on. | 1008 // Create and queue all image decode tasks that this tile depends on. |
1006 TileTask::Vector decode_tasks; | 1009 TileTask::Vector decode_tasks; |
1007 std::vector<DrawImage>& images = scheduled_draw_images_[tile->id()]; | 1010 std::vector<DrawImage>& images = scheduled_draw_images_[tile->id()]; |
1011 std::unordered_set<ImageId>& images_to_skip = | |
1012 playback_settings.images_to_skip; | |
1013 images_to_skip.clear(); | |
vmpstr
2017/02/10 19:25:43
It better be empty already since we just created p
Khushal
2017/02/10 22:09:19
Empty variable it is.
While we're here, why do we
| |
1008 images.clear(); | 1014 images.clear(); |
1009 if (!playback_settings.skip_images) { | 1015 if (!playback_settings.skip_images) { |
1010 prioritized_tile.raster_source()->GetDiscardableImagesInRect( | 1016 prioritized_tile.raster_source()->GetDiscardableImagesInRect( |
1011 tile->enclosing_layer_rect(), tile->contents_scale(), &images); | 1017 tile->enclosing_layer_rect(), tile->contents_scale(), &images); |
1018 checker_image_tracker_.FilterImagesForCheckeringForTile( | |
vmpstr
2017/02/10 19:25:43
Hey cool, this is like std::partition... kind of.
Khushal
2017/02/10 22:09:19
Yeah. Much neat now.
| |
1019 &images, &images_to_skip, prioritized_tile.tile()->tiling()->tree()); | |
1012 } | 1020 } |
1013 | 1021 |
1014 // We can skip the image hijack canvas if we have no images. | 1022 // We can skip the image hijack canvas if we have no images, or no images to |
1015 playback_settings.use_image_hijack_canvas = !images.empty(); | 1023 // skip during raster. |
1024 playback_settings.use_image_hijack_canvas = | |
1025 !images.empty() || !images_to_skip.empty(); | |
1016 | 1026 |
1017 // Get the tasks for the required images. | 1027 // Get the tasks for the required images. |
1018 ImageDecodeCache::TracingInfo tracing_info( | 1028 ImageDecodeCache::TracingInfo tracing_info( |
1019 prepare_tiles_count_, prioritized_tile.priority().priority_bin); | 1029 prepare_tiles_count_, prioritized_tile.priority().priority_bin); |
1020 image_controller_.GetTasksForImagesAndRef(&images, &decode_tasks, | 1030 image_controller_.GetTasksForImagesAndRef(&images, &decode_tasks, |
1021 tracing_info); | 1031 tracing_info); |
1022 | 1032 |
1023 std::unique_ptr<RasterBuffer> raster_buffer = | 1033 std::unique_ptr<RasterBuffer> raster_buffer = |
1024 raster_buffer_provider_->AcquireBufferForRaster( | 1034 raster_buffer_provider_->AcquireBufferForRaster( |
1025 resource, resource_content_id, tile->invalidated_id()); | 1035 resource, resource_content_id, tile->invalidated_id()); |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1272 // Mark required tiles as OOM so that we can activate/draw without them. | 1282 // Mark required tiles as OOM so that we can activate/draw without them. |
1273 for (; !queue->IsEmpty(); queue->Pop()) { | 1283 for (; !queue->IsEmpty(); queue->Pop()) { |
1274 Tile* tile = queue->Top().tile(); | 1284 Tile* tile = queue->Top().tile(); |
1275 if (tile->draw_info().IsReadyToDraw()) | 1285 if (tile->draw_info().IsReadyToDraw()) |
1276 continue; | 1286 continue; |
1277 tile->draw_info().set_oom(); | 1287 tile->draw_info().set_oom(); |
1278 client_->NotifyTileStateChanged(tile); | 1288 client_->NotifyTileStateChanged(tile); |
1279 } | 1289 } |
1280 } | 1290 } |
1281 | 1291 |
1292 const std::unordered_set<ImageId>& | |
1293 TileManager::TakeImagesToInvalidateOnSyncTree() { | |
1294 return checker_image_tracker_.TakeImagesToInvalidateOnSyncTree(); | |
1295 } | |
1296 | |
1297 void TileManager::DidActivateSyncTree() { | |
1298 checker_image_tracker_.DidActivateSyncTree(); | |
1299 } | |
1300 | |
1301 void TileManager::NeedsInvalidationForCheckerImagedTiles() { | |
1302 client_->RequestImplSideInvalidation(); | |
1303 } | |
1304 | |
1282 ResourceFormat TileManager::DetermineResourceFormat(const Tile* tile) const { | 1305 ResourceFormat TileManager::DetermineResourceFormat(const Tile* tile) const { |
1283 return raster_buffer_provider_->GetResourceFormat(!tile->is_opaque()); | 1306 return raster_buffer_provider_->GetResourceFormat(!tile->is_opaque()); |
1284 } | 1307 } |
1285 | 1308 |
1286 bool TileManager::DetermineResourceRequiresSwizzle(const Tile* tile) const { | 1309 bool TileManager::DetermineResourceRequiresSwizzle(const Tile* tile) const { |
1287 return raster_buffer_provider_->IsResourceSwizzleRequired(!tile->is_opaque()); | 1310 return raster_buffer_provider_->IsResourceSwizzleRequired(!tile->is_opaque()); |
1288 } | 1311 } |
1289 | 1312 |
1290 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> | 1313 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> |
1291 TileManager::ScheduledTasksStateAsValue() const { | 1314 TileManager::ScheduledTasksStateAsValue() const { |
1292 std::unique_ptr<base::trace_event::TracedValue> state( | 1315 std::unique_ptr<base::trace_event::TracedValue> state( |
1293 new base::trace_event::TracedValue()); | 1316 new base::trace_event::TracedValue()); |
1294 state->BeginDictionary("tasks_pending"); | 1317 state->BeginDictionary("tasks_pending"); |
1295 state->SetBoolean("ready_to_activate", signals_.ready_to_activate); | 1318 state->SetBoolean("ready_to_activate", signals_.ready_to_activate); |
1296 state->SetBoolean("ready_to_draw", signals_.ready_to_draw); | 1319 state->SetBoolean("ready_to_draw", signals_.ready_to_draw); |
1297 state->SetBoolean("all_tile_tasks_completed", | 1320 state->SetBoolean("all_tile_tasks_completed", |
1298 signals_.all_tile_tasks_completed); | 1321 signals_.all_tile_tasks_completed); |
1299 state->EndDictionary(); | 1322 state->EndDictionary(); |
1300 return std::move(state); | 1323 return std::move(state); |
1301 } | 1324 } |
1302 | 1325 |
1303 bool TileManager::UsePartialRaster() const { | 1326 bool TileManager::UsePartialRaster() const { |
1304 return use_partial_raster_ && | 1327 return tile_manager_settings_.use_partial_raster && |
1305 raster_buffer_provider_->CanPartialRasterIntoProvidedResource(); | 1328 raster_buffer_provider_->CanPartialRasterIntoProvidedResource(); |
1306 } | 1329 } |
1307 | 1330 |
1308 void TileManager::CheckPendingGpuWorkTiles(bool issue_signals) { | 1331 void TileManager::CheckPendingGpuWorkTiles(bool issue_signals) { |
1309 ResourceProvider::ResourceIdArray required_for_activation_ids; | 1332 ResourceProvider::ResourceIdArray required_for_activation_ids; |
1310 ResourceProvider::ResourceIdArray required_for_draw_ids; | 1333 ResourceProvider::ResourceIdArray required_for_draw_ids; |
1311 | 1334 |
1312 for (auto it = pending_gpu_work_tiles_.begin(); | 1335 for (auto it = pending_gpu_work_tiles_.begin(); |
1313 it != pending_gpu_work_tiles_.end();) { | 1336 it != pending_gpu_work_tiles_.end();) { |
1314 Tile* tile = *it; | 1337 Tile* tile = *it; |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1455 all_tile_tasks_completed = false; | 1478 all_tile_tasks_completed = false; |
1456 did_notify_all_tile_tasks_completed = false; | 1479 did_notify_all_tile_tasks_completed = false; |
1457 } | 1480 } |
1458 | 1481 |
1459 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule() = default; | 1482 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule() = default; |
1460 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule( | 1483 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule( |
1461 PrioritizedWorkToSchedule&& other) = default; | 1484 PrioritizedWorkToSchedule&& other) = default; |
1462 TileManager::PrioritizedWorkToSchedule::~PrioritizedWorkToSchedule() = default; | 1485 TileManager::PrioritizedWorkToSchedule::~PrioritizedWorkToSchedule() = default; |
1463 | 1486 |
1464 } // namespace cc | 1487 } // namespace cc |
OLD | NEW |