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

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

Issue 793693003: Tile Compression (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 unified diff | Download patch
« no previous file with comments | « cc/resources/tile_manager.h ('k') | cc/resources/tile_manager_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 state->SetInteger("canceled_count", stats.canceled_count); 202 state->SetInteger("canceled_count", stats.canceled_count);
203 return state; 203 return state;
204 } 204 }
205 205
206 // static 206 // static
207 scoped_ptr<TileManager> TileManager::Create( 207 scoped_ptr<TileManager> TileManager::Create(
208 TileManagerClient* client, 208 TileManagerClient* client,
209 base::SequencedTaskRunner* task_runner, 209 base::SequencedTaskRunner* task_runner,
210 ResourcePool* resource_pool, 210 ResourcePool* resource_pool,
211 TileTaskRunner* tile_task_runner, 211 TileTaskRunner* tile_task_runner,
212 int compression_threshold,
212 RenderingStatsInstrumentation* rendering_stats_instrumentation, 213 RenderingStatsInstrumentation* rendering_stats_instrumentation,
213 size_t scheduled_raster_task_limit) { 214 size_t scheduled_raster_task_limit) {
214 return make_scoped_ptr(new TileManager( 215 return make_scoped_ptr(
215 client, task_runner, resource_pool, tile_task_runner, 216 new TileManager(client, task_runner, resource_pool, tile_task_runner,
216 rendering_stats_instrumentation, scheduled_raster_task_limit)); 217 compression_threshold, rendering_stats_instrumentation,
218 scheduled_raster_task_limit));
217 } 219 }
218 220
219 TileManager::TileManager( 221 TileManager::TileManager(
220 TileManagerClient* client, 222 TileManagerClient* client,
221 const scoped_refptr<base::SequencedTaskRunner>& task_runner, 223 const scoped_refptr<base::SequencedTaskRunner>& task_runner,
222 ResourcePool* resource_pool, 224 ResourcePool* resource_pool,
223 TileTaskRunner* tile_task_runner, 225 TileTaskRunner* tile_task_runner,
226 int compression_threshold,
224 RenderingStatsInstrumentation* rendering_stats_instrumentation, 227 RenderingStatsInstrumentation* rendering_stats_instrumentation,
225 size_t scheduled_raster_task_limit) 228 size_t scheduled_raster_task_limit)
226 : client_(client), 229 : client_(client),
227 task_runner_(task_runner), 230 task_runner_(task_runner),
228 resource_pool_(resource_pool), 231 resource_pool_(resource_pool),
229 tile_task_runner_(tile_task_runner), 232 tile_task_runner_(tile_task_runner),
230 scheduled_raster_task_limit_(scheduled_raster_task_limit), 233 scheduled_raster_task_limit_(scheduled_raster_task_limit),
231 all_tiles_that_need_to_be_rasterized_are_scheduled_(true), 234 all_tiles_that_need_to_be_rasterized_are_scheduled_(true),
232 rendering_stats_instrumentation_(rendering_stats_instrumentation), 235 rendering_stats_instrumentation_(rendering_stats_instrumentation),
233 did_check_for_completed_tasks_since_last_schedule_tasks_(true), 236 did_check_for_completed_tasks_since_last_schedule_tasks_(true),
234 did_oom_on_last_assign_(false), 237 did_oom_on_last_assign_(false),
238 compression_threshold_(compression_threshold),
235 ready_to_activate_check_notifier_( 239 ready_to_activate_check_notifier_(
236 task_runner_.get(), 240 task_runner_.get(),
237 base::Bind(&TileManager::CheckIfReadyToActivate, 241 base::Bind(&TileManager::CheckIfReadyToActivate,
238 base::Unretained(this))), 242 base::Unretained(this))),
239 ready_to_draw_check_notifier_( 243 ready_to_draw_check_notifier_(
240 task_runner_.get(), 244 task_runner_.get(),
241 base::Bind(&TileManager::CheckIfReadyToDraw, base::Unretained(this))), 245 base::Bind(&TileManager::CheckIfReadyToDraw, base::Unretained(this))),
242 did_notify_ready_to_activate_(false), 246 did_notify_ready_to_activate_(false),
243 did_notify_ready_to_draw_(false) { 247 did_notify_ready_to_draw_(false) {
244 tile_task_runner_->SetClient(this); 248 tile_task_runner_->SetClient(this);
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 DCHECK(mts.draw_info.mode() == 588 DCHECK(mts.draw_info.mode() ==
585 ManagedTileState::DrawInfo::PICTURE_PILE_MODE || 589 ManagedTileState::DrawInfo::PICTURE_PILE_MODE ||
586 !mts.draw_info.IsReadyToDraw()); 590 !mts.draw_info.IsReadyToDraw());
587 591
588 // If the tile already has a raster_task, then the memory used by it is 592 // If the tile already has a raster_task, then the memory used by it is
589 // already accounted for in memory_usage. Otherwise, we'll have to acquire 593 // already accounted for in memory_usage. Otherwise, we'll have to acquire
590 // more memory to create a raster task. 594 // more memory to create a raster task.
591 MemoryUsage memory_required_by_tile_to_be_scheduled; 595 MemoryUsage memory_required_by_tile_to_be_scheduled;
592 if (!mts.raster_task.get()) { 596 if (!mts.raster_task.get()) {
593 memory_required_by_tile_to_be_scheduled = MemoryUsage::FromConfig( 597 memory_required_by_tile_to_be_scheduled = MemoryUsage::FromConfig(
594 tile->size(), resource_pool_->resource_format()); 598 tile->size(),
599 resource_pool_->resource_format(DetermineResourceFormatUsage(tile)));
595 } 600 }
596 601
597 bool tile_is_needed_now = priority.priority_bin == TilePriority::NOW; 602 bool tile_is_needed_now = priority.priority_bin == TilePriority::NOW;
598 603
599 // This is the memory limit that will be used by this tile. Depending on 604 // This is the memory limit that will be used by this tile. Depending on
600 // the tile priority, it will be one of hard_memory_limit or 605 // the tile priority, it will be one of hard_memory_limit or
601 // soft_memory_limit. 606 // soft_memory_limit.
602 MemoryUsage& tile_memory_limit = 607 MemoryUsage& tile_memory_limit =
603 tile_is_needed_now ? hard_memory_limit : soft_memory_limit; 608 tile_is_needed_now ? hard_memory_limit : soft_memory_limit;
604 609
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 raster_priority_queue_.Reset(); 645 raster_priority_queue_.Reset();
641 646
642 TRACE_EVENT_END2("cc", 647 TRACE_EVENT_END2("cc",
643 "TileManager::AssignGpuMemoryToTiles", 648 "TileManager::AssignGpuMemoryToTiles",
644 "all_tiles_that_need_to_be_rasterized_are_scheduled", 649 "all_tiles_that_need_to_be_rasterized_are_scheduled",
645 all_tiles_that_need_to_be_rasterized_are_scheduled_, 650 all_tiles_that_need_to_be_rasterized_are_scheduled_,
646 "had_enough_memory_to_schedule_tiles_needed_now", 651 "had_enough_memory_to_schedule_tiles_needed_now",
647 had_enough_memory_to_schedule_tiles_needed_now); 652 had_enough_memory_to_schedule_tiles_needed_now);
648 } 653 }
649 654
655 ResourceFormatUsage TileManager::DetermineResourceFormatUsage(
656 const Tile* tile) const {
657 ResourceFormatUsage usage;
658 if (tile->size().width() % 4 != 0 || tile->size().height() % 4 != 0 ||
659 tile->frequently_invalidated()) {
660 usage = FORMAT_USAGE_NATIVE;
661 } else {
662 usage = tile->IsOpaque() ? FORMAT_USAGE_OPAQUE : FORMAT_USAGE_TRANSLUCENT;
663 // Urgent tiles can be generated faster if we avoid memory optimized
664 // formats.
665 if (compression_threshold_ >= 0) {
666 TilePriority::PriorityBin bin = tile->combined_priority().priority_bin;
667 if (static_cast<int>(bin) < compression_threshold_) {
668 usage = FORMAT_USAGE_NATIVE;
669 }
670 }
671 }
672 return usage;
673 }
674
650 void TileManager::FreeResourcesForTile(Tile* tile) { 675 void TileManager::FreeResourcesForTile(Tile* tile) {
651 ManagedTileState& mts = tile->managed_state(); 676 ManagedTileState& mts = tile->managed_state();
652 if (mts.draw_info.resource_) 677 if (mts.draw_info.resource_)
653 resource_pool_->ReleaseResource(mts.draw_info.resource_.Pass()); 678 resource_pool_->ReleaseResource(mts.draw_info.resource_.Pass());
654 } 679 }
655 680
656 void TileManager::FreeResourcesForTileAndNotifyClientIfTileWasReadyToDraw( 681 void TileManager::FreeResourcesForTileAndNotifyClientIfTileWasReadyToDraw(
657 Tile* tile) { 682 Tile* tile) {
658 bool was_ready_to_draw = tile->IsReadyToDraw(); 683 bool was_ready_to_draw = tile->IsReadyToDraw();
659 FreeResourcesForTile(tile); 684 FreeResourcesForTile(tile);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 rendering_stats_instrumentation_, 747 rendering_stats_instrumentation_,
723 base::Bind(&TileManager::OnImageDecodeTaskCompleted, 748 base::Bind(&TileManager::OnImageDecodeTaskCompleted,
724 base::Unretained(this), 749 base::Unretained(this),
725 tile->layer_id(), 750 tile->layer_id(),
726 base::Unretained(pixel_ref)))); 751 base::Unretained(pixel_ref))));
727 } 752 }
728 753
729 scoped_refptr<RasterTask> TileManager::CreateRasterTask(Tile* tile) { 754 scoped_refptr<RasterTask> TileManager::CreateRasterTask(Tile* tile) {
730 ManagedTileState& mts = tile->managed_state(); 755 ManagedTileState& mts = tile->managed_state();
731 756
732 scoped_ptr<ScopedResource> resource = 757 scoped_ptr<ScopedResource> resource = resource_pool_->AcquireResource(
733 resource_pool_->AcquireResource(tile->size()); 758 tile->size(), DetermineResourceFormatUsage(tile));
734 const ScopedResource* const_resource = resource.get(); 759 const ScopedResource* const_resource = resource.get();
735 760
736 // Create and queue all image decode tasks that this tile depends on. 761 // Create and queue all image decode tasks that this tile depends on.
737 ImageDecodeTask::Vector decode_tasks; 762 ImageDecodeTask::Vector decode_tasks;
738 PixelRefTaskMap& existing_pixel_refs = image_decode_tasks_[tile->layer_id()]; 763 PixelRefTaskMap& existing_pixel_refs = image_decode_tasks_[tile->layer_id()];
739 std::vector<SkPixelRef*> pixel_refs; 764 std::vector<SkPixelRef*> pixel_refs;
740 tile->raster_source()->GatherPixelRefs( 765 tile->raster_source()->GatherPixelRefs(
741 tile->content_rect(), tile->contents_scale(), &pixel_refs); 766 tile->content_rect(), tile->contents_scale(), &pixel_refs);
742 for (SkPixelRef* pixel_ref : pixel_refs) { 767 for (SkPixelRef* pixel_ref : pixel_refs) {
743 uint32_t id = pixel_ref->getGenerationID(); 768 uint32_t id = pixel_ref->getGenerationID();
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 result -= other; 976 result -= other;
952 return result; 977 return result;
953 } 978 }
954 979
955 bool TileManager::MemoryUsage::Exceeds(const MemoryUsage& limit) const { 980 bool TileManager::MemoryUsage::Exceeds(const MemoryUsage& limit) const {
956 return memory_bytes_ > limit.memory_bytes_ || 981 return memory_bytes_ > limit.memory_bytes_ ||
957 resource_count_ > limit.resource_count_; 982 resource_count_ > limit.resource_count_;
958 } 983 }
959 984
960 } // namespace cc 985 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/tile_manager.h ('k') | cc/resources/tile_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698