Commit f3137fd6 authored by Kazuhiro Inaba's avatar Kazuhiro Inaba Committed by Commit Bot

Round down 1.7777... and 2.6666... scale factor constants.

The two source, display_util and display_change_observer, needs to
agree on the precise values of DSF so that the correct zoom table
is picked up.

A previous CL crrev.com/c/1815353 did that by consolidating the
constants to 1.77778 and 2.66667. The current CL does the reverse:
use the rounded-down values 1.77777 and 2.66666.

In many places, pixel-to-dip conversion looks to be done by flooring down.
  1920 / 1.777..... = 1080
  floor(1920 / 1.77778) = 1079
  floor(1920 / 1.77777) = 1080
Using a bigger value (1.77778) can cause 1 DIP diff, leading to a strange screen
size (like 1079*674) or bigger errors (b/141898654).

Bug: b/141325696
Bug: b/141898654
Test: screen.width on the devloper console of Krane returns 1080 (not 1079)
Test: chrome settings show multiple choices for display size
Change-Id: I8cbe719b13cd5b6ca5f73bb25c0d27465f6a3e62
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1832846Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Commit-Queue: Kazuhiro Inaba <kinaba@chromium.org>
Cr-Commit-Position: refs/heads/master@{#701492}
parent 5619c57d
...@@ -45,7 +45,7 @@ struct DeviceScaleFactorDPIThreshold { ...@@ -45,7 +45,7 @@ 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[] = {
{320.f, 2.66667f}, {270.0f, 2.25f}, {230.0f, 2.0f}, {220.0f, 1.77778f}, {320.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}, {180.0f, 1.6f}, {150.0f, 1.25f}, {0.0f, 1.0f},
}; };
......
...@@ -187,7 +187,7 @@ TEST_P(DisplayChangeObserverTest, FindDeviceScaleFactor) { ...@@ -187,7 +187,7 @@ TEST_P(DisplayChangeObserverTest, FindDeviceScaleFactor) {
EXPECT_EQ(1.0f, ComputeDeviceScaleFactor(21.5f, gfx::Rect(1920, 1080))); EXPECT_EQ(1.0f, ComputeDeviceScaleFactor(21.5f, gfx::Rect(1920, 1080)));
// 10" 1920x1200 // 10" 1920x1200
EXPECT_NEAR(1.77778f, ComputeDeviceScaleFactor(10.f, gfx::Rect(1920, 1200)), EXPECT_NEAR(1.77777f, ComputeDeviceScaleFactor(10.f, gfx::Rect(1920, 1200)),
std::numeric_limits<float>::epsilon()); std::numeric_limits<float>::epsilon());
// 12.1" 1280x800 // 12.1" 1280x800
...@@ -215,13 +215,13 @@ TEST_P(DisplayChangeObserverTest, FindDeviceScaleFactor) { ...@@ -215,13 +215,13 @@ TEST_P(DisplayChangeObserverTest, FindDeviceScaleFactor) {
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 // 13.1" 3840x2160
EXPECT_NEAR(2.66667f, ComputeDeviceScaleFactor(13.1f, gfx::Rect(3840, 2160)), EXPECT_NEAR(2.66666f, ComputeDeviceScaleFactor(13.1f, gfx::Rect(3840, 2160)),
std::numeric_limits<float>::epsilon()); std::numeric_limits<float>::epsilon());
// 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_NEAR(2.66667f, DisplayChangeObserver::FindDeviceScaleFactor(10000.0f), EXPECT_NEAR(2.66666f, DisplayChangeObserver::FindDeviceScaleFactor(10000.0f),
std::numeric_limits<float>::epsilon()); std::numeric_limits<float>::epsilon());
} }
......
...@@ -53,11 +53,11 @@ constexpr std::array<ZoomListBucketDsf, 7> kZoomListBucketsForDsf{{ ...@@ -53,11 +53,11 @@ constexpr std::array<ZoomListBucketDsf, 7> 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}},
{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}},
{1.77778f, {1.f / 1.77778f, 0.7f, 0.8f, 0.9f, 1.f, 1.2f, 1.35f}}, {1.77777f, {1.f / 1.77777f, 0.7f, 0.8f, 0.9f, 1.f, 1.2f, 1.35f}},
{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.66667f, {2.66666f,
{1.f / 2.66667f, 0.5f, 0.6f, 0.8f, 0.9f, 1.f, 1.2f, 1.35f, 1.5f}}, {1.f / 2.66666f, 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) {
......
...@@ -57,7 +57,7 @@ TEST_F(DisplayUtilTest, DisplayZooms) { ...@@ -57,7 +57,7 @@ TEST_F(DisplayUtilTest, DisplayZooms) {
} }
TEST_F(DisplayUtilTest, DisplayZoomsWithInternalDsf) { TEST_F(DisplayUtilTest, DisplayZoomsWithInternalDsf) {
std::vector<float> kDsfs = {1.25f, 1.6f, 1.77778f, 2.f, 2.25f, 2.66667f}; std::vector<float> kDsfs = {1.25f, 1.6f, 1.77777f, 2.f, 2.25f, 2.66666f};
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