OLD | NEW |
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 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 // resource(s) was returned. Note that in that case, one also need to | 540 // resource(s) was returned. Note that in that case, one also need to |
541 // invalidate when releasing some resource from the pool. | 541 // invalidate when releasing some resource from the pool. |
542 resource_pool_->CheckBusyResources(); | 542 resource_pool_->CheckBusyResources(); |
543 | 543 |
544 // Now give memory out to the tiles until we're out, and build | 544 // Now give memory out to the tiles until we're out, and build |
545 // the needs-to-be-rasterized queue. | 545 // the needs-to-be-rasterized queue. |
546 unsigned schedule_priority = 1u; | 546 unsigned schedule_priority = 1u; |
547 all_tiles_that_need_to_be_rasterized_are_scheduled_ = true; | 547 all_tiles_that_need_to_be_rasterized_are_scheduled_ = true; |
548 bool had_enough_memory_to_schedule_tiles_needed_now = true; | 548 bool had_enough_memory_to_schedule_tiles_needed_now = true; |
549 | 549 |
550 MemoryUsage hard_memory_limit(global_state_.hard_memory_limit_in_bytes, | 550 MemoryUsage hard_memory_limit(global_state_.hard_memory_limit_in_bytes); |
551 global_state_.num_resources_limit); | 551 MemoryUsage soft_memory_limit(global_state_.soft_memory_limit_in_bytes); |
552 MemoryUsage soft_memory_limit(global_state_.soft_memory_limit_in_bytes, | 552 MemoryUsage memory_usage(resource_pool_->acquired_memory_usage_bytes()); |
553 global_state_.num_resources_limit); | |
554 MemoryUsage memory_usage(resource_pool_->acquired_memory_usage_bytes(), | |
555 resource_pool_->acquired_resource_count()); | |
556 | 553 |
557 eviction_priority_queue_is_up_to_date_ = false; | 554 eviction_priority_queue_is_up_to_date_ = false; |
558 client_->BuildRasterQueue(&raster_priority_queue_, | 555 client_->BuildRasterQueue(&raster_priority_queue_, |
559 global_state_.tree_priority); | 556 global_state_.tree_priority); |
560 | 557 |
561 while (!raster_priority_queue_.IsEmpty()) { | 558 while (!raster_priority_queue_.IsEmpty()) { |
562 Tile* tile = raster_priority_queue_.Top(); | 559 Tile* tile = raster_priority_queue_.Top(); |
563 TilePriority priority = tile->combined_priority(); | 560 TilePriority priority = tile->combined_priority(); |
564 | 561 |
565 if (TilePriorityViolatesMemoryPolicy(priority)) { | 562 if (TilePriorityViolatesMemoryPolicy(priority)) { |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
870 void TileManager::CheckIfReadyToActivate() { | 867 void TileManager::CheckIfReadyToActivate() { |
871 TRACE_EVENT0("cc", "TileManager::CheckIfReadyToActivate"); | 868 TRACE_EVENT0("cc", "TileManager::CheckIfReadyToActivate"); |
872 | 869 |
873 rasterizer_->CheckForCompletedTasks(); | 870 rasterizer_->CheckForCompletedTasks(); |
874 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; | 871 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; |
875 | 872 |
876 if (IsReadyToActivate()) | 873 if (IsReadyToActivate()) |
877 client_->NotifyReadyToActivate(); | 874 client_->NotifyReadyToActivate(); |
878 } | 875 } |
879 | 876 |
880 TileManager::MemoryUsage::MemoryUsage() : memory_bytes_(0), resource_count_(0) { | 877 TileManager::MemoryUsage::MemoryUsage() : memory_bytes_(0) { |
881 } | 878 } |
882 | 879 |
883 TileManager::MemoryUsage::MemoryUsage(int64 memory_bytes, int resource_count) | 880 TileManager::MemoryUsage::MemoryUsage(int64 memory_bytes) |
884 : memory_bytes_(memory_bytes), resource_count_(resource_count) { | 881 : memory_bytes_(memory_bytes) { |
885 } | 882 } |
886 | 883 |
887 // static | 884 // static |
888 TileManager::MemoryUsage TileManager::MemoryUsage::FromConfig( | 885 TileManager::MemoryUsage TileManager::MemoryUsage::FromConfig( |
889 const gfx::Size& size, | 886 const gfx::Size& size, |
890 ResourceFormat format) { | 887 ResourceFormat format) { |
891 return MemoryUsage(Resource::MemorySizeBytes(size, format), 1); | 888 return MemoryUsage(Resource::MemorySizeBytes(size, format)); |
892 } | 889 } |
893 | 890 |
894 // static | 891 // static |
895 TileManager::MemoryUsage TileManager::MemoryUsage::FromTile(const Tile* tile) { | 892 TileManager::MemoryUsage TileManager::MemoryUsage::FromTile(const Tile* tile) { |
896 const ManagedTileState& mts = tile->managed_state(); | 893 const ManagedTileState& mts = tile->managed_state(); |
897 if (mts.draw_info.resource_) { | 894 if (mts.draw_info.resource_) { |
898 return MemoryUsage::FromConfig(tile->size(), | 895 return MemoryUsage::FromConfig(tile->size(), |
899 mts.draw_info.resource_->format()); | 896 mts.draw_info.resource_->format()); |
900 } | 897 } |
901 return MemoryUsage(); | 898 return MemoryUsage(); |
902 } | 899 } |
903 | 900 |
904 TileManager::MemoryUsage& TileManager::MemoryUsage::operator+=( | 901 TileManager::MemoryUsage& TileManager::MemoryUsage::operator+=( |
905 const MemoryUsage& other) { | 902 const MemoryUsage& other) { |
906 memory_bytes_ += other.memory_bytes_; | 903 memory_bytes_ += other.memory_bytes_; |
907 resource_count_ += other.resource_count_; | |
908 return *this; | 904 return *this; |
909 } | 905 } |
910 | 906 |
911 TileManager::MemoryUsage& TileManager::MemoryUsage::operator-=( | 907 TileManager::MemoryUsage& TileManager::MemoryUsage::operator-=( |
912 const MemoryUsage& other) { | 908 const MemoryUsage& other) { |
913 memory_bytes_ -= other.memory_bytes_; | 909 memory_bytes_ -= other.memory_bytes_; |
914 resource_count_ -= other.resource_count_; | |
915 return *this; | 910 return *this; |
916 } | 911 } |
917 | 912 |
918 TileManager::MemoryUsage TileManager::MemoryUsage::operator-( | 913 TileManager::MemoryUsage TileManager::MemoryUsage::operator-( |
919 const MemoryUsage& other) { | 914 const MemoryUsage& other) { |
920 MemoryUsage result = *this; | 915 MemoryUsage result = *this; |
921 result -= other; | 916 result -= other; |
922 return result; | 917 return result; |
923 } | 918 } |
924 | 919 |
925 bool TileManager::MemoryUsage::Exceeds(const MemoryUsage& limit) const { | 920 bool TileManager::MemoryUsage::Exceeds(const MemoryUsage& limit) const { |
926 return memory_bytes_ > limit.memory_bytes_ || | 921 return memory_bytes_ > limit.memory_bytes_; |
927 resource_count_ > limit.resource_count_; | |
928 } | 922 } |
929 | 923 |
930 } // namespace cc | 924 } // namespace cc |
OLD | NEW |