OLD | NEW |
---|---|
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 <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
92 | 92 |
93 DisplayManager::~DisplayManager() { | 93 DisplayManager::~DisplayManager() { |
94 } | 94 } |
95 | 95 |
96 // static | 96 // static |
97 void DisplayManager::CycleDisplay() { | 97 void DisplayManager::CycleDisplay() { |
98 Shell::GetInstance()->display_manager()->CycleDisplayImpl(); | 98 Shell::GetInstance()->display_manager()->CycleDisplayImpl(); |
99 } | 99 } |
100 | 100 |
101 // static | 101 // static |
102 void DisplayManager::ToggleDisplayScale() { | 102 void DisplayManager::ToggleDisplayScaleFactor() { |
103 Shell::GetInstance()->display_manager()->ScaleDisplayImpl(); | 103 Shell::GetInstance()->display_manager()->ScaleDisplayImpl(); |
104 } | 104 } |
105 | 105 |
106 bool DisplayManager::IsActiveDisplay(const gfx::Display& display) const { | 106 bool DisplayManager::IsActiveDisplay(const gfx::Display& display) const { |
107 for (DisplayList::const_iterator iter = displays_.begin(); | 107 for (DisplayList::const_iterator iter = displays_.begin(); |
108 iter != displays_.end(); ++iter) { | 108 iter != displays_.end(); ++iter) { |
109 if ((*iter).id() == display.id()) | 109 if ((*iter).id() == display.id()) |
110 return true; | 110 return true; |
111 } | 111 } |
112 return false; | 112 return false; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
163 DisplayInfoList display_info_list; | 163 DisplayInfoList display_info_list; |
164 for (DisplayList::const_iterator iter = displays_.begin(); | 164 for (DisplayList::const_iterator iter = displays_.begin(); |
165 iter != displays_.end(); ++iter) { | 165 iter != displays_.end(); ++iter) { |
166 display_info_list.push_back(GetDisplayInfo(*iter)); | 166 display_info_list.push_back(GetDisplayInfo(*iter)); |
167 } | 167 } |
168 UpdateDisplays(display_info_list); | 168 UpdateDisplays(display_info_list); |
169 } | 169 } |
170 | 170 |
171 void DisplayManager::SetDisplayRotation(int64 display_id, | 171 void DisplayManager::SetDisplayRotation(int64 display_id, |
172 DisplayInfo::Rotation rotation) { | 172 DisplayInfo::Rotation rotation) { |
173 if (!IsDisplayRotationEnabled()) | |
174 return; | |
173 DisplayInfoList display_info_list; | 175 DisplayInfoList display_info_list; |
174 for (DisplayList::const_iterator iter = displays_.begin(); | 176 for (DisplayList::const_iterator iter = displays_.begin(); |
175 iter != displays_.end(); ++iter) { | 177 iter != displays_.end(); ++iter) { |
176 DisplayInfo info = GetDisplayInfo(*iter); | 178 DisplayInfo info = GetDisplayInfo(*iter); |
177 if (info.id() == display_id) | 179 if (info.id() == display_id) |
178 info.set_rotation(rotation); | 180 info.set_rotation(rotation); |
179 display_info_list.push_back(info); | 181 display_info_list.push_back(info); |
180 } | 182 } |
181 UpdateDisplays(display_info_list); | 183 UpdateDisplays(display_info_list); |
182 } | 184 } |
183 | 185 |
186 void DisplayManager::SetDisplayUIScale(int64 display_id, | |
187 float ui_scale) { | |
188 if (!IsDisplayUIScalingEnabled()) | |
189 return; | |
190 DisplayInfoList display_info_list; | |
191 for (DisplayList::const_iterator iter = displays_.begin(); | |
192 iter != displays_.end(); ++iter) { | |
193 DisplayInfo info = GetDisplayInfo(*iter); | |
194 if (info.id() == display_id) | |
195 info.set_ui_scale(ui_scale); | |
196 display_info_list.push_back(info); | |
197 } | |
198 UpdateDisplays(display_info_list); | |
199 } | |
200 | |
201 | |
202 bool DisplayManager::IsDisplayRotationEnabled() const { | |
203 static bool enabled = !CommandLine::ForCurrentProcess()-> | |
204 HasSwitch(switches::kAshDisableDisplayRotation); | |
205 return enabled; | |
206 } | |
207 | |
208 bool DisplayManager::IsDisplayUIScalingEnabled() const { | |
209 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.
| |
210 HasSwitch(switches::kAshDisableUIScaling); | |
211 if (disabled) | |
212 return false; | |
213 // UI Scaling is effective only when the internal display has | |
214 // 2x density (currently Pixel). | |
215 int64 display_id = gfx::Display::InternalDisplayId(); | |
216 #if defined(OS_CHROMEOS) | |
217 // On linux desktop, allow ui scaling on the first dislpay. | |
218 if (!base::chromeos::IsRunningOnChromeOS()) | |
219 display_id = Shell::GetInstance()->display_manager()->first_display_id(); | |
220 #endif | |
221 return GetDisplayForId(display_id).device_scale_factor() == 2.0f; | |
222 } | |
223 | |
184 gfx::Insets DisplayManager::GetOverscanInsets(int64 display_id) const { | 224 gfx::Insets DisplayManager::GetOverscanInsets(int64 display_id) const { |
185 std::map<int64, DisplayInfo>::const_iterator it = | 225 std::map<int64, DisplayInfo>::const_iterator it = |
186 display_info_.find(display_id); | 226 display_info_.find(display_id); |
187 return (it != display_info_.end()) ? | 227 return (it != display_info_.end()) ? |
188 it->second.overscan_insets_in_dip() : gfx::Insets(); | 228 it->second.overscan_insets_in_dip() : gfx::Insets(); |
189 } | 229 } |
190 | 230 |
191 void DisplayManager::OnNativeDisplaysChanged( | 231 void DisplayManager::OnNativeDisplaysChanged( |
192 const std::vector<DisplayInfo>& updated_displays) { | 232 const std::vector<DisplayInfo>& updated_displays) { |
193 if (updated_displays.empty()) { | 233 if (updated_displays.empty()) { |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
595 // to change there. | 635 // to change there. |
596 if (DisplayController::HasPrimaryDisplay() && | 636 if (DisplayController::HasPrimaryDisplay() && |
597 display_info.id() == DisplayController::GetPrimaryDisplay().id()) { | 637 display_info.id() == DisplayController::GetPrimaryDisplay().id()) { |
598 new_display.set_bounds(gfx::Rect(new_display.bounds().size())); | 638 new_display.set_bounds(gfx::Rect(new_display.bounds().size())); |
599 } | 639 } |
600 return new_display; | 640 return new_display; |
601 } | 641 } |
602 | 642 |
603 } // namespace internal | 643 } // namespace internal |
604 } // namespace ash | 644 } // namespace ash |
OLD | NEW |