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

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: compile fix 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
« no previous file with comments | « cc/resources/tile_manager.h ('k') | cc/resources/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/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 = client_->BuildRasterQueue(
437 client_->BuildRasterQueue(&required_for_draw_queue, 437 global_state_.tree_priority,
438 global_state_.tree_priority, 438 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW);
439 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW);
440 439
441 // Use on-demand raster for any tiles that have not been been assigned 440 // Use on-demand raster for any tiles that have not been been assigned
442 // memory. This ensures that we draw even when OOM. 441 // memory. This ensures that we draw even when OOM.
443 for (; !required_for_draw_queue.IsEmpty(); required_for_draw_queue.Pop()) { 442 for (; !required_for_draw_queue->IsEmpty(); required_for_draw_queue->Pop()) {
444 Tile* tile = required_for_draw_queue.Top(); 443 Tile* tile = required_for_draw_queue->Top();
445 tile->draw_info().set_rasterize_on_demand(); 444 tile->draw_info().set_rasterize_on_demand();
446 client_->NotifyTileStateChanged(tile); 445 client_->NotifyTileStateChanged(tile);
447 } 446 }
448 447
449 TRACE_EVENT_INSTANT1("cc", "DidRasterize", TRACE_EVENT_SCOPE_THREAD, "state", 448 TRACE_EVENT_INSTANT1("cc", "DidRasterize", TRACE_EVENT_SCOPE_THREAD, "state",
450 BasicStateAsValue()); 449 BasicStateAsValue());
451 450
452 TRACE_COUNTER_ID1("cc", "unused_memory_bytes", this, 451 TRACE_COUNTER_ID1("cc", "unused_memory_bytes", this,
453 resource_pool_->total_memory_usage_bytes() - 452 resource_pool_->total_memory_usage_bytes() -
454 resource_pool_->acquired_memory_usage_bytes()); 453 resource_pool_->acquired_memory_usage_bytes());
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 NotifyReadyToDraw(); 936 NotifyReadyToDraw();
938 } 937 }
939 938
940 void TileManager::CheckIfMoreTilesNeedToBePrepared() { 939 void TileManager::CheckIfMoreTilesNeedToBePrepared() {
941 tile_task_runner_->CheckForCompletedTasks(); 940 tile_task_runner_->CheckForCompletedTasks();
942 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; 941 did_check_for_completed_tasks_since_last_schedule_tasks_ = true;
943 942
944 // When OOM, keep re-assigning memory until we reach a steady state 943 // When OOM, keep re-assigning memory until we reach a steady state
945 // where top-priority tiles are initialized. 944 // where top-priority tiles are initialized.
946 TileVector tiles_that_need_to_be_rasterized; 945 TileVector tiles_that_need_to_be_rasterized;
947 RasterTilePriorityQueue raster_priority_queue; 946 scoped_ptr<RasterTilePriorityQueue> raster_priority_queue(
948 client_->BuildRasterQueue(&raster_priority_queue, global_state_.tree_priority, 947 client_->BuildRasterQueue(global_state_.tree_priority,
949 RasterTilePriorityQueue::Type::ALL); 948 RasterTilePriorityQueue::Type::ALL));
950 AssignGpuMemoryToTiles(&raster_priority_queue, scheduled_raster_task_limit_, 949 AssignGpuMemoryToTiles(raster_priority_queue.get(),
950 scheduled_raster_task_limit_,
951 &tiles_that_need_to_be_rasterized); 951 &tiles_that_need_to_be_rasterized);
952 952
953 // |tiles_that_need_to_be_rasterized| will be empty when we reach a 953 // |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. 954 // steady memory state. Keep scheduling tasks until we reach this state.
955 if (!tiles_that_need_to_be_rasterized.empty()) { 955 if (!tiles_that_need_to_be_rasterized.empty()) {
956 ScheduleTasks(tiles_that_need_to_be_rasterized); 956 ScheduleTasks(tiles_that_need_to_be_rasterized);
957 return; 957 return;
958 } 958 }
959 959
960 FreeResourcesForReleasedTiles(); 960 FreeResourcesForReleasedTiles();
961 961
962 resource_pool_->ReduceResourceUsage(); 962 resource_pool_->ReduceResourceUsage();
963 963
964 // We don't reserve memory for required-for-activation tiles during 964 // We don't reserve memory for required-for-activation tiles during
965 // accelerated gestures, so we just postpone activation when we don't 965 // accelerated gestures, so we just postpone activation when we don't
966 // have these tiles, and activate after the accelerated gesture. 966 // 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 967 // 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 968 // invisible), if we have tiles that aren't ready, then we shouldn't
969 // activate as activation can cause checkerboards. 969 // activate as activation can cause checkerboards.
970 bool allow_rasterize_on_demand = 970 bool allow_rasterize_on_demand =
971 global_state_.tree_priority != SMOOTHNESS_TAKES_PRIORITY && 971 global_state_.tree_priority != SMOOTHNESS_TAKES_PRIORITY &&
972 global_state_.memory_limit_policy != ALLOW_NOTHING; 972 global_state_.memory_limit_policy != ALLOW_NOTHING;
973 973
974 // Use on-demand raster for any required-for-activation tiles that have 974 // 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 975 // 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 976 // ensures that we activate even when OOM. Note that we can't reuse the queue
977 // we used for AssignGpuMemoryToTiles, since the AssignGpuMemoryToTiles call 977 // we used for AssignGpuMemoryToTiles, since the AssignGpuMemoryToTiles call
978 // could have evicted some tiles that would not be picked up by the old raster 978 // could have evicted some tiles that would not be picked up by the old raster
979 // queue. 979 // queue.
980 RasterTilePriorityQueue required_for_activation_queue; 980 scoped_ptr<RasterTilePriorityQueue> required_for_activation_queue(
981 client_->BuildRasterQueue( 981 client_->BuildRasterQueue(
982 &required_for_activation_queue, global_state_.tree_priority, 982 global_state_.tree_priority,
983 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION); 983 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION));
984 984
985 // If we have tiles to mark as rasterize on demand, but we don't allow 985 // 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. 986 // rasterize on demand, then skip activation and return early.
987 if (!required_for_activation_queue.IsEmpty() && !allow_rasterize_on_demand) 987 if (!required_for_activation_queue->IsEmpty() && !allow_rasterize_on_demand)
988 return; 988 return;
989 989
990 // Mark required tiles as rasterize on demand. 990 // Mark required tiles as rasterize on demand.
991 for (; !required_for_activation_queue.IsEmpty(); 991 for (; !required_for_activation_queue->IsEmpty();
992 required_for_activation_queue.Pop()) { 992 required_for_activation_queue->Pop()) {
993 Tile* tile = required_for_activation_queue.Top(); 993 Tile* tile = required_for_activation_queue->Top();
994 tile->draw_info().set_rasterize_on_demand(); 994 tile->draw_info().set_rasterize_on_demand();
995 client_->NotifyTileStateChanged(tile); 995 client_->NotifyTileStateChanged(tile);
996 } 996 }
997 997
998 DCHECK(IsReadyToActivate()); 998 DCHECK(IsReadyToActivate());
999 ready_to_activate_check_notifier_.Schedule(); 999 ready_to_activate_check_notifier_.Schedule();
1000 } 1000 }
1001 1001
1002 TileManager::MemoryUsage::MemoryUsage() : memory_bytes_(0), resource_count_(0) { 1002 TileManager::MemoryUsage::MemoryUsage() : memory_bytes_(0), resource_count_(0) {
1003 } 1003 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1043 result -= other; 1043 result -= other;
1044 return result; 1044 return result;
1045 } 1045 }
1046 1046
1047 bool TileManager::MemoryUsage::Exceeds(const MemoryUsage& limit) const { 1047 bool TileManager::MemoryUsage::Exceeds(const MemoryUsage& limit) const {
1048 return memory_bytes_ > limit.memory_bytes_ || 1048 return memory_bytes_ > limit.memory_bytes_ ||
1049 resource_count_ > limit.resource_count_; 1049 resource_count_ > limit.resource_count_;
1050 } 1050 }
1051 1051
1052 } // namespace cc 1052 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/tile_manager.h ('k') | cc/resources/tile_manager_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698