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

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

Issue 837533002: cc: Re-enable prepaint for GPU rasterization (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
« no previous file with comments | « cc/resources/tile_manager.h ('k') | no next file » | 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 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 if (!did_check_for_completed_tasks_since_last_schedule_tasks_) { 357 if (!did_check_for_completed_tasks_since_last_schedule_tasks_) {
358 tile_task_runner_->CheckForCompletedTasks(); 358 tile_task_runner_->CheckForCompletedTasks();
359 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; 359 did_check_for_completed_tasks_since_last_schedule_tasks_ = true;
360 } 360 }
361 361
362 FreeResourcesForReleasedTiles(); 362 FreeResourcesForReleasedTiles();
363 CleanUpReleasedTiles(); 363 CleanUpReleasedTiles();
364 364
365 TileVector tiles_that_need_to_be_rasterized; 365 TileVector tiles_that_need_to_be_rasterized;
366 AssignGpuMemoryToTiles(&tiles_that_need_to_be_rasterized, 366 AssignGpuMemoryToTiles(&tiles_that_need_to_be_rasterized,
367 scheduled_raster_task_limit_, false); 367 scheduled_raster_task_limit_);
368 368
369 // Schedule tile tasks. 369 // Schedule tile tasks.
370 ScheduleTasks(tiles_that_need_to_be_rasterized); 370 ScheduleTasks(tiles_that_need_to_be_rasterized);
371 371
372 did_notify_ready_to_activate_ = false; 372 did_notify_ready_to_activate_ = false;
373 did_notify_ready_to_draw_ = false; 373 did_notify_ready_to_draw_ = false;
374 } else { 374 } else {
375 if (global_state_.hard_memory_limit_in_bytes == 0) { 375 if (global_state_.hard_memory_limit_in_bytes == 0) {
376 TileVector tiles_that_need_to_be_rasterized; 376 TileVector tiles_that_need_to_be_rasterized;
377 AssignGpuMemoryToTiles(&tiles_that_need_to_be_rasterized, 377 AssignGpuMemoryToTiles(&tiles_that_need_to_be_rasterized,
378 scheduled_raster_task_limit_, false); 378 scheduled_raster_task_limit_);
379 DCHECK(tiles_that_need_to_be_rasterized.empty()); 379 DCHECK(tiles_that_need_to_be_rasterized.empty());
380 } 380 }
381 381
382 did_notify_ready_to_activate_ = false; 382 did_notify_ready_to_activate_ = false;
383 did_notify_ready_to_draw_ = false; 383 did_notify_ready_to_draw_ = false;
384 ready_to_activate_notifier_.Schedule(); 384 ready_to_activate_notifier_.Schedule();
385 ready_to_draw_notifier_.Schedule(); 385 ready_to_draw_notifier_.Schedule();
386 } 386 }
387 387
388 TRACE_EVENT_INSTANT1("cc", "DidPrepareTiles", TRACE_EVENT_SCOPE_THREAD, 388 TRACE_EVENT_INSTANT1("cc", "DidPrepareTiles", TRACE_EVENT_SCOPE_THREAD,
(...skipping 11 matching lines...) Expand all
400 DCHECK(rasterizer_->GetPrepareTilesMode() != 400 DCHECK(rasterizer_->GetPrepareTilesMode() !=
401 PrepareTilesMode::RASTERIZE_PRIORITIZED_TILES); 401 PrepareTilesMode::RASTERIZE_PRIORITIZED_TILES);
402 402
403 global_state_ = state; 403 global_state_ = state;
404 404
405 FreeResourcesForReleasedTiles(); 405 FreeResourcesForReleasedTiles();
406 CleanUpReleasedTiles(); 406 CleanUpReleasedTiles();
407 407
408 TileVector tiles_that_need_to_be_rasterized; 408 TileVector tiles_that_need_to_be_rasterized;
409 AssignGpuMemoryToTiles(&tiles_that_need_to_be_rasterized, 409 AssignGpuMemoryToTiles(&tiles_that_need_to_be_rasterized,
410 std::numeric_limits<size_t>::max(), true); 410 std::numeric_limits<size_t>::max());
411 411
412 // We must reduce the amount of unused resources before calling 412 // We must reduce the amount of unused resources before calling
413 // RunTasks to prevent usage from rising above limits. 413 // RunTasks to prevent usage from rising above limits.
414 resource_pool_->ReduceResourceUsage(); 414 resource_pool_->ReduceResourceUsage();
415 415
416 // Run and complete all raster task synchronously. 416 // Run and complete all raster task synchronously.
417 rasterizer_->RasterizeTiles( 417 rasterizer_->RasterizeTiles(
418 tiles_that_need_to_be_rasterized, resource_pool_, 418 tiles_that_need_to_be_rasterized, resource_pool_,
419 base::Bind(&TileManager::UpdateTileDrawInfo, base::Unretained(this))); 419 base::Bind(&TileManager::UpdateTileDrawInfo, base::Unretained(this)));
420 420
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 case ALLOW_ANYTHING: 548 case ALLOW_ANYTHING:
549 return priority.distance_to_visible == 549 return priority.distance_to_visible ==
550 std::numeric_limits<float>::infinity(); 550 std::numeric_limits<float>::infinity();
551 } 551 }
552 NOTREACHED(); 552 NOTREACHED();
553 return true; 553 return true;
554 } 554 }
555 555
556 void TileManager::AssignGpuMemoryToTiles( 556 void TileManager::AssignGpuMemoryToTiles(
557 TileVector* tiles_that_need_to_be_rasterized, 557 TileVector* tiles_that_need_to_be_rasterized,
558 size_t scheduled_raster_task_limit, 558 size_t scheduled_raster_task_limit) {
559 bool required_for_draw_only) {
560 TRACE_EVENT_BEGIN0("cc", "TileManager::AssignGpuMemoryToTiles"); 559 TRACE_EVENT_BEGIN0("cc", "TileManager::AssignGpuMemoryToTiles");
561 560
562 // Maintain the list of released resources that can potentially be re-used 561 // Maintain the list of released resources that can potentially be re-used
563 // or deleted. 562 // or deleted.
564 // If this operation becomes expensive too, only do this after some 563 // If this operation becomes expensive too, only do this after some
565 // resource(s) was returned. Note that in that case, one also need to 564 // resource(s) was returned. Note that in that case, one also need to
566 // invalidate when releasing some resource from the pool. 565 // invalidate when releasing some resource from the pool.
567 resource_pool_->CheckBusyResources(false); 566 resource_pool_->CheckBusyResources(false);
568 567
569 // Now give memory out to the tiles until we're out, and build 568 // Now give memory out to the tiles until we're out, and build
570 // the needs-to-be-rasterized queue. 569 // the needs-to-be-rasterized queue.
571 unsigned schedule_priority = 1u; 570 unsigned schedule_priority = 1u;
572 all_tiles_that_need_to_be_rasterized_are_scheduled_ = true; 571 all_tiles_that_need_to_be_rasterized_are_scheduled_ = true;
573 bool had_enough_memory_to_schedule_tiles_needed_now = true; 572 bool had_enough_memory_to_schedule_tiles_needed_now = true;
574 573
575 MemoryUsage hard_memory_limit(global_state_.hard_memory_limit_in_bytes, 574 MemoryUsage hard_memory_limit(global_state_.hard_memory_limit_in_bytes,
576 global_state_.num_resources_limit); 575 global_state_.num_resources_limit);
577 MemoryUsage soft_memory_limit(global_state_.soft_memory_limit_in_bytes, 576 MemoryUsage soft_memory_limit(global_state_.soft_memory_limit_in_bytes,
578 global_state_.num_resources_limit); 577 global_state_.num_resources_limit);
579 MemoryUsage memory_usage(resource_pool_->acquired_memory_usage_bytes(), 578 MemoryUsage memory_usage(resource_pool_->acquired_memory_usage_bytes(),
580 resource_pool_->acquired_resource_count()); 579 resource_pool_->acquired_resource_count());
581 580
582 eviction_priority_queue_is_up_to_date_ = false; 581 eviction_priority_queue_is_up_to_date_ = false;
583 client_->BuildRasterQueue(&raster_priority_queue_, 582 client_->BuildRasterQueue(&raster_priority_queue_,
584 global_state_.tree_priority); 583 global_state_.tree_priority);
585 584
586 while (!raster_priority_queue_.IsEmpty()) { 585 while (!raster_priority_queue_.IsEmpty()) {
587 Tile* tile = raster_priority_queue_.Top(); 586 Tile* tile = raster_priority_queue_.Top();
588
589 // TODO(vmpstr): Remove this when the iterator returns the correct tiles
590 // to draw for GPU rasterization.
591 if (required_for_draw_only) {
592 if (!tile->required_for_draw()) {
593 raster_priority_queue_.Pop();
594 continue;
595 }
596 }
597 TilePriority priority = tile->combined_priority(); 587 TilePriority priority = tile->combined_priority();
598 588
599 if (TilePriorityViolatesMemoryPolicy(priority)) { 589 if (TilePriorityViolatesMemoryPolicy(priority)) {
600 TRACE_EVENT_INSTANT0( 590 TRACE_EVENT_INSTANT0(
601 "cc", "TileManager::AssignGpuMemory tile violates memory policy", 591 "cc", "TileManager::AssignGpuMemory tile violates memory policy",
602 TRACE_EVENT_SCOPE_THREAD); 592 TRACE_EVENT_SCOPE_THREAD);
603 break; 593 break;
604 } 594 }
605 595
606 // We won't be able to schedule this tile, so break out early. 596 // We won't be able to schedule this tile, so break out early.
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
944 } 934 }
945 935
946 void TileManager::CheckIfMoreTilesNeedToBePrepared() { 936 void TileManager::CheckIfMoreTilesNeedToBePrepared() {
947 tile_task_runner_->CheckForCompletedTasks(); 937 tile_task_runner_->CheckForCompletedTasks();
948 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; 938 did_check_for_completed_tasks_since_last_schedule_tasks_ = true;
949 939
950 // When OOM, keep re-assigning memory until we reach a steady state 940 // When OOM, keep re-assigning memory until we reach a steady state
951 // where top-priority tiles are initialized. 941 // where top-priority tiles are initialized.
952 TileVector tiles_that_need_to_be_rasterized; 942 TileVector tiles_that_need_to_be_rasterized;
953 AssignGpuMemoryToTiles(&tiles_that_need_to_be_rasterized, 943 AssignGpuMemoryToTiles(&tiles_that_need_to_be_rasterized,
954 scheduled_raster_task_limit_, false); 944 scheduled_raster_task_limit_);
955 945
956 // |tiles_that_need_to_be_rasterized| will be empty when we reach a 946 // |tiles_that_need_to_be_rasterized| will be empty when we reach a
957 // steady memory state. Keep scheduling tasks until we reach this state. 947 // steady memory state. Keep scheduling tasks until we reach this state.
958 if (!tiles_that_need_to_be_rasterized.empty()) { 948 if (!tiles_that_need_to_be_rasterized.empty()) {
959 ScheduleTasks(tiles_that_need_to_be_rasterized); 949 ScheduleTasks(tiles_that_need_to_be_rasterized);
960 return; 950 return;
961 } 951 }
962 952
963 FreeResourcesForReleasedTiles(); 953 FreeResourcesForReleasedTiles();
964 954
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1050 result -= other; 1040 result -= other;
1051 return result; 1041 return result;
1052 } 1042 }
1053 1043
1054 bool TileManager::MemoryUsage::Exceeds(const MemoryUsage& limit) const { 1044 bool TileManager::MemoryUsage::Exceeds(const MemoryUsage& limit) const {
1055 return memory_bytes_ > limit.memory_bytes_ || 1045 return memory_bytes_ > limit.memory_bytes_ ||
1056 resource_count_ > limit.resource_count_; 1046 resource_count_ > limit.resource_count_;
1057 } 1047 }
1058 1048
1059 } // namespace cc 1049 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/tile_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698