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 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
615 | 615 |
616 DCHECK(draw_info.mode() == TileDrawInfo::PICTURE_PILE_MODE || | 616 DCHECK(draw_info.mode() == TileDrawInfo::PICTURE_PILE_MODE || |
617 !draw_info.IsReadyToDraw()); | 617 !draw_info.IsReadyToDraw()); |
618 | 618 |
619 // If the tile already has a raster_task, then the memory used by it is | 619 // 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 | 620 // already accounted for in memory_usage. Otherwise, we'll have to acquire |
621 // more memory to create a raster task. | 621 // more memory to create a raster task. |
622 MemoryUsage memory_required_by_tile_to_be_scheduled; | 622 MemoryUsage memory_required_by_tile_to_be_scheduled; |
623 if (!tile->raster_task_.get()) { | 623 if (!tile->raster_task_.get()) { |
624 memory_required_by_tile_to_be_scheduled = MemoryUsage::FromConfig( | 624 memory_required_by_tile_to_be_scheduled = MemoryUsage::FromConfig( |
625 tile->desired_texture_size(), resource_pool_->resource_format()); | 625 tile->desired_texture_size(), resource_pool_->default_format()); |
626 } | 626 } |
627 | 627 |
628 bool tile_is_needed_now = priority.priority_bin == TilePriority::NOW; | 628 bool tile_is_needed_now = priority.priority_bin == TilePriority::NOW; |
629 | 629 |
630 // This is the memory limit that will be used by this tile. Depending on | 630 // 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 | 631 // the tile priority, it will be one of hard_memory_limit or |
632 // soft_memory_limit. | 632 // soft_memory_limit. |
633 MemoryUsage& tile_memory_limit = | 633 MemoryUsage& tile_memory_limit = |
634 tile_is_needed_now ? hard_memory_limit : soft_memory_limit; | 634 tile_is_needed_now ? hard_memory_limit : soft_memory_limit; |
635 | 635 |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
749 pixel_ref, | 749 pixel_ref, |
750 tile->layer_id(), | 750 tile->layer_id(), |
751 base::Bind(&TileManager::OnImageDecodeTaskCompleted, | 751 base::Bind(&TileManager::OnImageDecodeTaskCompleted, |
752 base::Unretained(this), | 752 base::Unretained(this), |
753 tile->layer_id(), | 753 tile->layer_id(), |
754 base::Unretained(pixel_ref)))); | 754 base::Unretained(pixel_ref)))); |
755 } | 755 } |
756 | 756 |
757 scoped_refptr<RasterTask> TileManager::CreateRasterTask(Tile* tile) { | 757 scoped_refptr<RasterTask> TileManager::CreateRasterTask(Tile* tile) { |
758 scoped_ptr<ScopedResource> resource = | 758 scoped_ptr<ScopedResource> resource = |
759 resource_pool_->AcquireResource(tile->desired_texture_size()); | 759 resource_pool_->AcquireResource(tile->desired_texture_size(), |
| 760 resource_pool_->default_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 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1050 result -= other; | 1051 result -= other; |
1051 return result; | 1052 return result; |
1052 } | 1053 } |
1053 | 1054 |
1054 bool TileManager::MemoryUsage::Exceeds(const MemoryUsage& limit) const { | 1055 bool TileManager::MemoryUsage::Exceeds(const MemoryUsage& limit) const { |
1055 return memory_bytes_ > limit.memory_bytes_ || | 1056 return memory_bytes_ > limit.memory_bytes_ || |
1056 resource_count_ > limit.resource_count_; | 1057 resource_count_ > limit.resource_count_; |
1057 } | 1058 } |
1058 | 1059 |
1059 } // namespace cc | 1060 } // namespace cc |
OLD | NEW |