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

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

Issue 257773009: cc: Change required_for_activation bookkeeping. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review Created 6 years, 8 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 | Annotate | Revision Log
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 657 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 mts.required_for_activation = tile_priority.required_for_activation; 668 mts.required_for_activation = tile_priority.required_for_activation;
669 669
670 mts.visible_and_ready_to_draw = 670 mts.visible_and_ready_to_draw =
671 tree_bin[ACTIVE_TREE] == NOW_AND_READY_TO_DRAW_BIN; 671 tree_bin[ACTIVE_TREE] == NOW_AND_READY_TO_DRAW_BIN;
672 672
673 // If the tile is in NEVER_BIN and it does not have an active task, then we 673 // If the tile is in NEVER_BIN and it does not have an active task, then we
674 // can release the resources early. If it does have the task however, we 674 // can release the resources early. If it does have the task however, we
675 // should keep it in the prioritized tile set to ensure that AssignGpuMemory 675 // should keep it in the prioritized tile set to ensure that AssignGpuMemory
676 // can visit it. 676 // can visit it.
677 if (mts.bin == NEVER_BIN && 677 if (mts.bin == NEVER_BIN &&
678 !mts.tile_versions[mts.raster_mode].raster_task_) { 678 !mts.tile_versions[mts.raster_mode].raster_task_ &&
679 !tile->required_for_activation()) {
679 FreeResourcesForTile(tile); 680 FreeResourcesForTile(tile);
680 continue; 681 continue;
681 } 682 }
682 683
683 // Insert the tile into a priority set. 684 // Insert the tile into a priority set.
684 tiles->InsertTile(tile, mts.bin); 685 tiles->InsertTile(tile, mts.bin);
685 } 686 }
686 } 687 }
687 688
688 void TileManager::ManageTiles(const GlobalStateThatImpactsTilePriority& state) { 689 void TileManager::ManageTiles(const GlobalStateThatImpactsTilePriority& state) {
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
833 bool have_hit_soft_memory = false; // Soft memory comes after hard. 834 bool have_hit_soft_memory = false; // Soft memory comes after hard.
834 835
835 // Memory we assign to raster tasks now will be deducted from our memory 836 // Memory we assign to raster tasks now will be deducted from our memory
836 // in future iterations if priorities change. By assigning at most half 837 // in future iterations if priorities change. By assigning at most half
837 // the raster limit, we will always have another 50% left even if priorities 838 // the raster limit, we will always have another 50% left even if priorities
838 // change completely (assuming we check for completed/cancelled rasters 839 // change completely (assuming we check for completed/cancelled rasters
839 // between each call to this function). 840 // between each call to this function).
840 size_t max_raster_bytes = max_raster_usage_bytes_ / 2; 841 size_t max_raster_bytes = max_raster_usage_bytes_ / 2;
841 size_t raster_bytes = 0; 842 size_t raster_bytes = 0;
842 843
844 size_t processed_required_for_activation_tile_count = 0u;
843 unsigned schedule_priority = 1u; 845 unsigned schedule_priority = 1u;
844 for (PrioritizedTileSet::Iterator it(tiles, true); it; ++it) { 846 for (PrioritizedTileSet::Iterator it(tiles, true); it; ++it) {
845 Tile* tile = *it; 847 Tile* tile = *it;
846 ManagedTileState& mts = tile->managed_state(); 848 ManagedTileState& mts = tile->managed_state();
847 849
848 mts.scheduled_priority = schedule_priority++; 850 mts.scheduled_priority = schedule_priority++;
849 851
850 mts.raster_mode = tile->DetermineOverallRasterMode(); 852 mts.raster_mode = tile->DetermineOverallRasterMode();
851 853
852 ManagedTileState::TileVersion& tile_version = 854 ManagedTileState::TileVersion& tile_version =
853 mts.tile_versions[mts.raster_mode]; 855 mts.tile_versions[mts.raster_mode];
854 856
855 // If this tile doesn't need a resource, then nothing to do. 857 // If this tile doesn't need a resource, then nothing to do.
856 if (!tile_version.requires_resource()) 858 if (!tile_version.requires_resource())
857 continue; 859 continue;
858 860
859 // If the tile is not needed, free it up. 861 // If the tile is not needed, free it up.
860 if (mts.bin == NEVER_BIN) { 862 if (mts.bin == NEVER_BIN) {
861 FreeResourcesForTile(tile); 863 FreeResourcesForTile(tile);
864 if (tile->required_for_activation())
865 ++processed_required_for_activation_tile_count;
862 continue; 866 continue;
863 } 867 }
864 868
865 const bool tile_uses_hard_limit = mts.bin <= NOW_BIN; 869 const bool tile_uses_hard_limit = mts.bin <= NOW_BIN;
866 const size_t bytes_if_allocated = BytesConsumedIfAllocated(tile); 870 const size_t bytes_if_allocated = BytesConsumedIfAllocated(tile);
867 const size_t raster_bytes_if_rastered = raster_bytes + bytes_if_allocated; 871 const size_t raster_bytes_if_rastered = raster_bytes + bytes_if_allocated;
868 const size_t tile_bytes_left = 872 const size_t tile_bytes_left =
869 (tile_uses_hard_limit) ? hard_bytes_left : soft_bytes_left; 873 (tile_uses_hard_limit) ? hard_bytes_left : soft_bytes_left;
870 874
871 // Hard-limit is reserved for tiles that would cause a calamity 875 // Hard-limit is reserved for tiles that would cause a calamity
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
910 oomed_soft = true; 914 oomed_soft = true;
911 if (tile_uses_hard_limit) { 915 if (tile_uses_hard_limit) {
912 oomed_hard = true; 916 oomed_hard = true;
913 bytes_that_exceeded_memory_budget += tile_bytes; 917 bytes_that_exceeded_memory_budget += tile_bytes;
914 } 918 }
915 } else { 919 } else {
916 resources_left -= tile_resources; 920 resources_left -= tile_resources;
917 hard_bytes_left -= tile_bytes; 921 hard_bytes_left -= tile_bytes;
918 soft_bytes_left = 922 soft_bytes_left =
919 (soft_bytes_left > tile_bytes) ? soft_bytes_left - tile_bytes : 0; 923 (soft_bytes_left > tile_bytes) ? soft_bytes_left - tile_bytes : 0;
920 if (tile_version.resource_) 924 if (tile_version.resource_) {
925 DCHECK(tile->IsReadyToDraw());
921 continue; 926 continue;
927 }
922 } 928 }
923 929
924 DCHECK(!tile_version.resource_); 930 DCHECK(!tile_version.resource_);
925 931
926 // Tile shouldn't be rasterized if |tiles_that_need_to_be_rasterized| 932 // Tile shouldn't be rasterized if |tiles_that_need_to_be_rasterized|
927 // has reached it's limit or we've failed to assign gpu memory to this 933 // has reached it's limit or we've failed to assign gpu memory to this
928 // or any higher priority tile. Preventing tiles that fit into memory 934 // or any higher priority tile. Preventing tiles that fit into memory
929 // budget to be rasterized when higher priority tile is oom is 935 // budget to be rasterized when higher priority tile is oom is
930 // important for two reasons: 936 // important for two reasons:
931 // 1. Tile size should not impact raster priority. 937 // 1. Tile size should not impact raster priority.
932 // 2. Tiles with existing raster task could otherwise incorrectly 938 // 2. Tiles with existing raster task could otherwise incorrectly
933 // be added as they are not affected by |bytes_allocatable|. 939 // be added as they are not affected by |bytes_allocatable|.
934 bool can_schedule_tile = 940 bool can_schedule_tile =
935 !oomed_soft && raster_bytes_if_rastered <= max_raster_bytes && 941 !oomed_soft && raster_bytes_if_rastered <= max_raster_bytes &&
936 tiles_that_need_to_be_rasterized->size() < kScheduledRasterTasksLimit; 942 tiles_that_need_to_be_rasterized->size() < kScheduledRasterTasksLimit;
937 943
938 if (!can_schedule_tile) { 944 if (!can_schedule_tile) {
939 all_tiles_that_need_to_be_rasterized_have_memory_ = false; 945 all_tiles_that_need_to_be_rasterized_have_memory_ = false;
940 if (tile->required_for_activation())
941 all_tiles_required_for_activation_have_memory_ = false;
942 it.DisablePriorityOrdering(); 946 it.DisablePriorityOrdering();
943 continue; 947 continue;
944 } 948 }
945 949
946 raster_bytes = raster_bytes_if_rastered; 950 raster_bytes = raster_bytes_if_rastered;
947 tiles_that_need_to_be_rasterized->push_back(tile); 951 tiles_that_need_to_be_rasterized->push_back(tile);
952 if (tile->required_for_activation())
953 ++processed_required_for_activation_tile_count;
948 } 954 }
949 955
956 size_t total_required_for_activation_tile_count = 0;
957 for (std::vector<PictureLayerImpl*>::const_iterator it = layers_.begin();
958 it != layers_.end();
959 ++it) {
960 if ((*it)->IsOnActiveOrPendingTree()) {
961 total_required_for_activation_tile_count +=
962 (*it)->UninitializedTilesRequiredForActivationCount();
963 }
964 }
965
966 all_tiles_required_for_activation_have_memory_ =
967 processed_required_for_activation_tile_count ==
968 total_required_for_activation_tile_count;
969
950 // OOM reporting uses hard-limit, soft-OOM is normal depending on limit. 970 // OOM reporting uses hard-limit, soft-OOM is normal depending on limit.
951 ever_exceeded_memory_budget_ |= oomed_hard; 971 ever_exceeded_memory_budget_ |= oomed_hard;
952 if (ever_exceeded_memory_budget_) { 972 if (ever_exceeded_memory_budget_) {
953 TRACE_COUNTER_ID2("cc", 973 TRACE_COUNTER_ID2("cc",
954 "over_memory_budget", 974 "over_memory_budget",
955 this, 975 this,
956 "budget", 976 "budget",
957 global_state_.hard_memory_limit_in_bytes, 977 global_state_.hard_memory_limit_in_bytes,
958 "over", 978 "over",
959 bytes_that_exceeded_memory_budget); 979 bytes_that_exceeded_memory_budget);
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
1192 tile_version.set_solid_color(analysis.solid_color); 1212 tile_version.set_solid_color(analysis.solid_color);
1193 resource_pool_->ReleaseResource(resource.Pass()); 1213 resource_pool_->ReleaseResource(resource.Pass());
1194 } else { 1214 } else {
1195 tile_version.set_use_resource(); 1215 tile_version.set_use_resource();
1196 tile_version.resource_ = resource.Pass(); 1216 tile_version.resource_ = resource.Pass();
1197 1217
1198 bytes_releasable_ += BytesConsumedIfAllocated(tile); 1218 bytes_releasable_ += BytesConsumedIfAllocated(tile);
1199 ++resources_releasable_; 1219 ++resources_releasable_;
1200 } 1220 }
1201 1221
1222 client_->NotifyTileInitialized(tile);
1223
1202 FreeUnusedResourcesForTile(tile); 1224 FreeUnusedResourcesForTile(tile);
1203 if (tile->priority(ACTIVE_TREE).distance_to_visible == 0.f) 1225 if (tile->priority(ACTIVE_TREE).distance_to_visible == 0.f)
1204 did_initialize_visible_tile_ = true; 1226 did_initialize_visible_tile_ = true;
1205 } 1227 }
1206 1228
1207 scoped_refptr<Tile> TileManager::CreateTile(PicturePileImpl* picture_pile, 1229 scoped_refptr<Tile> TileManager::CreateTile(PicturePileImpl* picture_pile,
1208 const gfx::Size& tile_size, 1230 const gfx::Size& tile_size,
1209 const gfx::Rect& content_rect, 1231 const gfx::Rect& content_rect,
1210 const gfx::Rect& opaque_rect, 1232 const gfx::Rect& opaque_rect,
1211 float contents_scale, 1233 float contents_scale,
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
1624 1646
1625 if (b_priority.resolution != a_priority.resolution) { 1647 if (b_priority.resolution != a_priority.resolution) {
1626 return (prioritize_low_res && b_priority.resolution == LOW_RESOLUTION) || 1648 return (prioritize_low_res && b_priority.resolution == LOW_RESOLUTION) ||
1627 (!prioritize_low_res && b_priority.resolution == HIGH_RESOLUTION) || 1649 (!prioritize_low_res && b_priority.resolution == HIGH_RESOLUTION) ||
1628 (a_priority.resolution == NON_IDEAL_RESOLUTION); 1650 (a_priority.resolution == NON_IDEAL_RESOLUTION);
1629 } 1651 }
1630 return a_priority.IsHigherPriorityThan(b_priority); 1652 return a_priority.IsHigherPriorityThan(b_priority);
1631 } 1653 }
1632 1654
1633 } // namespace cc 1655 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698