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

Side by Side Diff: cc/resources/tile_manager.cc

Issue 860813002: Remove the default format from ResourcePool. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compile error in another perftest. Created 5 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 unified diff | Download patch
OLDNEW
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/resources/tile_manager.h" 5 #include "cc/resources/tile_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <string> 9 #include <string>
10 10
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 size_t scheduled_raster_task_limit) 215 size_t scheduled_raster_task_limit)
216 : client_(client), 216 : client_(client),
217 task_runner_(task_runner), 217 task_runner_(task_runner),
218 resource_pool_(resource_pool), 218 resource_pool_(resource_pool),
219 tile_task_runner_(tile_task_runner), 219 tile_task_runner_(tile_task_runner),
220 rasterizer_(rasterizer), 220 rasterizer_(rasterizer),
221 scheduled_raster_task_limit_(scheduled_raster_task_limit), 221 scheduled_raster_task_limit_(scheduled_raster_task_limit),
222 all_tiles_that_need_to_be_rasterized_are_scheduled_(true), 222 all_tiles_that_need_to_be_rasterized_are_scheduled_(true),
223 did_check_for_completed_tasks_since_last_schedule_tasks_(true), 223 did_check_for_completed_tasks_since_last_schedule_tasks_(true),
224 did_oom_on_last_assign_(false), 224 did_oom_on_last_assign_(false),
225 resource_format_(tile_task_runner->GetResourceFormat()),
225 ready_to_activate_notifier_( 226 ready_to_activate_notifier_(
226 task_runner_.get(), 227 task_runner_.get(),
227 base::Bind(&TileManager::NotifyReadyToActivate, 228 base::Bind(&TileManager::NotifyReadyToActivate,
228 base::Unretained(this))), 229 base::Unretained(this))),
229 ready_to_draw_notifier_( 230 ready_to_draw_notifier_(
230 task_runner_.get(), 231 task_runner_.get(),
231 base::Bind(&TileManager::NotifyReadyToDraw, base::Unretained(this))), 232 base::Bind(&TileManager::NotifyReadyToDraw, base::Unretained(this))),
232 ready_to_activate_check_notifier_( 233 ready_to_activate_check_notifier_(
233 task_runner_.get(), 234 task_runner_.get(),
234 base::Bind(&TileManager::CheckIfReadyToActivate, 235 base::Bind(&TileManager::CheckIfReadyToActivate,
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 TileVector tiles_that_need_to_be_rasterized; 406 TileVector tiles_that_need_to_be_rasterized;
406 AssignGpuMemoryToTiles(&tiles_that_need_to_be_rasterized, 407 AssignGpuMemoryToTiles(&tiles_that_need_to_be_rasterized,
407 std::numeric_limits<size_t>::max(), true); 408 std::numeric_limits<size_t>::max(), true);
408 409
409 // We must reduce the amount of unused resources before calling 410 // We must reduce the amount of unused resources before calling
410 // RunTasks to prevent usage from rising above limits. 411 // RunTasks to prevent usage from rising above limits.
411 resource_pool_->ReduceResourceUsage(); 412 resource_pool_->ReduceResourceUsage();
412 413
413 // Run and complete all raster task synchronously. 414 // Run and complete all raster task synchronously.
414 rasterizer_->RasterizeTiles( 415 rasterizer_->RasterizeTiles(
415 tiles_that_need_to_be_rasterized, resource_pool_, 416 tiles_that_need_to_be_rasterized, resource_pool_, resource_format_,
416 base::Bind(&TileManager::UpdateTileDrawInfo, base::Unretained(this))); 417 base::Bind(&TileManager::UpdateTileDrawInfo, base::Unretained(this)));
417 418
418 // Use on-demand raster for any required-for-draw tiles that have not been 419 // Use on-demand raster for any required-for-draw tiles that have not been
419 // assigned memory after reaching a steady memory state. 420 // assigned memory after reaching a steady memory state.
420 // TODO(hendrikw): Figure out why this would improve jank on some tests - See 421 // TODO(hendrikw): Figure out why this would improve jank on some tests - See
421 // crbug.com/449288 422 // crbug.com/449288
422 client_->BuildRasterQueue(&raster_priority_queue_, 423 client_->BuildRasterQueue(&raster_priority_queue_,
423 global_state_.tree_priority, 424 global_state_.tree_priority,
424 RasterTilePriorityQueue::Type::ALL); 425 RasterTilePriorityQueue::Type::ALL);
425 426
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 616
616 DCHECK(draw_info.mode() == TileDrawInfo::PICTURE_PILE_MODE || 617 DCHECK(draw_info.mode() == TileDrawInfo::PICTURE_PILE_MODE ||
617 !draw_info.IsReadyToDraw()); 618 !draw_info.IsReadyToDraw());
618 619
619 // If the tile already has a raster_task, then the memory used by it is 620 // If the tile already has a raster_task, then the memory used by it is
620 // already accounted for in memory_usage. Otherwise, we'll have to acquire 621 // already accounted for in memory_usage. Otherwise, we'll have to acquire
621 // more memory to create a raster task. 622 // more memory to create a raster task.
622 MemoryUsage memory_required_by_tile_to_be_scheduled; 623 MemoryUsage memory_required_by_tile_to_be_scheduled;
623 if (!tile->raster_task_.get()) { 624 if (!tile->raster_task_.get()) {
624 memory_required_by_tile_to_be_scheduled = MemoryUsage::FromConfig( 625 memory_required_by_tile_to_be_scheduled = MemoryUsage::FromConfig(
625 tile->desired_texture_size(), resource_pool_->default_format()); 626 tile->desired_texture_size(), resource_format_);
626 } 627 }
627 628
628 bool tile_is_needed_now = priority.priority_bin == TilePriority::NOW; 629 bool tile_is_needed_now = priority.priority_bin == TilePriority::NOW;
629 630
630 // This is the memory limit that will be used by this tile. Depending on 631 // This is the memory limit that will be used by this tile. Depending on
631 // the tile priority, it will be one of hard_memory_limit or 632 // the tile priority, it will be one of hard_memory_limit or
632 // soft_memory_limit. 633 // soft_memory_limit.
633 MemoryUsage& tile_memory_limit = 634 MemoryUsage& tile_memory_limit =
634 tile_is_needed_now ? hard_memory_limit : soft_memory_limit; 635 tile_is_needed_now ? hard_memory_limit : soft_memory_limit;
635 636
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 pixel_ref, 750 pixel_ref,
750 base::Bind(&TileManager::OnImageDecodeTaskCompleted, 751 base::Bind(&TileManager::OnImageDecodeTaskCompleted,
751 base::Unretained(this), 752 base::Unretained(this),
752 tile->layer_id(), 753 tile->layer_id(),
753 base::Unretained(pixel_ref)))); 754 base::Unretained(pixel_ref))));
754 } 755 }
755 756
756 scoped_refptr<RasterTask> TileManager::CreateRasterTask(Tile* tile) { 757 scoped_refptr<RasterTask> TileManager::CreateRasterTask(Tile* tile) {
757 scoped_ptr<ScopedResource> resource = 758 scoped_ptr<ScopedResource> resource =
758 resource_pool_->AcquireResource(tile->desired_texture_size(), 759 resource_pool_->AcquireResource(tile->desired_texture_size(),
759 resource_pool_->default_format()); 760 resource_format_);
760 const ScopedResource* const_resource = resource.get(); 761 const ScopedResource* const_resource = resource.get();
761 762
762 // Create and queue all image decode tasks that this tile depends on. 763 // Create and queue all image decode tasks that this tile depends on.
763 ImageDecodeTask::Vector decode_tasks; 764 ImageDecodeTask::Vector decode_tasks;
764 PixelRefTaskMap& existing_pixel_refs = image_decode_tasks_[tile->layer_id()]; 765 PixelRefTaskMap& existing_pixel_refs = image_decode_tasks_[tile->layer_id()];
765 std::vector<SkPixelRef*> pixel_refs; 766 std::vector<SkPixelRef*> pixel_refs;
766 tile->raster_source()->GatherPixelRefs( 767 tile->raster_source()->GatherPixelRefs(
767 tile->content_rect(), tile->contents_scale(), &pixel_refs); 768 tile->content_rect(), tile->contents_scale(), &pixel_refs);
768 for (SkPixelRef* pixel_ref : pixel_refs) { 769 for (SkPixelRef* pixel_ref : pixel_refs) {
769 uint32_t id = pixel_ref->getGenerationID(); 770 uint32_t id = pixel_ref->getGenerationID();
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
1056 result -= other; 1057 result -= other;
1057 return result; 1058 return result;
1058 } 1059 }
1059 1060
1060 bool TileManager::MemoryUsage::Exceeds(const MemoryUsage& limit) const { 1061 bool TileManager::MemoryUsage::Exceeds(const MemoryUsage& limit) const {
1061 return memory_bytes_ > limit.memory_bytes_ || 1062 return memory_bytes_ > limit.memory_bytes_ ||
1062 resource_count_ > limit.resource_count_; 1063 resource_count_ > limit.resource_count_;
1063 } 1064 }
1064 1065
1065 } // namespace cc 1066 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698