Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2105)

Unified Diff: ash/display/display_manager.cc

Issue 12848004: Add shortcut keys to ui scaling (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: stl hates me Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ash/display/display_manager.cc
diff --git a/ash/display/display_manager.cc b/ash/display/display_manager.cc
index ff9748d638ce47f33c5e8290f61ce9a9cca64dd4..257e62b6215eeabf55a5ec8e9a779287cfbe1699 100644
--- a/ash/display/display_manager.cc
+++ b/ash/display/display_manager.cc
@@ -102,7 +102,7 @@ void DisplayManager::CycleDisplay() {
}
// static
-void DisplayManager::ToggleDisplayScale() {
+void DisplayManager::ToggleDisplayScaleFactor() {
Shell::GetInstance()->display_manager()->ScaleDisplayImpl();
}
@@ -173,6 +173,8 @@ void DisplayManager::ClearCustomOverscanInsets(int64 display_id) {
void DisplayManager::SetDisplayRotation(int64 display_id,
gfx::Display::Rotation rotation) {
+ if (!IsDisplayRotationEnabled())
+ return;
DisplayInfoList display_info_list;
for (DisplayList::const_iterator iter = displays_.begin();
iter != displays_.end(); ++iter) {
@@ -184,6 +186,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 enabled = !CommandLine::ForCurrentProcess()->
+ HasSwitch(switches::kAshDisableUIScaling);
+ if (!enabled)
+ 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);

Powered by Google App Engine
This is Rietveld 408576698