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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/display/display_manager.h" 5 #include "ash/display/display_manager.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 95
96 DisplayManager::~DisplayManager() { 96 DisplayManager::~DisplayManager() {
97 } 97 }
98 98
99 // static 99 // static
100 void DisplayManager::CycleDisplay() { 100 void DisplayManager::CycleDisplay() {
101 Shell::GetInstance()->display_manager()->CycleDisplayImpl(); 101 Shell::GetInstance()->display_manager()->CycleDisplayImpl();
102 } 102 }
103 103
104 // static 104 // static
105 void DisplayManager::ToggleDisplayScale() { 105 void DisplayManager::ToggleDisplayScaleFactor() {
106 Shell::GetInstance()->display_manager()->ScaleDisplayImpl(); 106 Shell::GetInstance()->display_manager()->ScaleDisplayImpl();
107 } 107 }
108 108
109 bool DisplayManager::IsActiveDisplay(const gfx::Display& display) const { 109 bool DisplayManager::IsActiveDisplay(const gfx::Display& display) const {
110 for (DisplayList::const_iterator iter = displays_.begin(); 110 for (DisplayList::const_iterator iter = displays_.begin();
111 iter != displays_.end(); ++iter) { 111 iter != displays_.end(); ++iter) {
112 if ((*iter).id() == display.id()) 112 if ((*iter).id() == display.id())
113 return true; 113 return true;
114 } 114 }
115 return false; 115 return false;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 DisplayInfoList display_info_list; 166 DisplayInfoList display_info_list;
167 for (DisplayList::const_iterator iter = displays_.begin(); 167 for (DisplayList::const_iterator iter = displays_.begin();
168 iter != displays_.end(); ++iter) { 168 iter != displays_.end(); ++iter) {
169 display_info_list.push_back(GetDisplayInfo(*iter)); 169 display_info_list.push_back(GetDisplayInfo(*iter));
170 } 170 }
171 UpdateDisplays(display_info_list); 171 UpdateDisplays(display_info_list);
172 } 172 }
173 173
174 void DisplayManager::SetDisplayRotation(int64 display_id, 174 void DisplayManager::SetDisplayRotation(int64 display_id,
175 gfx::Display::Rotation rotation) { 175 gfx::Display::Rotation rotation) {
176 if (!IsDisplayRotationEnabled())
177 return;
176 DisplayInfoList display_info_list; 178 DisplayInfoList display_info_list;
177 for (DisplayList::const_iterator iter = displays_.begin(); 179 for (DisplayList::const_iterator iter = displays_.begin();
178 iter != displays_.end(); ++iter) { 180 iter != displays_.end(); ++iter) {
179 DisplayInfo info = GetDisplayInfo(*iter); 181 DisplayInfo info = GetDisplayInfo(*iter);
180 if (info.id() == display_id) 182 if (info.id() == display_id)
181 info.set_rotation(rotation); 183 info.set_rotation(rotation);
182 display_info_list.push_back(info); 184 display_info_list.push_back(info);
183 } 185 }
184 UpdateDisplays(display_info_list); 186 UpdateDisplays(display_info_list);
185 } 187 }
186 188
189 void DisplayManager::SetDisplayUIScale(int64 display_id,
190 float ui_scale) {
191 if (!IsDisplayUIScalingEnabled())
192 return;
193 DisplayInfoList display_info_list;
194 for (DisplayList::const_iterator iter = displays_.begin();
195 iter != displays_.end(); ++iter) {
196 DisplayInfo info = GetDisplayInfo(*iter);
197 if (info.id() == display_id)
198 info.set_ui_scale(ui_scale);
199 display_info_list.push_back(info);
200 }
201 UpdateDisplays(display_info_list);
202 }
203
204
205 bool DisplayManager::IsDisplayRotationEnabled() const {
206 static bool enabled = !CommandLine::ForCurrentProcess()->
207 HasSwitch(switches::kAshDisableDisplayRotation);
208 return enabled;
209 }
210
211 bool DisplayManager::IsDisplayUIScalingEnabled() const {
212 static bool enabled = !CommandLine::ForCurrentProcess()->
213 HasSwitch(switches::kAshDisableUIScaling);
214 if (!enabled)
215 return false;
216 // UI Scaling is effective only when the internal display has
217 // 2x density (currently Pixel).
218 int64 display_id = gfx::Display::InternalDisplayId();
219 #if defined(OS_CHROMEOS)
220 // On linux desktop, allow ui scaling on the first dislpay.
221 if (!base::chromeos::IsRunningOnChromeOS())
222 display_id = Shell::GetInstance()->display_manager()->first_display_id();
223 #endif
224 return GetDisplayForId(display_id).device_scale_factor() == 2.0f;
225 }
226
187 gfx::Insets DisplayManager::GetOverscanInsets(int64 display_id) const { 227 gfx::Insets DisplayManager::GetOverscanInsets(int64 display_id) const {
188 std::map<int64, DisplayInfo>::const_iterator it = 228 std::map<int64, DisplayInfo>::const_iterator it =
189 display_info_.find(display_id); 229 display_info_.find(display_id);
190 return (it != display_info_.end()) ? 230 return (it != display_info_.end()) ?
191 it->second.overscan_insets_in_dip() : gfx::Insets(); 231 it->second.overscan_insets_in_dip() : gfx::Insets();
192 } 232 }
193 233
194 void DisplayManager::OnNativeDisplaysChanged( 234 void DisplayManager::OnNativeDisplaysChanged(
195 const std::vector<DisplayInfo>& updated_displays) { 235 const std::vector<DisplayInfo>& updated_displays) {
196 if (updated_displays.empty()) { 236 if (updated_displays.empty()) {
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 // always (0,0) and the secondary display's bounds will be updated 645 // always (0,0) and the secondary display's bounds will be updated
606 // by |DisplayController::UpdateDisplayBoundsForLayout|. 646 // by |DisplayController::UpdateDisplayBoundsForLayout|.
607 new_display.SetScaleAndBounds( 647 new_display.SetScaleAndBounds(
608 display_info.device_scale_factor(), gfx::Rect(bounds_in_pixel.size())); 648 display_info.device_scale_factor(), gfx::Rect(bounds_in_pixel.size()));
609 new_display.set_rotation(display_info.rotation()); 649 new_display.set_rotation(display_info.rotation());
610 return new_display; 650 return new_display;
611 } 651 }
612 652
613 } // namespace internal 653 } // namespace internal
614 } // namespace ash 654 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698