| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/gl/gl_context.h" | 5 #include "ui/gl/gl_context.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/sys_info.h" | 9 #include "base/sys_info.h" |
| 10 #include "ui/gl/gl_bindings.h" | 10 #include "ui/gl/gl_bindings.h" |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 physical_memory_mb = std::max(dalvik_mb * 4, | 113 physical_memory_mb = std::max(dalvik_mb * 4, |
| 114 (physical_mb * 4) / 3); | 114 (physical_mb * 4) / 3); |
| 115 | 115 |
| 116 // Now we take a default of 1/8th of memory on high-memory devices, | 116 // Now we take a default of 1/8th of memory on high-memory devices, |
| 117 // and gradually scale that back for low-memory devices (to be nicer | 117 // and gradually scale that back for low-memory devices (to be nicer |
| 118 // to other apps so they don't get killed). Examples: | 118 // to other apps so they don't get killed). Examples: |
| 119 // Nexus 4/10(2GB) 256MB (normally 128MB) | 119 // Nexus 4/10(2GB) 256MB (normally 128MB) |
| 120 // Droid Razr M(1GB) 114MB (normally 57MB) | 120 // Droid Razr M(1GB) 114MB (normally 57MB) |
| 121 // Galaxy Nexus(1GB) 100MB (normally 50MB) | 121 // Galaxy Nexus(1GB) 100MB (normally 50MB) |
| 122 // Xoom(1GB) 100MB (normally 50MB) | 122 // Xoom(1GB) 100MB (normally 50MB) |
| 123 // Nexus S(low-end) 12MB (normally 8MB) | 123 // Nexus S(low-end) 8MB (normally 8MB) |
| 124 // Note that the compositor now uses only some of this memory for | 124 // Note that the compositor now uses only some of this memory for |
| 125 // pre-painting and uses the rest only for 'emergencies'. | 125 // pre-painting and uses the rest only for 'emergencies'. |
| 126 static size_t limit_bytes = 0; | 126 static size_t limit_bytes = 0; |
| 127 if (limit_bytes == 0) { | 127 if (limit_bytes == 0) { |
| 128 // NOTE: Non-low-end devices use only 50% of these limits, | 128 // NOTE: Non-low-end devices use only 50% of these limits, |
| 129 // except during 'emergencies' where 100% can be used. | 129 // except during 'emergencies' where 100% can be used. |
| 130 if (!base::SysInfo::IsLowEndDevice()) { | 130 if (!base::SysInfo::IsLowEndDevice()) { |
| 131 if (physical_memory_mb >= 1536) | 131 if (physical_memory_mb >= 1536) |
| 132 limit_bytes = physical_memory_mb / 8; // >192MB | 132 limit_bytes = physical_memory_mb / 8; // >192MB |
| 133 else if (physical_memory_mb >= 1152) | 133 else if (physical_memory_mb >= 1152) |
| 134 limit_bytes = physical_memory_mb / 8; // >144MB | 134 limit_bytes = physical_memory_mb / 8; // >144MB |
| 135 else if (physical_memory_mb >= 768) | 135 else if (physical_memory_mb >= 768) |
| 136 limit_bytes = physical_memory_mb / 10; // >76MB | 136 limit_bytes = physical_memory_mb / 10; // >76MB |
| 137 else | 137 else |
| 138 limit_bytes = physical_memory_mb / 12; // <64MB | 138 limit_bytes = physical_memory_mb / 12; // <64MB |
| 139 } else { | 139 } else { |
| 140 // Low-end devices have 512MB or less memory by definition | 140 // Low-end devices have 512MB or less memory by definition |
| 141 // so we hard code the limit rather than relying on the heuristics | 141 // so we hard code the limit rather than relying on the heuristics |
| 142 // above. Low-end devices use 4444 textures so we can use a lower limit. | 142 // above. Low-end devices use 4444 textures so we can use a lower limit. |
| 143 // NOTE: Low-end uses 2/3 (67%) of this memory in practice, so we have | 143 limit_bytes = 8; |
| 144 // increased the limit to 12 (8MB, or 12MB in emergencies). | |
| 145 limit_bytes = 12; | |
| 146 } | 144 } |
| 147 limit_bytes = limit_bytes * 1024 * 1024; | 145 limit_bytes = limit_bytes * 1024 * 1024; |
| 148 } | 146 } |
| 149 *bytes = limit_bytes; | 147 *bytes = limit_bytes; |
| 150 return true; | 148 return true; |
| 151 } | 149 } |
| 152 | 150 |
| 153 } | 151 } |
| OLD | NEW |