Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / ui / gl / gl_context_android.cc
index a9e888b..f4555a2 100644 (file)
@@ -108,27 +108,33 @@ bool GLContextEGL::GetTotalGpuMemory(size_t* bytes) {
   // Now we take a default of 1/8th of memory on high-memory devices,
   // and gradually scale that back for low-memory devices (to be nicer
   // to other apps so they don't get killed). Examples:
-  // Nexus 4/10(2GB)    256MB
-  // Droid Razr M(1GB)  91MB
-  // Galaxy Nexus(1GB)  85MB
-  // Xoom(1GB)          85MB
-  // Nexus S(low-end)   8MB
+  // Nexus 4/10(2GB)    256MB (normally 128MB)
+  // Droid Razr M(1GB)  114MB (normally 57MB)
+  // Galaxy Nexus(1GB)  100MB (normally 50MB)
+  // Xoom(1GB)          100MB (normally 50MB)
+  // Nexus S(low-end)   12MB (normally 8MB)
+  // Note that the compositor now uses only some of this memory for
+  // pre-painting and uses the rest only for 'emergencies'.
   static size_t limit_bytes = 0;
   if (limit_bytes == 0) {
+    // NOTE: Non-low-end devices use only 50% of these limits,
+    // except during 'emergencies' where 100% can be used.
     if (!base::android::SysUtils::IsLowEndDevice()) {
       if (physical_memory_mb >= 1536)
-        limit_bytes = physical_memory_mb / 8;
+        limit_bytes = physical_memory_mb / 8; // >192MB
       else if (physical_memory_mb >= 1152)
-        limit_bytes = physical_memory_mb / 10;
+        limit_bytes = physical_memory_mb / 8; // >144MB
       else if (physical_memory_mb >= 768)
-        limit_bytes = physical_memory_mb / 12;
+        limit_bytes = physical_memory_mb / 10; // >76MB
       else
-        limit_bytes = physical_memory_mb / 16;
+        limit_bytes = physical_memory_mb / 12; // <64MB
     } else {
       // Low-end devices have 512MB or less memory by definition
       // so we hard code the limit rather than relying on the heuristics
       // above. Low-end devices use 4444 textures so we can use a lower limit.
-      limit_bytes = 8;
+      // NOTE: Low-end uses 2/3 (67%) of this memory in practice, so we have
+      // increased the limit to 12 (8MB, or 12MB in emergencies).
+      limit_bytes = 12;
     }
     limit_bytes = limit_bytes * 1024 * 1024;
   }