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" |
11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
12 #include "base/sys_info.h" | 12 #include "base/sys_info.h" |
13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
14 #include "ui/display/chromeos/touchscreen_delegate_impl.h" | |
15 #include "ui/display/display_switches.h" | 14 #include "ui/display/display_switches.h" |
16 #include "ui/display/types/chromeos/display_mode.h" | 15 #include "ui/display/types/chromeos/display_mode.h" |
17 #include "ui/display/types/chromeos/display_snapshot.h" | 16 #include "ui/display/types/chromeos/display_snapshot.h" |
18 #include "ui/display/types/chromeos/native_display_delegate.h" | 17 #include "ui/display/types/chromeos/native_display_delegate.h" |
19 | 18 |
20 namespace ui { | 19 namespace ui { |
21 | 20 |
22 namespace { | 21 namespace { |
23 | 22 |
24 typedef std::vector<const DisplayMode*> DisplayModeList; | 23 typedef std::vector<const DisplayMode*> DisplayModeList; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 } // namespace | 96 } // namespace |
98 | 97 |
99 | 98 |
100 const int DisplayConfigurator::kSetDisplayPowerNoFlags = 0; | 99 const int DisplayConfigurator::kSetDisplayPowerNoFlags = 0; |
101 const int DisplayConfigurator::kSetDisplayPowerForceProbe = 1 << 0; | 100 const int DisplayConfigurator::kSetDisplayPowerForceProbe = 1 << 0; |
102 const int | 101 const int |
103 DisplayConfigurator::kSetDisplayPowerOnlyIfSingleInternalDisplay = 1 << 1; | 102 DisplayConfigurator::kSetDisplayPowerOnlyIfSingleInternalDisplay = 1 << 1; |
104 | 103 |
105 DisplayConfigurator::DisplayState::DisplayState() | 104 DisplayConfigurator::DisplayState::DisplayState() |
106 : display(NULL), | 105 : display(NULL), |
107 touch_device_id(0), | |
108 selected_mode(NULL), | 106 selected_mode(NULL), |
109 mirror_mode(NULL) {} | 107 mirror_mode(NULL) {} |
110 | 108 |
111 bool DisplayConfigurator::TestApi::TriggerConfigureTimeout() { | 109 bool DisplayConfigurator::TestApi::TriggerConfigureTimeout() { |
112 if (configurator_->configure_timer_.IsRunning()) { | 110 if (configurator_->configure_timer_.IsRunning()) { |
113 configurator_->configure_timer_.user_task().Run(); | 111 configurator_->configure_timer_.user_task().Run(); |
114 configurator_->configure_timer_.Stop(); | 112 configurator_->configure_timer_.Stop(); |
115 return true; | 113 return true; |
116 } else { | 114 } else { |
117 return false; | 115 return false; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 configure_display_(base::SysInfo::IsRunningOnChromeOS()), | 161 configure_display_(base::SysInfo::IsRunningOnChromeOS()), |
164 display_state_(MULTIPLE_DISPLAY_STATE_INVALID), | 162 display_state_(MULTIPLE_DISPLAY_STATE_INVALID), |
165 power_state_(chromeos::DISPLAY_POWER_ALL_ON), | 163 power_state_(chromeos::DISPLAY_POWER_ALL_ON), |
166 next_display_protection_client_id_(1) {} | 164 next_display_protection_client_id_(1) {} |
167 | 165 |
168 DisplayConfigurator::~DisplayConfigurator() { | 166 DisplayConfigurator::~DisplayConfigurator() { |
169 if (native_display_delegate_) | 167 if (native_display_delegate_) |
170 native_display_delegate_->RemoveObserver(this); | 168 native_display_delegate_->RemoveObserver(this); |
171 } | 169 } |
172 | 170 |
173 void DisplayConfigurator::SetDelegatesForTesting( | 171 void DisplayConfigurator::SetDelegateForTesting( |
174 scoped_ptr<NativeDisplayDelegate> display_delegate, | 172 scoped_ptr<NativeDisplayDelegate> display_delegate) { |
175 scoped_ptr<TouchscreenDelegate> touchscreen_delegate) { | |
176 DCHECK(!native_display_delegate_); | 173 DCHECK(!native_display_delegate_); |
177 DCHECK(!touchscreen_delegate_); | |
178 | 174 |
179 native_display_delegate_ = display_delegate.Pass(); | 175 native_display_delegate_ = display_delegate.Pass(); |
180 touchscreen_delegate_ = touchscreen_delegate.Pass(); | |
181 configure_display_ = true; | 176 configure_display_ = true; |
182 } | 177 } |
183 | 178 |
184 void DisplayConfigurator::SetInitialDisplayPower( | 179 void DisplayConfigurator::SetInitialDisplayPower( |
185 chromeos::DisplayPowerState power_state) { | 180 chromeos::DisplayPowerState power_state) { |
186 DCHECK_EQ(display_state_, MULTIPLE_DISPLAY_STATE_INVALID); | 181 DCHECK_EQ(display_state_, MULTIPLE_DISPLAY_STATE_INVALID); |
187 power_state_ = power_state; | 182 power_state_ = power_state; |
188 } | 183 } |
189 | 184 |
190 void DisplayConfigurator::Init(bool is_panel_fitting_enabled) { | 185 void DisplayConfigurator::Init(bool is_panel_fitting_enabled) { |
191 is_panel_fitting_enabled_ = is_panel_fitting_enabled; | 186 is_panel_fitting_enabled_ = is_panel_fitting_enabled; |
192 if (!configure_display_) | 187 if (!configure_display_) |
193 return; | 188 return; |
194 | 189 |
195 // If the delegates are already initialized don't update them (For example, | 190 // If the delegate is already initialized don't update it (For example, tests |
196 // tests set their own delegates). | 191 // set their own delegates). |
197 if (!native_display_delegate_) { | 192 if (!native_display_delegate_) { |
198 native_display_delegate_ = CreatePlatformNativeDisplayDelegate(); | 193 native_display_delegate_ = CreatePlatformNativeDisplayDelegate(); |
199 native_display_delegate_->AddObserver(this); | 194 native_display_delegate_->AddObserver(this); |
200 } | 195 } |
201 | |
202 if (!touchscreen_delegate_) | |
203 touchscreen_delegate_.reset(new TouchscreenDelegateImpl()); | |
204 } | 196 } |
205 | 197 |
206 void DisplayConfigurator::ForceInitialConfigure( | 198 void DisplayConfigurator::ForceInitialConfigure( |
207 uint32_t background_color_argb) { | 199 uint32_t background_color_argb) { |
208 if (!configure_display_) | 200 if (!configure_display_) |
209 return; | 201 return; |
210 | 202 |
211 native_display_delegate_->GrabServer(); | 203 native_display_delegate_->GrabServer(); |
212 native_display_delegate_->Initialize(); | 204 native_display_delegate_->Initialize(); |
213 | 205 |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 std::vector<DisplaySnapshot*> snapshots = | 559 std::vector<DisplaySnapshot*> snapshots = |
568 native_display_delegate_->GetDisplays(); | 560 native_display_delegate_->GetDisplays(); |
569 | 561 |
570 cached_displays_.clear(); | 562 cached_displays_.clear(); |
571 for (size_t i = 0; i < snapshots.size(); ++i) { | 563 for (size_t i = 0; i < snapshots.size(); ++i) { |
572 DisplayState display_state; | 564 DisplayState display_state; |
573 display_state.display = snapshots[i]; | 565 display_state.display = snapshots[i]; |
574 cached_displays_.push_back(display_state); | 566 cached_displays_.push_back(display_state); |
575 } | 567 } |
576 | 568 |
577 touchscreen_delegate_->AssociateTouchscreens(&cached_displays_); | |
578 | |
579 // Set |selected_mode| fields. | 569 // Set |selected_mode| fields. |
580 for (size_t i = 0; i < cached_displays_.size(); ++i) { | 570 for (size_t i = 0; i < cached_displays_.size(); ++i) { |
581 DisplayState* display_state = &cached_displays_[i]; | 571 DisplayState* display_state = &cached_displays_[i]; |
582 if (display_state->display->has_proper_display_id()) { | 572 if (display_state->display->has_proper_display_id()) { |
583 gfx::Size size; | 573 gfx::Size size; |
584 if (state_controller_ && | 574 if (state_controller_ && |
585 state_controller_->GetResolutionForDisplayId( | 575 state_controller_->GetResolutionForDisplayId( |
586 display_state->display->display_id(), &size)) { | 576 display_state->display->display_id(), &size)) { |
587 display_state->selected_mode = | 577 display_state->selected_mode = |
588 FindDisplayModeMatchingSize(*display_state->display, size); | 578 FindDisplayModeMatchingSize(*display_state->display, size); |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
959 return state_controller_->GetStateForDisplayIds(display_ids); | 949 return state_controller_->GetStateForDisplayIds(display_ids); |
960 } | 950 } |
961 } | 951 } |
962 default: | 952 default: |
963 NOTREACHED(); | 953 NOTREACHED(); |
964 } | 954 } |
965 return MULTIPLE_DISPLAY_STATE_INVALID; | 955 return MULTIPLE_DISPLAY_STATE_INVALID; |
966 } | 956 } |
967 | 957 |
968 } // namespace ui | 958 } // namespace ui |
OLD | NEW |