summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChih-Wei Huang <cwhuang@linux.org.tw>2014-10-26 15:39:53 +0800
committerChih-Wei Huang <cwhuang@linux.org.tw>2016-05-06 01:57:09 +0800
commitae064fcc1b9fa383365521caf25c6cabdb7dfcd1 (patch)
tree48913bc1995d19ef4ac280d9300cdd379246f550
parent26be90a0bf2651184fcdbf3b1397edf398a78bfd (diff)
downloadframeworks_native-ae064fcc1b9fa383365521caf25c6cabdb7dfcd1.zip
frameworks_native-ae064fcc1b9fa383365521caf25c6cabdb7dfcd1.tar.gz
frameworks_native-ae064fcc1b9fa383365521caf25c6cabdb7dfcd1.tar.bz2
auto determine the density if not provided in surfaceflinger
We hope to support tablet UI for different resolutions. So adjust the density according to the resolution.
-rw-r--r--services/surfaceflinger/SurfaceFlinger.cpp29
1 files changed, 24 insertions, 5 deletions
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 48a4fbf..7461613 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -585,8 +585,27 @@ status_t SurfaceFlinger::getDisplayConfigs(const sp<IBinder>& display,
public:
static int getEmuDensity() {
return getDensityFromProperty("qemu.sf.lcd_density"); }
- static int getBuildDensity() {
- return getDensityFromProperty("ro.sf.lcd_density"); }
+ static int getBuildDensity(const DisplayInfo& info) {
+ static int density = getDensityFromProperty("ro.sf.lcd_density");
+#if defined(__i386__) || defined(__x86_64__)
+ if (density == 0) {
+ uint32_t area = info.w * info.h;
+ if (area <= 800 * 480) {
+ density = 120;
+ } else if (area <= 1024 * 600) {
+ density = 130;
+ } else if (area < 1024 * 768) {
+ density = 140;
+ } else if (area < 1920 * 1080) {
+ density = 160;
+ } else {
+ density = 240;
+ }
+ ALOGI("auto set density to %d", density);
+ }
+#endif
+ return density;
+ }
};
configs->clear();
@@ -599,10 +618,12 @@ status_t SurfaceFlinger::getDisplayConfigs(const sp<IBinder>& display,
float xdpi = hwConfig.xdpi;
float ydpi = hwConfig.ydpi;
+ info.w = hwConfig.width;
+ info.h = hwConfig.height;
if (type == DisplayDevice::DISPLAY_PRIMARY) {
// The density of the device is provided by a build property
- float density = Density::getBuildDensity() / 160.0f;
+ float density = Density::getBuildDensity(info) / 160.0f;
if (density == 0) {
// the build doesn't provide a density -- this is wrong!
// use xdpi instead
@@ -626,8 +647,6 @@ status_t SurfaceFlinger::getDisplayConfigs(const sp<IBinder>& display,
info.orientation = 0;
}
- info.w = hwConfig.width;
- info.h = hwConfig.height;
info.xdpi = xdpi;
info.ydpi = ydpi;
info.fps = float(1e9 / hwConfig.refresh);