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

Side by Side Diff: content/common/gpu/gpu_memory_manager.cc

Issue 10827342: Reduce per-tab memory to 128M maximum, reduce default maximum across all tabs to 256M (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Actually drop the limit to 256MB Created 8 years, 4 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "content/common/gpu/gpu_memory_manager.h" 5 #include "content/common/gpu/gpu_memory_manager.h"
6 6
7 #if defined(ENABLE_GPU) 7 #if defined(ENABLE_GPU)
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 CommandLine* command_line = CommandLine::ForCurrentProcess(); 79 CommandLine* command_line = CommandLine::ForCurrentProcess();
80 if (command_line->HasSwitch(switches::kForceGpuMemAvailableMb)) { 80 if (command_line->HasSwitch(switches::kForceGpuMemAvailableMb)) {
81 base::StringToSizeT( 81 base::StringToSizeT(
82 command_line->GetSwitchValueASCII(switches::kForceGpuMemAvailableMb), 82 command_line->GetSwitchValueASCII(switches::kForceGpuMemAvailableMb),
83 &bytes_available_gpu_memory_); 83 &bytes_available_gpu_memory_);
84 bytes_available_gpu_memory_ *= 1024 * 1024; 84 bytes_available_gpu_memory_ *= 1024 * 1024;
85 } else { 85 } else {
86 #if defined(OS_ANDROID) 86 #if defined(OS_ANDROID)
87 bytes_available_gpu_memory_ = 64 * 1024 * 1024; 87 bytes_available_gpu_memory_ = 64 * 1024 * 1024;
88 #else 88 #else
89 bytes_available_gpu_memory_ = 448 * 1024 * 1024; 89 bytes_available_gpu_memory_ = 256 * 1024 * 1024;
90 #endif 90 #endif
91 } 91 }
92 } 92 }
93 93
94 GpuMemoryManager::~GpuMemoryManager() { 94 GpuMemoryManager::~GpuMemoryManager() {
95 } 95 }
96 96
97 bool GpuMemoryManager::StubWithSurfaceComparator::operator()( 97 bool GpuMemoryManager::StubWithSurfaceComparator::operator()(
98 GpuCommandBufferStubBase* lhs, 98 GpuCommandBufferStubBase* lhs,
99 GpuCommandBufferStubBase* rhs) { 99 GpuCommandBufferStubBase* rhs) {
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 if (base_allocation_size < GetAvailableGpuMemory() && 255 if (base_allocation_size < GetAvailableGpuMemory() &&
256 !stubs_with_surface_foreground.empty()) 256 !stubs_with_surface_foreground.empty())
257 bonus_allocation = (GetAvailableGpuMemory() - base_allocation_size) / 257 bonus_allocation = (GetAvailableGpuMemory() - base_allocation_size) /
258 stubs_with_surface_foreground.size(); 258 stubs_with_surface_foreground.size();
259 #else 259 #else
260 // On android, calculate bonus allocation based on surface size. 260 // On android, calculate bonus allocation based on surface size.
261 if (!stubs_with_surface_foreground.empty()) 261 if (!stubs_with_surface_foreground.empty())
262 bonus_allocation = CalculateBonusMemoryAllocationBasedOnSize( 262 bonus_allocation = CalculateBonusMemoryAllocationBasedOnSize(
263 stubs_with_surface_foreground[0]->GetSurfaceSize()); 263 stubs_with_surface_foreground[0]->GetSurfaceSize());
264 #endif 264 #endif
265 size_t stubs_with_surface_foreground_allocation = GetMinimumTabAllocation() +
266 bonus_allocation;
267 if (stubs_with_surface_foreground_allocation >= GetMaximumTabAllocation())
268 stubs_with_surface_foreground_allocation = GetMaximumTabAllocation();
265 269
266 stub_memory_stats_for_last_manage_.clear(); 270 stub_memory_stats_for_last_manage_.clear();
267 271
268 // Now give out allocations to everyone. 272 // Now give out allocations to everyone.
269 AssignMemoryAllocations( 273 AssignMemoryAllocations(
270 &stub_memory_stats_for_last_manage_, 274 &stub_memory_stats_for_last_manage_,
271 stubs_with_surface_foreground, 275 stubs_with_surface_foreground,
272 GpuMemoryAllocation(GetMinimumTabAllocation() + bonus_allocation, 276 GpuMemoryAllocation(stubs_with_surface_foreground_allocation,
273 GpuMemoryAllocation::kHasFrontbuffer | 277 GpuMemoryAllocation::kHasFrontbuffer |
274 GpuMemoryAllocation::kHasBackbuffer), 278 GpuMemoryAllocation::kHasBackbuffer),
275 true); 279 true);
276 280
277 AssignMemoryAllocations( 281 AssignMemoryAllocations(
278 &stub_memory_stats_for_last_manage_, 282 &stub_memory_stats_for_last_manage_,
279 stubs_with_surface_background, 283 stubs_with_surface_background,
280 GpuMemoryAllocation(0, GpuMemoryAllocation::kHasFrontbuffer), 284 GpuMemoryAllocation(0, GpuMemoryAllocation::kHasFrontbuffer),
281 false); 285 false);
282 286
(...skipping 18 matching lines...) Expand all
301 false); 305 false);
302 306
303 AssignMemoryAllocations( 307 AssignMemoryAllocations(
304 &stub_memory_stats_for_last_manage_, 308 &stub_memory_stats_for_last_manage_,
305 stubs_without_surface_hibernated, 309 stubs_without_surface_hibernated,
306 GpuMemoryAllocation(0, GpuMemoryAllocation::kHasNoBuffers), 310 GpuMemoryAllocation(0, GpuMemoryAllocation::kHasNoBuffers),
307 false); 311 false);
308 } 312 }
309 313
310 #endif 314 #endif
OLDNEW
« no previous file with comments | « content/common/gpu/gpu_memory_manager.h ('k') | content/common/gpu/gpu_memory_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698