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

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: Created 5 years, 2 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
« cc/playback/display_list_raster_source.cc ('K') | « cc/tiles/tile_manager.h ('k') | no next file » | 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 56e6971a8b746abed8966fadd810f73c9b59a854..7086e800b45081d8aaa5e24f3d09f4947c69585b 100644
--- a/cc/tiles/tile_manager.cc
+++ b/cc/tiles/tile_manager.cc
@@ -24,6 +24,7 @@
#include "cc/tiles/tile.h"
#include "ui/gfx/geometry/rect_conversions.h"
+#include "ui/gfx/transform.h"
namespace cc {
namespace {
@@ -279,7 +280,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);
@@ -627,7 +627,7 @@ void TileManager::ScheduleTasks(
DCHECK(tile->draw_info().requires_resource());
DCHECK(!tile->draw_info().resource_);
- if (!tile->raster_task_.get())
+ if (!tile->raster_task_)
tile->raster_task_ = CreateRasterTask(prioritized_tile);
TaskSetCollection task_sets;
@@ -643,6 +643,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
@@ -660,6 +661,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()) {
@@ -680,12 +683,16 @@ 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_));
+ scoped_refptr<ImageDecodeTask> task =
+ image_decode_controller_.GetTaskForImageAndRef(image,
+ prepare_tiles_count_);
+ if (task)
+ decode_tasks.push_back(task);
}
return make_scoped_refptr(new RasterTaskImpl(
@@ -712,6 +719,15 @@ void TileManager::OnRasterTaskCompleted(
orphan_raster_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) {
+ const DrawImage& scaled_image = image.ApplyScale(tile->contents_scale());
+ image_decode_controller_.UnrefImage(scaled_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
@@ -766,7 +782,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;
}
« cc/playback/display_list_raster_source.cc ('K') | « cc/tiles/tile_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698