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 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
636 MemoryUsage soft_memory_limit(global_state_.soft_memory_limit_in_bytes, | 636 MemoryUsage soft_memory_limit(global_state_.soft_memory_limit_in_bytes, |
637 global_state_.num_resources_limit); | 637 global_state_.num_resources_limit); |
638 MemoryUsage memory_usage(resource_pool_->memory_usage_bytes(), | 638 MemoryUsage memory_usage(resource_pool_->memory_usage_bytes(), |
639 resource_pool_->resource_count()); | 639 resource_pool_->resource_count()); |
640 | 640 |
641 std::unique_ptr<RasterTilePriorityQueue> raster_priority_queue( | 641 std::unique_ptr<RasterTilePriorityQueue> raster_priority_queue( |
642 client_->BuildRasterQueue(global_state_.tree_priority, | 642 client_->BuildRasterQueue(global_state_.tree_priority, |
643 RasterTilePriorityQueue::Type::ALL)); | 643 RasterTilePriorityQueue::Type::ALL)); |
644 std::unique_ptr<EvictionTilePriorityQueue> eviction_priority_queue; | 644 std::unique_ptr<EvictionTilePriorityQueue> eviction_priority_queue; |
645 PrioritizedWorkToSchedule work_to_schedule; | 645 PrioritizedWorkToSchedule work_to_schedule; |
646 CheckerImageTracker::ImageDecodeQueue checker_image_decode_queue; | |
646 for (; !raster_priority_queue->IsEmpty(); raster_priority_queue->Pop()) { | 647 for (; !raster_priority_queue->IsEmpty(); raster_priority_queue->Pop()) { |
647 const PrioritizedTile& prioritized_tile = raster_priority_queue->Top(); | 648 const PrioritizedTile& prioritized_tile = raster_priority_queue->Top(); |
648 Tile* tile = prioritized_tile.tile(); | 649 Tile* tile = prioritized_tile.tile(); |
649 TilePriority priority = prioritized_tile.priority(); | 650 TilePriority priority = prioritized_tile.priority(); |
650 | 651 |
651 if (TilePriorityViolatesMemoryPolicy(priority)) { | 652 if (TilePriorityViolatesMemoryPolicy(priority)) { |
652 TRACE_EVENT_INSTANT0( | 653 TRACE_EVENT_INSTANT0( |
653 "cc", "TileManager::AssignGpuMemory tile violates memory policy", | 654 "cc", "TileManager::AssignGpuMemory tile violates memory policy", |
654 TRACE_EVENT_SCOPE_THREAD); | 655 TRACE_EVENT_SCOPE_THREAD); |
655 break; | 656 break; |
(...skipping 18 matching lines...) Expand all Loading... | |
674 } | 675 } |
675 } | 676 } |
676 | 677 |
677 // Prepaint tiles that are far away are only processed for images. | 678 // Prepaint tiles that are far away are only processed for images. |
678 if (!tile->required_for_activation() && !tile->required_for_draw() && | 679 if (!tile->required_for_activation() && !tile->required_for_draw() && |
679 prioritized_tile.is_process_for_images_only()) { | 680 prioritized_tile.is_process_for_images_only()) { |
680 work_to_schedule.tiles_to_process_for_images.push_back(prioritized_tile); | 681 work_to_schedule.tiles_to_process_for_images.push_back(prioritized_tile); |
681 continue; | 682 continue; |
682 } | 683 } |
683 | 684 |
685 // Tiles in the raster queue should either require raster or decode for | |
686 // checker-images. If this tile does not need raster, process it only to | |
687 // build the decode queue for checkered images. | |
vmpstr
2017/03/29 19:11:45
Add a comment saying that this block must come aft
Khushal
2017/03/31 04:31:00
Done.
| |
688 if (!tile->draw_info().NeedsRaster()) { | |
689 DCHECK(tile->draw_info().is_checker_imaged()); | |
690 std::vector<DrawImage> images_in_tile; | |
691 prioritized_tile.raster_source()->GetDiscardableImagesInRect( | |
692 tile->enclosing_layer_rect(), tile->contents_scale(), | |
693 &images_in_tile); | |
694 FilterImagesForCheckering(tile->tiling()->tree(), images_in_tile, nullptr, | |
695 nullptr, &checker_image_decode_queue); | |
696 continue; | |
697 } | |
698 | |
684 // We won't be able to schedule this tile, so break out early. | 699 // We won't be able to schedule this tile, so break out early. |
685 if (work_to_schedule.tiles_to_raster.size() >= | 700 if (work_to_schedule.tiles_to_raster.size() >= |
686 scheduled_raster_task_limit_) { | 701 scheduled_raster_task_limit_) { |
687 all_tiles_that_need_to_be_rasterized_are_scheduled_ = false; | 702 all_tiles_that_need_to_be_rasterized_are_scheduled_ = false; |
688 break; | 703 break; |
689 } | 704 } |
690 | 705 |
691 tile->scheduled_priority_ = schedule_priority++; | 706 tile->scheduled_priority_ = schedule_priority++; |
692 | 707 |
693 DCHECK(tile->draw_info().mode() == TileDrawInfo::OOM_MODE || | 708 DCHECK(tile->draw_info().mode() == TileDrawInfo::OOM_MODE || |
(...skipping 26 matching lines...) Expand all Loading... | |
720 // If we couldn't fit the tile into our current memory limit, then we're | 735 // If we couldn't fit the tile into our current memory limit, then we're |
721 // done. | 736 // done. |
722 if (!memory_usage_is_within_limit) { | 737 if (!memory_usage_is_within_limit) { |
723 if (tile_is_needed_now) | 738 if (tile_is_needed_now) |
724 had_enough_memory_to_schedule_tiles_needed_now = false; | 739 had_enough_memory_to_schedule_tiles_needed_now = false; |
725 all_tiles_that_need_to_be_rasterized_are_scheduled_ = false; | 740 all_tiles_that_need_to_be_rasterized_are_scheduled_ = false; |
726 break; | 741 break; |
727 } | 742 } |
728 | 743 |
729 memory_usage += memory_required_by_tile_to_be_scheduled; | 744 memory_usage += memory_required_by_tile_to_be_scheduled; |
745 | |
746 // If the tile has a scheduled task that will rasterize a resource with | |
747 // checker-imaged content, add those images to the decode queue. Note that | |
748 // we add all images as we process the raster priority queue to ensure that | |
749 // images are added to the decode queue in raster priority order. | |
750 if (tile->raster_task_scheduled_with_checker_images()) { | |
vmpstr
2017/03/29 19:11:45
Maybe flip the if and the dcheck? If, if tile has
Khushal
2017/03/29 22:10:20
Not sure I followed, at this point the tile should
| |
751 DCHECK(tile->HasRasterTask()); | |
752 std::vector<DrawImage> images_in_tile; | |
753 prioritized_tile.raster_source()->GetDiscardableImagesInRect( | |
vmpstr
2017/03/29 19:11:46
This isn't really a trivial operation, is there an
Khushal
2017/03/29 22:10:20
I was thinking about it. Is there a reason for not
Khushal
2017/03/31 04:31:00
Cached this on Tile. I didn't realize that |schedu
| |
754 tile->enclosing_layer_rect(), tile->contents_scale(), | |
755 &images_in_tile); | |
756 FilterImagesForCheckering(tile->tiling()->tree(), images_in_tile, nullptr, | |
757 nullptr, &checker_image_decode_queue); | |
758 } else if (!tile->HasRasterTask()) { | |
759 // Creating the raster task here will acquire resources, but | |
760 // this resource usage has already been accounted for above. | |
761 tile->raster_task_ = | |
762 CreateRasterTask(prioritized_tile, client_->GetRasterColorSpace(), | |
vmpstr
2017/03/29 19:11:46
It's a bit unfortunate that we're doing this here
Khushal
2017/03/31 04:31:01
Done.
| |
763 &checker_image_decode_queue); | |
764 } | |
730 work_to_schedule.tiles_to_raster.push_back(prioritized_tile); | 765 work_to_schedule.tiles_to_raster.push_back(prioritized_tile); |
731 } | 766 } |
732 | 767 |
733 // Note that we should try and further reduce memory in case the above loop | 768 // Note that we should try and further reduce memory in case the above loop |
734 // didn't reduce memory. This ensures that we always release as many resources | 769 // didn't reduce memory. This ensures that we always release as many resources |
735 // as possible to stay within the memory limit. | 770 // as possible to stay within the memory limit. |
736 eviction_priority_queue = FreeTileResourcesUntilUsageIsWithinLimit( | 771 eviction_priority_queue = FreeTileResourcesUntilUsageIsWithinLimit( |
vmpstr
2017/03/29 19:11:46
What happens if eviction evicts tiles that are bei
Khushal
2017/03/29 22:10:20
The eviction here shouldn't remove resources from
| |
737 std::move(eviction_priority_queue), hard_memory_limit, &memory_usage); | 772 std::move(eviction_priority_queue), hard_memory_limit, &memory_usage); |
738 | 773 |
774 // At this point if we still have a tile that is holding onto a resource with | |
775 // checker-imaged content, add it to the decode queue to ensure that the | |
776 // resource is eventually invalidated. | |
777 while (!raster_priority_queue->IsEmpty()) { | |
vmpstr
2017/03/29 19:11:46
You can't do this here. This part defeats the poin
Khushal
2017/03/29 22:10:20
Sorry, I had missed looking at the implementation
| |
778 const PrioritizedTile& prioritized_tile = raster_priority_queue->Top(); | |
779 Tile* tile = prioritized_tile.tile(); | |
780 if (tile->draw_info().is_checker_imaged() || | |
781 tile->raster_task_scheduled_with_checker_images()) { | |
782 std::vector<DrawImage> images_in_tile; | |
783 prioritized_tile.raster_source()->GetDiscardableImagesInRect( | |
784 tile->enclosing_layer_rect(), tile->contents_scale(), | |
785 &images_in_tile); | |
786 FilterImagesForCheckering(tile->tiling()->tree(), images_in_tile, nullptr, | |
787 nullptr, &checker_image_decode_queue); | |
788 } | |
789 raster_priority_queue->Pop(); | |
790 } | |
791 | |
792 // Schedule running of the checker-image decode queue. This replaces the | |
793 // previously scheduled queue and effectively cancels image decodes from the | |
794 // previously scheduled queue, if not already started. | |
795 checker_image_tracker_.ScheduleImageDecodeQueue( | |
vmpstr
2017/03/29 19:11:46
Can you move this call out of this function and do
Khushal
2017/03/31 04:31:00
Moved it to ScheduleTasks.
| |
796 std::move(checker_image_decode_queue)); | |
797 | |
739 UMA_HISTOGRAM_BOOLEAN("TileManager.ExceededMemoryBudget", | 798 UMA_HISTOGRAM_BOOLEAN("TileManager.ExceededMemoryBudget", |
740 !had_enough_memory_to_schedule_tiles_needed_now); | 799 !had_enough_memory_to_schedule_tiles_needed_now); |
741 did_oom_on_last_assign_ = !had_enough_memory_to_schedule_tiles_needed_now; | 800 did_oom_on_last_assign_ = !had_enough_memory_to_schedule_tiles_needed_now; |
742 | 801 |
743 memory_stats_from_last_assign_.total_budget_in_bytes = | 802 memory_stats_from_last_assign_.total_budget_in_bytes = |
744 global_state_.hard_memory_limit_in_bytes; | 803 global_state_.hard_memory_limit_in_bytes; |
745 memory_stats_from_last_assign_.total_bytes_used = memory_usage.memory_bytes(); | 804 memory_stats_from_last_assign_.total_bytes_used = memory_usage.memory_bytes(); |
746 DCHECK_GE(memory_stats_from_last_assign_.total_bytes_used, 0); | 805 DCHECK_GE(memory_stats_from_last_assign_.total_bytes_used, 0); |
747 memory_stats_from_last_assign_.had_enough_memory = | 806 memory_stats_from_last_assign_.had_enough_memory = |
748 had_enough_memory_to_schedule_tiles_needed_now; | 807 had_enough_memory_to_schedule_tiles_needed_now; |
(...skipping 16 matching lines...) Expand all Loading... | |
765 } | 824 } |
766 | 825 |
767 void TileManager::FreeResourcesForTileAndNotifyClientIfTileWasReadyToDraw( | 826 void TileManager::FreeResourcesForTileAndNotifyClientIfTileWasReadyToDraw( |
768 Tile* tile) { | 827 Tile* tile) { |
769 bool was_ready_to_draw = tile->draw_info().IsReadyToDraw(); | 828 bool was_ready_to_draw = tile->draw_info().IsReadyToDraw(); |
770 FreeResourcesForTile(tile); | 829 FreeResourcesForTile(tile); |
771 if (was_ready_to_draw) | 830 if (was_ready_to_draw) |
772 client_->NotifyTileStateChanged(tile); | 831 client_->NotifyTileStateChanged(tile); |
773 } | 832 } |
774 | 833 |
834 void TileManager::FilterImagesForCheckering( | |
835 WhichTree tree, | |
836 const std::vector<DrawImage>& images_in_tile, | |
837 std::vector<DrawImage>* images_to_decode_for_raster, | |
838 ImageIdFlatSet* checkered_images, | |
839 CheckerImageTracker::ImageDecodeQueue* image_decode_queue) { | |
840 DCHECK(!images_to_decode_for_raster || images_to_decode_for_raster->empty()); | |
vmpstr
2017/03/29 19:11:46
It's not clear to me why some of the output parame
Khushal
2017/03/29 22:10:20
I think computing it once and storing it on tile s
Khushal
2017/03/31 04:31:00
Done.
| |
841 DCHECK(!checkered_images || checkered_images->empty()); | |
842 | |
843 for (const auto& draw_image : images_in_tile) { | |
844 const sk_sp<const SkImage>& image = draw_image.image(); | |
845 DCHECK(image->isLazyGenerated()); | |
846 if (checker_image_tracker_.ShouldCheckerImage(image, tree)) { | |
847 if (checkered_images) | |
848 checkered_images->insert(image->uniqueID()); | |
vmpstr
2017/03/29 19:11:46
Here you're adding the image to both the vector an
Khushal
2017/03/31 04:31:00
Function died.
| |
849 image_decode_queue->push_back(std::move(image)); | |
850 } else if (images_to_decode_for_raster) { | |
851 images_to_decode_for_raster->push_back(draw_image); | |
vmpstr
2017/03/29 19:11:45
image to decode for raster is not a clear name. I
Khushal
2017/03/31 04:31:00
Function died.
| |
852 } | |
853 } | |
854 } | |
855 | |
775 void TileManager::ScheduleTasks( | 856 void TileManager::ScheduleTasks( |
776 const PrioritizedWorkToSchedule& work_to_schedule) { | 857 const PrioritizedWorkToSchedule& work_to_schedule) { |
777 const std::vector<PrioritizedTile>& tiles_that_need_to_be_rasterized = | 858 const std::vector<PrioritizedTile>& tiles_that_need_to_be_rasterized = |
778 work_to_schedule.tiles_to_raster; | 859 work_to_schedule.tiles_to_raster; |
779 TRACE_EVENT1("cc", "TileManager::ScheduleTasks", "count", | 860 TRACE_EVENT1("cc", "TileManager::ScheduleTasks", "count", |
780 tiles_that_need_to_be_rasterized.size()); | 861 tiles_that_need_to_be_rasterized.size()); |
781 | 862 |
782 DCHECK(did_check_for_completed_tasks_since_last_schedule_tasks_); | 863 DCHECK(did_check_for_completed_tasks_since_last_schedule_tasks_); |
783 | 864 |
784 if (!has_scheduled_tile_tasks_) { | 865 if (!has_scheduled_tile_tasks_) { |
(...skipping 28 matching lines...) Expand all Loading... | |
813 scoped_refptr<TileTask> all_done_task = | 894 scoped_refptr<TileTask> all_done_task = |
814 CreateTaskSetFinishedTask(&TileManager::DidFinishRunningAllTileTasks); | 895 CreateTaskSetFinishedTask(&TileManager::DidFinishRunningAllTileTasks); |
815 | 896 |
816 // Build a new task queue containing all task currently needed. Tasks | 897 // Build a new task queue containing all task currently needed. Tasks |
817 // are added in order of priority, highest priority task first. | 898 // are added in order of priority, highest priority task first. |
818 for (auto& prioritized_tile : tiles_that_need_to_be_rasterized) { | 899 for (auto& prioritized_tile : tiles_that_need_to_be_rasterized) { |
819 Tile* tile = prioritized_tile.tile(); | 900 Tile* tile = prioritized_tile.tile(); |
820 | 901 |
821 DCHECK(tile->draw_info().requires_resource()); | 902 DCHECK(tile->draw_info().requires_resource()); |
822 DCHECK(!tile->draw_info().resource()); | 903 DCHECK(!tile->draw_info().resource()); |
823 | 904 DCHECK(tile->HasRasterTask()); |
vmpstr
2017/03/29 19:11:46
comment why this is true now.
Khushal
2017/03/31 04:31:00
Done.
| |
824 if (!tile->raster_task_) { | |
825 tile->raster_task_ = | |
826 CreateRasterTask(prioritized_tile, raster_color_space); | |
827 } | |
828 | 905 |
829 TileTask* task = tile->raster_task_.get(); | 906 TileTask* task = tile->raster_task_.get(); |
830 | 907 |
831 DCHECK(!task->HasCompleted()); | 908 DCHECK(!task->HasCompleted()); |
832 | 909 |
833 if (tile->required_for_activation()) { | 910 if (tile->required_for_activation()) { |
834 required_for_activate_count++; | 911 required_for_activate_count++; |
835 graph_.edges.push_back( | 912 graph_.edges.push_back( |
836 TaskGraph::Edge(task, required_for_activation_done_task.get())); | 913 TaskGraph::Edge(task, required_for_activation_done_task.get())); |
837 } | 914 } |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
926 tile_task_manager_->ScheduleTasks(&graph_); | 1003 tile_task_manager_->ScheduleTasks(&graph_); |
927 | 1004 |
928 did_check_for_completed_tasks_since_last_schedule_tasks_ = false; | 1005 did_check_for_completed_tasks_since_last_schedule_tasks_ = false; |
929 | 1006 |
930 TRACE_EVENT_ASYNC_STEP_INTO1("cc", "ScheduledTasks", this, "running", "state", | 1007 TRACE_EVENT_ASYNC_STEP_INTO1("cc", "ScheduledTasks", this, "running", "state", |
931 ScheduledTasksStateAsValue()); | 1008 ScheduledTasksStateAsValue()); |
932 } | 1009 } |
933 | 1010 |
934 scoped_refptr<TileTask> TileManager::CreateRasterTask( | 1011 scoped_refptr<TileTask> TileManager::CreateRasterTask( |
935 const PrioritizedTile& prioritized_tile, | 1012 const PrioritizedTile& prioritized_tile, |
936 const gfx::ColorSpace& color_space) { | 1013 const gfx::ColorSpace& color_space, |
1014 CheckerImageTracker::ImageDecodeQueue* checker_image_decode_queue) { | |
937 Tile* tile = prioritized_tile.tile(); | 1015 Tile* tile = prioritized_tile.tile(); |
938 | 1016 |
939 // Get the resource. | 1017 // Get the resource. |
940 uint64_t resource_content_id = 0; | 1018 uint64_t resource_content_id = 0; |
941 Resource* resource = nullptr; | 1019 Resource* resource = nullptr; |
942 gfx::Rect invalidated_rect = tile->invalidated_content_rect(); | 1020 gfx::Rect invalidated_rect = tile->invalidated_content_rect(); |
943 if (UsePartialRaster() && tile->invalidated_id()) { | 1021 if (UsePartialRaster() && tile->invalidated_id()) { |
944 resource = resource_pool_->TryAcquireResourceForPartialRaster( | 1022 resource = resource_pool_->TryAcquireResourceForPartialRaster( |
945 tile->id(), tile->invalidated_content_rect(), tile->invalidated_id(), | 1023 tile->id(), tile->invalidated_content_rect(), tile->invalidated_id(), |
946 &invalidated_rect); | 1024 &invalidated_rect); |
947 } | 1025 } |
948 | 1026 |
949 if (resource) { | 1027 if (resource) { |
950 resource_content_id = tile->invalidated_id(); | 1028 resource_content_id = tile->invalidated_id(); |
951 DCHECK_EQ(DetermineResourceFormat(tile), resource->format()); | 1029 DCHECK_EQ(DetermineResourceFormat(tile), resource->format()); |
952 } else { | 1030 } else { |
953 resource = resource_pool_->AcquireResource(tile->desired_texture_size(), | 1031 resource = resource_pool_->AcquireResource(tile->desired_texture_size(), |
954 DetermineResourceFormat(tile), | 1032 DetermineResourceFormat(tile), |
955 color_space); | 1033 color_space); |
956 } | 1034 } |
957 | 1035 |
958 // For LOW_RESOLUTION tiles, we don't draw or predecode images. | 1036 // For LOW_RESOLUTION tiles, we don't draw or predecode images. |
959 RasterSource::PlaybackSettings playback_settings; | 1037 RasterSource::PlaybackSettings playback_settings; |
960 playback_settings.skip_images = | 1038 playback_settings.skip_images = |
961 prioritized_tile.priority().resolution == LOW_RESOLUTION; | 1039 prioritized_tile.priority().resolution == LOW_RESOLUTION; |
962 | 1040 |
963 // Create and queue all image decode tasks that this tile depends on. | 1041 // Create and queue all image decode tasks that this tile depends on. |
964 TileTask::Vector decode_tasks; | 1042 TileTask::Vector decode_tasks; |
965 std::vector<DrawImage>& images = scheduled_draw_images_[tile->id()]; | 1043 std::vector<DrawImage>& images_to_decode_for_raster = |
966 ImageIdFlatSet images_to_skip; | 1044 scheduled_draw_images_[tile->id()]; |
967 images.clear(); | 1045 images_to_decode_for_raster.clear(); |
968 if (!playback_settings.skip_images) { | 1046 if (!playback_settings.skip_images) { |
1047 std::vector<DrawImage> images_in_tile; | |
969 prioritized_tile.raster_source()->GetDiscardableImagesInRect( | 1048 prioritized_tile.raster_source()->GetDiscardableImagesInRect( |
vmpstr
2017/03/29 19:11:46
The pattern of these two calls appears throughout.
Khushal
2017/03/31 04:31:00
Happens only once now. Moved to EnsureImageAnalysi
| |
970 tile->enclosing_layer_rect(), tile->contents_scale(), &images); | 1049 tile->enclosing_layer_rect(), tile->contents_scale(), &images_in_tile); |
971 checker_image_tracker_.FilterImagesForCheckeringForTile( | 1050 FilterImagesForCheckering( |
972 &images, &images_to_skip, prioritized_tile.tile()->tiling()->tree()); | 1051 tile->tiling()->tree(), images_in_tile, &images_to_decode_for_raster, |
1052 &playback_settings.images_to_skip, checker_image_decode_queue); | |
973 } | 1053 } |
974 | 1054 |
975 // We can skip the image hijack canvas if we have no images, or no images to | 1055 // We can skip the image hijack canvas if we have no images, or no images to |
976 // skip during raster. | 1056 // skip during raster. |
977 playback_settings.use_image_hijack_canvas = | 1057 playback_settings.use_image_hijack_canvas = |
978 !images.empty() || !images_to_skip.empty(); | 1058 !images_to_decode_for_raster.empty() || |
979 playback_settings.images_to_skip = std::move(images_to_skip); | 1059 !playback_settings.images_to_skip.empty(); |
1060 tile->raster_task_scheduled_with_checker_images_ = | |
1061 !playback_settings.images_to_skip.empty(); | |
980 | 1062 |
981 // Get the tasks for the required images. | 1063 // Get the tasks for the required images. |
982 ImageDecodeCache::TracingInfo tracing_info( | 1064 ImageDecodeCache::TracingInfo tracing_info( |
983 prepare_tiles_count_, prioritized_tile.priority().priority_bin); | 1065 prepare_tiles_count_, prioritized_tile.priority().priority_bin); |
984 image_controller_.GetTasksForImagesAndRef(&images, &decode_tasks, | 1066 image_controller_.GetTasksForImagesAndRef(&images_to_decode_for_raster, |
985 tracing_info); | 1067 &decode_tasks, tracing_info); |
986 | 1068 |
987 std::unique_ptr<RasterBuffer> raster_buffer = | 1069 std::unique_ptr<RasterBuffer> raster_buffer = |
988 raster_buffer_provider_->AcquireBufferForRaster( | 1070 raster_buffer_provider_->AcquireBufferForRaster( |
989 resource, resource_content_id, tile->invalidated_id()); | 1071 resource, resource_content_id, tile->invalidated_id()); |
990 return make_scoped_refptr(new RasterTaskImpl( | 1072 return make_scoped_refptr(new RasterTaskImpl( |
991 this, tile, resource, prioritized_tile.raster_source(), playback_settings, | 1073 this, tile, resource, prioritized_tile.raster_source(), playback_settings, |
992 prioritized_tile.priority().resolution, invalidated_rect, | 1074 prioritized_tile.priority().resolution, invalidated_rect, |
993 prepare_tiles_count_, std::move(raster_buffer), &decode_tasks, | 1075 prepare_tiles_count_, std::move(raster_buffer), &decode_tasks, |
994 use_gpu_rasterization_)); | 1076 use_gpu_rasterization_)); |
995 } | 1077 } |
996 | 1078 |
997 void TileManager::ResetSignalsForTesting() { | 1079 void TileManager::ResetSignalsForTesting() { |
998 signals_.reset(); | 1080 signals_.reset(); |
999 } | 1081 } |
1000 | 1082 |
1001 void TileManager::OnRasterTaskCompleted( | 1083 void TileManager::OnRasterTaskCompleted( |
1002 std::unique_ptr<RasterBuffer> raster_buffer, | 1084 std::unique_ptr<RasterBuffer> raster_buffer, |
1003 Tile::Id tile_id, | 1085 Tile::Id tile_id, |
1004 Resource* resource, | 1086 Resource* resource, |
1005 bool was_canceled) { | 1087 bool was_canceled) { |
1006 raster_buffer_provider_->ReleaseBufferForRaster(std::move(raster_buffer)); | 1088 raster_buffer_provider_->ReleaseBufferForRaster(std::move(raster_buffer)); |
1007 | 1089 |
1008 auto found = tiles_.find(tile_id); | 1090 auto found = tiles_.find(tile_id); |
1009 Tile* tile = nullptr; | 1091 Tile* tile = nullptr; |
1092 bool raster_task_scheduled_with_checker_images = false; | |
1010 if (found != tiles_.end()) { | 1093 if (found != tiles_.end()) { |
1011 tile = found->second; | 1094 tile = found->second; |
1012 DCHECK(tile->raster_task_.get()); | 1095 DCHECK(tile->raster_task_.get()); |
1096 raster_task_scheduled_with_checker_images = | |
vmpstr
2017/03/29 19:11:46
just make the setter return the old value
Khushal
2017/03/31 04:31:00
Done.
| |
1097 tile->raster_task_scheduled_with_checker_images_; | |
1013 tile->raster_task_ = nullptr; | 1098 tile->raster_task_ = nullptr; |
1099 tile->raster_task_scheduled_with_checker_images_ = false; | |
1014 } | 1100 } |
1015 | 1101 |
1016 // Unref all the images. | 1102 // Unref all the images. |
1017 auto images_it = scheduled_draw_images_.find(tile_id); | 1103 auto images_it = scheduled_draw_images_.find(tile_id); |
1018 image_controller_.UnrefImages(images_it->second); | 1104 image_controller_.UnrefImages(images_it->second); |
1019 scheduled_draw_images_.erase(images_it); | 1105 scheduled_draw_images_.erase(images_it); |
1020 | 1106 |
1021 if (was_canceled) { | 1107 if (was_canceled) { |
1022 ++flush_stats_.canceled_count; | 1108 ++flush_stats_.canceled_count; |
1023 resource_pool_->ReleaseResource(resource); | 1109 resource_pool_->ReleaseResource(resource); |
1024 return; | 1110 return; |
1025 } | 1111 } |
1026 | 1112 |
1027 resource_pool_->OnContentReplaced(resource->id(), tile_id); | 1113 resource_pool_->OnContentReplaced(resource->id(), tile_id); |
1028 ++flush_stats_.completed_count; | 1114 ++flush_stats_.completed_count; |
1029 | 1115 |
1030 if (!tile) { | 1116 if (!tile) { |
1031 resource_pool_->ReleaseResource(resource); | 1117 resource_pool_->ReleaseResource(resource); |
1032 return; | 1118 return; |
1033 } | 1119 } |
1034 | 1120 |
1035 TileDrawInfo& draw_info = tile->draw_info(); | 1121 TileDrawInfo& draw_info = tile->draw_info(); |
1036 draw_info.set_resource(resource); | 1122 draw_info.set_resource(resource); |
1123 draw_info.resource_is_checker_imaged_ = | |
1124 raster_task_scheduled_with_checker_images; | |
1037 draw_info.contents_swizzled_ = DetermineResourceRequiresSwizzle(tile); | 1125 draw_info.contents_swizzled_ = DetermineResourceRequiresSwizzle(tile); |
1038 | 1126 |
1039 // In SMOOTHNESS_TAKES_PRIORITY mode, we wait for GPU work to complete for a | 1127 // In SMOOTHNESS_TAKES_PRIORITY mode, we wait for GPU work to complete for a |
1040 // tile before setting it as ready to draw. | 1128 // tile before setting it as ready to draw. |
1041 if (global_state_.tree_priority == SMOOTHNESS_TAKES_PRIORITY && | 1129 if (global_state_.tree_priority == SMOOTHNESS_TAKES_PRIORITY && |
1042 !raster_buffer_provider_->IsResourceReadyToDraw(resource->id())) { | 1130 !raster_buffer_provider_->IsResourceReadyToDraw(resource->id())) { |
1043 pending_gpu_work_tiles_.insert(tile); | 1131 pending_gpu_work_tiles_.insert(tile); |
1044 return; | 1132 return; |
1045 } | 1133 } |
1046 | 1134 |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1432 all_tile_tasks_completed = false; | 1520 all_tile_tasks_completed = false; |
1433 did_notify_all_tile_tasks_completed = false; | 1521 did_notify_all_tile_tasks_completed = false; |
1434 } | 1522 } |
1435 | 1523 |
1436 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule() = default; | 1524 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule() = default; |
1437 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule( | 1525 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule( |
1438 PrioritizedWorkToSchedule&& other) = default; | 1526 PrioritizedWorkToSchedule&& other) = default; |
1439 TileManager::PrioritizedWorkToSchedule::~PrioritizedWorkToSchedule() = default; | 1527 TileManager::PrioritizedWorkToSchedule::~PrioritizedWorkToSchedule() = default; |
1440 | 1528 |
1441 } // namespace cc | 1529 } // namespace cc |
OLD | NEW |