diff options
author | Jason Macnak <natsu@google.com> | 2021-10-14 08:50:13 -0700 |
---|---|---|
committer | Jason Macnak <natsu@google.com> | 2021-10-14 11:06:42 -0700 |
commit | 9877e18b82fed1dbca0ca3d05d5bce2d8f7b542e (patch) | |
tree | d8aed68be718346b467f7fd5beea646d0f819070 | |
parent | 64a179f2f608bf1c71be3c54bc66d1988833ad65 (diff) | |
download | goldfish-opengl-android12-qpr3-release.tar.gz |
Fix DPI handling after hwcomposer 2.4 updateandroid-12.1.0_r9android-12.1.0_r8android-12.1.0_r7android-12.1.0_r22android-12.1.0_r21android-12.1.0_r20android-12.1.0_r19android-12.1.0_r11android-12.1.0_r10android12L-devandroid12-qpr3-s7-releaseandroid12-qpr3-s6-releaseandroid12-qpr3-s5-releaseandroid12-qpr3-s4-releaseandroid12-qpr3-s3-releaseandroid12-qpr3-s2-releaseandroid12-qpr3-s1-releaseandroid12-qpr3-release
aosp/1843498 accidently dropped the factor of 1000 that was applied
in Display::init(). Instead, move the factor of 1000 to DisplayConfig
and document the factor better.
Bug: b/201578179
Bug: b/202358218
Test: `launch_cvd` and inspect DPI
Change-Id: I40fb96900ea864497eee093049b8b707e6991298
Merged-In: I40fb96900ea864497eee093049b8b707e6991298
-rw-r--r-- | system/hwc2/Display.cpp | 4 | ||||
-rw-r--r-- | system/hwc2/DisplayConfig.cpp | 10 | ||||
-rw-r--r-- | system/hwc2/DisplayConfig.h | 3 |
3 files changed, 11 insertions, 6 deletions
diff --git a/system/hwc2/Display.cpp b/system/hwc2/Display.cpp index 9d754cba..a7cff779 100644 --- a/system/hwc2/Display.cpp +++ b/system/hwc2/Display.cpp @@ -114,8 +114,8 @@ HWC2::Error Display::updateParameters( 1000 * 1000 * 1000 / refreshRateHz); it->second.setAttribute(HWC2::Attribute::Width, width); it->second.setAttribute(HWC2::Attribute::Height, height); - it->second.setAttribute(HWC2::Attribute::DpiX, dpiX * 1000); - it->second.setAttribute(HWC2::Attribute::DpiY, dpiY * 1000); + it->second.setAttribute(HWC2::Attribute::DpiX, dpiX); + it->second.setAttribute(HWC2::Attribute::DpiY, dpiY); mEdid = edid; diff --git a/system/hwc2/DisplayConfig.cpp b/system/hwc2/DisplayConfig.cpp index b05f9076..ee4cbb1e 100644 --- a/system/hwc2/DisplayConfig.cpp +++ b/system/hwc2/DisplayConfig.cpp @@ -57,10 +57,12 @@ int32_t DisplayConfig::getAttribute(HWC2::Attribute attribute) const { return mHeight; } if (attribute == HWC2::Attribute::DpiX) { - return mDpiX; + // From hwcomposer2.h, HWC2_ATTRIBUTE_DPI_X returns "Dots per thousand inches (DPI * 1000)". + return getDotsPerThousandInchesX(); } if (attribute == HWC2::Attribute::DpiY) { - return mDpiY; + // From hwcomposer2.h, HWC2_ATTRIBUTE_DPI_Y returns "Dots per thousand inches (DPI * 1000)" + return getDotsPerThousandInchesY(); } if (attribute == HWC2::Attribute::VsyncPeriod) { return mVsyncPeriodNanos; @@ -75,8 +77,8 @@ std::string DisplayConfig::toString() const { std::string output; output += " w:" + std::to_string(mWidth); output += " h:" + std::to_string(mHeight); - output += " dpi-x:" + std::to_string(mDpiX / 1000.0f); - output += " dpi-y:" + std::to_string(mDpiY / 1000.0f); + output += " dpi-x:" + std::to_string(mDpiX); + output += " dpi-y:" + std::to_string(mDpiY); output += " vsync:" + std::to_string(1e9 / mVsyncPeriodNanos); output += " config-group:" + std::to_string(mConfigGroup); return output; diff --git a/system/hwc2/DisplayConfig.h b/system/hwc2/DisplayConfig.h index f7502d70..67e4c49e 100644 --- a/system/hwc2/DisplayConfig.h +++ b/system/hwc2/DisplayConfig.h @@ -60,6 +60,9 @@ class DisplayConfig { int32_t getDpiY() const { return mDpiY; } void setDpiY(int32_t dpi) { mDpiY = dpi; } + int32_t getDotsPerThousandInchesX() const { return mDpiX * 1000; } + int32_t getDotsPerThousandInchesY() const { return mDpiY * 1000; } + int32_t getVsyncPeriod() const { return mVsyncPeriodNanos; } void setVsyncPeriod(int32_t vsync) { mVsyncPeriodNanos = vsync; } |