Chromium Code Reviews| Index: ash/display/display_manager.cc |
| diff --git a/ash/display/display_manager.cc b/ash/display/display_manager.cc |
| index ab8b4d07c96cddcdbc93e7bf4adc9793243a1b83..6c27f11c525d77051d38274cfc5b198548d23c5d 100644 |
| --- a/ash/display/display_manager.cc |
| +++ b/ash/display/display_manager.cc |
| @@ -99,7 +99,7 @@ void DisplayManager::CycleDisplay() { |
| } |
| // static |
| -void DisplayManager::ToggleDisplayScale() { |
| +void DisplayManager::ToggleDisplayScaleFactor() { |
| Shell::GetInstance()->display_manager()->ScaleDisplayImpl(); |
| } |
| @@ -170,6 +170,8 @@ void DisplayManager::ClearCustomOverscanInsets(int64 display_id) { |
| void DisplayManager::SetDisplayRotation(int64 display_id, |
| DisplayInfo::Rotation rotation) { |
| + if (!IsDisplayRotationEnabled()) |
| + return; |
| DisplayInfoList display_info_list; |
| for (DisplayList::const_iterator iter = displays_.begin(); |
| iter != displays_.end(); ++iter) { |
| @@ -181,6 +183,44 @@ void DisplayManager::SetDisplayRotation(int64 display_id, |
| UpdateDisplays(display_info_list); |
| } |
| +void DisplayManager::SetDisplayUIScale(int64 display_id, |
| + float ui_scale) { |
| + if (!IsDisplayUIScalingEnabled()) |
| + return; |
| + DisplayInfoList display_info_list; |
| + for (DisplayList::const_iterator iter = displays_.begin(); |
| + iter != displays_.end(); ++iter) { |
| + DisplayInfo info = GetDisplayInfo(*iter); |
| + if (info.id() == display_id) |
| + info.set_ui_scale(ui_scale); |
| + display_info_list.push_back(info); |
| + } |
| + UpdateDisplays(display_info_list); |
| +} |
| + |
| + |
| +bool DisplayManager::IsDisplayRotationEnabled() const { |
| + static bool enabled = !CommandLine::ForCurrentProcess()-> |
| + HasSwitch(switches::kAshDisableDisplayRotation); |
| + return enabled; |
| +} |
| + |
| +bool DisplayManager::IsDisplayUIScalingEnabled() const { |
| + static bool disabled = CommandLine::ForCurrentProcess()-> |
|
James Cook
2013/03/14 17:50:43
nit: Consider naming this variable "enabled" like
oshima
2013/03/14 19:56:15
Done.
|
| + HasSwitch(switches::kAshDisableUIScaling); |
| + if (disabled) |
| + return false; |
| + // UI Scaling is effective only when the internal display has |
| + // 2x density (currently Pixel). |
| + int64 display_id = gfx::Display::InternalDisplayId(); |
| +#if defined(OS_CHROMEOS) |
| + // On linux desktop, allow ui scaling on the first dislpay. |
| + if (!base::chromeos::IsRunningOnChromeOS()) |
| + display_id = Shell::GetInstance()->display_manager()->first_display_id(); |
| +#endif |
| + return GetDisplayForId(display_id).device_scale_factor() == 2.0f; |
| +} |
| + |
| gfx::Insets DisplayManager::GetOverscanInsets(int64 display_id) const { |
| std::map<int64, DisplayInfo>::const_iterator it = |
| display_info_.find(display_id); |