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

Side by Side Diff: ui/gl/gl_context_android.cc

Issue 168053002: GPU: Adjust memory and use the soft-limit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Typo. Created 6 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 unified diff | Download patch
OLDNEW
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/android/sys_utils.h" 7 #include "base/android/sys_utils.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/sys_info.h" 10 #include "base/sys_info.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 size_t physical_memory_mb = 0; 101 size_t physical_memory_mb = 0;
102 if (dalvik_mb >= 256) 102 if (dalvik_mb >= 256)
103 physical_memory_mb = dalvik_mb * 4; 103 physical_memory_mb = dalvik_mb * 4;
104 else 104 else
105 physical_memory_mb = std::max(dalvik_mb * 4, 105 physical_memory_mb = std::max(dalvik_mb * 4,
106 (physical_mb * 4) / 3); 106 (physical_mb * 4) / 3);
107 107
108 // Now we take a default of 1/8th of memory on high-memory devices, 108 // Now we take a default of 1/8th of memory on high-memory devices,
109 // and gradually scale that back for low-memory devices (to be nicer 109 // and gradually scale that back for low-memory devices (to be nicer
110 // to other apps so they don't get killed). Examples: 110 // to other apps so they don't get killed). Examples:
111 // Nexus 4/10(2GB) 256MB 111 // Nexus 4/10(2GB) 256MB (normally 128MB)
112 // Droid Razr M(1GB) 91MB 112 // Droid Razr M(1GB) 114MB (normally 57MB)
113 // Galaxy Nexus(1GB) 85MB 113 // Galaxy Nexus(1GB) 100MB (normally 50MB)
114 // Xoom(1GB) 85MB 114 // Xoom(1GB) 100MB (normally 50MB)
115 // Nexus S(low-end) 8MB 115 // Nexus S(low-end) 12MB (normally 8MB)
116 // Note that the compositor now uses only some of this memory for
117 // pre-painting and uses the rest only for 'emergencies'.
klobag.chromium 2014/02/15 07:27:20 Can we move this two lines up and say the number i
epenner 2014/02/17 05:43:23 Yes, much better way to explain the numbers.
116 static size_t limit_bytes = 0; 118 static size_t limit_bytes = 0;
117 if (limit_bytes == 0) { 119 if (limit_bytes == 0) {
120 // NOTE: Non-low-end devices use only 50% of these limits,
121 // except during 'emergencies' where 100% can be used.
118 if (!base::android::SysUtils::IsLowEndDevice()) { 122 if (!base::android::SysUtils::IsLowEndDevice()) {
119 if (physical_memory_mb >= 1536) 123 if (physical_memory_mb >= 1536)
120 limit_bytes = physical_memory_mb / 8; 124 limit_bytes = physical_memory_mb / 8; // >192MB
121 else if (physical_memory_mb >= 1152) 125 else if (physical_memory_mb >= 1152)
122 limit_bytes = physical_memory_mb / 10; 126 limit_bytes = physical_memory_mb / 8; // >144MB
klobag.chromium 2014/02/15 07:27:20 merge the above two?
epenner 2014/02/17 05:43:23 Good point will do. I think this number is common
123 else if (physical_memory_mb >= 768) 127 else if (physical_memory_mb >= 768)
124 limit_bytes = physical_memory_mb / 12; 128 limit_bytes = physical_memory_mb / 10; // >76MB
125 else 129 else
126 limit_bytes = physical_memory_mb / 16; 130 limit_bytes = physical_memory_mb / 12; // <64MB
127 } else { 131 } else {
128 // Low-end devices have 512MB or less memory by definition 132 // Low-end devices have 512MB or less memory by definition
129 // so we hard code the limit rather than relying on the heuristics 133 // so we hard code the limit rather than relying on the heuristics
130 // above. Low-end devices use 4444 textures so we can use a lower limit. 134 // above. Low-end devices use 4444 textures so we can use a lower limit.
131 limit_bytes = 8; 135 // NOTE: Low-end uses 2/3 (67%) of this memory in practice, so we have
136 // increased the limit to 12 (8MB, or 12MB in emergencies).
137 limit_bytes = 12;
132 } 138 }
133 limit_bytes = limit_bytes * 1024 * 1024; 139 limit_bytes = limit_bytes * 1024 * 1024;
134 } 140 }
135 *bytes = limit_bytes; 141 *bytes = limit_bytes;
136 return true; 142 return true;
137 } 143 }
138 144
139 } 145 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698