Chromium Code Reviews| 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 "chromeos/display/output_configurator.h" | 5 #include "chromeos/display/output_configurator.h" |
| 6 | 6 |
| 7 #include <X11/Xlib.h> | 7 #include <X11/Xlib.h> |
| 8 #include <X11/extensions/Xrandr.h> | 8 #include <X11/extensions/Xrandr.h> |
| 9 #include <X11/extensions/XInput2.h> | 9 #include <X11/extensions/XInput2.h> |
| 10 | 10 |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 220 return found; | 220 return found; |
| 221 } | 221 } |
| 222 | 222 |
| 223 OutputConfigurator::OutputConfigurator() | 223 OutputConfigurator::OutputConfigurator() |
| 224 : state_controller_(NULL), | 224 : state_controller_(NULL), |
| 225 mirroring_controller_(NULL), | 225 mirroring_controller_(NULL), |
| 226 is_panel_fitting_enabled_(false), | 226 is_panel_fitting_enabled_(false), |
| 227 configure_display_(base::chromeos::IsRunningOnChromeOS()), | 227 configure_display_(base::chromeos::IsRunningOnChromeOS()), |
| 228 xrandr_event_base_(0), | 228 xrandr_event_base_(0), |
| 229 output_state_(STATE_INVALID), | 229 output_state_(STATE_INVALID), |
| 230 power_state_(DISPLAY_POWER_ALL_ON) { | 230 power_state_(DISPLAY_POWER_ALL_ON), |
| 231 next_output_protection_client_id_(1) { | |
| 231 } | 232 } |
| 232 | 233 |
| 233 OutputConfigurator::~OutputConfigurator() {} | 234 OutputConfigurator::~OutputConfigurator() {} |
| 234 | 235 |
| 235 void OutputConfigurator::SetDelegateForTesting(scoped_ptr<Delegate> delegate) { | 236 void OutputConfigurator::SetDelegateForTesting(scoped_ptr<Delegate> delegate) { |
| 236 delegate_ = delegate.Pass(); | 237 delegate_ = delegate.Pass(); |
| 237 configure_display_ = true; | 238 configure_display_ = true; |
| 238 } | 239 } |
| 239 | 240 |
| 240 void OutputConfigurator::SetInitialDisplayPower(DisplayPowerState power_state) { | 241 void OutputConfigurator::SetInitialDisplayPower(DisplayPowerState power_state) { |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 266 new_state, power_state_, outputs); | 267 new_state, power_state_, outputs); |
| 267 | 268 |
| 268 // Force the DPMS on chrome startup as the driver doesn't always detect | 269 // Force the DPMS on chrome startup as the driver doesn't always detect |
| 269 // that all displays are on when signing out. | 270 // that all displays are on when signing out. |
| 270 delegate_->ForceDPMSOn(); | 271 delegate_->ForceDPMSOn(); |
| 271 delegate_->UngrabServer(); | 272 delegate_->UngrabServer(); |
| 272 delegate_->SendProjectingStateToPowerManager(IsProjecting(outputs)); | 273 delegate_->SendProjectingStateToPowerManager(IsProjecting(outputs)); |
| 273 NotifyObservers(success, new_state); | 274 NotifyObservers(success, new_state); |
| 274 } | 275 } |
| 275 | 276 |
| 277 OutputConfigurator::OutputProtectionClientId | |
| 278 OutputConfigurator::RegisterOutputProtectionClient() { | |
| 279 if (!configure_display_) | |
| 280 return 0; | |
| 281 | |
| 282 return next_output_protection_client_id_++; | |
| 283 } | |
| 284 | |
| 285 void OutputConfigurator::UnregisterOutputProtectionClient( | |
| 286 OutputProtectionClientId client_id) { | |
| 287 EnableOutputProtection(client_id, OUTPUT_PROTECTION_METHOD_NONE); | |
| 288 } | |
| 289 | |
| 290 bool OutputConfigurator::QueryOutputProtectionStatus( | |
| 291 OutputProtectionClientId client_id, | |
| 292 uint32_t* link_mask, | |
| 293 uint32_t* protection_mask) { | |
| 294 if (!configure_display_) | |
| 295 return false; | |
| 296 | |
| 297 bool result = delegate_->QueryOutputProtectionStatus(client_id, link_mask, | |
| 298 protection_mask); | |
| 299 return result; | |
|
Daniel Erat
2013/09/20 15:00:24
just do:
return delegate_->Query...
kcwu
2013/09/20 20:29:30
Done.
| |
| 300 } | |
| 301 | |
| 302 bool OutputConfigurator::EnableOutputProtection( | |
| 303 OutputProtectionClientId client_id, | |
| 304 uint32_t desired_method_mask) { | |
| 305 if (!configure_display_) | |
| 306 return false; | |
| 307 | |
| 308 delegate_->GrabServer(); | |
| 309 bool result = delegate_->EnableOutputProtection(client_id, | |
| 310 desired_method_mask); | |
| 311 delegate_->UngrabServer(); | |
| 312 return result; | |
| 313 } | |
| 314 | |
| 276 void OutputConfigurator::Stop() { | 315 void OutputConfigurator::Stop() { |
| 277 configure_display_ = false; | 316 configure_display_ = false; |
| 278 } | 317 } |
| 279 | 318 |
| 280 bool OutputConfigurator::SetDisplayPower(DisplayPowerState power_state, | 319 bool OutputConfigurator::SetDisplayPower(DisplayPowerState power_state, |
| 281 int flags) { | 320 int flags) { |
| 282 if (!configure_display_) | 321 if (!configure_display_) |
| 283 return false; | 322 return false; |
| 284 | 323 |
| 285 VLOG(1) << "SetDisplayPower: power_state=" | 324 VLOG(1) << "SetDisplayPower: power_state=" |
| (...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 861 float width_ratio = static_cast<float>(mirror_mode_info->width) / | 900 float width_ratio = static_cast<float>(mirror_mode_info->width) / |
| 862 static_cast<float>(native_mode_info->width); | 901 static_cast<float>(native_mode_info->width); |
| 863 float height_ratio = static_cast<float>(mirror_mode_info->height) / | 902 float height_ratio = static_cast<float>(mirror_mode_info->height) / |
| 864 static_cast<float>(native_mode_info->height); | 903 static_cast<float>(native_mode_info->height); |
| 865 | 904 |
| 866 area_ratio = width_ratio * height_ratio; | 905 area_ratio = width_ratio * height_ratio; |
| 867 return area_ratio; | 906 return area_ratio; |
| 868 } | 907 } |
| 869 | 908 |
| 870 } // namespace chromeos | 909 } // namespace chromeos |
| OLD | NEW |