Commit 1311953b authored by Malay Keshav's avatar Malay Keshav Committed by Commit Bot

Display Zoom: Set correct device scale factor for DPI

The device scale factor set for the 320 and 220 DPI are off by a
fraction and hence do not match the entries in the display zoom table.
This patch fixes it.

Bug: b/141325696
Change-Id: Ib4c5effb66bee7e1e360cfdf724d8100a10cd702
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1815353Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Commit-Queue: Malay Keshav <malaykeshav@chromium.org>
Cr-Commit-Position: refs/heads/master@{#698681}
parent 15dd9bba
......@@ -45,7 +45,7 @@ struct DeviceScaleFactorDPIThreshold {
// 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
const DeviceScaleFactorDPIThreshold kThresholdTableForInternal[] = {
{320.f, 2.66666f}, {270.0f, 2.25f}, {230.0f, 2.0f}, {220.0f, 1.77777f},
{320.f, 2.66667f}, {270.0f, 2.25f}, {230.0f, 2.0f}, {220.0f, 1.77778f},
{180.0f, 1.6f}, {150.0f, 1.25f}, {0.0f, 1.0f},
};
......
......@@ -187,7 +187,7 @@ TEST_P(DisplayChangeObserverTest, FindDeviceScaleFactor) {
EXPECT_EQ(1.0f, ComputeDeviceScaleFactor(21.5f, gfx::Rect(1920, 1080)));
// 10" 1920x1200
EXPECT_NEAR(1.77777f, ComputeDeviceScaleFactor(10.f, gfx::Rect(1920, 1200)),
EXPECT_NEAR(1.77778f, ComputeDeviceScaleFactor(10.f, gfx::Rect(1920, 1200)),
std::numeric_limits<float>::epsilon());
// 12.1" 1280x800
......@@ -215,13 +215,13 @@ TEST_P(DisplayChangeObserverTest, FindDeviceScaleFactor) {
EXPECT_EQ(2.25f, ComputeDeviceScaleFactor(12.3f, gfx::Rect(3000, 2000)));
// 13.1" 3840x2160
EXPECT_NEAR(2.66666f, ComputeDeviceScaleFactor(13.1f, gfx::Rect(3840, 2160)),
EXPECT_NEAR(2.66667f, ComputeDeviceScaleFactor(13.1f, gfx::Rect(3840, 2160)),
std::numeric_limits<float>::epsilon());
// Erroneous values should still work.
EXPECT_EQ(1.0f, DisplayChangeObserver::FindDeviceScaleFactor(-100.0f));
EXPECT_EQ(1.0f, DisplayChangeObserver::FindDeviceScaleFactor(0.0f));
EXPECT_NEAR(2.66666f, DisplayChangeObserver::FindDeviceScaleFactor(10000.0f),
EXPECT_NEAR(2.66667f, DisplayChangeObserver::FindDeviceScaleFactor(10000.0f),
std::numeric_limits<float>::epsilon());
}
......
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