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

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: Remove Android specific path. 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..3202e660297b59979e580e639d1a3dbe9bb5eece 100644
--- a/content/common/gpu/gpu_memory_manager.cc
+++ b/content/common/gpu/gpu_memory_manager.cc
@@ -12,7 +12,6 @@
#include "base/message_loop.h"
#include "base/process_util.h"
#include "base/string_number_conversions.h"
-#include "base/sys_info.h"
#include "content/common/gpu/gpu_channel_manager.h"
#include "content/common/gpu/gpu_memory_allocation.h"
#include "content/common/gpu/gpu_memory_manager_client.h"
@@ -151,26 +150,6 @@ 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;
-#if !defined(OS_ANDROID)
- return viewport_limit;
-#else
- static uint64 dalvik_limit = 0;
- if (!dalvik_limit)
- dalvik_limit = (base::SysInfo::DalvikHeapSizeMB() / 2) * 1024 * 1024;
- return std::min(viewport_limit, dalvik_limit);
-#endif
-}
-
uint64 GpuMemoryManager::CalcAvailableFromGpuTotal(uint64 total_gpu_memory) {
// Allow Chrome to use 75% of total GPU memory, or all-but-64MB of GPU
// memory, whichever is less.
@@ -183,16 +162,10 @@ void GpuMemoryManager::UpdateAvailableGpuMemory() {
if (bytes_available_gpu_memory_overridden_)
return;
-#if defined(OS_ANDROID)
- // On Android we use the surface size, so this finds the largest visible
- // surface size instead of lowest gpu's limit.
- int max_surface_area = 0;
-#else
// On non-Android, we use an operating system query when possible.
// We do not have a reliable concept of multiple GPUs existing in
// a system, so just be safe and go with the minimum encountered.
uint64 bytes_min = 0;
-#endif
// Only use the clients that are visible, because otherwise the set of clients
// we are querying could become extremely large.
@@ -205,25 +178,21 @@ void GpuMemoryManager::UpdateAvailableGpuMemory() {
if (!client_state->visible_)
continue;
-#if defined(OS_ANDROID)
- gfx::Size surface_size = client_state->client_->GetSurfaceSize();
- max_surface_area = std::max(max_surface_area, surface_size.width() *
- surface_size.height());
-#else
uint64 bytes = 0;
if (client_state->client_->GetTotalGpuMemory(&bytes)) {
if (!bytes_min || bytes < bytes_min)
bytes_min = bytes;
}
-#endif
}
-#if defined(OS_ANDROID)
- bytes_available_gpu_memory_ = CalcAvailableFromViewportArea(max_surface_area);
-#else
if (!bytes_min)
return;
+#if defined(OS_ANDROID)
+ // We don't need to reduce the total on Android, since
ccameron 2013/02/12 01:56:23 Nit: can you put this #if inside CalcAvialbleFromG
+ // the total is an estimate to begin with.
+ bytes_available_gpu_memory_ = bytes_min;
+#else
bytes_available_gpu_memory_ = CalcAvailableFromGpuTotal(bytes_min);
#endif

Powered by Google App Engine
This is Rietveld 408576698