| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_configuration_controller.h" | 5 #include "ash/display/display_configuration_controller.h" |
| 6 | 6 |
| 7 #include "ash/display/display_animator.h" | 7 #include "ash/display/display_animator.h" |
| 8 #include "ash/display/display_layout.h" | |
| 9 #include "ash/display/display_manager.h" | 8 #include "ash/display/display_manager.h" |
| 10 #include "ash/rotator/screen_rotation_animator.h" | 9 #include "ash/rotator/screen_rotation_animator.h" |
| 11 #include "ash/screen_util.h" | 10 #include "ash/screen_util.h" |
| 12 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 12 #include "ui/display/manager/display_layout.h" |
| 13 | 13 |
| 14 #if defined(OS_CHROMEOS) | 14 #if defined(OS_CHROMEOS) |
| 15 #include "ash/display/display_animator_chromeos.h" | 15 #include "ash/display/display_animator_chromeos.h" |
| 16 #include "base/sys_info.h" | 16 #include "base/sys_info.h" |
| 17 #endif | 17 #endif |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 // Specifies how long the display change should have been disabled | 21 // Specifies how long the display change should have been disabled |
| 22 // after each display change operations. | 22 // after each display change operations. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 limiter_.reset(new DisplayChangeLimiter); | 61 limiter_.reset(new DisplayChangeLimiter); |
| 62 display_animator_.reset(new DisplayAnimatorChromeOS()); | 62 display_animator_.reset(new DisplayAnimatorChromeOS()); |
| 63 #endif | 63 #endif |
| 64 } | 64 } |
| 65 | 65 |
| 66 DisplayConfigurationController::~DisplayConfigurationController() { | 66 DisplayConfigurationController::~DisplayConfigurationController() { |
| 67 window_tree_host_manager_->RemoveObserver(this); | 67 window_tree_host_manager_->RemoveObserver(this); |
| 68 } | 68 } |
| 69 | 69 |
| 70 void DisplayConfigurationController::SetDisplayLayout( | 70 void DisplayConfigurationController::SetDisplayLayout( |
| 71 scoped_ptr<DisplayLayout> layout, | 71 scoped_ptr<display::DisplayLayout> layout, |
| 72 bool user_action) { | 72 bool user_action) { |
| 73 if (user_action && display_animator_) { | 73 if (user_action && display_animator_) { |
| 74 display_animator_->StartFadeOutAnimation( | 74 display_animator_->StartFadeOutAnimation( |
| 75 base::Bind(&DisplayConfigurationController::SetDisplayLayoutImpl, | 75 base::Bind(&DisplayConfigurationController::SetDisplayLayoutImpl, |
| 76 weak_ptr_factory_.GetWeakPtr(), base::Passed(&layout))); | 76 weak_ptr_factory_.GetWeakPtr(), base::Passed(&layout))); |
| 77 } else { | 77 } else { |
| 78 SetDisplayLayoutImpl(std::move(layout)); | 78 SetDisplayLayoutImpl(std::move(layout)); |
| 79 } | 79 } |
| 80 } | 80 } |
| 81 | 81 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 void DisplayConfigurationController::SetThrottleTimeout(int64_t throttle_ms) { | 140 void DisplayConfigurationController::SetThrottleTimeout(int64_t throttle_ms) { |
| 141 if (limiter_) | 141 if (limiter_) |
| 142 limiter_->SetThrottleTimeout(throttle_ms); | 142 limiter_->SetThrottleTimeout(throttle_ms); |
| 143 } | 143 } |
| 144 | 144 |
| 145 bool DisplayConfigurationController::IsLimited() { | 145 bool DisplayConfigurationController::IsLimited() { |
| 146 return limiter_ && limiter_->IsThrottled(); | 146 return limiter_ && limiter_->IsThrottled(); |
| 147 } | 147 } |
| 148 | 148 |
| 149 void DisplayConfigurationController::SetDisplayLayoutImpl( | 149 void DisplayConfigurationController::SetDisplayLayoutImpl( |
| 150 scoped_ptr<DisplayLayout> layout) { | 150 scoped_ptr<display::DisplayLayout> layout) { |
| 151 // TODO(oshima/stevenjb): Add support for 3+ displays. | 151 // TODO(oshima/stevenjb): Add support for 3+ displays. |
| 152 display_manager_->SetLayoutForCurrentDisplays(std::move(layout)); | 152 display_manager_->SetLayoutForCurrentDisplays(std::move(layout)); |
| 153 if (display_animator_) | 153 if (display_animator_) |
| 154 display_animator_->StartFadeInAnimation(); | 154 display_animator_->StartFadeInAnimation(); |
| 155 } | 155 } |
| 156 | 156 |
| 157 void DisplayConfigurationController::SetMirrorModeImpl(bool mirror) { | 157 void DisplayConfigurationController::SetMirrorModeImpl(bool mirror) { |
| 158 display_manager_->SetMirrorMode(mirror); | 158 display_manager_->SetMirrorMode(mirror); |
| 159 if (display_animator_) | 159 if (display_animator_) |
| 160 display_animator_->StartFadeInAnimation(); | 160 display_animator_->StartFadeInAnimation(); |
| 161 } | 161 } |
| 162 | 162 |
| 163 void DisplayConfigurationController::SetPrimaryDisplayIdImpl( | 163 void DisplayConfigurationController::SetPrimaryDisplayIdImpl( |
| 164 int64_t display_id) { | 164 int64_t display_id) { |
| 165 window_tree_host_manager_->SetPrimaryDisplayId(display_id); | 165 window_tree_host_manager_->SetPrimaryDisplayId(display_id); |
| 166 if (display_animator_) | 166 if (display_animator_) |
| 167 display_animator_->StartFadeInAnimation(); | 167 display_animator_->StartFadeInAnimation(); |
| 168 } | 168 } |
| 169 | 169 |
| 170 } // namespace ash | 170 } // namespace ash |
| OLD | NEW |