| OLD | NEW |
| 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 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 AssignGpuMemoryToTiles(&tiles_that_need_to_be_rasterized, | 406 AssignGpuMemoryToTiles(&tiles_that_need_to_be_rasterized, |
| 407 std::numeric_limits<size_t>::max(), true); | 407 std::numeric_limits<size_t>::max(), true); |
| 408 | 408 |
| 409 // We must reduce the amount of unused resources before calling | 409 // We must reduce the amount of unused resources before calling |
| 410 // RunTasks to prevent usage from rising above limits. | 410 // RunTasks to prevent usage from rising above limits. |
| 411 resource_pool_->ReduceResourceUsage(); | 411 resource_pool_->ReduceResourceUsage(); |
| 412 | 412 |
| 413 // Run and complete all raster task synchronously. | 413 // Run and complete all raster task synchronously. |
| 414 rasterizer_->RasterizeTiles( | 414 rasterizer_->RasterizeTiles( |
| 415 tiles_that_need_to_be_rasterized, resource_pool_, | 415 tiles_that_need_to_be_rasterized, resource_pool_, |
| 416 tile_task_runner_->GetResourceFormat(), |
| 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 Loading... |
| 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(), tile_task_runner_->GetResourceFormat()); |
| 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 Loading... |
| 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 tile_task_runner_->GetResourceFormat()); |
| 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 Loading... |
| 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 |
| OLD | NEW |