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

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

Issue 651503004: cc: Bump up pending tree now tiles order for smoothness mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: format fix Created 6 years, 2 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 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 return false; 505 return false;
506 } 506 }
507 507
508 *usage -= MemoryUsage::FromTile(tile); 508 *usage -= MemoryUsage::FromTile(tile);
509 FreeResourcesForTileAndNotifyClientIfTileWasReadyToDraw(tile); 509 FreeResourcesForTileAndNotifyClientIfTileWasReadyToDraw(tile);
510 eviction_priority_queue_.Pop(); 510 eviction_priority_queue_.Pop();
511 } 511 }
512 return true; 512 return true;
513 } 513 }
514 514
515 bool TileManager::TilePriorityViolatesMemoryPolicy( 515 bool TileManager::TileViolatesMemoryPolicy(const Tile* tile) {
516 const TilePriority& priority) { 516 bool memory_policy_violated = true;
517 const TilePriority& priority =
518 tile->priority_for_tree_priority(global_state_.tree_priority);
517 switch (global_state_.memory_limit_policy) { 519 switch (global_state_.memory_limit_policy) {
518 case ALLOW_NOTHING: 520 case ALLOW_NOTHING:
521 // In the case of ALLOW_NOTHING, there are no special cases. A tile always
522 // violated memory policy.
519 return true; 523 return true;
520 case ALLOW_ABSOLUTE_MINIMUM: 524 case ALLOW_ABSOLUTE_MINIMUM:
521 return priority.priority_bin > TilePriority::NOW; 525 memory_policy_violated = priority.priority_bin > TilePriority::NOW;
526 break;
522 case ALLOW_PREPAINT_ONLY: 527 case ALLOW_PREPAINT_ONLY:
523 return priority.priority_bin > TilePriority::SOON; 528 memory_policy_violated = priority.priority_bin > TilePriority::SOON;
529 break;
524 case ALLOW_ANYTHING: 530 case ALLOW_ANYTHING:
525 return priority.distance_to_visible == 531 memory_policy_violated = priority.distance_to_visible ==
526 std::numeric_limits<float>::infinity(); 532 std::numeric_limits<float>::infinity();
533 break;
527 } 534 }
528 NOTREACHED(); 535
529 return true; 536 // If memory policy was violated, we need to check whether this tile is coming
reveman 2014/10/13 19:45:11 can we keep this NOTREACHED statement?
vmpstr 2014/10/13 20:20:14 Done.
537 // from the NOW bin on the pending tree. The reason for this is that there is
538 // a possibility that a pending tree tile could be required for activation and
539 // we don't want to starve activation in any of the above cases.
540 // TODO(vmpstr): Note that it is insufficient to check whether tile is
541 // required for activation, since pending tree iterator can return NOW bin
542 // tiles not required for activation before NOW bin tiles that are required.
543 // The todo here is to fix this, so that we can check only the activation
544 // requirement.
545 if (memory_policy_violated) {
546 const TilePriority& pending_priority = tile->priority(PENDING_TREE);
547 memory_policy_violated = pending_priority.priority_bin != TilePriority::NOW;
548 }
reveman 2014/10/13 19:45:11 Looks like this is just being tacked on as a quick
vmpstr 2014/10/13 20:20:14 Reworked this a bit.
549 return memory_policy_violated;
530 } 550 }
531 551
532 void TileManager::AssignGpuMemoryToTiles( 552 void TileManager::AssignGpuMemoryToTiles(
533 TileVector* tiles_that_need_to_be_rasterized) { 553 TileVector* tiles_that_need_to_be_rasterized) {
534 TRACE_EVENT0("cc", "TileManager::AssignGpuMemoryToTiles"); 554 TRACE_EVENT0("cc", "TileManager::AssignGpuMemoryToTiles");
535 555
536 // Maintain the list of released resources that can potentially be re-used 556 // Maintain the list of released resources that can potentially be re-used
537 // or deleted. 557 // or deleted.
538 // If this operation becomes expensive too, only do this after some 558 // If this operation becomes expensive too, only do this after some
539 // resource(s) was returned. Note that in that case, one also need to 559 // resource(s) was returned. Note that in that case, one also need to
(...skipping 13 matching lines...) Expand all
553 MemoryUsage memory_usage(resource_pool_->acquired_memory_usage_bytes(), 573 MemoryUsage memory_usage(resource_pool_->acquired_memory_usage_bytes(),
554 resource_pool_->acquired_resource_count()); 574 resource_pool_->acquired_resource_count());
555 575
556 eviction_priority_queue_is_up_to_date_ = false; 576 eviction_priority_queue_is_up_to_date_ = false;
557 raster_priority_queue_.Reset(); 577 raster_priority_queue_.Reset();
558 client_->BuildRasterQueue(&raster_priority_queue_, 578 client_->BuildRasterQueue(&raster_priority_queue_,
559 global_state_.tree_priority); 579 global_state_.tree_priority);
560 580
561 while (!raster_priority_queue_.IsEmpty()) { 581 while (!raster_priority_queue_.IsEmpty()) {
562 Tile* tile = raster_priority_queue_.Top(); 582 Tile* tile = raster_priority_queue_.Top();
563 TilePriority priority = 583 if (TileViolatesMemoryPolicy(tile))
564 tile->priority_for_tree_priority(global_state_.tree_priority);
565
566 if (TilePriorityViolatesMemoryPolicy(priority))
567 break; 584 break;
568 585
569 // We won't be able to schedule this tile, so break out early. 586 // We won't be able to schedule this tile, so break out early.
570 if (tiles_that_need_to_be_rasterized->size() >= 587 if (tiles_that_need_to_be_rasterized->size() >=
571 kScheduledRasterTasksLimit) { 588 kScheduledRasterTasksLimit) {
572 all_tiles_that_need_to_be_rasterized_are_scheduled_ = false; 589 all_tiles_that_need_to_be_rasterized_are_scheduled_ = false;
573 break; 590 break;
574 } 591 }
575 592
576 ManagedTileState& mts = tile->managed_state(); 593 ManagedTileState& mts = tile->managed_state();
577 mts.scheduled_priority = schedule_priority++; 594 mts.scheduled_priority = schedule_priority++;
578 595
579 DCHECK(mts.draw_info.mode() == 596 DCHECK(mts.draw_info.mode() ==
580 ManagedTileState::DrawInfo::PICTURE_PILE_MODE || 597 ManagedTileState::DrawInfo::PICTURE_PILE_MODE ||
581 !mts.draw_info.IsReadyToDraw()); 598 !mts.draw_info.IsReadyToDraw());
582 599
583 // If the tile already has a raster_task, then the memory used by it is 600 // If the tile already has a raster_task, then the memory used by it is
584 // already accounted for in memory_usage. Otherwise, we'll have to acquire 601 // already accounted for in memory_usage. Otherwise, we'll have to acquire
585 // more memory to create a raster task. 602 // more memory to create a raster task.
586 MemoryUsage memory_required_by_tile_to_be_scheduled; 603 MemoryUsage memory_required_by_tile_to_be_scheduled;
587 if (!mts.raster_task.get()) { 604 if (!mts.raster_task.get()) {
588 memory_required_by_tile_to_be_scheduled = MemoryUsage::FromConfig( 605 memory_required_by_tile_to_be_scheduled = MemoryUsage::FromConfig(
589 tile->size(), resource_pool_->resource_format()); 606 tile->size(), resource_pool_->resource_format());
590 } 607 }
591 608
609 const TilePriority& priority =
610 tile->priority_for_tree_priority(global_state_.tree_priority);
592 bool tile_is_needed_now = priority.priority_bin == TilePriority::NOW; 611 bool tile_is_needed_now = priority.priority_bin == TilePriority::NOW;
593 612
594 // This is the memory limit that will be used by this tile. Depending on 613 // This is the memory limit that will be used by this tile. Depending on
595 // the tile priority, it will be one of hard_memory_limit or 614 // the tile priority, it will be one of hard_memory_limit or
596 // soft_memory_limit. 615 // soft_memory_limit.
597 MemoryUsage& tile_memory_limit = 616 MemoryUsage& tile_memory_limit =
598 tile_is_needed_now ? hard_memory_limit : soft_memory_limit; 617 tile_is_needed_now ? hard_memory_limit : soft_memory_limit;
599 618
600 bool memory_usage_is_within_limit = 619 bool memory_usage_is_within_limit =
601 FreeTileResourcesWithLowerPriorityUntilUsageIsWithinLimit( 620 FreeTileResourcesWithLowerPriorityUntilUsageIsWithinLimit(
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 result -= other; 927 result -= other;
909 return result; 928 return result;
910 } 929 }
911 930
912 bool TileManager::MemoryUsage::Exceeds(const MemoryUsage& limit) const { 931 bool TileManager::MemoryUsage::Exceeds(const MemoryUsage& limit) const {
913 return memory_bytes_ > limit.memory_bytes_ || 932 return memory_bytes_ > limit.memory_bytes_ ||
914 resource_count_ > limit.resource_count_; 933 resource_count_ > limit.resource_count_;
915 } 934 }
916 935
917 } // namespace cc 936 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698