Commit 4433bc75 authored by oshima's avatar oshima Committed by Commit bot

Use DSF instead of UI scale if the native DSF is 1.25 and UI Scale is 0.8x (dsf=1.25 equivalent)

Disable high DPI assets for ui scaling. This will be removed in 39, after this change is landed.

BUG=413368

Review URL: https://codereview.chromium.org/578553002

Cr-Commit-Position: refs/heads/master@{#295209}
parent 769be209
...@@ -636,7 +636,6 @@ void DisplayController::OnDisplayMetricsChanged(const gfx::Display& display, ...@@ -636,7 +636,6 @@ void DisplayController::OnDisplayMetricsChanged(const gfx::Display& display,
if (!(metrics & (DISPLAY_METRIC_BOUNDS | DISPLAY_METRIC_ROTATION | if (!(metrics & (DISPLAY_METRIC_BOUNDS | DISPLAY_METRIC_ROTATION |
DISPLAY_METRIC_DEVICE_SCALE_FACTOR))) DISPLAY_METRIC_DEVICE_SCALE_FACTOR)))
return; return;
const DisplayInfo& display_info = const DisplayInfo& display_info =
GetDisplayManager()->GetDisplayInfo(display.id()); GetDisplayManager()->GetDisplayInfo(display.id());
DCHECK(!display_info.bounds_in_native().IsEmpty()); DCHECK(!display_info.bounds_in_native().IsEmpty());
......
...@@ -26,6 +26,8 @@ namespace { ...@@ -26,6 +26,8 @@ namespace {
// TODO(oshima): This feature is obsolete. Remove this after m38. // TODO(oshima): This feature is obsolete. Remove this after m38.
bool allow_upgrade_to_high_dpi = false; bool allow_upgrade_to_high_dpi = false;
bool use_125_dsf_for_ui_scaling = false;
// Check the content of |spec| and fill |bounds| and |device_scale_factor|. // Check the content of |spec| and fill |bounds| and |device_scale_factor|.
// Returns true when |bounds| is found. // Returns true when |bounds| is found.
bool GetDisplayBounds( bool GetDisplayBounds(
...@@ -88,6 +90,11 @@ void DisplayInfo::SetAllowUpgradeToHighDPI(bool enable) { ...@@ -88,6 +90,11 @@ void DisplayInfo::SetAllowUpgradeToHighDPI(bool enable) {
allow_upgrade_to_high_dpi = enable; allow_upgrade_to_high_dpi = enable;
} }
// static
void DisplayInfo::SetUse125DSFForUIScaling(bool enable) {
use_125_dsf_for_ui_scaling = enable;
}
// static // static
DisplayInfo DisplayInfo::CreateFromSpecWithID(const std::string& spec, DisplayInfo DisplayInfo::CreateFromSpecWithID(const std::string& spec,
int64 id) { int64 id) {
...@@ -283,6 +290,9 @@ void DisplayInfo::SetBounds(const gfx::Rect& new_bounds_in_native) { ...@@ -283,6 +290,9 @@ void DisplayInfo::SetBounds(const gfx::Rect& new_bounds_in_native) {
} }
float DisplayInfo::GetEffectiveDeviceScaleFactor() const { float DisplayInfo::GetEffectiveDeviceScaleFactor() const {
if (use_125_dsf_for_ui_scaling && device_scale_factor_ == 1.25f)
return (configured_ui_scale_ == 0.8f) ? 1.25f : 1.0f;
if (allow_upgrade_to_high_dpi && configured_ui_scale_ < 1.0f && if (allow_upgrade_to_high_dpi && configured_ui_scale_ < 1.0f &&
device_scale_factor_ == 1.0f) { device_scale_factor_ == 1.0f) {
return 2.0f; return 2.0f;
...@@ -293,6 +303,9 @@ float DisplayInfo::GetEffectiveDeviceScaleFactor() const { ...@@ -293,6 +303,9 @@ float DisplayInfo::GetEffectiveDeviceScaleFactor() const {
} }
float DisplayInfo::GetEffectiveUIScale() const { float DisplayInfo::GetEffectiveUIScale() const {
if (use_125_dsf_for_ui_scaling && device_scale_factor_ == 1.25f)
return (configured_ui_scale_ == 0.8f) ? 1.0f : configured_ui_scale_;
if (allow_upgrade_to_high_dpi && configured_ui_scale_ < 1.0f && if (allow_upgrade_to_high_dpi && configured_ui_scale_ < 1.0f &&
device_scale_factor_ == 1.0f) { device_scale_factor_ == 1.0f) {
return configured_ui_scale_ * 2.0f; return configured_ui_scale_ * 2.0f;
......
...@@ -94,6 +94,11 @@ class ASH_EXPORT DisplayInfo { ...@@ -94,6 +94,11 @@ class ASH_EXPORT DisplayInfo {
// scale on 1x DSF to 1.2 scale on 2x DSF. // scale on 1x DSF to 1.2 scale on 2x DSF.
static void SetAllowUpgradeToHighDPI(bool enable); static void SetAllowUpgradeToHighDPI(bool enable);
// When this is set to true on the device whose internal display has
// 1.25 dsf, Chrome uses 1.0f as a default scale factor, and uses
// dsf 1.25 when UI scaling is set to 0.8f.
static void SetUse125DSFForUIScaling(bool enable);
int64 id() const { return id_; } int64 id() const { return id_; }
// The name of the display. // The name of the display.
......
...@@ -168,10 +168,6 @@ DisplayManager::DisplayManager() ...@@ -168,10 +168,6 @@ DisplayManager::DisplayManager()
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
change_display_upon_host_resize_ = !base::SysInfo::IsRunningOnChromeOS(); change_display_upon_host_resize_ = !base::SysInfo::IsRunningOnChromeOS();
#endif #endif
DisplayInfo::SetAllowUpgradeToHighDPI(
ui::ResourceBundle::GetSharedInstance().GetMaxScaleFactor() ==
ui::SCALE_FACTOR_200P);
gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_ALTERNATE, gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_ALTERNATE,
screen_ash_.get()); screen_ash_.get());
gfx::Screen* current_native = gfx::Screen* current_native =
...@@ -252,6 +248,7 @@ bool DisplayManager::InitFromCommandLine() { ...@@ -252,6 +248,7 @@ bool DisplayManager::InitFromCommandLine() {
for (vector<string>::const_iterator iter = parts.begin(); for (vector<string>::const_iterator iter = parts.begin();
iter != parts.end(); ++iter) { iter != parts.end(); ++iter) {
info_list.push_back(DisplayInfo::CreateFromSpec(*iter)); info_list.push_back(DisplayInfo::CreateFromSpec(*iter));
info_list.back().set_native(true);
} }
MaybeInitInternalDisplay(info_list[0].id()); MaybeInitInternalDisplay(info_list[0].id());
if (info_list.size() > 1 && if (info_list.size() > 1 &&
...@@ -265,6 +262,7 @@ bool DisplayManager::InitFromCommandLine() { ...@@ -265,6 +262,7 @@ bool DisplayManager::InitFromCommandLine() {
void DisplayManager::InitDefaultDisplay() { void DisplayManager::InitDefaultDisplay() {
DisplayInfoList info_list; DisplayInfoList info_list;
info_list.push_back(DisplayInfo::CreateFromSpec(std::string())); info_list.push_back(DisplayInfo::CreateFromSpec(std::string()));
info_list.back().set_native(true);
MaybeInitInternalDisplay(info_list[0].id()); MaybeInitInternalDisplay(info_list[0].id());
OnNativeDisplaysChanged(info_list); OnNativeDisplaysChanged(info_list);
} }
...@@ -276,7 +274,7 @@ void DisplayManager::InitFontParams() { ...@@ -276,7 +274,7 @@ void DisplayManager::InitFontParams() {
const DisplayInfo& display_info = const DisplayInfo& display_info =
GetDisplayInfo(gfx::Display::InternalDisplayId()); GetDisplayInfo(gfx::Display::InternalDisplayId());
gfx::SetFontRenderParamsDeviceScaleFactor( gfx::SetFontRenderParamsDeviceScaleFactor(
display_info.device_scale_factor()); display_info.GetEffectiveDeviceScaleFactor());
#endif // OS_CHROMEOS #endif // OS_CHROMEOS
} }
......
...@@ -1102,6 +1102,33 @@ TEST_F(DisplayManagerTest, UIScaleUpgradeToHighDPI) { ...@@ -1102,6 +1102,33 @@ TEST_F(DisplayManagerTest, UIScaleUpgradeToHighDPI) {
EXPECT_EQ("480x270", GetDisplayForId(display_id).size().ToString()); EXPECT_EQ("480x270", GetDisplayForId(display_id).size().ToString());
} }
TEST_F(DisplayManagerTest, Use125DSFRorUIScaling) {
int64 display_id = Shell::GetScreen()->GetPrimaryDisplay().id();
gfx::Display::SetInternalDisplayId(display_id);
DisplayInfo::SetUse125DSFForUIScaling(true);
UpdateDisplay("1920x1080*1.25");
EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor());
EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale());
display_manager()->SetDisplayUIScale(display_id, 0.8f);
EXPECT_EQ(1.25f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor());
EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale());
EXPECT_EQ("1536x864", GetDisplayForId(display_id).size().ToString());
display_manager()->SetDisplayUIScale(display_id, 0.5f);
EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor());
EXPECT_EQ(0.5f, GetDisplayInfoAt(0).GetEffectiveUIScale());
EXPECT_EQ("960x540", GetDisplayForId(display_id).size().ToString());
display_manager()->SetDisplayUIScale(display_id, 1.25f);
EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveDeviceScaleFactor());
EXPECT_EQ(1.25f, GetDisplayInfoAt(0).GetEffectiveUIScale());
EXPECT_EQ("2400x1350", GetDisplayForId(display_id).size().ToString());
DisplayInfo::SetUse125DSFForUIScaling(false);
}
#if defined(OS_WIN) #if defined(OS_WIN)
// TODO(scottmg): RootWindow doesn't get resized on Windows // TODO(scottmg): RootWindow doesn't get resized on Windows
// Ash. http://crbug.com/247916. // Ash. http://crbug.com/247916.
...@@ -1474,6 +1501,16 @@ TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf200External) { ...@@ -1474,6 +1501,16 @@ TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf200External) {
EXPECT_FALSE(IsTextSubpixelPositioningEnabled()); EXPECT_FALSE(IsTextSubpixelPositioningEnabled());
} }
TEST_F(DisplayManagerFontTest,
TextSubpixelPositioningWithDsf125InternalWithScaling) {
DisplayInfo::SetUse125DSFForUIScaling(true);
FontTestHelper helper(1.25f, FontTestHelper::INTERNAL);
ASSERT_DOUBLE_EQ(
1.0f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor());
EXPECT_FALSE(IsTextSubpixelPositioningEnabled());
DisplayInfo::SetUse125DSFForUIScaling(false);
}
#endif // OS_CHROMEOS #endif // OS_CHROMEOS
} // namespace ash } // namespace ash
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