diff options
author | Jesse Hall <jessehall@google.com> | 2014-09-28 12:14:12 -0700 |
---|---|---|
committer | Jesse Hall <jessehall@google.com> | 2014-09-28 22:26:28 +0000 |
commit | bacc28ef1df329f4dc21bae44b09a6c5018af908 (patch) | |
tree | 94487090b5b1c15d2ac573442add0a7f26264b96 /services/surfaceflinger | |
parent | 71e351d96b551ccdbc39b52a0c66da86cae83701 (diff) | |
download | frameworks_native-bacc28ef1df329f4dc21bae44b09a6c5018af908.zip frameworks_native-bacc28ef1df329f4dc21bae44b09a6c5018af908.tar.gz frameworks_native-bacc28ef1df329f4dc21bae44b09a6c5018af908.tar.bz2 |
surfaceflinger: Use landscape resolution for default dpi
When HWC doesn't provide DPI values for a display, we pick a default
DPI based on resolution. The intent was that 1080p and higher displays
would get XHIGH density, and lower resolutions would get TV density.
In KK (and possibly forever) we had a bug that we'd always use TV
density. That was fixed in L, but that fix exposed a pre-existing bug
that we always used the display's height in its native orientation,
rather than in landscape orientation. So an 800x1280 tablet like N7v1
started getting XHIGH density instead of the intended TV density.
Bug: 17461633
Change-Id: Ia57fa49e61f36bdda63ce283ef62c9953297222c
Diffstat (limited to 'services/surfaceflinger')
-rw-r--r-- | services/surfaceflinger/DisplayHardware/HWComposer.cpp | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.cpp b/services/surfaceflinger/DisplayHardware/HWComposer.cpp index 6302053..edfed49 100644 --- a/services/surfaceflinger/DisplayHardware/HWComposer.cpp +++ b/services/surfaceflinger/DisplayHardware/HWComposer.cpp @@ -314,9 +314,17 @@ void HWComposer::hotplug(int disp, int connected) { mEventHandler.onHotplugReceived(disp, bool(connected)); } -static float getDefaultDensity(uint32_t height) { - if (height >= 1080) return ACONFIGURATION_DENSITY_XHIGH; - else return ACONFIGURATION_DENSITY_TV; +static float getDefaultDensity(uint32_t width, uint32_t height) { + // Default density is based on TVs: 1080p displays get XHIGH density, + // lower-resolution displays get TV density. Maybe eventually we'll need + // to update it for 4K displays, though hopefully those just report + // accurate DPI information to begin with. This is also used for virtual + // displays and even primary displays with older hwcomposers, so be + // careful about orientation. + + uint32_t h = width < height ? width : height; + if (h >= 1080) return ACONFIGURATION_DENSITY_XHIGH; + else return ACONFIGURATION_DENSITY_TV; } static const uint32_t DISPLAY_ATTRIBUTES[] = { @@ -383,7 +391,7 @@ status_t HWComposer::queryDisplayProperties(int disp) { } if (config.xdpi == 0.0f || config.ydpi == 0.0f) { - float dpi = getDefaultDensity(config.height); + float dpi = getDefaultDensity(config.width, config.height); config.xdpi = dpi; config.ydpi = dpi; } @@ -408,7 +416,7 @@ status_t HWComposer::setVirtualDisplayProperties(int32_t id, DisplayConfig& config = mDisplayData[id].configs.editItemAt(configId); config.width = w; config.height = h; - config.xdpi = config.ydpi = getDefaultDensity(h); + config.xdpi = config.ydpi = getDefaultDensity(w, h); return NO_ERROR; } |