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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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/trees/layer_tree_host_impl.h" 5 #include "cc/trees/layer_tree_host_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 1153 matching lines...) Expand 10 before | Expand all | Expand 10 after
1164 UpdateTileManagerMemoryPolicy(policy); 1164 UpdateTileManagerMemoryPolicy(policy);
1165 } 1165 }
1166 1166
1167 void LayerTreeHostImpl::UpdateTileManagerMemoryPolicy( 1167 void LayerTreeHostImpl::UpdateTileManagerMemoryPolicy(
1168 const ManagedMemoryPolicy& policy) { 1168 const ManagedMemoryPolicy& policy) {
1169 if (!tile_manager_) 1169 if (!tile_manager_)
1170 return; 1170 return;
1171 1171
1172 // TODO(reveman): We should avoid keeping around unused resources if 1172 // TODO(reveman): We should avoid keeping around unused resources if
1173 // possible. crbug.com/224475 1173 // possible. crbug.com/224475
1174 global_tile_state_.memory_limit_in_bytes = 1174 global_tile_state_.hard_memory_limit_in_bytes = 0;
1175 visible_ ? 1175 global_tile_state_.soft_memory_limit_in_bytes = 0;
1176 policy.bytes_limit_when_visible : 0; 1176 if (visible_ && policy.bytes_limit_when_visible > 0) {
1177 global_tile_state_.hard_memory_limit_in_bytes =
1178 policy.bytes_limit_when_visible;
1179 global_tile_state_.soft_memory_limit_in_bytes =
1180 global_tile_state_.hard_memory_limit_in_bytes *
1181 settings_.max_memory_for_prepaint_percentage / 100;
1182 }
1183 // Unused limit is calculated from soft-limit, as hard-limit may
1184 // be very high and shouldn't typically be exceeded.
1177 global_tile_state_.unused_memory_limit_in_bytes = static_cast<size_t>( 1185 global_tile_state_.unused_memory_limit_in_bytes = static_cast<size_t>(
1178 (static_cast<int64>(global_tile_state_.memory_limit_in_bytes) * 1186 (static_cast<int64>(global_tile_state_.soft_memory_limit_in_bytes) *
1179 settings_.max_unused_resource_memory_percentage) / 100); 1187 settings_.max_unused_resource_memory_percentage) /
1188 100);
1180 global_tile_state_.memory_limit_policy = 1189 global_tile_state_.memory_limit_policy =
1181 ManagedMemoryPolicy::PriorityCutoffToTileMemoryLimitPolicy( 1190 ManagedMemoryPolicy::PriorityCutoffToTileMemoryLimitPolicy(
1182 visible_ ? 1191 visible_ ?
1183 policy.priority_cutoff_when_visible : 1192 policy.priority_cutoff_when_visible :
1184 gpu::MemoryAllocation::CUTOFF_ALLOW_NOTHING); 1193 gpu::MemoryAllocation::CUTOFF_ALLOW_NOTHING);
1185 global_tile_state_.num_resources_limit = policy.num_resources_limit; 1194 global_tile_state_.num_resources_limit = policy.num_resources_limit;
1186 1195
1187 DidModifyTilePriorities(); 1196 DidModifyTilePriorities();
1188 } 1197 }
1189 1198
(...skipping 1802 matching lines...) Expand 10 before | Expand all | Expand 10 after
2992 swap_promise_monitor_.erase(monitor); 3001 swap_promise_monitor_.erase(monitor);
2993 } 3002 }
2994 3003
2995 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { 3004 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() {
2996 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); 3005 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin();
2997 for (; it != swap_promise_monitor_.end(); it++) 3006 for (; it != swap_promise_monitor_.end(); it++)
2998 (*it)->OnSetNeedsRedrawOnImpl(); 3007 (*it)->OnSetNeedsRedrawOnImpl();
2999 } 3008 }
3000 3009
3001 } // namespace cc 3010 } // namespace cc
OLDNEW
« 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