From acb0cc8301178540cf3b9a1cf664c7bf985171a7 Mon Sep 17 00:00:00 2001 From: Brad Lassey Date: Tue, 2 Jul 2013 09:44:44 -0400 Subject: [PATCH] bug 803299 - Investigate using 24-bit or 32-bit color, only use 24bit for high memory (768MB RAM) devices r=kats --- mobile/android/base/GeckoAppShell.java | 50 ++++++++++++++++++++------ 1 file changed, 40 insertions(+), 10 deletions(-) diff --git a/mobile/android/base/GeckoAppShell.java b/mobile/android/base/GeckoAppShell.java index 75da98f21210..2c2a1d640f11 100644 --- a/mobile/android/base/GeckoAppShell.java +++ b/mobile/android/base/GeckoAppShell.java @@ -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; + } + } } }