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

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

Issue 269633006: Revert of cc: Change required_for_activation bookkeeping. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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
« no previous file with comments | « cc/layers/picture_layer_impl.cc ('k') | cc/test/fake_tile_manager_client.h » ('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 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()) {
680 FreeResourcesForTile(tile); 679 FreeResourcesForTile(tile);
681 continue; 680 continue;
682 } 681 }
683 682
684 // Insert the tile into a priority set. 683 // Insert the tile into a priority set.
685 tiles->InsertTile(tile, mts.bin); 684 tiles->InsertTile(tile, mts.bin);
686 } 685 }
687 } 686 }
688 687
689 void TileManager::ManageTiles(const GlobalStateThatImpactsTilePriority& state) { 688 void TileManager::ManageTiles(const GlobalStateThatImpactsTilePriority& state) {
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
834 bool have_hit_soft_memory = false; // Soft memory comes after hard. 833 bool have_hit_soft_memory = false; // Soft memory comes after hard.
835 834
836 // Memory we assign to raster tasks now will be deducted from our memory 835 // Memory we assign to raster tasks now will be deducted from our memory
837 // in future iterations if priorities change. By assigning at most half 836 // in future iterations if priorities change. By assigning at most half
838 // the raster limit, we will always have another 50% left even if priorities 837 // the raster limit, we will always have another 50% left even if priorities
839 // change completely (assuming we check for completed/cancelled rasters 838 // change completely (assuming we check for completed/cancelled rasters
840 // between each call to this function). 839 // between each call to this function).
841 size_t max_raster_bytes = max_raster_usage_bytes_ / 2; 840 size_t max_raster_bytes = max_raster_usage_bytes_ / 2;
842 size_t raster_bytes = 0; 841 size_t raster_bytes = 0;
843 842
844 int processed_required_for_activation_tile_count = 0;
845 unsigned schedule_priority = 1u; 843 unsigned schedule_priority = 1u;
846 for (PrioritizedTileSet::Iterator it(tiles, true); it; ++it) { 844 for (PrioritizedTileSet::Iterator it(tiles, true); it; ++it) {
847 Tile* tile = *it; 845 Tile* tile = *it;
848 ManagedTileState& mts = tile->managed_state(); 846 ManagedTileState& mts = tile->managed_state();
849 847
850 mts.scheduled_priority = schedule_priority++; 848 mts.scheduled_priority = schedule_priority++;
851 849
852 mts.raster_mode = tile->DetermineOverallRasterMode(); 850 mts.raster_mode = tile->DetermineOverallRasterMode();
853 851
854 ManagedTileState::TileVersion& tile_version = 852 ManagedTileState::TileVersion& tile_version =
855 mts.tile_versions[mts.raster_mode]; 853 mts.tile_versions[mts.raster_mode];
856 854
857 // If this tile doesn't need a resource, then nothing to do. 855 // If this tile doesn't need a resource, then nothing to do.
858 if (!tile_version.requires_resource()) 856 if (!tile_version.requires_resource())
859 continue; 857 continue;
860 858
861 // If the tile is not needed, free it up. 859 // If the tile is not needed, free it up.
862 if (mts.bin == NEVER_BIN) { 860 if (mts.bin == NEVER_BIN) {
863 FreeResourcesForTile(tile); 861 FreeResourcesForTile(tile);
864 if (tile->required_for_activation())
865 ++processed_required_for_activation_tile_count;
866 continue; 862 continue;
867 } 863 }
868 864
869 const bool tile_uses_hard_limit = mts.bin <= NOW_BIN; 865 const bool tile_uses_hard_limit = mts.bin <= NOW_BIN;
870 const size_t bytes_if_allocated = BytesConsumedIfAllocated(tile); 866 const size_t bytes_if_allocated = BytesConsumedIfAllocated(tile);
871 const size_t raster_bytes_if_rastered = raster_bytes + bytes_if_allocated; 867 const size_t raster_bytes_if_rastered = raster_bytes + bytes_if_allocated;
872 const size_t tile_bytes_left = 868 const size_t tile_bytes_left =
873 (tile_uses_hard_limit) ? hard_bytes_left : soft_bytes_left; 869 (tile_uses_hard_limit) ? hard_bytes_left : soft_bytes_left;
874 870
875 // Hard-limit is reserved for tiles that would cause a calamity 871 // Hard-limit is reserved for tiles that would cause a calamity
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
914 oomed_soft = true; 910 oomed_soft = true;
915 if (tile_uses_hard_limit) { 911 if (tile_uses_hard_limit) {
916 oomed_hard = true; 912 oomed_hard = true;
917 bytes_that_exceeded_memory_budget += tile_bytes; 913 bytes_that_exceeded_memory_budget += tile_bytes;
918 } 914 }
919 } else { 915 } else {
920 resources_left -= tile_resources; 916 resources_left -= tile_resources;
921 hard_bytes_left -= tile_bytes; 917 hard_bytes_left -= tile_bytes;
922 soft_bytes_left = 918 soft_bytes_left =
923 (soft_bytes_left > tile_bytes) ? soft_bytes_left - tile_bytes : 0; 919 (soft_bytes_left > tile_bytes) ? soft_bytes_left - tile_bytes : 0;
924 if (tile_version.resource_) { 920 if (tile_version.resource_)
925 DCHECK(tile->IsReadyToDraw());
926 continue; 921 continue;
927 }
928 } 922 }
929 923
930 DCHECK(!tile_version.resource_); 924 DCHECK(!tile_version.resource_);
931 925
932 // Tile shouldn't be rasterized if |tiles_that_need_to_be_rasterized| 926 // Tile shouldn't be rasterized if |tiles_that_need_to_be_rasterized|
933 // has reached it's limit or we've failed to assign gpu memory to this 927 // has reached it's limit or we've failed to assign gpu memory to this
934 // or any higher priority tile. Preventing tiles that fit into memory 928 // or any higher priority tile. Preventing tiles that fit into memory
935 // budget to be rasterized when higher priority tile is oom is 929 // budget to be rasterized when higher priority tile is oom is
936 // important for two reasons: 930 // important for two reasons:
937 // 1. Tile size should not impact raster priority. 931 // 1. Tile size should not impact raster priority.
938 // 2. Tiles with existing raster task could otherwise incorrectly 932 // 2. Tiles with existing raster task could otherwise incorrectly
939 // be added as they are not affected by |bytes_allocatable|. 933 // be added as they are not affected by |bytes_allocatable|.
940 bool can_schedule_tile = 934 bool can_schedule_tile =
941 !oomed_soft && raster_bytes_if_rastered <= max_raster_bytes && 935 !oomed_soft && raster_bytes_if_rastered <= max_raster_bytes &&
942 tiles_that_need_to_be_rasterized->size() < kScheduledRasterTasksLimit; 936 tiles_that_need_to_be_rasterized->size() < kScheduledRasterTasksLimit;
943 937
944 if (!can_schedule_tile) { 938 if (!can_schedule_tile) {
945 all_tiles_that_need_to_be_rasterized_have_memory_ = false; 939 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;
946 it.DisablePriorityOrdering(); 942 it.DisablePriorityOrdering();
947 continue; 943 continue;
948 } 944 }
949 945
950 raster_bytes = raster_bytes_if_rastered; 946 raster_bytes = raster_bytes_if_rastered;
951 tiles_that_need_to_be_rasterized->push_back(tile); 947 tiles_that_need_to_be_rasterized->push_back(tile);
952 if (tile->required_for_activation())
953 ++processed_required_for_activation_tile_count;
954 } 948 }
955 949
956 int 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)->GetTree() == PENDING_TREE) {
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
970 // OOM reporting uses hard-limit, soft-OOM is normal depending on limit. 950 // OOM reporting uses hard-limit, soft-OOM is normal depending on limit.
971 ever_exceeded_memory_budget_ |= oomed_hard; 951 ever_exceeded_memory_budget_ |= oomed_hard;
972 if (ever_exceeded_memory_budget_) { 952 if (ever_exceeded_memory_budget_) {
973 TRACE_COUNTER_ID2("cc", 953 TRACE_COUNTER_ID2("cc",
974 "over_memory_budget", 954 "over_memory_budget",
975 this, 955 this,
976 "budget", 956 "budget",
977 global_state_.hard_memory_limit_in_bytes, 957 global_state_.hard_memory_limit_in_bytes,
978 "over", 958 "over",
979 bytes_that_exceeded_memory_budget); 959 bytes_that_exceeded_memory_budget);
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after
1646 1626
1647 if (b_priority.resolution != a_priority.resolution) { 1627 if (b_priority.resolution != a_priority.resolution) {
1648 return (prioritize_low_res && b_priority.resolution == LOW_RESOLUTION) || 1628 return (prioritize_low_res && b_priority.resolution == LOW_RESOLUTION) ||
1649 (!prioritize_low_res && b_priority.resolution == HIGH_RESOLUTION) || 1629 (!prioritize_low_res && b_priority.resolution == HIGH_RESOLUTION) ||
1650 (a_priority.resolution == NON_IDEAL_RESOLUTION); 1630 (a_priority.resolution == NON_IDEAL_RESOLUTION);
1651 } 1631 }
1652 return a_priority.IsHigherPriorityThan(b_priority); 1632 return a_priority.IsHigherPriorityThan(b_priority);
1653 } 1633 }
1654 1634
1655 } // namespace cc 1635 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/picture_layer_impl.cc ('k') | cc/test/fake_tile_manager_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698