Commit 2bd736b9 authored by Mitsuru Oshima's avatar Mitsuru Oshima Committed by Commit Bot

Use closest representation of float to 1.777.. and 2.666..

Bug: 141898654
Change-Id: If41d13054daf681f1502c3c0c2d35777ba03b261
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1921207
Commit-Queue: Mitsuru Oshima <oshima@chromium.org>
Reviewed-by: default avatarMalay Keshav <malaykeshav@chromium.org>
Cr-Commit-Position: refs/heads/master@{#720804}
parent 00d311a0
......@@ -45,8 +45,13 @@ 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[] = {
{300.f, 2.66666f}, {270.0f, 2.25f}, {230.0f, 2.0f}, {220.0f, 1.77777f},
{180.0f, 1.6f}, {150.0f, 1.25f}, {0.0f, 1.0f},
{300.f, 2.6666667461395263671875f},
{270.0f, 2.25f},
{230.0f, 2.0f},
{220.0f, 1.77777779102325439453125f},
{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
......
......@@ -187,7 +187,9 @@ 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)),
float scale_factor_1777x = 1920.f / 1080.f;
EXPECT_NEAR(scale_factor_1777x,
ComputeDeviceScaleFactor(10.f, gfx::Rect(1920, 1200)),
std::numeric_limits<float>::epsilon());
// 12.1" 1280x800
......@@ -214,14 +216,17 @@ TEST_P(DisplayChangeObserverTest, FindDeviceScaleFactor) {
// 12.3" 3000x2000
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)),
// 13.1" 3840x2160 uses maximum scale factor which is 2.66666...
float max_scale_factor = 3840.f / 1440.f;
EXPECT_NEAR(max_scale_factor,
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(max_scale_factor,
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