Chromium Code Reviews| 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 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 683 | 683 |
| 684 // We won't be able to schedule this tile, so break out early. | 684 // We won't be able to schedule this tile, so break out early. |
| 685 if (work_to_schedule.tiles_to_raster.size() >= | 685 if (work_to_schedule.tiles_to_raster.size() >= |
| 686 scheduled_raster_task_limit_) { | 686 scheduled_raster_task_limit_) { |
| 687 all_tiles_that_need_to_be_rasterized_are_scheduled_ = false; | 687 all_tiles_that_need_to_be_rasterized_are_scheduled_ = false; |
| 688 break; | 688 break; |
| 689 } | 689 } |
| 690 | 690 |
| 691 tile->scheduled_priority_ = schedule_priority++; | 691 tile->scheduled_priority_ = schedule_priority++; |
| 692 | 692 |
| 693 DCHECK(tile->draw_info().mode() == TileDrawInfo::OOM_MODE || | 693 DCHECK(tile->draw_info().mode() == TileDrawInfo::OOM_MODE || |
|
vmpstr
2017/03/17 18:32:13
Can you comment this DCHECK, since it's getting a
Khushal
2017/03/27 13:57:33
Its good that you pointed this out. I hadn't reali
| |
| 694 !tile->draw_info().IsReadyToDraw()); | 694 !tile->draw_info().IsReadyToDraw() || tile->is_checker_imaged()); |
| 695 | 695 |
| 696 // If the tile already has a raster_task, then the memory used by it is | 696 // If the tile already has a raster_task, then the memory used by it is |
| 697 // already accounted for in memory_usage. Otherwise, we'll have to acquire | 697 // already accounted for in memory_usage. Otherwise, we'll have to acquire |
| 698 // more memory to create a raster task. | 698 // more memory to create a raster task. |
| 699 MemoryUsage memory_required_by_tile_to_be_scheduled; | 699 MemoryUsage memory_required_by_tile_to_be_scheduled; |
| 700 if (!tile->raster_task_.get()) { | 700 if (!tile->raster_task_.get()) { |
| 701 memory_required_by_tile_to_be_scheduled = MemoryUsage::FromConfig( | 701 memory_required_by_tile_to_be_scheduled = MemoryUsage::FromConfig( |
| 702 tile->desired_texture_size(), DetermineResourceFormat(tile)); | 702 tile->desired_texture_size(), DetermineResourceFormat(tile)); |
| 703 } | 703 } |
| 704 | 704 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 806 | 806 |
| 807 scoped_refptr<TileTask> required_for_activation_done_task = | 807 scoped_refptr<TileTask> required_for_activation_done_task = |
| 808 CreateTaskSetFinishedTask( | 808 CreateTaskSetFinishedTask( |
| 809 &TileManager::DidFinishRunningTileTasksRequiredForActivation); | 809 &TileManager::DidFinishRunningTileTasksRequiredForActivation); |
| 810 scoped_refptr<TileTask> required_for_draw_done_task = | 810 scoped_refptr<TileTask> required_for_draw_done_task = |
| 811 CreateTaskSetFinishedTask( | 811 CreateTaskSetFinishedTask( |
| 812 &TileManager::DidFinishRunningTileTasksRequiredForDraw); | 812 &TileManager::DidFinishRunningTileTasksRequiredForDraw); |
| 813 scoped_refptr<TileTask> all_done_task = | 813 scoped_refptr<TileTask> all_done_task = |
| 814 CreateTaskSetFinishedTask(&TileManager::DidFinishRunningAllTileTasks); | 814 CreateTaskSetFinishedTask(&TileManager::DidFinishRunningAllTileTasks); |
| 815 | 815 |
| 816 CheckerImageTracker::ImageDecodeQueue checker_image_decode_queue; | |
| 817 | |
| 816 // Build a new task queue containing all task currently needed. Tasks | 818 // Build a new task queue containing all task currently needed. Tasks |
| 817 // are added in order of priority, highest priority task first. | 819 // are added in order of priority, highest priority task first. |
| 818 for (auto& prioritized_tile : tiles_that_need_to_be_rasterized) { | 820 for (auto& prioritized_tile : tiles_that_need_to_be_rasterized) { |
| 819 Tile* tile = prioritized_tile.tile(); | 821 Tile* tile = prioritized_tile.tile(); |
| 820 | 822 |
| 821 DCHECK(tile->draw_info().requires_resource()); | 823 DCHECK(tile->draw_info().requires_resource()); |
| 822 DCHECK(!tile->draw_info().resource()); | 824 DCHECK(!tile->draw_info().resource() || tile->is_checker_imaged()); |
| 825 | |
| 826 bool process_tile_for_checker_images_only = | |
|
vmpstr
2017/03/17 18:32:13
Comment pls
| |
| 827 tile->draw_info().resource() && tile->is_checker_imaged(); | |
| 828 if (process_tile_for_checker_images_only) { | |
| 829 std::vector<DrawImage> images; | |
| 830 ImageIdFlatSet checkered_images; | |
| 831 FilterImagesForCheckering(prioritized_tile, &images, &checkered_images, | |
| 832 &checker_image_decode_queue); | |
| 833 DCHECK(!checkered_images.empty()) | |
| 834 << "Checker-imaged state is sticky on a Tile"; | |
|
vmpstr
2017/03/17 18:32:13
nit: "should be sticky", since when this fails it
| |
| 835 continue; | |
| 836 } | |
| 823 | 837 |
| 824 if (!tile->raster_task_) { | 838 if (!tile->raster_task_) { |
| 825 tile->raster_task_ = | 839 tile->raster_task_ = CreateRasterTask( |
| 826 CreateRasterTask(prioritized_tile, raster_color_space); | 840 prioritized_tile, raster_color_space, &checker_image_decode_queue); |
| 827 } | 841 } |
| 828 | 842 |
| 829 TileTask* task = tile->raster_task_.get(); | 843 TileTask* task = tile->raster_task_.get(); |
| 830 | 844 |
| 831 DCHECK(!task->HasCompleted()); | 845 DCHECK(!task->HasCompleted()); |
| 832 | 846 |
| 833 if (tile->required_for_activation()) { | 847 if (tile->required_for_activation()) { |
| 834 required_for_activate_count++; | 848 required_for_activate_count++; |
| 835 graph_.edges.push_back( | 849 graph_.edges.push_back( |
| 836 TaskGraph::Edge(task, required_for_activation_done_task.get())); | 850 TaskGraph::Edge(task, required_for_activation_done_task.get())); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 918 kAllDoneTaskPriority, all_count); | 932 kAllDoneTaskPriority, all_count); |
| 919 | 933 |
| 920 // Synchronize worker with compositor. | 934 // Synchronize worker with compositor. |
| 921 raster_buffer_provider_->OrderingBarrier(); | 935 raster_buffer_provider_->OrderingBarrier(); |
| 922 | 936 |
| 923 // Schedule running of |raster_queue_|. This replaces any previously | 937 // Schedule running of |raster_queue_|. This replaces any previously |
| 924 // scheduled tasks and effectively cancels all tasks not present | 938 // scheduled tasks and effectively cancels all tasks not present |
| 925 // in |raster_queue_|. | 939 // in |raster_queue_|. |
| 926 tile_task_manager_->ScheduleTasks(&graph_); | 940 tile_task_manager_->ScheduleTasks(&graph_); |
| 927 | 941 |
| 942 // Schedule running of the checker-image decode queue. This replaces the | |
| 943 // previously scheduled queue and effectively cancels image decodes from the | |
| 944 // previously scheduled queue, if not already started. | |
| 945 checker_image_tracker_.SetImageDecodeQueue( | |
|
vmpstr
2017/03/17 18:32:13
Can you call this ScheduleImageDecodes or somethin
Khushal
2017/03/27 13:57:33
Done.
| |
| 946 std::move(checker_image_decode_queue)); | |
| 947 | |
| 928 did_check_for_completed_tasks_since_last_schedule_tasks_ = false; | 948 did_check_for_completed_tasks_since_last_schedule_tasks_ = false; |
| 929 | 949 |
| 930 TRACE_EVENT_ASYNC_STEP_INTO1("cc", "ScheduledTasks", this, "running", "state", | 950 TRACE_EVENT_ASYNC_STEP_INTO1("cc", "ScheduledTasks", this, "running", "state", |
| 931 ScheduledTasksStateAsValue()); | 951 ScheduledTasksStateAsValue()); |
| 932 } | 952 } |
| 933 | 953 |
| 934 scoped_refptr<TileTask> TileManager::CreateRasterTask( | 954 scoped_refptr<TileTask> TileManager::CreateRasterTask( |
| 935 const PrioritizedTile& prioritized_tile, | 955 const PrioritizedTile& prioritized_tile, |
| 936 const gfx::ColorSpace& color_space) { | 956 const gfx::ColorSpace& color_space, |
| 957 CheckerImageTracker::ImageDecodeQueue* checker_image_decode_queue) { | |
| 937 Tile* tile = prioritized_tile.tile(); | 958 Tile* tile = prioritized_tile.tile(); |
| 938 | 959 |
| 939 // Get the resource. | 960 // Get the resource. |
| 940 uint64_t resource_content_id = 0; | 961 uint64_t resource_content_id = 0; |
| 941 Resource* resource = nullptr; | 962 Resource* resource = nullptr; |
| 942 gfx::Rect invalidated_rect = tile->invalidated_content_rect(); | 963 gfx::Rect invalidated_rect = tile->invalidated_content_rect(); |
| 943 if (UsePartialRaster() && tile->invalidated_id()) { | 964 if (UsePartialRaster() && tile->invalidated_id()) { |
| 944 resource = resource_pool_->TryAcquireResourceForPartialRaster( | 965 resource = resource_pool_->TryAcquireResourceForPartialRaster( |
| 945 tile->id(), tile->invalidated_content_rect(), tile->invalidated_id(), | 966 tile->id(), tile->invalidated_content_rect(), tile->invalidated_id(), |
| 946 &invalidated_rect); | 967 &invalidated_rect); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 959 RasterSource::PlaybackSettings playback_settings; | 980 RasterSource::PlaybackSettings playback_settings; |
| 960 playback_settings.skip_images = | 981 playback_settings.skip_images = |
| 961 prioritized_tile.priority().resolution == LOW_RESOLUTION; | 982 prioritized_tile.priority().resolution == LOW_RESOLUTION; |
| 962 | 983 |
| 963 // Create and queue all image decode tasks that this tile depends on. | 984 // Create and queue all image decode tasks that this tile depends on. |
| 964 TileTask::Vector decode_tasks; | 985 TileTask::Vector decode_tasks; |
| 965 std::vector<DrawImage>& images = scheduled_draw_images_[tile->id()]; | 986 std::vector<DrawImage>& images = scheduled_draw_images_[tile->id()]; |
| 966 ImageIdFlatSet images_to_skip; | 987 ImageIdFlatSet images_to_skip; |
| 967 images.clear(); | 988 images.clear(); |
| 968 if (!playback_settings.skip_images) { | 989 if (!playback_settings.skip_images) { |
| 969 prioritized_tile.raster_source()->GetDiscardableImagesInRect( | 990 FilterImagesForCheckering(prioritized_tile, &images, &images_to_skip, |
| 970 tile->enclosing_layer_rect(), tile->contents_scale(), &images); | 991 checker_image_decode_queue); |
| 971 checker_image_tracker_.FilterImagesForCheckeringForTile( | 992 if (!images_to_skip.empty()) |
| 972 &images, &images_to_skip, prioritized_tile.tile()->tiling()->tree()); | 993 tile->set_is_checker_imaged(); |
| 973 } | 994 } |
| 974 | 995 |
| 975 // We can skip the image hijack canvas if we have no images, or no images to | 996 // We can skip the image hijack canvas if we have no images, or no images to |
| 976 // skip during raster. | 997 // skip during raster. |
| 977 playback_settings.use_image_hijack_canvas = | 998 playback_settings.use_image_hijack_canvas = |
| 978 !images.empty() || !images_to_skip.empty(); | 999 !images.empty() || !images_to_skip.empty(); |
| 979 playback_settings.images_to_skip = std::move(images_to_skip); | 1000 playback_settings.images_to_skip = std::move(images_to_skip); |
| 980 | 1001 |
| 981 // Get the tasks for the required images. | 1002 // Get the tasks for the required images. |
| 982 ImageDecodeCache::TracingInfo tracing_info( | 1003 ImageDecodeCache::TracingInfo tracing_info( |
| 983 prepare_tiles_count_, prioritized_tile.priority().priority_bin); | 1004 prepare_tiles_count_, prioritized_tile.priority().priority_bin); |
| 984 image_controller_.GetTasksForImagesAndRef(&images, &decode_tasks, | 1005 image_controller_.GetTasksForImagesAndRef(&images, &decode_tasks, |
| 985 tracing_info); | 1006 tracing_info); |
| 986 | 1007 |
| 987 std::unique_ptr<RasterBuffer> raster_buffer = | 1008 std::unique_ptr<RasterBuffer> raster_buffer = |
| 988 raster_buffer_provider_->AcquireBufferForRaster( | 1009 raster_buffer_provider_->AcquireBufferForRaster( |
| 989 resource, resource_content_id, tile->invalidated_id()); | 1010 resource, resource_content_id, tile->invalidated_id()); |
| 990 return make_scoped_refptr(new RasterTaskImpl( | 1011 return make_scoped_refptr(new RasterTaskImpl( |
| 991 this, tile, resource, prioritized_tile.raster_source(), playback_settings, | 1012 this, tile, resource, prioritized_tile.raster_source(), playback_settings, |
| 992 prioritized_tile.priority().resolution, invalidated_rect, | 1013 prioritized_tile.priority().resolution, invalidated_rect, |
| 993 prepare_tiles_count_, std::move(raster_buffer), &decode_tasks, | 1014 prepare_tiles_count_, std::move(raster_buffer), &decode_tasks, |
| 994 use_gpu_rasterization_)); | 1015 use_gpu_rasterization_)); |
| 995 } | 1016 } |
| 996 | 1017 |
| 1018 void TileManager::FilterImagesForCheckering( | |
| 1019 const PrioritizedTile& prioritized_tile, | |
| 1020 std::vector<DrawImage>* images_to_decode, | |
| 1021 ImageIdFlatSet* checker_images, | |
| 1022 CheckerImageTracker::ImageDecodeQueue* checker_image_decode_queue) { | |
| 1023 DCHECK_EQ(images_to_decode->size(), 0u); | |
| 1024 DCHECK_EQ(checker_images->size(), 0u); | |
| 1025 | |
| 1026 const Tile* tile = prioritized_tile.tile(); | |
| 1027 std::vector<DrawImage> images_in_tile; | |
| 1028 prioritized_tile.raster_source()->GetDiscardableImagesInRect( | |
|
vmpstr
2017/03/17 18:32:13
I'd prefer you leave this call outside and pass th
Khushal
2017/03/27 13:57:33
Done.
| |
| 1029 tile->enclosing_layer_rect(), tile->contents_scale(), &images_in_tile); | |
| 1030 for (auto draw_image : images_in_tile) { | |
| 1031 const sk_sp<const SkImage>& image = draw_image.image(); | |
| 1032 DCHECK(image->isLazyGenerated()); | |
| 1033 if (checker_image_tracker_.ShouldCheckerImage(image, | |
| 1034 tile->tiling()->tree())) { | |
| 1035 checker_images->insert(image->uniqueID()); | |
| 1036 checker_image_decode_queue->push_back(std::move(image)); | |
| 1037 } else { | |
| 1038 images_to_decode->push_back(draw_image); | |
| 1039 } | |
| 1040 } | |
| 1041 } | |
| 1042 | |
| 997 void TileManager::ResetSignalsForTesting() { | 1043 void TileManager::ResetSignalsForTesting() { |
| 998 signals_.reset(); | 1044 signals_.reset(); |
| 999 } | 1045 } |
| 1000 | 1046 |
| 1001 void TileManager::OnRasterTaskCompleted( | 1047 void TileManager::OnRasterTaskCompleted( |
| 1002 std::unique_ptr<RasterBuffer> raster_buffer, | 1048 std::unique_ptr<RasterBuffer> raster_buffer, |
| 1003 Tile::Id tile_id, | 1049 Tile::Id tile_id, |
| 1004 Resource* resource, | 1050 Resource* resource, |
| 1005 bool was_canceled) { | 1051 bool was_canceled) { |
| 1006 raster_buffer_provider_->ReleaseBufferForRaster(std::move(raster_buffer)); | 1052 raster_buffer_provider_->ReleaseBufferForRaster(std::move(raster_buffer)); |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1432 all_tile_tasks_completed = false; | 1478 all_tile_tasks_completed = false; |
| 1433 did_notify_all_tile_tasks_completed = false; | 1479 did_notify_all_tile_tasks_completed = false; |
| 1434 } | 1480 } |
| 1435 | 1481 |
| 1436 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule() = default; | 1482 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule() = default; |
| 1437 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule( | 1483 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule( |
| 1438 PrioritizedWorkToSchedule&& other) = default; | 1484 PrioritizedWorkToSchedule&& other) = default; |
| 1439 TileManager::PrioritizedWorkToSchedule::~PrioritizedWorkToSchedule() = default; | 1485 TileManager::PrioritizedWorkToSchedule::~PrioritizedWorkToSchedule() = default; |
| 1440 | 1486 |
| 1441 } // namespace cc | 1487 } // namespace cc |
| OLD | NEW |