Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Side by Side Diff: ui/display/chromeos/display_configurator.cc

Issue 336863002: Moving input device hotplug event processing outside of ui/display (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 if (on) 84 if (on)
85 num_on_displays++; 85 num_on_displays++;
86 } 86 }
87 return num_on_displays; 87 return num_on_displays;
88 } 88 }
89 89
90 } // namespace 90 } // namespace
91 91
92 DisplayConfigurator::DisplayState::DisplayState() 92 DisplayConfigurator::DisplayState::DisplayState()
93 : display(NULL), 93 : display(NULL),
94 touch_device_id(0),
95 selected_mode(NULL), 94 selected_mode(NULL),
96 mirror_mode(NULL) {} 95 mirror_mode(NULL) {}
97 96
98 bool DisplayConfigurator::TestApi::TriggerConfigureTimeout() { 97 bool DisplayConfigurator::TestApi::TriggerConfigureTimeout() {
99 if (configurator_->configure_timer_.get() && 98 if (configurator_->configure_timer_.get() &&
100 configurator_->configure_timer_->IsRunning()) { 99 configurator_->configure_timer_->IsRunning()) {
101 configurator_->configure_timer_.reset(); 100 configurator_->configure_timer_.reset();
102 configurator_->ConfigureDisplays(); 101 configurator_->ConfigureDisplays();
103 return true; 102 return true;
104 } else { 103 } else {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 display_state_(MULTIPLE_DISPLAY_STATE_INVALID), 151 display_state_(MULTIPLE_DISPLAY_STATE_INVALID),
153 power_state_(chromeos::DISPLAY_POWER_ALL_ON), 152 power_state_(chromeos::DISPLAY_POWER_ALL_ON),
154 next_display_protection_client_id_(1) {} 153 next_display_protection_client_id_(1) {}
155 154
156 DisplayConfigurator::~DisplayConfigurator() { 155 DisplayConfigurator::~DisplayConfigurator() {
157 if (native_display_delegate_) 156 if (native_display_delegate_)
158 native_display_delegate_->RemoveObserver(this); 157 native_display_delegate_->RemoveObserver(this);
159 } 158 }
160 159
161 void DisplayConfigurator::SetDelegatesForTesting( 160 void DisplayConfigurator::SetDelegatesForTesting(
162 scoped_ptr<NativeDisplayDelegate> display_delegate, 161 scoped_ptr<NativeDisplayDelegate> display_delegate) {
163 scoped_ptr<TouchscreenDelegate> touchscreen_delegate) {
164 DCHECK(!native_display_delegate_); 162 DCHECK(!native_display_delegate_);
165 DCHECK(!touchscreen_delegate_);
166 163
167 InitializeDelegates(display_delegate.Pass(), touchscreen_delegate.Pass()); 164 InitializeDelegates(display_delegate.Pass());
168 configure_display_ = true; 165 configure_display_ = true;
169 } 166 }
170 167
171 void DisplayConfigurator::SetInitialDisplayPower( 168 void DisplayConfigurator::SetInitialDisplayPower(
172 chromeos::DisplayPowerState power_state) { 169 chromeos::DisplayPowerState power_state) {
173 DCHECK_EQ(display_state_, MULTIPLE_DISPLAY_STATE_INVALID); 170 DCHECK_EQ(display_state_, MULTIPLE_DISPLAY_STATE_INVALID);
174 power_state_ = power_state; 171 power_state_ = power_state;
175 } 172 }
176 173
177 void DisplayConfigurator::Init(bool is_panel_fitting_enabled) { 174 void DisplayConfigurator::Init(bool is_panel_fitting_enabled) {
178 is_panel_fitting_enabled_ = is_panel_fitting_enabled; 175 is_panel_fitting_enabled_ = is_panel_fitting_enabled;
179 if (!configure_display_) 176 if (!configure_display_)
180 return; 177 return;
181 178
182 PlatformInitialize(); 179 PlatformInitialize();
183 } 180 }
184 181
185 void DisplayConfigurator::InitializeDelegates( 182 void DisplayConfigurator::InitializeDelegates(
186 scoped_ptr<NativeDisplayDelegate> display_delegate, 183 scoped_ptr<NativeDisplayDelegate> display_delegate) {
187 scoped_ptr<TouchscreenDelegate> touchscreen_delegate) { 184 if (!native_display_delegate_) {
188 if (!native_display_delegate_ && !touchscreen_delegate_) {
189 native_display_delegate_ = display_delegate.Pass(); 185 native_display_delegate_ = display_delegate.Pass();
190 touchscreen_delegate_ = touchscreen_delegate.Pass();
191
192 native_display_delegate_->AddObserver(this); 186 native_display_delegate_->AddObserver(this);
193 } 187 }
194 } 188 }
195 189
196 void DisplayConfigurator::ForceInitialConfigure( 190 void DisplayConfigurator::ForceInitialConfigure(
197 uint32_t background_color_argb) { 191 uint32_t background_color_argb) {
198 if (!configure_display_) 192 if (!configure_display_)
199 return; 193 return;
200 194
201 native_display_delegate_->GrabServer(); 195 native_display_delegate_->GrabServer();
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 std::vector<DisplaySnapshot*> snapshots = 542 std::vector<DisplaySnapshot*> snapshots =
549 native_display_delegate_->GetDisplays(); 543 native_display_delegate_->GetDisplays();
550 544
551 cached_displays_.clear(); 545 cached_displays_.clear();
552 for (size_t i = 0; i < snapshots.size(); ++i) { 546 for (size_t i = 0; i < snapshots.size(); ++i) {
553 DisplayState display_state; 547 DisplayState display_state;
554 display_state.display = snapshots[i]; 548 display_state.display = snapshots[i];
555 cached_displays_.push_back(display_state); 549 cached_displays_.push_back(display_state);
556 } 550 }
557 551
558 touchscreen_delegate_->AssociateTouchscreens(&cached_displays_);
559
560 // Set |selected_mode| fields. 552 // Set |selected_mode| fields.
561 for (size_t i = 0; i < cached_displays_.size(); ++i) { 553 for (size_t i = 0; i < cached_displays_.size(); ++i) {
562 DisplayState* display_state = &cached_displays_[i]; 554 DisplayState* display_state = &cached_displays_[i];
563 if (display_state->display->has_proper_display_id()) { 555 if (display_state->display->has_proper_display_id()) {
564 gfx::Size size; 556 gfx::Size size;
565 if (state_controller_ && 557 if (state_controller_ &&
566 state_controller_->GetResolutionForDisplayId( 558 state_controller_->GetResolutionForDisplayId(
567 display_state->display->display_id(), &size)) { 559 display_state->display->display_id(), &size)) {
568 display_state->selected_mode = 560 display_state->selected_mode =
569 FindDisplayModeMatchingSize(*display_state->display, size); 561 FindDisplayModeMatchingSize(*display_state->display, size);
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
933 return state_controller_->GetStateForDisplayIds(display_ids); 925 return state_controller_->GetStateForDisplayIds(display_ids);
934 } 926 }
935 } 927 }
936 default: 928 default:
937 NOTREACHED(); 929 NOTREACHED();
938 } 930 }
939 return MULTIPLE_DISPLAY_STATE_INVALID; 931 return MULTIPLE_DISPLAY_STATE_INVALID;
940 } 932 }
941 933
942 } // namespace ui 934 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698