Commit ea6fa9bc authored by Mitsuru Oshima's avatar Mitsuru Oshima Committed by Commit Bot

Add 2.5x scale factor support

Bug: b/139810037
Test: covered by unittest. also tested manually.

Change-Id: I18a1f7e3d368d51823a3cd1b21e5d905fcc3d00e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1757686Reviewed-by: default avatarYusuke Sato <yusukes@chromium.org>
Reviewed-by: default avatarJun Mukai <mukai@chromium.org>
Commit-Queue: Mitsuru Oshima (slow) <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#689570}
parent fbd57753
...@@ -275,13 +275,15 @@ bool IsArcPlayAutoInstallDisabled() { ...@@ -275,13 +275,15 @@ bool IsArcPlayAutoInstallDisabled() {
// static // static
int32_t GetLcdDensityForDeviceScaleFactor(float device_scale_factor) { int32_t GetLcdDensityForDeviceScaleFactor(float device_scale_factor) {
// Keep this consistent with wayland_client.cpp on Android side. // TODO(b/131884992): Remove the logic to update default lcd density once
// TODO(oshima): Consider sending this through wayland. // per-display-density is supported.
constexpr float kEpsilon = 0.001; constexpr float kEpsilon = 0.001;
if (std::abs(device_scale_factor - 2.25f) < kEpsilon) if (std::abs(device_scale_factor - 2.25f) < kEpsilon)
return 280; return 280;
if (std::abs(device_scale_factor - 1.6f) < kEpsilon) if (std::abs(device_scale_factor - 1.6f) < kEpsilon)
return 213; // TVDPI return 213; // TVDPI
if (std::abs(device_scale_factor - 2.5f) < kEpsilon)
return 320; // XHDPI
constexpr float kChromeScaleToAndroidScaleRatio = 0.75f; constexpr float kChromeScaleToAndroidScaleRatio = 0.75f;
constexpr int32_t kDefaultDensityDpi = 160; constexpr int32_t kDefaultDensityDpi = 160;
......
...@@ -266,6 +266,7 @@ TEST_F(ArcUtilTest, ScaleFactorToDensity) { ...@@ -266,6 +266,7 @@ TEST_F(ArcUtilTest, ScaleFactorToDensity) {
EXPECT_EQ(213, GetLcdDensityForDeviceScaleFactor(1.6f)); EXPECT_EQ(213, GetLcdDensityForDeviceScaleFactor(1.6f));
EXPECT_EQ(240, GetLcdDensityForDeviceScaleFactor(2.0f)); EXPECT_EQ(240, GetLcdDensityForDeviceScaleFactor(2.0f));
EXPECT_EQ(280, GetLcdDensityForDeviceScaleFactor(2.25f)); EXPECT_EQ(280, GetLcdDensityForDeviceScaleFactor(2.25f));
EXPECT_EQ(320, GetLcdDensityForDeviceScaleFactor(2.5f));
// Bad scale factors shouldn't blow up. // Bad scale factors shouldn't blow up.
EXPECT_EQ(160, GetLcdDensityForDeviceScaleFactor(0.5f)); EXPECT_EQ(160, GetLcdDensityForDeviceScaleFactor(0.5f));
......
...@@ -45,8 +45,8 @@ struct DeviceScaleFactorDPIThreshold { ...@@ -45,8 +45,8 @@ struct DeviceScaleFactorDPIThreshold {
// Update the list of zoom levels whenever a new device scale factor is added // Update the list of zoom levels whenever a new device scale factor is added
// here. See zoom level list in /ui/display/manager/display_util.cc // here. See zoom level list in /ui/display/manager/display_util.cc
const DeviceScaleFactorDPIThreshold kThresholdTableForInternal[] = { const DeviceScaleFactorDPIThreshold kThresholdTableForInternal[] = {
{270.0f, 2.25f}, {220.0f, 2.0f}, {180.0f, 1.6f}, {320.f, 2.5f}, {270.0f, 2.25f}, {220.0f, 2.0f},
{150.0f, 1.25f}, {0.0f, 1.0f}, {180.0f, 1.6f}, {150.0f, 1.25f}, {0.0f, 1.0f},
}; };
// Returns a list of display modes for the given |output| that doesn't exclude // Returns a list of display modes for the given |output| that doesn't exclude
......
...@@ -207,13 +207,16 @@ TEST_P(DisplayChangeObserverTest, FindDeviceScaleFactor) { ...@@ -207,13 +207,16 @@ TEST_P(DisplayChangeObserverTest, FindDeviceScaleFactor) {
// 12.3" 2400x1600 // 12.3" 2400x1600
EXPECT_EQ(2.0f, ComputeDeviceScaleFactor(12.3f, gfx::Rect(2400, 1600))); EXPECT_EQ(2.0f, ComputeDeviceScaleFactor(12.3f, gfx::Rect(2400, 1600)));
// 12.3" 3000x2000 (meowth) // 12.3" 3000x2000
EXPECT_EQ(2.25f, ComputeDeviceScaleFactor(12.3f, gfx::Rect(3000, 2000))); EXPECT_EQ(2.25f, ComputeDeviceScaleFactor(12.3f, gfx::Rect(3000, 2000)));
// 13.1" 3840x2160
EXPECT_EQ(2.5f, ComputeDeviceScaleFactor(13.1f, gfx::Rect(3840, 2160)));
// Erroneous values should still work. // Erroneous values should still work.
EXPECT_EQ(1.0f, DisplayChangeObserver::FindDeviceScaleFactor(-100.0f)); EXPECT_EQ(1.0f, DisplayChangeObserver::FindDeviceScaleFactor(-100.0f));
EXPECT_EQ(1.0f, DisplayChangeObserver::FindDeviceScaleFactor(0.0f)); EXPECT_EQ(1.0f, DisplayChangeObserver::FindDeviceScaleFactor(0.0f));
EXPECT_EQ(2.25f, DisplayChangeObserver::FindDeviceScaleFactor(10000.0f)); EXPECT_EQ(2.5f, DisplayChangeObserver::FindDeviceScaleFactor(10000.0f));
} }
TEST_P(DisplayChangeObserverTest, TEST_P(DisplayChangeObserverTest,
......
...@@ -49,11 +49,12 @@ constexpr std::array<ZoomListBucket, 8> kZoomListBuckets{{ ...@@ -49,11 +49,12 @@ constexpr std::array<ZoomListBucket, 8> kZoomListBuckets{{
// zoom values that includes a zoom level to go to the native resolution of the // zoom values that includes a zoom level to go to the native resolution of the
// display. Ensure that the list of DSFs are in sync with the list of default // display. Ensure that the list of DSFs are in sync with the list of default
// device scale factors in display_change_observer.cc. // device scale factors in display_change_observer.cc.
constexpr std::array<ZoomListBucketDsf, 4> kZoomListBucketsForDsf{{ constexpr std::array<ZoomListBucketDsf, 5> kZoomListBucketsForDsf{{
{1.25f, {0.7f, 1.f / 1.25f, 0.85f, 0.9f, 0.95f, 1.f, 1.1f, 1.2f, 1.3f}}, {1.25f, {0.7f, 1.f / 1.25f, 0.85f, 0.9f, 0.95f, 1.f, 1.1f, 1.2f, 1.3f}},
{1.6f, {1.f / 1.6f, 0.7f, 0.75f, 0.8f, 0.85f, 0.9f, 1.f, 1.15f, 1.3f}}, {1.6f, {1.f / 1.6f, 0.7f, 0.75f, 0.8f, 0.85f, 0.9f, 1.f, 1.15f, 1.3f}},
{2.f, {1.f / 2.f, 0.6f, 0.7f, 0.8f, 0.9f, 1.f, 1.1f, 1.25f, 1.5f}}, {2.f, {1.f / 2.f, 0.6f, 0.7f, 0.8f, 0.9f, 1.f, 1.1f, 1.25f, 1.5f}},
{2.25f, {1.f / 2.25f, 0.6f, 0.7f, 0.8f, 0.9f, 1.f, 1.15f, 1.3f, 1.5f}}, {2.25f, {1.f / 2.25f, 0.6f, 0.7f, 0.8f, 0.9f, 1.f, 1.15f, 1.3f, 1.5f}},
{2.5f, {1.f / 2.5f, 0.5f, 0.6f, 0.8f, 0.9f, 1.f, 1.2f, 1.35f, 1.5f}},
}}; }};
bool WithinEpsilon(float a, float b) { bool WithinEpsilon(float a, float b) {
......
...@@ -46,7 +46,7 @@ TEST_F(DisplayUtilTest, DisplayZooms) { ...@@ -46,7 +46,7 @@ TEST_F(DisplayUtilTest, DisplayZooms) {
} }
TEST_F(DisplayUtilTest, DisplayZoomsWithInternalDsf) { TEST_F(DisplayUtilTest, DisplayZoomsWithInternalDsf) {
std::vector<float> kDsfs = {1.25f, 1.6f, 2.f, 2.25f}; std::vector<float> kDsfs = {1.25f, 1.6f, 2.f, 2.25f, 2.5f};
for (const auto& dsf : kDsfs) { for (const auto& dsf : kDsfs) {
SCOPED_TRACE(base::StringPrintf("dsf=%f", dsf)); SCOPED_TRACE(base::StringPrintf("dsf=%f", dsf));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment