From 1b15e1e26b3d410b6bd51feeb7077251a464fee0 Mon Sep 17 00:00:00 2001 From: Dima Zavin Date: Wed, 14 Mar 2012 17:15:10 -0700 Subject: [PATCH] surfaceflinger: use display dpi if not forced with ro.sf.lcd_nensity Change-Id: I52c4b872e0f2c088c2a6ada7a5bb15db071f0002 Signed-off-by: Dima Zavin --- .../DisplayHardware/DisplayHardware.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/services/surfaceflinger/DisplayHardware/DisplayHardware.cpp b/services/surfaceflinger/DisplayHardware/DisplayHardware.cpp index 9baae800e..3a0ff7156 100644 --- a/services/surfaceflinger/DisplayHardware/DisplayHardware.cpp +++ b/services/surfaceflinger/DisplayHardware/DisplayHardware.cpp @@ -251,15 +251,21 @@ void DisplayHardware::init(uint32_t dpy) */ if (property_get("qemu.sf.lcd_density", property, NULL) <= 0) { if (property_get("ro.sf.lcd_density", property, NULL) <= 0) { - ALOGW("ro.sf.lcd_density not defined, using 160 dpi by default."); - strcpy(property, "160"); + if (mDpiX && mDpiY) { + ALOGI("Using density info from display: xdpi=%d ydpi=%d\n", + mDpiX, mDpiY); + } else { + ALOGW("No display dpi and ro.sf.lcd_density not defined, using 160 dpi by default."); + mDpiX = mDpiY = 160; + } } } else { /* for the emulator case, reset the dpi values too */ mDpiX = mDpiY = atoi(property); } - mDensity = atoi(property) * (1.0f/160.0f); + /* use the xdpi as our density baseline */ + mDensity = mDpiX * (1.0f / 160.0f); /* * Create our OpenGL ES context