diff options
author | epenner@chromium.org <epenner@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-14 22:47:27 +0000 |
---|---|---|
committer | epenner@chromium.org <epenner@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-14 22:47:27 +0000 |
commit | 66f39728225a46827c9fbae3cf4aa9cceede3466 (patch) | |
tree | 8ece9abc4938bece8798b66ac9f7f427de3ad9d5 /ui/gl/gl_context_android.cc | |
parent | 97de555bafee6fdb5ecd2edc1372d85bbfb18132 (diff) | |
download | chromium_src-66f39728225a46827c9fbae3cf4aa9cceede3466.zip chromium_src-66f39728225a46827c9fbae3cf4aa9cceede3466.tar.gz chromium_src-66f39728225a46827c9fbae3cf4aa9cceede3466.tar.bz2 |
gpu: Remove viewport from Android memory limit.
TBR=ccameron@chromium.org
TBR=piman@chromium.org
BUG=175238
NOTRY=true
No try since this has passed tests several times but is stuck.
Review URL: https://chromiumcodereview.appspot.com/12269002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@182562 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gl/gl_context_android.cc')
-rw-r--r-- | ui/gl/gl_context_android.cc | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/ui/gl/gl_context_android.cc b/ui/gl/gl_context_android.cc index 270c312..5da75694 100644 --- a/ui/gl/gl_context_android.cc +++ b/ui/gl/gl_context_android.cc @@ -6,6 +6,7 @@ #include "base/logging.h" #include "base/memory/ref_counted.h" +#include "base/sys_info.h" #include "ui/gl/gl_bindings.h" #include "ui/gl/gl_context_egl.h" #include "ui/gl/gl_context_stub.h" @@ -32,4 +33,40 @@ scoped_refptr<GLContext> GLContext::CreateGLContext( return context; } +bool GLContextEGL::GetTotalGpuMemory(size_t* bytes) { + DCHECK(bytes); + *bytes = 0; + // 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 + size_t dalvik_limit = 0; + if (!dalvik_limit) { + size_t heap_size = static_cast<size_t>(base::SysInfo::DalvikHeapSizeMB()); + // TODO(epenner): Use real heap-growth-limit when it is available. + size_t heap_growth = (heap_size / 2); + size_t limit = 0; + if (heap_size >= 350) + limit = heap_size / 2; + else + limit = (heap_size + (heap_growth * 2)) / 4; + dalvik_limit = limit * 1024 * 1024; + } + *bytes = dalvik_limit; + return true; +} + } |