Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ui/display/chromeos/display_configurator.h" | 5 #include "ui/display/chromeos/display_configurator.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 155 | 155 |
| 156 best_mode = mode; | 156 best_mode = mode; |
| 157 } | 157 } |
| 158 | 158 |
| 159 return best_mode; | 159 return best_mode; |
| 160 } | 160 } |
| 161 | 161 |
| 162 DisplayConfigurator::DisplayConfigurator() | 162 DisplayConfigurator::DisplayConfigurator() |
| 163 : state_controller_(NULL), | 163 : state_controller_(NULL), |
| 164 mirroring_controller_(NULL), | 164 mirroring_controller_(NULL), |
| 165 display_externally_controlled_(false), | |
| 165 is_panel_fitting_enabled_(false), | 166 is_panel_fitting_enabled_(false), |
| 166 configure_display_(base::SysInfo::IsRunningOnChromeOS()), | 167 configure_display_(base::SysInfo::IsRunningOnChromeOS()), |
| 167 display_state_(MULTIPLE_DISPLAY_STATE_INVALID), | 168 display_state_(MULTIPLE_DISPLAY_STATE_INVALID), |
| 168 requested_power_state_(chromeos::DISPLAY_POWER_ALL_ON), | 169 requested_power_state_(chromeos::DISPLAY_POWER_ALL_ON), |
| 169 current_power_state_(chromeos::DISPLAY_POWER_ALL_ON), | 170 current_power_state_(chromeos::DISPLAY_POWER_ALL_ON), |
| 170 next_display_protection_client_id_(1) {} | 171 next_display_protection_client_id_(1) { |
| 172 } | |
| 171 | 173 |
| 172 DisplayConfigurator::~DisplayConfigurator() { | 174 DisplayConfigurator::~DisplayConfigurator() { |
| 173 if (native_display_delegate_) | 175 if (native_display_delegate_) |
| 174 native_display_delegate_->RemoveObserver(this); | 176 native_display_delegate_->RemoveObserver(this); |
| 175 } | 177 } |
| 176 | 178 |
| 177 void DisplayConfigurator::SetDelegateForTesting( | 179 void DisplayConfigurator::SetDelegateForTesting( |
| 178 scoped_ptr<NativeDisplayDelegate> display_delegate) { | 180 scoped_ptr<NativeDisplayDelegate> display_delegate) { |
| 179 DCHECK(!native_display_delegate_); | 181 DCHECK(!native_display_delegate_); |
| 180 | 182 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 194 return; | 196 return; |
| 195 | 197 |
| 196 // If the delegate is already initialized don't update it (For example, tests | 198 // If the delegate is already initialized don't update it (For example, tests |
| 197 // set their own delegates). | 199 // set their own delegates). |
| 198 if (!native_display_delegate_) { | 200 if (!native_display_delegate_) { |
| 199 native_display_delegate_ = CreatePlatformNativeDisplayDelegate(); | 201 native_display_delegate_ = CreatePlatformNativeDisplayDelegate(); |
| 200 native_display_delegate_->AddObserver(this); | 202 native_display_delegate_->AddObserver(this); |
| 201 } | 203 } |
| 202 } | 204 } |
| 203 | 205 |
| 206 void DisplayConfigurator::RelinquishControl() { | |
| 207 // Note: This cannot be enabled yet until a subsequent change | |
| 208 // in the native_display_delegate to allow it to relinquish | |
| 209 // control of the display. | |
| 210 // | |
| 211 // native_display_delegate_->RelinquishDisplayControl(); | |
|
Daniel Erat
2014/11/02 13:48:34
please don't check in commented-out code; just rep
dsodman
2014/11/04 05:19:40
Done.
| |
| 212 // display_externally_controlled_ = true; | |
| 213 } | |
| 214 | |
| 204 void DisplayConfigurator::ForceInitialConfigure( | 215 void DisplayConfigurator::ForceInitialConfigure( |
| 205 uint32_t background_color_argb) { | 216 uint32_t background_color_argb) { |
| 206 if (!configure_display_) | 217 if (!configure_display_) |
| 207 return; | 218 return; |
| 208 | 219 |
| 209 native_display_delegate_->GrabServer(); | 220 native_display_delegate_->GrabServer(); |
| 210 native_display_delegate_->Initialize(); | 221 native_display_delegate_->Initialize(); |
| 211 | 222 |
| 212 UpdateCachedDisplays(); | 223 UpdateCachedDisplays(); |
| 213 if (cached_displays_.size() > 1 && background_color_argb) | 224 if (cached_displays_.size() > 1 && background_color_argb) |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 489 if (attempted_change) | 500 if (attempted_change) |
| 490 NotifyObservers(success, new_state); | 501 NotifyObservers(success, new_state); |
| 491 return success; | 502 return success; |
| 492 } | 503 } |
| 493 | 504 |
| 494 bool DisplayConfigurator::SetDisplayMode(MultipleDisplayState new_state) { | 505 bool DisplayConfigurator::SetDisplayMode(MultipleDisplayState new_state) { |
| 495 if (!configure_display_) | 506 if (!configure_display_) |
| 496 return false; | 507 return false; |
| 497 | 508 |
| 498 VLOG(1) << "SetDisplayMode: state=" << DisplayStateToString(new_state); | 509 VLOG(1) << "SetDisplayMode: state=" << DisplayStateToString(new_state); |
| 499 if (display_state_ == new_state) { | 510 if ((display_state_ == new_state) && |
| 511 (display_externally_controlled_ == false)) { | |
| 500 // Cancel software mirroring if the state is moving from | 512 // Cancel software mirroring if the state is moving from |
| 501 // MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED to | 513 // MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED to |
| 502 // MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED. | 514 // MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED. |
| 503 if (mirroring_controller_ && | 515 if (mirroring_controller_ && |
| 504 new_state == MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED) | 516 new_state == MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED) |
| 505 mirroring_controller_->SetSoftwareMirroring(false); | 517 mirroring_controller_->SetSoftwareMirroring(false); |
| 506 NotifyObservers(true, new_state); | 518 NotifyObservers(true, new_state); |
| 507 return true; | 519 return true; |
| 508 } | 520 } |
| 509 | 521 |
| 510 native_display_delegate_->GrabServer(); | 522 native_display_delegate_->GrabServer(); |
| 523 display_externally_controlled_ = false; | |
| 511 UpdateCachedDisplays(); | 524 UpdateCachedDisplays(); |
| 512 const bool success = EnterStateOrFallBackToSoftwareMirroring( | 525 const bool success = EnterStateOrFallBackToSoftwareMirroring( |
| 513 new_state, requested_power_state_); | 526 new_state, requested_power_state_); |
| 514 native_display_delegate_->UngrabServer(); | 527 native_display_delegate_->UngrabServer(); |
| 515 | 528 |
| 516 NotifyObservers(success, new_state); | 529 NotifyObservers(success, new_state); |
| 517 return success; | 530 return success; |
| 518 } | 531 } |
| 519 | 532 |
| 520 void DisplayConfigurator::OnConfigurationChanged() { | 533 void DisplayConfigurator::OnConfigurationChanged() { |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 970 return state_controller_->GetStateForDisplayIds(display_ids); | 983 return state_controller_->GetStateForDisplayIds(display_ids); |
| 971 } | 984 } |
| 972 } | 985 } |
| 973 default: | 986 default: |
| 974 NOTREACHED(); | 987 NOTREACHED(); |
| 975 } | 988 } |
| 976 return MULTIPLE_DISPLAY_STATE_INVALID; | 989 return MULTIPLE_DISPLAY_STATE_INVALID; |
| 977 } | 990 } |
| 978 | 991 |
| 979 } // namespace ui | 992 } // namespace ui |
| OLD | NEW |