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

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

Issue 817133006: Support different formats in the same resource pool. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(),
626 resource_pool_->resource_format(DetermineResourceFormatUsage(tile)));
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 670
670 raster_priority_queue_.Reset(); 671 raster_priority_queue_.Reset();
671 672
672 TRACE_EVENT_END2("cc", "TileManager::AssignGpuMemoryToTiles", 673 TRACE_EVENT_END2("cc", "TileManager::AssignGpuMemoryToTiles",
673 "all_tiles_that_need_to_be_rasterized_are_scheduled", 674 "all_tiles_that_need_to_be_rasterized_are_scheduled",
674 all_tiles_that_need_to_be_rasterized_are_scheduled_, 675 all_tiles_that_need_to_be_rasterized_are_scheduled_,
675 "had_enough_memory_to_schedule_tiles_needed_now", 676 "had_enough_memory_to_schedule_tiles_needed_now",
676 had_enough_memory_to_schedule_tiles_needed_now); 677 had_enough_memory_to_schedule_tiles_needed_now);
677 } 678 }
678 679
680 ResourceFormatUsage TileManager::DetermineResourceFormatUsage(
681 const Tile* tile) const {
682 ResourceFormatUsage usage;
683 gfx::Size size = tile->desired_texture_size();
684 if ((size.width() % 4 != 0) || (size.height() % 4 != 0)) {
685 usage = FORMAT_USAGE_NATIVE;
686 } else {
687 usage = tile->IsOpaque() ? FORMAT_USAGE_OPAQUE : FORMAT_USAGE_TRANSLUSCENT;
688 }
689 return usage;
690 }
691
679 void TileManager::FreeResourcesForTile(Tile* tile) { 692 void TileManager::FreeResourcesForTile(Tile* tile) {
680 TileDrawInfo& draw_info = tile->draw_info(); 693 TileDrawInfo& draw_info = tile->draw_info();
681 if (draw_info.resource_) 694 if (draw_info.resource_)
682 resource_pool_->ReleaseResource(draw_info.resource_.Pass()); 695 resource_pool_->ReleaseResource(draw_info.resource_.Pass());
683 } 696 }
684 697
685 void TileManager::FreeResourcesForTileAndNotifyClientIfTileWasReadyToDraw( 698 void TileManager::FreeResourcesForTileAndNotifyClientIfTileWasReadyToDraw(
686 Tile* tile) { 699 Tile* tile) {
687 bool was_ready_to_draw = tile->IsReadyToDraw(); 700 bool was_ready_to_draw = tile->IsReadyToDraw();
688 FreeResourcesForTile(tile); 701 FreeResourcesForTile(tile);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 pixel_ref, 762 pixel_ref,
750 tile->layer_id(), 763 tile->layer_id(),
751 base::Bind(&TileManager::OnImageDecodeTaskCompleted, 764 base::Bind(&TileManager::OnImageDecodeTaskCompleted,
752 base::Unretained(this), 765 base::Unretained(this),
753 tile->layer_id(), 766 tile->layer_id(),
754 base::Unretained(pixel_ref)))); 767 base::Unretained(pixel_ref))));
755 } 768 }
756 769
757 scoped_refptr<RasterTask> TileManager::CreateRasterTask(Tile* tile) { 770 scoped_refptr<RasterTask> TileManager::CreateRasterTask(Tile* tile) {
758 scoped_ptr<ScopedResource> resource = 771 scoped_ptr<ScopedResource> resource =
759 resource_pool_->AcquireResource(tile->desired_texture_size()); 772 resource_pool_->AcquireResource(tile->desired_texture_size(),
773 DetermineResourceFormatUsage(tile));
760 const ScopedResource* const_resource = resource.get(); 774 const ScopedResource* const_resource = resource.get();
761 775
762 // Create and queue all image decode tasks that this tile depends on. 776 // Create and queue all image decode tasks that this tile depends on.
763 ImageDecodeTask::Vector decode_tasks; 777 ImageDecodeTask::Vector decode_tasks;
764 PixelRefTaskMap& existing_pixel_refs = image_decode_tasks_[tile->layer_id()]; 778 PixelRefTaskMap& existing_pixel_refs = image_decode_tasks_[tile->layer_id()];
765 std::vector<SkPixelRef*> pixel_refs; 779 std::vector<SkPixelRef*> pixel_refs;
766 tile->raster_source()->GatherPixelRefs( 780 tile->raster_source()->GatherPixelRefs(
767 tile->content_rect(), tile->contents_scale(), &pixel_refs); 781 tile->content_rect(), tile->contents_scale(), &pixel_refs);
768 for (SkPixelRef* pixel_ref : pixel_refs) { 782 for (SkPixelRef* pixel_ref : pixel_refs) {
769 uint32_t id = pixel_ref->getGenerationID(); 783 uint32_t id = pixel_ref->getGenerationID();
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
1050 result -= other; 1064 result -= other;
1051 return result; 1065 return result;
1052 } 1066 }
1053 1067
1054 bool TileManager::MemoryUsage::Exceeds(const MemoryUsage& limit) const { 1068 bool TileManager::MemoryUsage::Exceeds(const MemoryUsage& limit) const {
1055 return memory_bytes_ > limit.memory_bytes_ || 1069 return memory_bytes_ > limit.memory_bytes_ ||
1056 resource_count_ > limit.resource_count_; 1070 resource_count_ > limit.resource_count_;
1057 } 1071 }
1058 1072
1059 } // namespace cc 1073 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698