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

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

Issue 1293873005: Expire resources in ResourcePool after non-use (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@re-use
Patch Set: Fix unit test Created 5 years, 4 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
« no previous file with comments | « cc/test/layer_tree_pixel_resource_test.cc ('k') | cc/tiles/tile_manager_perftest.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/tiles/tile_manager.h" 5 #include "cc/tiles/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 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 void TileManager::DidFinishRunningTileTasks(TaskSet task_set) { 293 void TileManager::DidFinishRunningTileTasks(TaskSet task_set) {
294 TRACE_EVENT1("cc", "TileManager::DidFinishRunningTileTasks", "task_set", 294 TRACE_EVENT1("cc", "TileManager::DidFinishRunningTileTasks", "task_set",
295 TaskSetName(task_set)); 295 TaskSetName(task_set));
296 DCHECK(resource_pool_); 296 DCHECK(resource_pool_);
297 DCHECK(tile_task_runner_); 297 DCHECK(tile_task_runner_);
298 298
299 switch (task_set) { 299 switch (task_set) {
300 case ALL: { 300 case ALL: {
301 has_scheduled_tile_tasks_ = false; 301 has_scheduled_tile_tasks_ = false;
302 302
303 bool memory_usage_above_limit = 303 bool memory_usage_above_limit = resource_pool_->memory_usage_bytes() >
304 resource_pool_->total_memory_usage_bytes() > 304 global_state_.soft_memory_limit_in_bytes;
305 global_state_.soft_memory_limit_in_bytes;
306 305
307 if (all_tiles_that_need_to_be_rasterized_are_scheduled_ && 306 if (all_tiles_that_need_to_be_rasterized_are_scheduled_ &&
308 !memory_usage_above_limit) { 307 !memory_usage_above_limit) {
309 // TODO(ericrk): We should find a better way to safely handle re-entrant 308 // TODO(ericrk): We should find a better way to safely handle re-entrant
310 // notifications than always having to schedule a new task. 309 // notifications than always having to schedule a new task.
311 // http://crbug.com/498439 310 // http://crbug.com/498439
312 signals_.all_tile_tasks_completed = true; 311 signals_.all_tile_tasks_completed = true;
313 signals_check_notifier_.Schedule(); 312 signals_check_notifier_.Schedule();
314 return; 313 return;
315 } 314 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 // tile that will be rasterized is required for draw. 368 // tile that will be rasterized is required for draw.
370 client_->SetIsLikelyToRequireADraw( 369 client_->SetIsLikelyToRequireADraw(
371 !tiles_that_need_to_be_rasterized.empty() && 370 !tiles_that_need_to_be_rasterized.empty() &&
372 tiles_that_need_to_be_rasterized.front().tile()->required_for_draw()); 371 tiles_that_need_to_be_rasterized.front().tile()->required_for_draw());
373 372
374 // Schedule tile tasks. 373 // Schedule tile tasks.
375 ScheduleTasks(tiles_that_need_to_be_rasterized); 374 ScheduleTasks(tiles_that_need_to_be_rasterized);
376 375
377 TRACE_EVENT_INSTANT1("cc", "DidPrepareTiles", TRACE_EVENT_SCOPE_THREAD, 376 TRACE_EVENT_INSTANT1("cc", "DidPrepareTiles", TRACE_EVENT_SCOPE_THREAD,
378 "state", BasicStateAsValue()); 377 "state", BasicStateAsValue());
379
380 TRACE_COUNTER_ID1("cc", "unused_memory_bytes", this,
381 resource_pool_->total_memory_usage_bytes() -
382 resource_pool_->acquired_memory_usage_bytes());
383 return true; 378 return true;
384 } 379 }
385 380
386 void TileManager::Flush() { 381 void TileManager::Flush() {
387 TRACE_EVENT0("cc", "TileManager::Flush"); 382 TRACE_EVENT0("cc", "TileManager::Flush");
388 383
389 if (!tile_task_runner_) { 384 if (!tile_task_runner_) {
390 TRACE_EVENT_INSTANT0("cc", "Flush aborted", TRACE_EVENT_SCOPE_THREAD); 385 TRACE_EVENT_INSTANT0("cc", "Flush aborted", TRACE_EVENT_SCOPE_THREAD);
391 return; 386 return;
392 } 387 }
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 // Now give memory out to the tiles until we're out, and build 494 // Now give memory out to the tiles until we're out, and build
500 // the needs-to-be-rasterized queue. 495 // the needs-to-be-rasterized queue.
501 unsigned schedule_priority = 1u; 496 unsigned schedule_priority = 1u;
502 all_tiles_that_need_to_be_rasterized_are_scheduled_ = true; 497 all_tiles_that_need_to_be_rasterized_are_scheduled_ = true;
503 bool had_enough_memory_to_schedule_tiles_needed_now = true; 498 bool had_enough_memory_to_schedule_tiles_needed_now = true;
504 499
505 MemoryUsage hard_memory_limit(global_state_.hard_memory_limit_in_bytes, 500 MemoryUsage hard_memory_limit(global_state_.hard_memory_limit_in_bytes,
506 global_state_.num_resources_limit); 501 global_state_.num_resources_limit);
507 MemoryUsage soft_memory_limit(global_state_.soft_memory_limit_in_bytes, 502 MemoryUsage soft_memory_limit(global_state_.soft_memory_limit_in_bytes,
508 global_state_.num_resources_limit); 503 global_state_.num_resources_limit);
509 MemoryUsage memory_usage(resource_pool_->acquired_memory_usage_bytes(), 504 MemoryUsage memory_usage(resource_pool_->memory_usage_bytes(),
510 resource_pool_->acquired_resource_count()); 505 resource_pool_->resource_count());
511 506
512 scoped_ptr<EvictionTilePriorityQueue> eviction_priority_queue; 507 scoped_ptr<EvictionTilePriorityQueue> eviction_priority_queue;
513 for (; !raster_priority_queue->IsEmpty(); raster_priority_queue->Pop()) { 508 for (; !raster_priority_queue->IsEmpty(); raster_priority_queue->Pop()) {
514 const PrioritizedTile& prioritized_tile = raster_priority_queue->Top(); 509 const PrioritizedTile& prioritized_tile = raster_priority_queue->Top();
515 Tile* tile = prioritized_tile.tile(); 510 Tile* tile = prioritized_tile.tile();
516 TilePriority priority = prioritized_tile.priority(); 511 TilePriority priority = prioritized_tile.priority();
517 512
518 if (TilePriorityViolatesMemoryPolicy(priority)) { 513 if (TilePriorityViolatesMemoryPolicy(priority)) {
519 TRACE_EVENT_INSTANT0( 514 TRACE_EVENT_INSTANT0(
520 "cc", "TileManager::AssignGpuMemory tile violates memory policy", 515 "cc", "TileManager::AssignGpuMemory tile violates memory policy",
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
1005 void TileManager::Signals::reset() { 1000 void TileManager::Signals::reset() {
1006 ready_to_activate = false; 1001 ready_to_activate = false;
1007 did_notify_ready_to_activate = false; 1002 did_notify_ready_to_activate = false;
1008 ready_to_draw = false; 1003 ready_to_draw = false;
1009 did_notify_ready_to_draw = false; 1004 did_notify_ready_to_draw = false;
1010 all_tile_tasks_completed = false; 1005 all_tile_tasks_completed = false;
1011 did_notify_all_tile_tasks_completed = false; 1006 did_notify_all_tile_tasks_completed = false;
1012 } 1007 }
1013 1008
1014 } // namespace cc 1009 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/layer_tree_pixel_resource_test.cc ('k') | cc/tiles/tile_manager_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698