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

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

Issue 863013004: cc: Split RasterTilePriorityQueue into required and all based on type. (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 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 // to ScheduleTasks() to prevent canceled tasks from being scheduled. 353 // to ScheduleTasks() to prevent canceled tasks from being scheduled.
354 if (!did_check_for_completed_tasks_since_last_schedule_tasks_) { 354 if (!did_check_for_completed_tasks_since_last_schedule_tasks_) {
355 tile_task_runner_->CheckForCompletedTasks(); 355 tile_task_runner_->CheckForCompletedTasks();
356 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; 356 did_check_for_completed_tasks_since_last_schedule_tasks_ = true;
357 } 357 }
358 358
359 FreeResourcesForReleasedTiles(); 359 FreeResourcesForReleasedTiles();
360 CleanUpReleasedTiles(); 360 CleanUpReleasedTiles();
361 361
362 TileVector tiles_that_need_to_be_rasterized; 362 TileVector tiles_that_need_to_be_rasterized;
363 RasterTilePriorityQueue raster_priority_queue; 363 scoped_ptr<RasterTilePriorityQueue> raster_priority_queue(
364 client_->BuildRasterQueue(&raster_priority_queue, 364 client_->BuildRasterQueue(global_state_.tree_priority,
365 global_state_.tree_priority, 365 RasterTilePriorityQueue::Type::ALL));
366 RasterTilePriorityQueue::Type::ALL); 366 AssignGpuMemoryToTiles(raster_priority_queue.get(),
367 AssignGpuMemoryToTiles(&raster_priority_queue, scheduled_raster_task_limit_, 367 scheduled_raster_task_limit_,
368 &tiles_that_need_to_be_rasterized); 368 &tiles_that_need_to_be_rasterized);
369 369
370 // Schedule tile tasks. 370 // Schedule tile tasks.
371 ScheduleTasks(tiles_that_need_to_be_rasterized); 371 ScheduleTasks(tiles_that_need_to_be_rasterized);
372 372
373 did_notify_ready_to_activate_ = false; 373 did_notify_ready_to_activate_ = false;
374 did_notify_ready_to_draw_ = false; 374 did_notify_ready_to_draw_ = false;
375 } else { 375 } else {
376 if (global_state_.hard_memory_limit_in_bytes == 0) { 376 if (global_state_.hard_memory_limit_in_bytes == 0) {
377 // TODO(vmpstr): Add a function to unconditionally create an eviction 377 // TODO(vmpstr): Add a function to unconditionally create an eviction
(...skipping 26 matching lines...) Expand all
404 TRACE_EVENT0("cc", "TileManager::SynchronouslyRasterizeTiles"); 404 TRACE_EVENT0("cc", "TileManager::SynchronouslyRasterizeTiles");
405 405
406 DCHECK(rasterizer_->GetPrepareTilesMode() != 406 DCHECK(rasterizer_->GetPrepareTilesMode() !=
407 PrepareTilesMode::RASTERIZE_PRIORITIZED_TILES); 407 PrepareTilesMode::RASTERIZE_PRIORITIZED_TILES);
408 408
409 global_state_ = state; 409 global_state_ = state;
410 410
411 FreeResourcesForReleasedTiles(); 411 FreeResourcesForReleasedTiles();
412 CleanUpReleasedTiles(); 412 CleanUpReleasedTiles();
413 413
414 RasterTilePriorityQueue required_for_draw_queue; 414 scoped_ptr<RasterTilePriorityQueue> required_for_draw_queue(
415 client_->BuildRasterQueue(&required_for_draw_queue, 415 client_->BuildRasterQueue(
416 global_state_.tree_priority, 416 global_state_.tree_priority,
417 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW); 417 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW));
418 TileVector tiles_that_need_to_be_rasterized; 418 TileVector tiles_that_need_to_be_rasterized;
419 AssignGpuMemoryToTiles(&required_for_draw_queue, 419 AssignGpuMemoryToTiles(required_for_draw_queue.get(),
420 std::numeric_limits<size_t>::max(), 420 std::numeric_limits<size_t>::max(),
421 &tiles_that_need_to_be_rasterized); 421 &tiles_that_need_to_be_rasterized);
422 422
423 // We must reduce the amount of unused resources before calling 423 // We must reduce the amount of unused resources before calling
424 // RunTasks to prevent usage from rising above limits. 424 // RunTasks to prevent usage from rising above limits.
425 resource_pool_->ReduceResourceUsage(); 425 resource_pool_->ReduceResourceUsage();
426 426
427 // Run and complete all raster task synchronously. 427 // Run and complete all raster task synchronously.
428 rasterizer_->RasterizeTiles( 428 rasterizer_->RasterizeTiles(
429 tiles_that_need_to_be_rasterized, resource_pool_, 429 tiles_that_need_to_be_rasterized, resource_pool_,
430 base::Bind(&TileManager::UpdateTileDrawInfo, base::Unretained(this))); 430 base::Bind(&TileManager::UpdateTileDrawInfo, base::Unretained(this)));
431 431
432 // Use on-demand raster for any required-for-draw tiles that have not been 432 // Use on-demand raster for any required-for-draw tiles that have not been
433 // assigned memory after reaching a steady memory state. 433 // assigned memory after reaching a steady memory state.
434 // TODO(hendrikw): Figure out why this would improve jank on some tests - See 434 // TODO(hendrikw): Figure out why this would improve jank on some tests - See
435 // crbug.com/449288 435 // crbug.com/449288
436 required_for_draw_queue.Reset(); 436 required_for_draw_queue.reset(
danakj 2015/01/22 20:24:16 why not queue =
vmpstr 2015/01/22 22:44:35 Done.
437 client_->BuildRasterQueue(&required_for_draw_queue, 437 client_->BuildRasterQueue(
438 global_state_.tree_priority, 438 global_state_.tree_priority,
439 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW); 439 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW).release());
440 440
441 // Use on-demand raster for any tiles that have not been been assigned 441 // Use on-demand raster for any tiles that have not been been assigned
442 // memory. This ensures that we draw even when OOM. 442 // memory. This ensures that we draw even when OOM.
443 for (; !required_for_draw_queue.IsEmpty(); required_for_draw_queue.Pop()) { 443 for (; !required_for_draw_queue->IsEmpty(); required_for_draw_queue->Pop()) {
444 Tile* tile = required_for_draw_queue.Top(); 444 Tile* tile = required_for_draw_queue->Top();
445 tile->draw_info().set_rasterize_on_demand(); 445 tile->draw_info().set_rasterize_on_demand();
446 client_->NotifyTileStateChanged(tile); 446 client_->NotifyTileStateChanged(tile);
447 } 447 }
448 448
449 TRACE_EVENT_INSTANT1("cc", "DidRasterize", TRACE_EVENT_SCOPE_THREAD, "state", 449 TRACE_EVENT_INSTANT1("cc", "DidRasterize", TRACE_EVENT_SCOPE_THREAD, "state",
450 BasicStateAsValue()); 450 BasicStateAsValue());
451 451
452 TRACE_COUNTER_ID1("cc", "unused_memory_bytes", this, 452 TRACE_COUNTER_ID1("cc", "unused_memory_bytes", this,
453 resource_pool_->total_memory_usage_bytes() - 453 resource_pool_->total_memory_usage_bytes() -
454 resource_pool_->acquired_memory_usage_bytes()); 454 resource_pool_->acquired_memory_usage_bytes());
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 NotifyReadyToDraw(); 937 NotifyReadyToDraw();
938 } 938 }
939 939
940 void TileManager::CheckIfMoreTilesNeedToBePrepared() { 940 void TileManager::CheckIfMoreTilesNeedToBePrepared() {
941 tile_task_runner_->CheckForCompletedTasks(); 941 tile_task_runner_->CheckForCompletedTasks();
942 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; 942 did_check_for_completed_tasks_since_last_schedule_tasks_ = true;
943 943
944 // When OOM, keep re-assigning memory until we reach a steady state 944 // When OOM, keep re-assigning memory until we reach a steady state
945 // where top-priority tiles are initialized. 945 // where top-priority tiles are initialized.
946 TileVector tiles_that_need_to_be_rasterized; 946 TileVector tiles_that_need_to_be_rasterized;
947 RasterTilePriorityQueue raster_priority_queue; 947 scoped_ptr<RasterTilePriorityQueue> raster_priority_queue(
948 client_->BuildRasterQueue(&raster_priority_queue, global_state_.tree_priority, 948 client_->BuildRasterQueue(global_state_.tree_priority,
949 RasterTilePriorityQueue::Type::ALL); 949 RasterTilePriorityQueue::Type::ALL));
950 AssignGpuMemoryToTiles(&raster_priority_queue, scheduled_raster_task_limit_, 950 AssignGpuMemoryToTiles(raster_priority_queue.get(),
951 scheduled_raster_task_limit_,
951 &tiles_that_need_to_be_rasterized); 952 &tiles_that_need_to_be_rasterized);
952 953
953 // |tiles_that_need_to_be_rasterized| will be empty when we reach a 954 // |tiles_that_need_to_be_rasterized| will be empty when we reach a
954 // steady memory state. Keep scheduling tasks until we reach this state. 955 // steady memory state. Keep scheduling tasks until we reach this state.
955 if (!tiles_that_need_to_be_rasterized.empty()) { 956 if (!tiles_that_need_to_be_rasterized.empty()) {
956 ScheduleTasks(tiles_that_need_to_be_rasterized); 957 ScheduleTasks(tiles_that_need_to_be_rasterized);
957 return; 958 return;
958 } 959 }
959 960
960 FreeResourcesForReleasedTiles(); 961 FreeResourcesForReleasedTiles();
961 962
962 resource_pool_->ReduceResourceUsage(); 963 resource_pool_->ReduceResourceUsage();
963 964
964 // We don't reserve memory for required-for-activation tiles during 965 // We don't reserve memory for required-for-activation tiles during
965 // accelerated gestures, so we just postpone activation when we don't 966 // accelerated gestures, so we just postpone activation when we don't
966 // have these tiles, and activate after the accelerated gesture. 967 // have these tiles, and activate after the accelerated gesture.
967 // Likewise if we don't allow any tiles (as is the case when we're 968 // Likewise if we don't allow any tiles (as is the case when we're
968 // invisible), if we have tiles that aren't ready, then we shouldn't 969 // invisible), if we have tiles that aren't ready, then we shouldn't
969 // activate as activation can cause checkerboards. 970 // activate as activation can cause checkerboards.
970 bool allow_rasterize_on_demand = 971 bool allow_rasterize_on_demand =
971 global_state_.tree_priority != SMOOTHNESS_TAKES_PRIORITY && 972 global_state_.tree_priority != SMOOTHNESS_TAKES_PRIORITY &&
972 global_state_.memory_limit_policy != ALLOW_NOTHING; 973 global_state_.memory_limit_policy != ALLOW_NOTHING;
973 974
974 // Use on-demand raster for any required-for-activation tiles that have 975 // Use on-demand raster for any required-for-activation tiles that have
975 // not been been assigned memory after reaching a steady memory state. This 976 // not been been assigned memory after reaching a steady memory state. This
976 // ensures that we activate even when OOM. Note that we can't reuse the queue 977 // ensures that we activate even when OOM. Note that we can't reuse the queue
977 // we used for AssignGpuMemoryToTiles, since the AssignGpuMemoryToTiles call 978 // we used for AssignGpuMemoryToTiles, since the AssignGpuMemoryToTiles call
978 // could have evicted some tiles that would not be picked up by the old raster 979 // could have evicted some tiles that would not be picked up by the old raster
979 // queue. 980 // queue.
980 RasterTilePriorityQueue required_for_activation_queue; 981 scoped_ptr<RasterTilePriorityQueue> required_for_activation_queue(
981 client_->BuildRasterQueue( 982 client_->BuildRasterQueue(
982 &required_for_activation_queue, global_state_.tree_priority, 983 global_state_.tree_priority,
983 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION); 984 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION));
984 985
985 // If we have tiles to mark as rasterize on demand, but we don't allow 986 // If we have tiles to mark as rasterize on demand, but we don't allow
986 // rasterize on demand, then skip activation and return early. 987 // rasterize on demand, then skip activation and return early.
987 if (!required_for_activation_queue.IsEmpty() && !allow_rasterize_on_demand) 988 if (!required_for_activation_queue->IsEmpty() && !allow_rasterize_on_demand)
988 return; 989 return;
989 990
990 // Mark required tiles as rasterize on demand. 991 // Mark required tiles as rasterize on demand.
991 for (; !required_for_activation_queue.IsEmpty(); 992 for (; !required_for_activation_queue->IsEmpty();
992 required_for_activation_queue.Pop()) { 993 required_for_activation_queue->Pop()) {
993 Tile* tile = required_for_activation_queue.Top(); 994 Tile* tile = required_for_activation_queue->Top();
994 tile->draw_info().set_rasterize_on_demand(); 995 tile->draw_info().set_rasterize_on_demand();
995 client_->NotifyTileStateChanged(tile); 996 client_->NotifyTileStateChanged(tile);
996 } 997 }
997 998
998 DCHECK(IsReadyToActivate()); 999 DCHECK(IsReadyToActivate());
999 ready_to_activate_check_notifier_.Schedule(); 1000 ready_to_activate_check_notifier_.Schedule();
1000 } 1001 }
1001 1002
1002 TileManager::MemoryUsage::MemoryUsage() : memory_bytes_(0), resource_count_(0) { 1003 TileManager::MemoryUsage::MemoryUsage() : memory_bytes_(0), resource_count_(0) {
1003 } 1004 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1043 result -= other; 1044 result -= other;
1044 return result; 1045 return result;
1045 } 1046 }
1046 1047
1047 bool TileManager::MemoryUsage::Exceeds(const MemoryUsage& limit) const { 1048 bool TileManager::MemoryUsage::Exceeds(const MemoryUsage& limit) const {
1048 return memory_bytes_ > limit.memory_bytes_ || 1049 return memory_bytes_ > limit.memory_bytes_ ||
1049 resource_count_ > limit.resource_count_; 1050 resource_count_ > limit.resource_count_;
1050 } 1051 }
1051 1052
1052 } // namespace cc 1053 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698