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/display_mode.h" | |
15 #include "ui/display/chromeos/display_snapshot.h" | |
16 #include "ui/display/chromeos/native_display_delegate.h" | |
17 #include "ui/display/display_switches.h" | 14 #include "ui/display/display_switches.h" |
18 | 15 #include "ui/display/types/chromeos/display_mode.h" |
19 #if defined(USE_OZONE) | 16 #include "ui/display/types/chromeos/display_snapshot.h" |
20 #include "ui/display/chromeos/ozone/native_display_delegate_ozone.h" | 17 #include "ui/display/types/chromeos/native_display_delegate.h" |
21 #include "ui/display/chromeos/ozone/touchscreen_delegate_ozone.h" | |
22 #elif defined(USE_X11) | |
23 #include "ui/display/chromeos/x11/native_display_delegate_x11.h" | |
24 #include "ui/display/chromeos/x11/touchscreen_delegate_x11.h" | |
25 #endif | |
26 | 18 |
27 namespace ui { | 19 namespace ui { |
28 | 20 |
29 namespace { | 21 namespace { |
30 | 22 |
31 typedef std::vector<const DisplayMode*> DisplayModeList; | 23 typedef std::vector<const DisplayMode*> DisplayModeList; |
32 | 24 |
33 // The delay to perform configuration after RRNotify. See the comment | 25 // The delay to perform configuration after RRNotify. See the comment |
34 // in |Dispatch()|. | 26 // in |Dispatch()|. |
35 const int kConfigureDelayMs = 500; | 27 const int kConfigureDelayMs = 500; |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 configure_display_(base::SysInfo::IsRunningOnChromeOS()), | 157 configure_display_(base::SysInfo::IsRunningOnChromeOS()), |
166 display_state_(MULTIPLE_DISPLAY_STATE_INVALID), | 158 display_state_(MULTIPLE_DISPLAY_STATE_INVALID), |
167 power_state_(chromeos::DISPLAY_POWER_ALL_ON), | 159 power_state_(chromeos::DISPLAY_POWER_ALL_ON), |
168 next_display_protection_client_id_(1) {} | 160 next_display_protection_client_id_(1) {} |
169 | 161 |
170 DisplayConfigurator::~DisplayConfigurator() { | 162 DisplayConfigurator::~DisplayConfigurator() { |
171 if (native_display_delegate_) | 163 if (native_display_delegate_) |
172 native_display_delegate_->RemoveObserver(this); | 164 native_display_delegate_->RemoveObserver(this); |
173 } | 165 } |
174 | 166 |
175 void DisplayConfigurator::SetNativeDisplayDelegateForTesting( | 167 void DisplayConfigurator::SetDelegatesForTesting( |
176 scoped_ptr<NativeDisplayDelegate> delegate) { | 168 scoped_ptr<NativeDisplayDelegate> display_delegate, |
| 169 scoped_ptr<TouchscreenDelegate> touchscreen_delegate) { |
177 DCHECK(!native_display_delegate_); | 170 DCHECK(!native_display_delegate_); |
| 171 DCHECK(!touchscreen_delegate_); |
178 | 172 |
179 native_display_delegate_ = delegate.Pass(); | 173 InitializeDelegates(display_delegate.Pass(), touchscreen_delegate.Pass()); |
180 native_display_delegate_->AddObserver(this); | |
181 configure_display_ = true; | 174 configure_display_ = true; |
182 } | 175 } |
183 | 176 |
184 void DisplayConfigurator::SetTouchscreenDelegateForTesting( | |
185 scoped_ptr<TouchscreenDelegate> delegate) { | |
186 DCHECK(!touchscreen_delegate_); | |
187 | |
188 touchscreen_delegate_ = delegate.Pass(); | |
189 } | |
190 | |
191 void DisplayConfigurator::SetInitialDisplayPower( | 177 void DisplayConfigurator::SetInitialDisplayPower( |
192 chromeos::DisplayPowerState power_state) { | 178 chromeos::DisplayPowerState power_state) { |
193 DCHECK_EQ(display_state_, MULTIPLE_DISPLAY_STATE_INVALID); | 179 DCHECK_EQ(display_state_, MULTIPLE_DISPLAY_STATE_INVALID); |
194 power_state_ = power_state; | 180 power_state_ = power_state; |
195 } | 181 } |
196 | 182 |
197 void DisplayConfigurator::Init(bool is_panel_fitting_enabled) { | 183 void DisplayConfigurator::Init(bool is_panel_fitting_enabled) { |
198 is_panel_fitting_enabled_ = is_panel_fitting_enabled; | 184 is_panel_fitting_enabled_ = is_panel_fitting_enabled; |
199 if (!configure_display_) | 185 if (!configure_display_) |
200 return; | 186 return; |
201 | 187 |
202 if (!native_display_delegate_) { | 188 PlatformInitialize(); |
203 #if defined(USE_OZONE) | 189 } |
204 native_display_delegate_.reset(new NativeDisplayDelegateOzone()); | 190 |
205 #elif defined(USE_X11) | 191 void DisplayConfigurator::InitializeDelegates( |
206 native_display_delegate_.reset(new NativeDisplayDelegateX11()); | 192 scoped_ptr<NativeDisplayDelegate> display_delegate, |
207 #else | 193 scoped_ptr<TouchscreenDelegate> touchscreen_delegate) { |
208 NOTREACHED(); | 194 if (!native_display_delegate_ && !touchscreen_delegate_) { |
209 #endif | 195 native_display_delegate_ = display_delegate.Pass(); |
| 196 touchscreen_delegate_ = touchscreen_delegate.Pass(); |
| 197 |
210 native_display_delegate_->AddObserver(this); | 198 native_display_delegate_->AddObserver(this); |
211 } | 199 } |
212 | |
213 if (!touchscreen_delegate_) { | |
214 #if defined(USE_OZONE) | |
215 touchscreen_delegate_.reset(new TouchscreenDelegateOzone()); | |
216 #elif defined(USE_X11) | |
217 touchscreen_delegate_.reset(new TouchscreenDelegateX11()); | |
218 #else | |
219 NOTREACHED(); | |
220 #endif | |
221 } | |
222 } | 200 } |
223 | 201 |
224 void DisplayConfigurator::ForceInitialConfigure( | 202 void DisplayConfigurator::ForceInitialConfigure( |
225 uint32_t background_color_argb) { | 203 uint32_t background_color_argb) { |
226 if (!configure_display_) | 204 if (!configure_display_) |
227 return; | 205 return; |
228 | 206 |
229 native_display_delegate_->GrabServer(); | 207 native_display_delegate_->GrabServer(); |
230 native_display_delegate_->Initialize(); | 208 native_display_delegate_->Initialize(); |
231 | 209 |
(...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1059 float width_ratio = static_cast<float>(mirror_mode_info->size().width()) / | 1037 float width_ratio = static_cast<float>(mirror_mode_info->size().width()) / |
1060 static_cast<float>(native_mode_info->size().width()); | 1038 static_cast<float>(native_mode_info->size().width()); |
1061 float height_ratio = static_cast<float>(mirror_mode_info->size().height()) / | 1039 float height_ratio = static_cast<float>(mirror_mode_info->size().height()) / |
1062 static_cast<float>(native_mode_info->size().height()); | 1040 static_cast<float>(native_mode_info->size().height()); |
1063 | 1041 |
1064 area_ratio = width_ratio * height_ratio; | 1042 area_ratio = width_ratio * height_ratio; |
1065 return area_ratio; | 1043 return area_ratio; |
1066 } | 1044 } |
1067 | 1045 |
1068 } // namespace ui | 1046 } // namespace ui |
OLD | NEW |