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

Unified Diff: cc/trees/layer_tree_host_impl.cc

Issue 140673009: CC/GPU: Add a soft limit to the compositor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/resources/tile_priority.cc ('k') | cc/trees/layer_tree_settings.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/layer_tree_host_impl.cc
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc
index 9939822a34b56ca7026b7dd32246dddbabc39ca0..fb1ebbcc9466baab70200ba9646a41799b8cc6d3 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -1171,12 +1171,21 @@ void LayerTreeHostImpl::UpdateTileManagerMemoryPolicy(
// TODO(reveman): We should avoid keeping around unused resources if
// possible. crbug.com/224475
- global_tile_state_.memory_limit_in_bytes =
- visible_ ?
- policy.bytes_limit_when_visible : 0;
+ global_tile_state_.hard_memory_limit_in_bytes = 0;
+ global_tile_state_.soft_memory_limit_in_bytes = 0;
+ if (visible_ && policy.bytes_limit_when_visible > 0) {
+ global_tile_state_.hard_memory_limit_in_bytes =
+ policy.bytes_limit_when_visible;
+ global_tile_state_.soft_memory_limit_in_bytes =
+ global_tile_state_.hard_memory_limit_in_bytes *
+ settings_.max_memory_for_prepaint_percentage / 100;
+ }
+ // Unused limit is calculated from soft-limit, as hard-limit may
+ // be very high and shouldn't typically be exceeded.
global_tile_state_.unused_memory_limit_in_bytes = static_cast<size_t>(
- (static_cast<int64>(global_tile_state_.memory_limit_in_bytes) *
- settings_.max_unused_resource_memory_percentage) / 100);
+ (static_cast<int64>(global_tile_state_.soft_memory_limit_in_bytes) *
+ settings_.max_unused_resource_memory_percentage) /
+ 100);
global_tile_state_.memory_limit_policy =
ManagedMemoryPolicy::PriorityCutoffToTileMemoryLimitPolicy(
visible_ ?
« no previous file with comments | « cc/resources/tile_priority.cc ('k') | cc/trees/layer_tree_settings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698