Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2617)

Unified Diff: cc/tiles/tile_manager.cc

Issue 1418573002: cc: Add image decode control in the compositor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/tiles/tile_manager.h ('k') | content/renderer/render_thread_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/tiles/tile_manager.cc
diff --git a/cc/tiles/tile_manager.cc b/cc/tiles/tile_manager.cc
index ebb1d3fd6360c9350ab68eb55379b42049a6c818..ca40d23467916a1277d2a253929b02a80dc2baa4 100644
--- a/cc/tiles/tile_manager.cc
+++ b/cc/tiles/tile_manager.cc
@@ -342,6 +342,7 @@ void TileManager::SetResources(ResourcePool* resource_pool,
scheduled_raster_task_limit_ = scheduled_raster_task_limit;
resource_pool_ = resource_pool;
tile_task_runner_ = tile_task_runner;
+ image_decode_controller_.SetIsUsingGpuRasterization(use_gpu_rasterization_);
}
void TileManager::Release(Tile* tile) {
@@ -365,7 +366,6 @@ void TileManager::CleanUpReleasedTiles() {
DCHECK(tiles_.find(tile->id()) != tiles_.end());
tiles_.erase(tile->id());
- image_decode_controller_.SubtractLayerUsedCount(tile->layer_id());
delete tile;
}
released_tiles_.swap(tiles_to_retain);
@@ -752,16 +752,12 @@ void TileManager::ScheduleTasks(
DCHECK(tile->draw_info().requires_resource());
DCHECK(!tile->draw_info().resource_);
- if (!tile->raster_task_) {
+ if (!tile->raster_task_)
tile->raster_task_ = CreateRasterTask(prioritized_tile);
- }
RasterTask* task = tile->raster_task_.get();
DCHECK(!task->HasCompleted());
- if (!tile->raster_task_.get())
- tile->raster_task_ = CreateRasterTask(prioritized_tile);
-
if (tile->required_for_activation()) {
required_for_activate_count++;
graph_.edges.push_back(
@@ -797,6 +793,7 @@ void TileManager::ScheduleTasks(
// We must reduce the amount of unused resoruces before calling
// ScheduleTasks to prevent usage from rising above limits.
resource_pool_->ReduceResourceUsage();
+ image_decode_controller_.ReduceCacheUsage();
// Schedule running of |raster_queue_|. This replaces any previously
// scheduled tasks and effectively cancels all tasks not present
@@ -823,6 +820,8 @@ void TileManager::ScheduleTasks(
scoped_refptr<RasterTask> TileManager::CreateRasterTask(
const PrioritizedTile& prioritized_tile) {
Tile* tile = prioritized_tile.tile();
+
+ // Get the resource.
uint64_t resource_content_id = 0;
Resource* resource = nullptr;
if (use_partial_raster_ && tile->invalidated_id()) {
@@ -843,12 +842,22 @@ scoped_refptr<RasterTask> TileManager::CreateRasterTask(
// Create and queue all image decode tasks that this tile depends on.
ImageDecodeTask::Vector decode_tasks;
- std::vector<DrawImage> images;
+ std::vector<DrawImage>& images = scheduled_draw_images_[tile->id()];
+ images.clear();
prioritized_tile.raster_source()->GetDiscardableImagesInRect(
tile->enclosing_layer_rect(), tile->contents_scale(), &images);
- for (const auto& image : images) {
- decode_tasks.push_back(image_decode_controller_.GetTaskForImage(
- image, tile->layer_id(), prepare_tiles_count_));
+ for (auto it = images.begin(); it != images.end();) {
+ scoped_refptr<ImageDecodeTask> task;
+ bool need_to_unref_when_finished =
+ image_decode_controller_.GetTaskForImageAndRef(
+ *it, prepare_tiles_count_, &task);
+ if (task)
+ decode_tasks.push_back(task);
+
+ if (need_to_unref_when_finished)
+ ++it;
+ else
+ it = images.erase(it);
}
return make_scoped_refptr(new RasterTaskImpl(
@@ -874,6 +883,13 @@ void TileManager::OnRasterTaskCompleted(
orphan_tasks_.push_back(tile->raster_task_);
tile->raster_task_ = nullptr;
+ // Unref all the images.
+ auto images_it = scheduled_draw_images_.find(tile->id());
+ const std::vector<DrawImage>& images = images_it->second;
+ for (const auto& image : images)
+ image_decode_controller_.UnrefImage(image);
+ scheduled_draw_images_.erase(images_it);
+
if (was_canceled) {
++flush_stats_.canceled_count;
// TODO(ericrk): If more partial raster work is done in the future, it may
@@ -908,7 +924,6 @@ ScopedTilePtr TileManager::CreateTile(const Tile::CreateInfo& info,
DCHECK(tiles_.find(tile->id()) == tiles_.end());
tiles_[tile->id()] = tile.get();
- image_decode_controller_.AddLayerUsedCount(tile->layer_id());
return tile;
}
@@ -1024,6 +1039,7 @@ void TileManager::CheckIfMoreTilesNeedToBePrepared() {
FreeResourcesForReleasedTiles();
resource_pool_->ReduceResourceUsage();
+ image_decode_controller_.ReduceCacheUsage();
signals_.all_tile_tasks_completed = true;
signals_check_notifier_.Schedule();
« no previous file with comments | « cc/tiles/tile_manager.h ('k') | content/renderer/render_thread_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698