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

Unified Diff: ui/gl/gl_context_android.cc

Issue 12223064: base: Fix parsing and add dalvik-heap-limit (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address feedback, 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: 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();
jar (doing other things) 2013/02/14 01:48:41 Why are we using uint64 here? The range of the fu
epenner 2013/02/14 04:18:36 I think the uint64 crept in from the other code. H
+ 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;
jar (doing other things) 2013/02/14 01:48:41 I'm surprised this assignment didn't generate a co
epenner 2013/02/14 04:18:36 See above, I think size_t is uint64 on both 32/64
+ return true;
+}
+
}

Powered by Google App Engine
This is Rietveld 408576698