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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 if (native_display_delegate_) | 157 if (native_display_delegate_) |
158 native_display_delegate_->RemoveObserver(this); | 158 native_display_delegate_->RemoveObserver(this); |
159 } | 159 } |
160 | 160 |
161 void DisplayConfigurator::SetDelegatesForTesting( | 161 void DisplayConfigurator::SetDelegatesForTesting( |
162 scoped_ptr<NativeDisplayDelegate> display_delegate, | 162 scoped_ptr<NativeDisplayDelegate> display_delegate, |
163 scoped_ptr<TouchscreenDelegate> touchscreen_delegate) { | 163 scoped_ptr<TouchscreenDelegate> touchscreen_delegate) { |
164 DCHECK(!native_display_delegate_); | 164 DCHECK(!native_display_delegate_); |
165 DCHECK(!touchscreen_delegate_); | 165 DCHECK(!touchscreen_delegate_); |
166 | 166 |
167 InitializeDelegates(display_delegate.Pass(), touchscreen_delegate.Pass()); | 167 native_display_delegate_ = display_delegate.Pass(); |
| 168 touchscreen_delegate_ = touchscreen_delegate.Pass(); |
168 configure_display_ = true; | 169 configure_display_ = true; |
169 } | 170 } |
170 | 171 |
171 void DisplayConfigurator::SetInitialDisplayPower( | 172 void DisplayConfigurator::SetInitialDisplayPower( |
172 chromeos::DisplayPowerState power_state) { | 173 chromeos::DisplayPowerState power_state) { |
173 DCHECK_EQ(display_state_, MULTIPLE_DISPLAY_STATE_INVALID); | 174 DCHECK_EQ(display_state_, MULTIPLE_DISPLAY_STATE_INVALID); |
174 power_state_ = power_state; | 175 power_state_ = power_state; |
175 } | 176 } |
176 | 177 |
177 void DisplayConfigurator::Init(bool is_panel_fitting_enabled) { | 178 void DisplayConfigurator::Init(bool is_panel_fitting_enabled) { |
178 is_panel_fitting_enabled_ = is_panel_fitting_enabled; | 179 is_panel_fitting_enabled_ = is_panel_fitting_enabled; |
179 if (!configure_display_) | 180 if (!configure_display_) |
180 return; | 181 return; |
181 | 182 |
182 PlatformInitialize(); | 183 // If the delegates are already initialized don't update them (For example, |
183 } | 184 // tests set their own delegates). |
184 | 185 if (!native_display_delegate_) { |
185 void DisplayConfigurator::InitializeDelegates( | 186 native_display_delegate_ = CreatePlatformNativeDisplayDelegate(); |
186 scoped_ptr<NativeDisplayDelegate> display_delegate, | |
187 scoped_ptr<TouchscreenDelegate> touchscreen_delegate) { | |
188 if (!native_display_delegate_ && !touchscreen_delegate_) { | |
189 native_display_delegate_ = display_delegate.Pass(); | |
190 touchscreen_delegate_ = touchscreen_delegate.Pass(); | |
191 | |
192 native_display_delegate_->AddObserver(this); | 187 native_display_delegate_->AddObserver(this); |
193 } | 188 } |
| 189 |
| 190 if (!touchscreen_delegate_) |
| 191 touchscreen_delegate_ = CreatePlatformTouchscreenDelegate(); |
194 } | 192 } |
195 | 193 |
196 void DisplayConfigurator::ForceInitialConfigure( | 194 void DisplayConfigurator::ForceInitialConfigure( |
197 uint32_t background_color_argb) { | 195 uint32_t background_color_argb) { |
198 if (!configure_display_) | 196 if (!configure_display_) |
199 return; | 197 return; |
200 | 198 |
201 native_display_delegate_->GrabServer(); | 199 native_display_delegate_->GrabServer(); |
202 native_display_delegate_->Initialize(); | 200 native_display_delegate_->Initialize(); |
203 | 201 |
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
933 return state_controller_->GetStateForDisplayIds(display_ids); | 931 return state_controller_->GetStateForDisplayIds(display_ids); |
934 } | 932 } |
935 } | 933 } |
936 default: | 934 default: |
937 NOTREACHED(); | 935 NOTREACHED(); |
938 } | 936 } |
939 return MULTIPLE_DISPLAY_STATE_INVALID; | 937 return MULTIPLE_DISPLAY_STATE_INVALID; |
940 } | 938 } |
941 | 939 |
942 } // namespace ui | 940 } // namespace ui |
OLD | NEW |