| Index: ui/gl/gl_context_android.cc
|
| diff --git a/ui/gl/gl_context_android.cc b/ui/gl/gl_context_android.cc
|
| index 270c312fe6148c5189d23c25a0a7492e6c83fd1d..005f039a6928691fbfe03fa9f831c97bd1297145 100644
|
| --- a/ui/gl/gl_context_android.cc
|
| +++ b/ui/gl/gl_context_android.cc
|
| @@ -6,12 +6,14 @@
|
|
|
| #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"
|
| #include "ui/gl/gl_implementation.h"
|
| #include "ui/gl/gl_surface.h"
|
|
|
| +
|
| namespace gfx {
|
|
|
| // static
|
| @@ -32,4 +34,44 @@ 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
|
| +
|
| + static uint64 dalvik_limit = 0;
|
| + 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;
|
| + }
|
| +
|
| + *bytes = dalvik_limit;
|
| + return true;
|
| +}
|
| +
|
| }
|
|
|