Index: cc/tiles/tile_manager.cc |
diff --git a/cc/tiles/tile_manager.cc b/cc/tiles/tile_manager.cc |
index 20a29ad8d0297d68109bb7cf9ef835f0ae248bc2..4af4d6fd2e267554ad793ae2fdb19826a04a14d7 100644 |
--- a/cc/tiles/tile_manager.cc |
+++ b/cc/tiles/tile_manager.cc |
@@ -361,8 +361,7 @@ void TileManager::FinishTasksAndCleanUp() { |
signals_check_notifier_.Cancel(); |
task_set_finished_weak_ptr_factory_.InvalidateWeakPtrs(); |
- image_manager_.UnrefImages(locked_images_); |
- locked_images_.clear(); |
+ image_manager_.SetImageDecodeController(nullptr); |
locked_image_tasks_.clear(); |
} |
@@ -843,21 +842,25 @@ void TileManager::ScheduleTasks( |
const std::vector<PrioritizedTile>& tiles_to_process_for_images = |
work_to_schedule.tiles_to_process_for_images; |
std::vector<DrawImage> new_locked_images; |
- std::vector<scoped_refptr<TileTask>> new_locked_image_tasks; |
for (const PrioritizedTile& prioritized_tile : tiles_to_process_for_images) { |
Tile* tile = prioritized_tile.tile(); |
std::vector<DrawImage> images; |
prioritized_tile.raster_source()->GetDiscardableImagesInRect( |
tile->enclosing_layer_rect(), tile->contents_scale(), &images); |
- ImageDecodeController::TracingInfo tracing_info( |
- prepare_tiles_count_, prioritized_tile.priority().priority_bin); |
- image_manager_.GetTasksForImagesAndRef(&images, &new_locked_image_tasks, |
- tracing_info); |
new_locked_images.insert(new_locked_images.end(), images.begin(), |
images.end()); |
} |
+ // TODO(vmpstr): SOON is misleading here, but these images can come from |
+ // several diffent tiles. Rethink what we actually want to trace here. Note |
+ // that I'm using SOON, since it can't be NOW (these are prepaint). |
+ ImageDecodeController::TracingInfo tracing_info(prepare_tiles_count_, |
+ TilePriority::SOON); |
+ std::vector<scoped_refptr<TileTask>> new_locked_image_tasks = |
+ image_manager_.SetPredecodeImages(std::move(new_locked_images), |
+ tracing_info); |
+ |
for (auto& task : new_locked_image_tasks) { |
auto decode_it = std::find_if(graph_.nodes.begin(), graph_.nodes.end(), |
[&task](const TaskGraph::Node& node) { |
@@ -872,10 +875,11 @@ void TileManager::ScheduleTasks( |
graph_.edges.push_back(TaskGraph::Edge(task.get(), all_done_task.get())); |
} |
- image_manager_.UnrefImages(locked_images_); |
- // The old locked images have to stay around until past the ScheduleTasks call |
- // below, so we do a swap instead of a move. |
- locked_images_.swap(new_locked_images); |
+ // The old locked images tasks have to stay around until past the |
+ // ScheduleTasks call below, so we do a swap instead of a move. |
+ // TODO(crbug.com/647402): Have the tile_task_manager keep a ref on the tasks, |
+ // since it makes it awkward for the callers to keep refs on tasks that only |
+ // exist within the task graph runner. |
locked_image_tasks_.swap(new_locked_image_tasks); |
// We must reduce the amount of unused resources before calling |
@@ -994,8 +998,7 @@ void TileManager::OnRasterTaskCompleted( |
// Unref all the images. |
auto images_it = scheduled_draw_images_.find(tile->id()); |
- const std::vector<DrawImage>& images = images_it->second; |
- image_manager_.UnrefImages(images); |
+ image_manager_.UnrefImages(images_it->second); |
scheduled_draw_images_.erase(images_it); |
if (was_canceled) { |
@@ -1145,8 +1148,8 @@ void TileManager::CheckIfMoreTilesNeedToBePrepared() { |
// If we're not in SMOOTHNESS_TAKES_PRIORITY mode, we should unlock all |
// images since we're technically going idle here at least for this frame. |
if (global_state_.tree_priority != SMOOTHNESS_TAKES_PRIORITY) { |
- image_manager_.UnrefImages(locked_images_); |
- locked_images_.clear(); |
+ image_manager_.SetPredecodeImages(std::vector<DrawImage>(), |
+ ImageDecodeController::TracingInfo()); |
locked_image_tasks_.clear(); |
} |