| 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 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 more_tiles_need_prepare_check_notifier_( | 359 more_tiles_need_prepare_check_notifier_( |
| 360 task_runner_, | 360 task_runner_, |
| 361 base::Bind(&TileManager::CheckIfMoreTilesNeedToBePrepared, | 361 base::Bind(&TileManager::CheckIfMoreTilesNeedToBePrepared, |
| 362 base::Unretained(this))), | 362 base::Unretained(this))), |
| 363 signals_check_notifier_(task_runner_, | 363 signals_check_notifier_(task_runner_, |
| 364 base::Bind(&TileManager::CheckAndIssueSignals, | 364 base::Bind(&TileManager::CheckAndIssueSignals, |
| 365 base::Unretained(this))), | 365 base::Unretained(this))), |
| 366 has_scheduled_tile_tasks_(false), | 366 has_scheduled_tile_tasks_(false), |
| 367 prepare_tiles_count_(0u), | 367 prepare_tiles_count_(0u), |
| 368 next_tile_id_(0u), | 368 next_tile_id_(0u), |
| 369 task_set_finished_weak_ptr_factory_(this) {} | 369 task_set_finished_weak_ptr_factory_(this), |
| 370 weak_ptr_factory_(this) {} |
| 370 | 371 |
| 371 TileManager::~TileManager() { | 372 TileManager::~TileManager() { |
| 372 FinishTasksAndCleanUp(); | 373 FinishTasksAndCleanUp(); |
| 373 } | 374 } |
| 374 | 375 |
| 375 void TileManager::FinishTasksAndCleanUp() { | 376 void TileManager::FinishTasksAndCleanUp() { |
| 376 if (!tile_task_manager_) | 377 if (!tile_task_manager_) |
| 377 return; | 378 return; |
| 378 | 379 |
| 379 global_state_ = GlobalStateThatImpactsTilePriority(); | 380 global_state_ = GlobalStateThatImpactsTilePriority(); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 released_tiles_.swap(tiles_to_retain); | 443 released_tiles_.swap(tiles_to_retain); |
| 443 } | 444 } |
| 444 | 445 |
| 445 void TileManager::DidFinishRunningTileTasksRequiredForActivation() { | 446 void TileManager::DidFinishRunningTileTasksRequiredForActivation() { |
| 446 TRACE_EVENT0("cc", | 447 TRACE_EVENT0("cc", |
| 447 "TileManager::DidFinishRunningTileTasksRequiredForActivation"); | 448 "TileManager::DidFinishRunningTileTasksRequiredForActivation"); |
| 448 TRACE_EVENT_ASYNC_STEP_INTO1("cc", "ScheduledTasks", this, "running", "state", | 449 TRACE_EVENT_ASYNC_STEP_INTO1("cc", "ScheduledTasks", this, "running", "state", |
| 449 ScheduledTasksStateAsValue()); | 450 ScheduledTasksStateAsValue()); |
| 450 // TODO(vmpstr): Temporary check to debug crbug.com/642927. | 451 // TODO(vmpstr): Temporary check to debug crbug.com/642927. |
| 451 CHECK(tile_task_manager_); | 452 CHECK(tile_task_manager_); |
| 453 |
| 452 signals_.ready_to_activate = true; | 454 signals_.ready_to_activate = true; |
| 453 signals_check_notifier_.Schedule(); | 455 signals_check_notifier_.Schedule(); |
| 454 } | 456 } |
| 455 | 457 |
| 456 void TileManager::DidFinishRunningTileTasksRequiredForDraw() { | 458 void TileManager::DidFinishRunningTileTasksRequiredForDraw() { |
| 457 TRACE_EVENT0("cc", "TileManager::DidFinishRunningTileTasksRequiredForDraw"); | 459 TRACE_EVENT0("cc", "TileManager::DidFinishRunningTileTasksRequiredForDraw"); |
| 458 TRACE_EVENT_ASYNC_STEP_INTO1("cc", "ScheduledTasks", this, "running", "state", | 460 TRACE_EVENT_ASYNC_STEP_INTO1("cc", "ScheduledTasks", this, "running", "state", |
| 459 ScheduledTasksStateAsValue()); | 461 ScheduledTasksStateAsValue()); |
| 460 // TODO(vmpstr): Temporary check to debug crbug.com/642927. | 462 // TODO(vmpstr): Temporary check to debug crbug.com/642927. |
| 461 CHECK(tile_task_manager_); | 463 CHECK(tile_task_manager_); |
| 464 |
| 462 signals_.ready_to_draw = true; | 465 signals_.ready_to_draw = true; |
| 463 signals_check_notifier_.Schedule(); | 466 signals_check_notifier_.Schedule(); |
| 464 } | 467 } |
| 465 | 468 |
| 466 void TileManager::DidFinishRunningAllTileTasks() { | 469 void TileManager::DidFinishRunningAllTileTasks() { |
| 467 TRACE_EVENT0("cc", "TileManager::DidFinishRunningAllTileTasks"); | 470 TRACE_EVENT0("cc", "TileManager::DidFinishRunningAllTileTasks"); |
| 468 TRACE_EVENT_ASYNC_END0("cc", "ScheduledTasks", this); | 471 TRACE_EVENT_ASYNC_END0("cc", "ScheduledTasks", this); |
| 469 DCHECK(resource_pool_); | 472 DCHECK(resource_pool_); |
| 470 DCHECK(tile_task_manager_); | 473 DCHECK(tile_task_manager_); |
| 471 | 474 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 TRACE_EVENT0("cc", "TileManager::Flush"); | 535 TRACE_EVENT0("cc", "TileManager::Flush"); |
| 533 | 536 |
| 534 if (!tile_task_manager_) { | 537 if (!tile_task_manager_) { |
| 535 TRACE_EVENT_INSTANT0("cc", "Flush aborted", TRACE_EVENT_SCOPE_THREAD); | 538 TRACE_EVENT_INSTANT0("cc", "Flush aborted", TRACE_EVENT_SCOPE_THREAD); |
| 536 return; | 539 return; |
| 537 } | 540 } |
| 538 | 541 |
| 539 tile_task_manager_->CheckForCompletedTasks(); | 542 tile_task_manager_->CheckForCompletedTasks(); |
| 540 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; | 543 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; |
| 541 | 544 |
| 545 CheckRequiredForActivationTilesReadyToDraw(); |
| 546 CheckRequiredForDrawTilesReadyToDraw(); |
| 547 |
| 542 TRACE_EVENT_INSTANT1("cc", "DidFlush", TRACE_EVENT_SCOPE_THREAD, "stats", | 548 TRACE_EVENT_INSTANT1("cc", "DidFlush", TRACE_EVENT_SCOPE_THREAD, "stats", |
| 543 RasterTaskCompletionStatsAsValue(flush_stats_)); | 549 RasterTaskCompletionStatsAsValue(flush_stats_)); |
| 544 flush_stats_ = RasterTaskCompletionStats(); | 550 flush_stats_ = RasterTaskCompletionStats(); |
| 545 } | 551 } |
| 546 | 552 |
| 547 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> | 553 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> |
| 548 TileManager::BasicStateAsValue() const { | 554 TileManager::BasicStateAsValue() const { |
| 549 std::unique_ptr<base::trace_event::TracedValue> value( | 555 std::unique_ptr<base::trace_event::TracedValue> value( |
| 550 new base::trace_event::TracedValue()); | 556 new base::trace_event::TracedValue()); |
| 551 BasicStateAsValueInto(value.get()); | 557 BasicStateAsValueInto(value.get()); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 all_tiles_that_need_to_be_rasterized_are_scheduled_ = true; | 649 all_tiles_that_need_to_be_rasterized_are_scheduled_ = true; |
| 644 bool had_enough_memory_to_schedule_tiles_needed_now = true; | 650 bool had_enough_memory_to_schedule_tiles_needed_now = true; |
| 645 | 651 |
| 646 MemoryUsage hard_memory_limit(global_state_.hard_memory_limit_in_bytes, | 652 MemoryUsage hard_memory_limit(global_state_.hard_memory_limit_in_bytes, |
| 647 global_state_.num_resources_limit); | 653 global_state_.num_resources_limit); |
| 648 MemoryUsage soft_memory_limit(global_state_.soft_memory_limit_in_bytes, | 654 MemoryUsage soft_memory_limit(global_state_.soft_memory_limit_in_bytes, |
| 649 global_state_.num_resources_limit); | 655 global_state_.num_resources_limit); |
| 650 MemoryUsage memory_usage(resource_pool_->memory_usage_bytes(), | 656 MemoryUsage memory_usage(resource_pool_->memory_usage_bytes(), |
| 651 resource_pool_->resource_count()); | 657 resource_pool_->resource_count()); |
| 652 | 658 |
| 659 pending_required_for_activation_tiles_.clear(); |
| 660 pending_required_for_draw_tiles_.clear(); |
| 661 |
| 653 std::unique_ptr<RasterTilePriorityQueue> raster_priority_queue( | 662 std::unique_ptr<RasterTilePriorityQueue> raster_priority_queue( |
| 654 client_->BuildRasterQueue(global_state_.tree_priority, | 663 client_->BuildRasterQueue(global_state_.tree_priority, |
| 655 RasterTilePriorityQueue::Type::ALL)); | 664 RasterTilePriorityQueue::Type::ALL)); |
| 656 std::unique_ptr<EvictionTilePriorityQueue> eviction_priority_queue; | 665 std::unique_ptr<EvictionTilePriorityQueue> eviction_priority_queue; |
| 657 PrioritizedWorkToSchedule work_to_schedule; | 666 PrioritizedWorkToSchedule work_to_schedule; |
| 658 for (; !raster_priority_queue->IsEmpty(); raster_priority_queue->Pop()) { | 667 for (; !raster_priority_queue->IsEmpty(); raster_priority_queue->Pop()) { |
| 659 const PrioritizedTile& prioritized_tile = raster_priority_queue->Top(); | 668 const PrioritizedTile& prioritized_tile = raster_priority_queue->Top(); |
| 660 Tile* tile = prioritized_tile.tile(); | 669 Tile* tile = prioritized_tile.tile(); |
| 661 TilePriority priority = prioritized_tile.priority(); | 670 TilePriority priority = prioritized_tile.priority(); |
| 662 | 671 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 689 } | 698 } |
| 690 } | 699 } |
| 691 | 700 |
| 692 // Prepaint tiles that are far away are only processed for images. | 701 // Prepaint tiles that are far away are only processed for images. |
| 693 if (!tile->required_for_activation() && !tile->required_for_draw() && | 702 if (!tile->required_for_activation() && !tile->required_for_draw() && |
| 694 prioritized_tile.is_process_for_images_only()) { | 703 prioritized_tile.is_process_for_images_only()) { |
| 695 work_to_schedule.tiles_to_process_for_images.push_back(prioritized_tile); | 704 work_to_schedule.tiles_to_process_for_images.push_back(prioritized_tile); |
| 696 continue; | 705 continue; |
| 697 } | 706 } |
| 698 | 707 |
| 708 if (tile->required_for_activation()) |
| 709 pending_required_for_activation_tiles_.push_back(tile); |
| 710 |
| 711 if (tile->required_for_draw()) |
| 712 pending_required_for_draw_tiles_.push_back(tile); |
| 713 |
| 714 // If tile already has a resource then its raster task has completed but |
| 715 // we're still waiting on raster to complete on the service side. |
| 716 // TODO(sunnyps): Mark such tiles as ready to draw if not in smoothness |
| 717 // takes priority mode. |
| 718 if (tile->draw_info().has_resource()) { |
| 719 continue; |
| 720 } |
| 721 |
| 699 // We won't be able to schedule this tile, so break out early. | 722 // We won't be able to schedule this tile, so break out early. |
| 700 if (work_to_schedule.tiles_to_raster.size() >= | 723 if (work_to_schedule.tiles_to_raster.size() >= |
| 701 scheduled_raster_task_limit_) { | 724 scheduled_raster_task_limit_) { |
| 702 all_tiles_that_need_to_be_rasterized_are_scheduled_ = false; | 725 all_tiles_that_need_to_be_rasterized_are_scheduled_ = false; |
| 703 break; | 726 break; |
| 704 } | 727 } |
| 705 | 728 |
| 706 tile->scheduled_priority_ = schedule_priority++; | 729 tile->scheduled_priority_ = schedule_priority++; |
| 707 | 730 |
| 708 DCHECK(tile->draw_info().mode() == TileDrawInfo::OOM_MODE || | 731 DCHECK(tile->draw_info().mode() == TileDrawInfo::OOM_MODE || |
| 709 !tile->draw_info().IsReadyToDraw()); | 732 !tile->draw_info().IsReadyToDraw()); |
| 710 | 733 |
| 711 // If the tile already has a raster_task, then the memory used by it is | 734 // If the tile already has a raster_task, then the memory used by it is |
| 712 // already accounted for in memory_usage. Otherwise, we'll have to acquire | 735 // already accounted for in memory_usage. Otherwise, we'll have to acquire |
| 713 // more memory to create a raster task. | 736 // more memory to create a raster task. |
| 714 MemoryUsage memory_required_by_tile_to_be_scheduled; | 737 MemoryUsage memory_required_by_tile_to_be_scheduled; |
| 715 if (!tile->raster_task_.get()) { | 738 if (!tile->raster_task_) { |
| 716 memory_required_by_tile_to_be_scheduled = MemoryUsage::FromConfig( | 739 memory_required_by_tile_to_be_scheduled = MemoryUsage::FromConfig( |
| 717 tile->desired_texture_size(), DetermineResourceFormat(tile)); | 740 tile->desired_texture_size(), DetermineResourceFormat(tile)); |
| 718 } | 741 } |
| 719 | 742 |
| 720 // This is the memory limit that will be used by this tile. Depending on | 743 // This is the memory limit that will be used by this tile. Depending on |
| 721 // the tile priority, it will be one of hard_memory_limit or | 744 // the tile priority, it will be one of hard_memory_limit or |
| 722 // soft_memory_limit. | 745 // soft_memory_limit. |
| 723 MemoryUsage& tile_memory_limit = | 746 MemoryUsage& tile_memory_limit = |
| 724 tile_is_needed_now ? hard_memory_limit : soft_memory_limit; | 747 tile_is_needed_now ? hard_memory_limit : soft_memory_limit; |
| 725 | 748 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 767 memory_stats_from_last_assign_.total_bytes_used = memory_usage.memory_bytes(); | 790 memory_stats_from_last_assign_.total_bytes_used = memory_usage.memory_bytes(); |
| 768 DCHECK_GE(memory_stats_from_last_assign_.total_bytes_used, 0); | 791 DCHECK_GE(memory_stats_from_last_assign_.total_bytes_used, 0); |
| 769 memory_stats_from_last_assign_.had_enough_memory = | 792 memory_stats_from_last_assign_.had_enough_memory = |
| 770 had_enough_memory_to_schedule_tiles_needed_now; | 793 had_enough_memory_to_schedule_tiles_needed_now; |
| 771 | 794 |
| 772 TRACE_EVENT_END2("cc", "TileManager::AssignGpuMemoryToTiles", | 795 TRACE_EVENT_END2("cc", "TileManager::AssignGpuMemoryToTiles", |
| 773 "all_tiles_that_need_to_be_rasterized_are_scheduled", | 796 "all_tiles_that_need_to_be_rasterized_are_scheduled", |
| 774 all_tiles_that_need_to_be_rasterized_are_scheduled_, | 797 all_tiles_that_need_to_be_rasterized_are_scheduled_, |
| 775 "had_enough_memory_to_schedule_tiles_needed_now", | 798 "had_enough_memory_to_schedule_tiles_needed_now", |
| 776 had_enough_memory_to_schedule_tiles_needed_now); | 799 had_enough_memory_to_schedule_tiles_needed_now); |
| 800 |
| 777 return work_to_schedule; | 801 return work_to_schedule; |
| 778 } | 802 } |
| 779 | 803 |
| 780 void TileManager::FreeResourcesForTile(Tile* tile) { | 804 void TileManager::FreeResourcesForTile(Tile* tile) { |
| 781 TileDrawInfo& draw_info = tile->draw_info(); | 805 TileDrawInfo& draw_info = tile->draw_info(); |
| 782 if (draw_info.resource_) { | 806 if (draw_info.has_resource()) { |
| 783 resource_pool_->ReleaseResource(draw_info.resource_); | 807 resource_pool_->ReleaseResource(draw_info.resource()); |
| 784 draw_info.resource_ = nullptr; | 808 draw_info.set_resource(nullptr); |
| 809 draw_info.set_ready_to_draw(false); |
| 785 } | 810 } |
| 786 } | 811 } |
| 787 | 812 |
| 788 void TileManager::FreeResourcesForTileAndNotifyClientIfTileWasReadyToDraw( | 813 void TileManager::FreeResourcesForTileAndNotifyClientIfTileWasReadyToDraw( |
| 789 Tile* tile) { | 814 Tile* tile) { |
| 790 bool was_ready_to_draw = tile->draw_info().IsReadyToDraw(); | 815 bool was_ready_to_draw = tile->draw_info().IsReadyToDraw(); |
| 791 FreeResourcesForTile(tile); | 816 FreeResourcesForTile(tile); |
| 792 if (was_ready_to_draw) | 817 if (was_ready_to_draw) |
| 793 client_->NotifyTileStateChanged(tile); | 818 client_->NotifyTileStateChanged(tile); |
| 794 } | 819 } |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 969 | 994 |
| 970 if (resource) { | 995 if (resource) { |
| 971 resource_content_id = tile->invalidated_id(); | 996 resource_content_id = tile->invalidated_id(); |
| 972 DCHECK_EQ(DetermineResourceFormat(tile), resource->format()); | 997 DCHECK_EQ(DetermineResourceFormat(tile), resource->format()); |
| 973 } else { | 998 } else { |
| 974 resource = resource_pool_->AcquireResource(tile->desired_texture_size(), | 999 resource = resource_pool_->AcquireResource(tile->desired_texture_size(), |
| 975 DetermineResourceFormat(tile), | 1000 DetermineResourceFormat(tile), |
| 976 color_space); | 1001 color_space); |
| 977 } | 1002 } |
| 978 | 1003 |
| 1004 tile->draw_info().set_use_resource(); |
| 1005 DCHECK(!tile->draw_info().IsReadyToDraw()); |
| 1006 |
| 979 // For LOW_RESOLUTION tiles, we don't draw or predecode images. | 1007 // For LOW_RESOLUTION tiles, we don't draw or predecode images. |
| 980 RasterSource::PlaybackSettings playback_settings; | 1008 RasterSource::PlaybackSettings playback_settings; |
| 981 playback_settings.skip_images = | 1009 playback_settings.skip_images = |
| 982 prioritized_tile.priority().resolution == LOW_RESOLUTION; | 1010 prioritized_tile.priority().resolution == LOW_RESOLUTION; |
| 983 | 1011 |
| 984 // Create and queue all image decode tasks that this tile depends on. | 1012 // Create and queue all image decode tasks that this tile depends on. |
| 985 TileTask::Vector decode_tasks; | 1013 TileTask::Vector decode_tasks; |
| 986 std::vector<DrawImage>& images = scheduled_draw_images_[tile->id()]; | 1014 std::vector<DrawImage>& images = scheduled_draw_images_[tile->id()]; |
| 987 images.clear(); | 1015 images.clear(); |
| 988 if (!playback_settings.skip_images) { | 1016 if (!playback_settings.skip_images) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1009 use_gpu_rasterization_)); | 1037 use_gpu_rasterization_)); |
| 1010 } | 1038 } |
| 1011 | 1039 |
| 1012 void TileManager::OnRasterTaskCompleted( | 1040 void TileManager::OnRasterTaskCompleted( |
| 1013 std::unique_ptr<RasterBuffer> raster_buffer, | 1041 std::unique_ptr<RasterBuffer> raster_buffer, |
| 1014 Tile* tile, | 1042 Tile* tile, |
| 1015 Resource* resource, | 1043 Resource* resource, |
| 1016 bool was_canceled) { | 1044 bool was_canceled) { |
| 1017 DCHECK(tile); | 1045 DCHECK(tile); |
| 1018 DCHECK(tiles_.find(tile->id()) != tiles_.end()); | 1046 DCHECK(tiles_.find(tile->id()) != tiles_.end()); |
| 1047 |
| 1048 TRACE_EVENT1("cc", "TileManager::OnRasterTaskCompleted", "tile_id", |
| 1049 tile->id()); |
| 1050 |
| 1019 raster_buffer_provider_->ReleaseBufferForRaster(std::move(raster_buffer)); | 1051 raster_buffer_provider_->ReleaseBufferForRaster(std::move(raster_buffer)); |
| 1020 | 1052 |
| 1021 TileDrawInfo& draw_info = tile->draw_info(); | 1053 DCHECK(tile->raster_task_); |
| 1022 DCHECK(tile->raster_task_.get()); | 1054 orphan_tasks_.push_back(std::move(tile->raster_task_)); |
| 1023 tile->raster_task_ = nullptr; | |
| 1024 | 1055 |
| 1025 // Unref all the images. | 1056 // Unref all the images. |
| 1026 auto images_it = scheduled_draw_images_.find(tile->id()); | 1057 auto images_it = scheduled_draw_images_.find(tile->id()); |
| 1027 image_controller_.UnrefImages(images_it->second); | 1058 image_controller_.UnrefImages(images_it->second); |
| 1028 scheduled_draw_images_.erase(images_it); | 1059 scheduled_draw_images_.erase(images_it); |
| 1029 | 1060 |
| 1030 if (was_canceled) { | 1061 if (was_canceled) { |
| 1031 ++flush_stats_.canceled_count; | 1062 ++flush_stats_.canceled_count; |
| 1032 resource_pool_->ReleaseResource(resource); | 1063 resource_pool_->ReleaseResource(resource); |
| 1033 return; | 1064 return; |
| 1034 } | 1065 } |
| 1035 | 1066 |
| 1036 resource_pool_->OnContentReplaced(resource->id(), tile->id()); | 1067 resource_pool_->OnContentReplaced(resource->id(), tile->id()); |
| 1037 ++flush_stats_.completed_count; | 1068 ++flush_stats_.completed_count; |
| 1038 | 1069 |
| 1039 draw_info.set_use_resource(); | 1070 TileDrawInfo& draw_info = tile->draw_info(); |
| 1040 draw_info.resource_ = resource; | 1071 draw_info.set_resource(resource); |
| 1041 draw_info.contents_swizzled_ = DetermineResourceRequiresSwizzle(tile); | 1072 draw_info.set_contents_swizzled(DetermineResourceRequiresSwizzle(tile)); |
| 1073 } |
| 1042 | 1074 |
| 1043 DCHECK(draw_info.IsReadyToDraw()); | 1075 void TileManager::OnRequiredForActivationTilesReadyToDraw() { |
| 1076 signals_.ready_to_activate = true; |
| 1077 signals_check_notifier_.Schedule(); |
| 1078 } |
| 1079 |
| 1080 void TileManager::OnRequiredForDrawTilesReadyToDraw() { |
| 1081 signals_.ready_to_draw = true; |
| 1082 signals_check_notifier_.Schedule(); |
| 1083 } |
| 1084 |
| 1085 void TileManager::CheckRequiredForActivationTilesReadyToDraw() { |
| 1086 std::vector<Tile*> pending_tiles; |
| 1087 for (Tile* tile : pending_required_for_activation_tiles_) { |
| 1088 const Resource* resource = tile->draw_info().resource(); |
| 1089 if (resource && raster_buffer_provider_->IsResourceReadyToDraw(resource)) { |
| 1090 OnTileReadyToDraw(tile); |
| 1091 } else { |
| 1092 pending_tiles.push_back(tile); |
| 1093 } |
| 1094 } |
| 1095 pending_required_for_activation_tiles_.swap(pending_tiles); |
| 1096 |
| 1097 std::vector<const Resource*> resources; |
| 1098 for (Tile* tile : pending_required_for_activation_tiles_) { |
| 1099 const Resource* resource = tile->draw_info().resource(); |
| 1100 if (resource) |
| 1101 resources.push_back(resource); |
| 1102 } |
| 1103 |
| 1104 if (!resources.empty()) { |
| 1105 raster_buffer_provider_->SignalResourcesReadyToDraw( |
| 1106 resources, |
| 1107 base::Bind(&TileManager::OnRequiredForActivationTilesReadyToDraw, |
| 1108 weak_ptr_factory_.GetWeakPtr())); |
| 1109 } |
| 1110 } |
| 1111 |
| 1112 void TileManager::CheckRequiredForDrawTilesReadyToDraw() { |
| 1113 std::vector<Tile*> pending_tiles; |
| 1114 for (Tile* tile : pending_required_for_draw_tiles_) { |
| 1115 const Resource* resource = tile->draw_info().resource(); |
| 1116 if (resource && raster_buffer_provider_->IsResourceReadyToDraw(resource)) { |
| 1117 OnTileReadyToDraw(tile); |
| 1118 } else { |
| 1119 pending_tiles.push_back(tile); |
| 1120 } |
| 1121 } |
| 1122 pending_required_for_draw_tiles_.swap(pending_tiles); |
| 1123 |
| 1124 std::vector<const Resource*> resources; |
| 1125 for (Tile* tile : pending_required_for_activation_tiles_) { |
| 1126 const Resource* resource = tile->draw_info().resource(); |
| 1127 if (resource) |
| 1128 resources.push_back(resource); |
| 1129 } |
| 1130 |
| 1131 if (!resources.empty()) { |
| 1132 raster_buffer_provider_->SignalResourcesReadyToDraw( |
| 1133 resources, base::Bind(&TileManager::OnRequiredForDrawTilesReadyToDraw, |
| 1134 weak_ptr_factory_.GetWeakPtr())); |
| 1135 } |
| 1136 } |
| 1137 |
| 1138 void TileManager::OnTileReadyToDraw(Tile* tile) { |
| 1139 TRACE_EVENT1("cc", "TileManager::OnTileReadyToDraw", "tile_id", tile->id()); |
| 1140 |
| 1141 TileDrawInfo& draw_info = tile->draw_info(); |
| 1142 if (draw_info.IsReadyToDraw()) |
| 1143 return; |
| 1144 |
| 1145 DCHECK_EQ(TileDrawInfo::RESOURCE_MODE, draw_info.mode()); |
| 1146 DCHECK(draw_info.has_resource()); |
| 1147 draw_info.set_ready_to_draw(true); |
| 1044 draw_info.set_was_ever_ready_to_draw(); | 1148 draw_info.set_was_ever_ready_to_draw(); |
| 1045 | 1149 |
| 1046 client_->NotifyTileStateChanged(tile); | 1150 client_->NotifyTileStateChanged(tile); |
| 1047 } | 1151 } |
| 1048 | 1152 |
| 1049 ScopedTilePtr TileManager::CreateTile(const Tile::CreateInfo& info, | 1153 ScopedTilePtr TileManager::CreateTile(const Tile::CreateInfo& info, |
| 1050 int layer_id, | 1154 int layer_id, |
| 1051 int source_frame_number, | 1155 int source_frame_number, |
| 1052 int flags) { | 1156 int flags) { |
| 1053 // We need to have a tile task worker pool to do anything meaningful with | 1157 // We need to have a tile task worker pool to do anything meaningful with |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1100 } | 1204 } |
| 1101 | 1205 |
| 1102 void TileManager::CheckAndIssueSignals() { | 1206 void TileManager::CheckAndIssueSignals() { |
| 1103 TRACE_EVENT0("cc", "TileManager::CheckAndIssueSignals"); | 1207 TRACE_EVENT0("cc", "TileManager::CheckAndIssueSignals"); |
| 1104 tile_task_manager_->CheckForCompletedTasks(); | 1208 tile_task_manager_->CheckForCompletedTasks(); |
| 1105 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; | 1209 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; |
| 1106 | 1210 |
| 1107 // Ready to activate. | 1211 // Ready to activate. |
| 1108 if (signals_.ready_to_activate && !signals_.did_notify_ready_to_activate) { | 1212 if (signals_.ready_to_activate && !signals_.did_notify_ready_to_activate) { |
| 1109 signals_.ready_to_activate = false; | 1213 signals_.ready_to_activate = false; |
| 1214 CheckRequiredForActivationTilesReadyToDraw(); |
| 1110 if (IsReadyToActivate()) { | 1215 if (IsReadyToActivate()) { |
| 1111 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"), | 1216 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"), |
| 1112 "TileManager::CheckAndIssueSignals - ready to activate"); | 1217 "TileManager::CheckAndIssueSignals - ready to activate"); |
| 1113 signals_.did_notify_ready_to_activate = true; | 1218 signals_.did_notify_ready_to_activate = true; |
| 1114 client_->NotifyReadyToActivate(); | 1219 client_->NotifyReadyToActivate(); |
| 1115 } | 1220 } |
| 1116 } | 1221 } |
| 1117 | 1222 |
| 1118 // Ready to draw. | 1223 // Ready to draw. |
| 1119 if (signals_.ready_to_draw && !signals_.did_notify_ready_to_draw) { | 1224 if (signals_.ready_to_draw && !signals_.did_notify_ready_to_draw) { |
| 1120 signals_.ready_to_draw = false; | 1225 signals_.ready_to_draw = false; |
| 1226 CheckRequiredForDrawTilesReadyToDraw(); |
| 1121 if (IsReadyToDraw()) { | 1227 if (IsReadyToDraw()) { |
| 1122 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"), | 1228 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"), |
| 1123 "TileManager::CheckAndIssueSignals - ready to draw"); | 1229 "TileManager::CheckAndIssueSignals - ready to draw"); |
| 1124 signals_.did_notify_ready_to_draw = true; | 1230 signals_.did_notify_ready_to_draw = true; |
| 1125 client_->NotifyReadyToDraw(); | 1231 client_->NotifyReadyToDraw(); |
| 1126 } | 1232 } |
| 1127 } | 1233 } |
| 1128 | 1234 |
| 1129 // All tile tasks completed. | 1235 // All tile tasks completed. |
| 1130 if (signals_.all_tile_tasks_completed && | 1236 if (signals_.all_tile_tasks_completed && |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1341 all_tile_tasks_completed = false; | 1447 all_tile_tasks_completed = false; |
| 1342 did_notify_all_tile_tasks_completed = false; | 1448 did_notify_all_tile_tasks_completed = false; |
| 1343 } | 1449 } |
| 1344 | 1450 |
| 1345 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule() = default; | 1451 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule() = default; |
| 1346 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule( | 1452 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule( |
| 1347 PrioritizedWorkToSchedule&& other) = default; | 1453 PrioritizedWorkToSchedule&& other) = default; |
| 1348 TileManager::PrioritizedWorkToSchedule::~PrioritizedWorkToSchedule() = default; | 1454 TileManager::PrioritizedWorkToSchedule::~PrioritizedWorkToSchedule() = default; |
| 1349 | 1455 |
| 1350 } // namespace cc | 1456 } // namespace cc |
| OLD | NEW |