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

Unified Diff: content/common/gpu/gpu_memory_manager.cc

Issue 12223064: base: Fix parsing and add dalvik-heap-limit (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix tests. Created 7 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
Index: content/common/gpu/gpu_memory_manager.cc
diff --git a/content/common/gpu/gpu_memory_manager.cc b/content/common/gpu/gpu_memory_manager.cc
index 07a4d10782dc6521cfd449c9d0a82156ec00c0b6..89078e9b4fcea480a4c3ea98486b22c6b661bc5a 100644
--- a/content/common/gpu/gpu_memory_manager.cc
+++ b/content/common/gpu/gpu_memory_manager.cc
@@ -151,23 +151,44 @@ uint64 GpuMemoryManager::GetMaximumClientAllocation() const {
#endif
}
-uint64 GpuMemoryManager::CalcAvailableFromViewportArea(int viewport_area) {
- // We can't query available GPU memory from the system on Android, but
- // 18X the viewport and 50% of the dalvik heap size give us a good
- // estimate of available GPU memory on a wide range of devices.
- const int kViewportMultiplier = 18;
- const unsigned int kComponentsPerPixel = 4; // GraphicsContext3D::RGBA
- const unsigned int kBytesPerComponent = 1; // sizeof(GC3Dubyte)
- uint64 viewport_limit = viewport_area * kViewportMultiplier *
- kComponentsPerPixel *
- kBytesPerComponent;
+uint64 GpuMemoryManager::CalcAvailableFromDalvikHeap() {
#if !defined(OS_ANDROID)
- return viewport_limit;
+ CHECK(false);
+ return 0;
#else
+ // We can't query available GPU memory from the system on Android,
+ // but the dalvik heap size give us a good estimate of available
+ // GPU memory on a wide range of devices.
+
+ // The heap size tends to be about 1/4 of total ram on higher end
+ // devices, so we use 1/2 of that by default. For example both the
+ // Nexus 4/10 have 2GB of ram and 512MB Dalvik heap size. For lower
+ // end devices, 1/2 of the heap size can be too high, but this
+ // correlates well with having a small heap-growth-limit. So for
+ // devices with less ram, we factor in the growth limit.
+
+ // This is the result of the calculation below:
+ // Droid DNA 1080P 128MB
+ // Nexus S 56MB
+ // Galaxy Nexus 112MB
+ // Nexus 4/10 256MB
+ // Xoom 88MB
+
static uint64 dalvik_limit = 0;
- if (!dalvik_limit)
- dalvik_limit = (base::SysInfo::DalvikHeapSizeMB() / 2) * 1024 * 1024;
- return std::min(viewport_limit, dalvik_limit);
+ if (!dalvik_limit) {
+ uint64 heap_size = base::SysInfo::DalvikHeapSizeMB();
+ uint64 heap_growth = base::SysInfo::DalvikHeapGrowthLimitMB();
+ uint64 limit = 0;
+
+ if (heap_size >= 350)
+ limit = heap_size / 2;
+ else
+ limit = (heap_size + (heap_growth * 2)) / 4;
+
+ dalvik_limit = limit * 1024 * 1024;
+ }
+
+ return dalvik_limit;
#endif
}
@@ -219,7 +240,7 @@ void GpuMemoryManager::UpdateAvailableGpuMemory() {
}
#if defined(OS_ANDROID)
- bytes_available_gpu_memory_ = CalcAvailableFromViewportArea(max_surface_area);
+ bytes_available_gpu_memory_ = CalcAvailableFromDalvikHeap();
#else
if (!bytes_min)
return;

Powered by Google App Engine
This is Rietveld 408576698