bug 803299 - Investigate using 24-bit or 32-bit color, only use 24bit for high memory (768MB RAM) devices r=kats

This commit is contained in:
Brad Lassey 2013-07-02 09:44:44 -04:00
Родитель 7daa48df2e
Коммит acb0cc8301
1 изменённых файлов: 40 добавлений и 10 удалений

Просмотреть файл

@ -1322,21 +1322,51 @@ public class GeckoAppShell
return sDensityDpi;
}
private static boolean isHighMemoryDevice() {
BufferedReader br = null;
FileReader fr = null;
try {
fr = new FileReader("/proc/meminfo");
if (fr == null)
return false;
br = new BufferedReader(fr);
String line = br.readLine();
while (line != null && !line.startsWith("MemTotal")) {
line = br.readLine();
}
String[] tokens = line.split("\\s+");
if (tokens.length >= 2 && Long.parseLong(tokens[1]) >= 786432 /* 768MB in kb*/) {
return true;
}
} catch (Exception ex) {
} finally {
try {
if (fr != null)
fr.close();
} catch (IOException ioe) {}
}
return false;
}
/**
* Returns the colour depth of the default screen. This will either be
* 24 or 16.
*/
public static synchronized int getScreenDepth() {
if (sScreenDepth == 0 && getGeckoInterface() != null) {
switch (getGeckoInterface().getActivity().getWindowManager().getDefaultDisplay().getPixelFormat()) {
case PixelFormat.RGBA_8888 :
case PixelFormat.RGBX_8888 :
case PixelFormat.RGB_888 :
sScreenDepth = 24;
break;
default:
sScreenDepth = 16;
break;
if (sScreenDepth == 0) {
sScreenDepth = 16;
if (getGeckoInterface() != null) {
switch (getGeckoInterface().getActivity().getWindowManager().getDefaultDisplay().getPixelFormat()) {
case PixelFormat.RGBA_8888 :
case PixelFormat.RGBX_8888 :
case PixelFormat.RGB_888 :
{
if (isHighMemoryDevice()) {
sScreenDepth = 24;
}
break;
}
}
}
}