Commit 4a959bdd authored by Mitsuru Oshima's avatar Mitsuru Oshima Committed by Commit Bot

Allow using repeating decimal scale factor in command line.

Use these scale factor when 2.25, 1.77 and 2.66 are given from command line.

Bug: None

Change-Id: I20f227a80ed38eb3643a63abb50ba6c454036b41
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2448651Reviewed-by: default avatarMalay Keshav <malaykeshav@chromium.org>
Commit-Queue: Mitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#816516}
parent dcad1a4d
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "components/exo/test/exo_test_base.h" #include "components/exo/test/exo_test_base.h"
#include "ui/display/display.h" #include "ui/display/display.h"
#include "ui/display/screen.h" #include "ui/display/screen.h"
#include "ui/display/types/display_constants.h"
#include "ui/gfx/geometry/insets.h" #include "ui/gfx/geometry/insets.h"
#include "ui/views/widget/widget.h" #include "ui/views/widget/widget.h"
...@@ -19,11 +20,11 @@ TEST_F(ZcrRemoteShellTest, GetWorkAreaInsetsInPixel) { ...@@ -19,11 +20,11 @@ TEST_F(ZcrRemoteShellTest, GetWorkAreaInsetsInPixel) {
auto display = display::Screen::GetScreen()->GetPrimaryDisplay(); auto display = display::Screen::GetScreen()->GetPrimaryDisplay();
const float device_scale_factor = display.device_scale_factor(); const float device_scale_factor = display.device_scale_factor();
EXPECT_EQ(2.25f, device_scale_factor); EXPECT_EQ(display::kDsf_2_252, device_scale_factor);
gfx::Insets insets = wayland::GetWorkAreaInsetsInPixel( gfx::Insets insets = wayland::GetWorkAreaInsetsInPixel(
display, device_scale_factor, display.GetSizeInPixel(), display, device_scale_factor, display.GetSizeInPixel(),
display.work_area()); display.work_area());
EXPECT_EQ(gfx::Insets(0, 0, 110, 0).ToString(), insets.ToString()); EXPECT_EQ(gfx::Insets(0, 0, 108, 0).ToString(), insets.ToString());
auto secondary_display = GetSecondaryDisplay(); auto secondary_display = GetSecondaryDisplay();
gfx::Size secondary_size(secondary_display.size()); gfx::Size secondary_size(secondary_display.size());
...@@ -42,7 +43,7 @@ TEST_F(ZcrRemoteShellTest, GetWorkAreaInsetsInPixel) { ...@@ -42,7 +43,7 @@ TEST_F(ZcrRemoteShellTest, GetWorkAreaInsetsInPixel) {
gfx::Insets stable_insets = wayland::GetWorkAreaInsetsInPixel( gfx::Insets stable_insets = wayland::GetWorkAreaInsetsInPixel(
display, device_scale_factor, display.GetSizeInPixel(), display, device_scale_factor, display.GetSizeInPixel(),
wayland::GetStableWorkArea(display)); wayland::GetStableWorkArea(display));
EXPECT_EQ(gfx::Insets(0, 0, 110, 0).ToString(), stable_insets.ToString()); EXPECT_EQ(gfx::Insets(0, 0, 108, 0).ToString(), stable_insets.ToString());
gfx::Insets secondary_stable_insets = wayland::GetWorkAreaInsetsInPixel( gfx::Insets secondary_stable_insets = wayland::GetWorkAreaInsetsInPixel(
secondary_display, device_scale_factor, secondary_size_in_pixel, secondary_display, device_scale_factor, secondary_size_in_pixel,
wayland::GetStableWorkArea(secondary_display)); wayland::GetStableWorkArea(secondary_display));
......
...@@ -54,6 +54,17 @@ bool GetDisplayBounds(const std::string& spec, ...@@ -54,6 +54,17 @@ bool GetDisplayBounds(const std::string& spec,
sscanf(spec.c_str(), "%d+%d-%dx%d*%f", &x, &y, &width, &height, sscanf(spec.c_str(), "%d+%d-%dx%d*%f", &x, &y, &width, &height,
device_scale_factor) >= 4) { device_scale_factor) >= 4) {
bounds->SetRect(x, y, width, height); bounds->SetRect(x, y, width, height);
auto equals_within_epsilon = [device_scale_factor](float dsf) {
return std::abs(*device_scale_factor - dsf) < 0.01f;
};
if (equals_within_epsilon(1.77f)) {
*device_scale_factor = kDsf_1_777;
} else if (equals_within_epsilon(2.25f)) {
*device_scale_factor = kDsf_2_252;
} else if (equals_within_epsilon(2.66)) {
*device_scale_factor = kDsf_2_666;
}
return true; return true;
} }
return false; return false;
......
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