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

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 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
Index: cc/tiles/tile_manager.cc
diff --git a/cc/tiles/tile_manager.cc b/cc/tiles/tile_manager.cc
index 477025f3f80f9da5f0eb9304eafe787d7c398c64..e0abab84d42984d5960d2579a2f0c14c5237fe44 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 {
@@ -248,7 +249,8 @@ void TileManager::FinishTasksAndCleanUp() {
void TileManager::SetResources(ResourcePool* resource_pool,
TileTaskRunner* tile_task_runner,
- size_t scheduled_raster_task_limit) {
+ size_t scheduled_raster_task_limit,
+ bool is_using_gpu_rasterization) {
DCHECK(!tile_task_runner_);
DCHECK(tile_task_runner);
@@ -256,6 +258,8 @@ void TileManager::SetResources(ResourcePool* resource_pool,
resource_pool_ = resource_pool;
tile_task_runner_ = tile_task_runner;
tile_task_runner_->SetClient(this);
+ image_decode_controller_.SetIsUsingGpuRasterization(
+ is_using_gpu_rasterization);
}
void TileManager::Release(Tile* tile) {
@@ -279,7 +283,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 +630,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 +646,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 +664,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 +686,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(
@@ -712,6 +728,13 @@ 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)
+ 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
@@ -766,7 +789,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;
}

Powered by Google App Engine
This is Rietveld 408576698