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

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 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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 state->SetInteger("completed_count", stats.completed_count); 191 state->SetInteger("completed_count", stats.completed_count);
192 state->SetInteger("canceled_count", stats.canceled_count); 192 state->SetInteger("canceled_count", stats.canceled_count);
193 return state; 193 return state;
194 } 194 }
195 195
196 // static 196 // static
197 scoped_ptr<TileManager> TileManager::Create( 197 scoped_ptr<TileManager> TileManager::Create(
198 TileManagerClient* client, 198 TileManagerClient* client,
199 base::SequencedTaskRunner* task_runner, 199 base::SequencedTaskRunner* task_runner,
200 ResourcePool* resource_pool, 200 ResourcePool* resource_pool,
201 ResourceFormat resource_format,
201 TileTaskRunner* tile_task_runner, 202 TileTaskRunner* tile_task_runner,
202 Rasterizer* rasterizer, 203 Rasterizer* rasterizer,
203 size_t scheduled_raster_task_limit) { 204 size_t scheduled_raster_task_limit) {
204 return make_scoped_ptr(new TileManager(client, task_runner, resource_pool, 205 return make_scoped_ptr(new TileManager(client, task_runner, resource_pool,
205 tile_task_runner, rasterizer, 206 resource_format, tile_task_runner,
207 rasterizer,
206 scheduled_raster_task_limit)); 208 scheduled_raster_task_limit));
207 } 209 }
208 210
209 TileManager::TileManager( 211 TileManager::TileManager(
210 TileManagerClient* client, 212 TileManagerClient* client,
211 const scoped_refptr<base::SequencedTaskRunner>& task_runner, 213 const scoped_refptr<base::SequencedTaskRunner>& task_runner,
212 ResourcePool* resource_pool, 214 ResourcePool* resource_pool,
215 ResourceFormat resource_format,
213 TileTaskRunner* tile_task_runner, 216 TileTaskRunner* tile_task_runner,
214 Rasterizer* rasterizer, 217 Rasterizer* rasterizer,
215 size_t scheduled_raster_task_limit) 218 size_t scheduled_raster_task_limit)
216 : client_(client), 219 : client_(client),
217 task_runner_(task_runner), 220 task_runner_(task_runner),
218 resource_pool_(resource_pool), 221 resource_pool_(resource_pool),
219 tile_task_runner_(tile_task_runner), 222 tile_task_runner_(tile_task_runner),
220 rasterizer_(rasterizer), 223 rasterizer_(rasterizer),
221 scheduled_raster_task_limit_(scheduled_raster_task_limit), 224 scheduled_raster_task_limit_(scheduled_raster_task_limit),
222 all_tiles_that_need_to_be_rasterized_are_scheduled_(true), 225 all_tiles_that_need_to_be_rasterized_are_scheduled_(true),
223 did_check_for_completed_tasks_since_last_schedule_tasks_(true), 226 did_check_for_completed_tasks_since_last_schedule_tasks_(true),
224 did_oom_on_last_assign_(false), 227 did_oom_on_last_assign_(false),
228 resource_format_(resource_format),
225 ready_to_activate_notifier_( 229 ready_to_activate_notifier_(
226 task_runner_.get(), 230 task_runner_.get(),
227 base::Bind(&TileManager::NotifyReadyToActivate, 231 base::Bind(&TileManager::NotifyReadyToActivate,
228 base::Unretained(this))), 232 base::Unretained(this))),
229 ready_to_draw_notifier_( 233 ready_to_draw_notifier_(
230 task_runner_.get(), 234 task_runner_.get(),
231 base::Bind(&TileManager::NotifyReadyToDraw, base::Unretained(this))), 235 base::Bind(&TileManager::NotifyReadyToDraw, base::Unretained(this))),
232 ready_to_activate_check_notifier_( 236 ready_to_activate_check_notifier_(
233 task_runner_.get(), 237 task_runner_.get(),
234 base::Bind(&TileManager::CheckIfReadyToActivate, 238 base::Bind(&TileManager::CheckIfReadyToActivate,
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 TileVector tiles_that_need_to_be_rasterized; 409 TileVector tiles_that_need_to_be_rasterized;
406 AssignGpuMemoryToTiles(&tiles_that_need_to_be_rasterized, 410 AssignGpuMemoryToTiles(&tiles_that_need_to_be_rasterized,
407 std::numeric_limits<size_t>::max(), true); 411 std::numeric_limits<size_t>::max(), true);
408 412
409 // We must reduce the amount of unused resources before calling 413 // We must reduce the amount of unused resources before calling
410 // RunTasks to prevent usage from rising above limits. 414 // RunTasks to prevent usage from rising above limits.
411 resource_pool_->ReduceResourceUsage(); 415 resource_pool_->ReduceResourceUsage();
412 416
413 // Run and complete all raster task synchronously. 417 // Run and complete all raster task synchronously.
414 rasterizer_->RasterizeTiles( 418 rasterizer_->RasterizeTiles(
415 tiles_that_need_to_be_rasterized, resource_pool_, 419 tiles_that_need_to_be_rasterized, resource_pool_, resource_format_,
416 base::Bind(&TileManager::UpdateTileDrawInfo, base::Unretained(this))); 420 base::Bind(&TileManager::UpdateTileDrawInfo, base::Unretained(this)));
417 421
418 // Use on-demand raster for any required-for-draw tiles that have not been 422 // Use on-demand raster for any required-for-draw tiles that have not been
419 // assigned memory after reaching a steady memory state. 423 // assigned memory after reaching a steady memory state.
420 // TODO(hendrikw): Figure out why this would improve jank on some tests - See 424 // TODO(hendrikw): Figure out why this would improve jank on some tests - See
421 // crbug.com/449288 425 // crbug.com/449288
422 client_->BuildRasterQueue(&raster_priority_queue_, 426 client_->BuildRasterQueue(&raster_priority_queue_,
423 global_state_.tree_priority, 427 global_state_.tree_priority,
424 RasterTilePriorityQueue::Type::ALL); 428 RasterTilePriorityQueue::Type::ALL);
425 429
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 619
616 DCHECK(draw_info.mode() == TileDrawInfo::PICTURE_PILE_MODE || 620 DCHECK(draw_info.mode() == TileDrawInfo::PICTURE_PILE_MODE ||
617 !draw_info.IsReadyToDraw()); 621 !draw_info.IsReadyToDraw());
618 622
619 // If the tile already has a raster_task, then the memory used by it is 623 // 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 624 // already accounted for in memory_usage. Otherwise, we'll have to acquire
621 // more memory to create a raster task. 625 // more memory to create a raster task.
622 MemoryUsage memory_required_by_tile_to_be_scheduled; 626 MemoryUsage memory_required_by_tile_to_be_scheduled;
623 if (!tile->raster_task_.get()) { 627 if (!tile->raster_task_.get()) {
624 memory_required_by_tile_to_be_scheduled = MemoryUsage::FromConfig( 628 memory_required_by_tile_to_be_scheduled = MemoryUsage::FromConfig(
625 tile->desired_texture_size(), resource_pool_->default_format()); 629 tile->desired_texture_size(), resource_format_);
626 } 630 }
627 631
628 bool tile_is_needed_now = priority.priority_bin == TilePriority::NOW; 632 bool tile_is_needed_now = priority.priority_bin == TilePriority::NOW;
629 633
630 // This is the memory limit that will be used by this tile. Depending on 634 // 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 635 // the tile priority, it will be one of hard_memory_limit or
632 // soft_memory_limit. 636 // soft_memory_limit.
633 MemoryUsage& tile_memory_limit = 637 MemoryUsage& tile_memory_limit =
634 tile_is_needed_now ? hard_memory_limit : soft_memory_limit; 638 tile_is_needed_now ? hard_memory_limit : soft_memory_limit;
635 639
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 pixel_ref, 753 pixel_ref,
750 base::Bind(&TileManager::OnImageDecodeTaskCompleted, 754 base::Bind(&TileManager::OnImageDecodeTaskCompleted,
751 base::Unretained(this), 755 base::Unretained(this),
752 tile->layer_id(), 756 tile->layer_id(),
753 base::Unretained(pixel_ref)))); 757 base::Unretained(pixel_ref))));
754 } 758 }
755 759
756 scoped_refptr<RasterTask> TileManager::CreateRasterTask(Tile* tile) { 760 scoped_refptr<RasterTask> TileManager::CreateRasterTask(Tile* tile) {
757 scoped_ptr<ScopedResource> resource = 761 scoped_ptr<ScopedResource> resource =
758 resource_pool_->AcquireResource(tile->desired_texture_size(), 762 resource_pool_->AcquireResource(tile->desired_texture_size(),
759 resource_pool_->default_format()); 763 resource_format_);
760 const ScopedResource* const_resource = resource.get(); 764 const ScopedResource* const_resource = resource.get();
761 765
762 // Create and queue all image decode tasks that this tile depends on. 766 // Create and queue all image decode tasks that this tile depends on.
763 ImageDecodeTask::Vector decode_tasks; 767 ImageDecodeTask::Vector decode_tasks;
764 PixelRefTaskMap& existing_pixel_refs = image_decode_tasks_[tile->layer_id()]; 768 PixelRefTaskMap& existing_pixel_refs = image_decode_tasks_[tile->layer_id()];
765 std::vector<SkPixelRef*> pixel_refs; 769 std::vector<SkPixelRef*> pixel_refs;
766 tile->raster_source()->GatherPixelRefs( 770 tile->raster_source()->GatherPixelRefs(
767 tile->content_rect(), tile->contents_scale(), &pixel_refs); 771 tile->content_rect(), tile->contents_scale(), &pixel_refs);
768 for (SkPixelRef* pixel_ref : pixel_refs) { 772 for (SkPixelRef* pixel_ref : pixel_refs) {
769 uint32_t id = pixel_ref->getGenerationID(); 773 uint32_t id = pixel_ref->getGenerationID();
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
1056 result -= other; 1060 result -= other;
1057 return result; 1061 return result;
1058 } 1062 }
1059 1063
1060 bool TileManager::MemoryUsage::Exceeds(const MemoryUsage& limit) const { 1064 bool TileManager::MemoryUsage::Exceeds(const MemoryUsage& limit) const {
1061 return memory_bytes_ > limit.memory_bytes_ || 1065 return memory_bytes_ > limit.memory_bytes_ ||
1062 resource_count_ > limit.resource_count_; 1066 resource_count_ > limit.resource_count_;
1063 } 1067 }
1064 1068
1065 } // namespace cc 1069 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698