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

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

Issue 1019623002: Remove DisplayState from the public interface for DisplayConfigurator (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
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/sys_info.h" 10 #include "base/sys_info.h"
(...skipping 14 matching lines...) Expand all
25 // The delay to perform configuration after RRNotify. See the comment for 25 // The delay to perform configuration after RRNotify. See the comment for
26 // |configure_timer_|. 26 // |configure_timer_|.
27 const int kConfigureDelayMs = 500; 27 const int kConfigureDelayMs = 500;
28 28
29 // The delay spent before reading the display configuration after coming out of 29 // The delay spent before reading the display configuration after coming out of
30 // suspend. While coming out of suspend the display state may be updating. This 30 // suspend. While coming out of suspend the display state may be updating. This
31 // is used to wait until the hardware had a chance to update the display state 31 // is used to wait until the hardware had a chance to update the display state
32 // such that we read an up to date state. 32 // such that we read an up to date state.
33 const int kResumeDelayMs = 500; 33 const int kResumeDelayMs = 500;
34 34
35 struct DisplayState {
36 DisplayState()
37 : display(nullptr), selected_mode(nullptr), mirror_mode(nullptr) {}
38
39 DisplaySnapshot* display; // Not owned.
40
41 // User-selected mode for the display.
42 const DisplayMode* selected_mode;
43
44 // Mode used when displaying the same desktop on multiple displays.
45 const DisplayMode* mirror_mode;
46 };
47
35 void DoNothing(bool status) { 48 void DoNothing(bool status) {
36 } 49 }
37 50
38 } // namespace 51 } // namespace
39 52
40
41 const int DisplayConfigurator::kSetDisplayPowerNoFlags = 0; 53 const int DisplayConfigurator::kSetDisplayPowerNoFlags = 0;
42 const int DisplayConfigurator::kSetDisplayPowerForceProbe = 1 << 0; 54 const int DisplayConfigurator::kSetDisplayPowerForceProbe = 1 << 0;
43 const int 55 const int
44 DisplayConfigurator::kSetDisplayPowerOnlyIfSingleInternalDisplay = 1 << 1; 56 DisplayConfigurator::kSetDisplayPowerOnlyIfSingleInternalDisplay = 1 << 1;
45 57
46 DisplayConfigurator::DisplayState::DisplayState()
47 : display(NULL),
48 selected_mode(NULL),
49 mirror_mode(NULL) {}
50
51 bool DisplayConfigurator::TestApi::TriggerConfigureTimeout() { 58 bool DisplayConfigurator::TestApi::TriggerConfigureTimeout() {
52 if (configurator_->configure_timer_.IsRunning()) { 59 if (configurator_->configure_timer_.IsRunning()) {
53 configurator_->configure_timer_.user_task().Run(); 60 configurator_->configure_timer_.user_task().Run();
54 configurator_->configure_timer_.Stop(); 61 configurator_->configure_timer_.Stop();
55 return true; 62 return true;
56 } else { 63 } else {
57 return false; 64 return false;
58 } 65 }
59 } 66 }
60 67
61 //////////////////////////////////////////////////////////////////////////////// 68 ////////////////////////////////////////////////////////////////////////////////
62 // DisplayConfigurator::DisplayLayoutManagerImpl implementation 69 // DisplayConfigurator::DisplayLayoutManagerImpl implementation
63 70
64 class DisplayConfigurator::DisplayLayoutManagerImpl 71 class DisplayConfigurator::DisplayLayoutManagerImpl
65 : public DisplayLayoutManager { 72 : public DisplayLayoutManager {
66 public: 73 public:
67 DisplayLayoutManagerImpl(DisplayConfigurator* configurator); 74 DisplayLayoutManagerImpl(DisplayConfigurator* configurator);
68 ~DisplayLayoutManagerImpl() override; 75 ~DisplayLayoutManagerImpl() override;
69 76
70 // DisplayConfigurator::DisplayLayoutManager: 77 // DisplayConfigurator::DisplayLayoutManager:
71 SoftwareMirroringController* GetSoftwareMirroringController() const override; 78 SoftwareMirroringController* GetSoftwareMirroringController() const override;
72 StateController* GetStateController() const override; 79 StateController* GetStateController() const override;
73 MultipleDisplayState GetDisplayState() const override; 80 MultipleDisplayState GetDisplayState() const override;
74 chromeos::DisplayPowerState GetPowerState() const override; 81 chromeos::DisplayPowerState GetPowerState() const override;
75 std::vector<DisplayState> ParseDisplays( 82 bool GetDisplayLayout(const std::vector<DisplaySnapshot*>& displays,
76 const std::vector<DisplaySnapshot*>& displays) const override;
77 bool GetDisplayLayout(const std::vector<DisplayState>& displays,
78 MultipleDisplayState new_display_state, 83 MultipleDisplayState new_display_state,
79 chromeos::DisplayPowerState new_power_state, 84 chromeos::DisplayPowerState new_power_state,
80 std::vector<DisplayConfigureRequest>* requests, 85 std::vector<DisplayConfigureRequest>* requests,
81 gfx::Size* framebuffer_size) const override; 86 gfx::Size* framebuffer_size) const override;
82 87
83 private: 88 private:
89 // Parses the |displays| into a list of DisplayStates. This effectively adds
90 // |mirror_mode| and |selected_mode| to the returned results.
91 // TODO(dnicoara): Break this into GetSelectedMode() and GetMirrorMode() and
92 // remove DisplayState.
93 std::vector<DisplayState> ParseDisplays(
94 const std::vector<DisplaySnapshot*>& displays) const;
95
84 // Helper method for ParseDisplays() that initializes the passed-in 96 // Helper method for ParseDisplays() that initializes the passed-in
85 // displays' |mirror_mode| fields by looking for a mode in |internal_display| 97 // displays' |mirror_mode| fields by looking for a mode in |internal_display|
86 // and |external_display| having the same resolution. Returns false if a 98 // and |external_display| having the same resolution. Returns false if a
87 // shared mode wasn't found or created. 99 // shared mode wasn't found or created.
88 // 100 //
89 // |try_panel_fitting| allows creating a panel-fitting mode for 101 // |try_panel_fitting| allows creating a panel-fitting mode for
90 // |internal_display| instead of only searching for a matching mode (note that 102 // |internal_display| instead of only searching for a matching mode (note that
91 // it may lead to a crash if |internal_display| is not capable of panel 103 // it may lead to a crash if |internal_display| is not capable of panel
92 // fitting). 104 // fitting).
93 // 105 //
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 MultipleDisplayState 137 MultipleDisplayState
126 DisplayConfigurator::DisplayLayoutManagerImpl::GetDisplayState() const { 138 DisplayConfigurator::DisplayLayoutManagerImpl::GetDisplayState() const {
127 return configurator_->current_display_state_; 139 return configurator_->current_display_state_;
128 } 140 }
129 141
130 chromeos::DisplayPowerState 142 chromeos::DisplayPowerState
131 DisplayConfigurator::DisplayLayoutManagerImpl::GetPowerState() const { 143 DisplayConfigurator::DisplayLayoutManagerImpl::GetPowerState() const {
132 return configurator_->current_power_state_; 144 return configurator_->current_power_state_;
133 } 145 }
134 146
135 std::vector<DisplayConfigurator::DisplayState> 147 std::vector<DisplayState>
136 DisplayConfigurator::DisplayLayoutManagerImpl::ParseDisplays( 148 DisplayConfigurator::DisplayLayoutManagerImpl::ParseDisplays(
137 const std::vector<DisplaySnapshot*>& snapshots) const { 149 const std::vector<DisplaySnapshot*>& snapshots) const {
138 std::vector<DisplayState> cached_displays; 150 std::vector<DisplayState> cached_displays;
139 for (auto snapshot : snapshots) { 151 for (auto snapshot : snapshots) {
140 DisplayState display_state; 152 DisplayState display_state;
141 display_state.display = snapshot; 153 display_state.display = snapshot;
142 cached_displays.push_back(display_state); 154 cached_displays.push_back(display_state);
143 } 155 }
144 156
145 // Set |selected_mode| fields. 157 // Set |selected_mode| fields.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 false, preserve_aspect); 206 false, preserve_aspect);
195 } 207 }
196 } 208 }
197 } 209 }
198 } 210 }
199 211
200 return cached_displays; 212 return cached_displays;
201 } 213 }
202 214
203 bool DisplayConfigurator::DisplayLayoutManagerImpl::GetDisplayLayout( 215 bool DisplayConfigurator::DisplayLayoutManagerImpl::GetDisplayLayout(
204 const std::vector<DisplayState>& displays, 216 const std::vector<DisplaySnapshot*>& displays,
205 MultipleDisplayState new_display_state, 217 MultipleDisplayState new_display_state,
206 chromeos::DisplayPowerState new_power_state, 218 chromeos::DisplayPowerState new_power_state,
207 std::vector<DisplayConfigureRequest>* requests, 219 std::vector<DisplayConfigureRequest>* requests,
208 gfx::Size* framebuffer_size) const { 220 gfx::Size* framebuffer_size) const {
221 std::vector<DisplayState> states = ParseDisplays(displays);
209 std::vector<bool> display_power; 222 std::vector<bool> display_power;
210 int num_on_displays = 223 int num_on_displays =
211 GetDisplayPower(displays, new_power_state, &display_power); 224 GetDisplayPower(displays, new_power_state, &display_power);
212 VLOG(1) << "EnterState: display=" 225 VLOG(1) << "EnterState: display="
213 << MultipleDisplayStateToString(new_display_state) 226 << MultipleDisplayStateToString(new_display_state)
214 << " power=" << DisplayPowerStateToString(new_power_state); 227 << " power=" << DisplayPowerStateToString(new_power_state);
215 228
216 // Framebuffer dimensions. 229 // Framebuffer dimensions.
217 gfx::Size size; 230 gfx::Size size;
218 231
219 for (size_t i = 0; i < displays.size(); ++i) { 232 for (size_t i = 0; i < displays.size(); ++i) {
220 requests->push_back(DisplayConfigureRequest( 233 requests->push_back(DisplayConfigureRequest(
221 displays[i].display, displays[i].display->current_mode(), 234 displays[i], displays[i]->current_mode(), gfx::Point()));
222 gfx::Point()));
223 } 235 }
224 236
225 switch (new_display_state) { 237 switch (new_display_state) {
226 case MULTIPLE_DISPLAY_STATE_INVALID: 238 case MULTIPLE_DISPLAY_STATE_INVALID:
227 NOTREACHED() << "Ignoring request to enter invalid state with " 239 NOTREACHED() << "Ignoring request to enter invalid state with "
228 << displays.size() << " connected display(s)"; 240 << displays.size() << " connected display(s)";
229 return false; 241 return false;
230 case MULTIPLE_DISPLAY_STATE_HEADLESS: 242 case MULTIPLE_DISPLAY_STATE_HEADLESS:
231 if (displays.size() != 0) { 243 if (displays.size() != 0) {
232 LOG(WARNING) << "Ignoring request to enter headless mode with " 244 LOG(WARNING) << "Ignoring request to enter headless mode with "
233 << displays.size() << " connected display(s)"; 245 << displays.size() << " connected display(s)";
234 return false; 246 return false;
235 } 247 }
236 break; 248 break;
237 case MULTIPLE_DISPLAY_STATE_SINGLE: { 249 case MULTIPLE_DISPLAY_STATE_SINGLE: {
238 // If there are multiple displays connected, only one should be turned on. 250 // If there are multiple displays connected, only one should be turned on.
239 if (displays.size() != 1 && num_on_displays != 1) { 251 if (displays.size() != 1 && num_on_displays != 1) {
240 LOG(WARNING) << "Ignoring request to enter single mode with " 252 LOG(WARNING) << "Ignoring request to enter single mode with "
241 << displays.size() << " connected displays and " 253 << displays.size() << " connected displays and "
242 << num_on_displays << " turned on"; 254 << num_on_displays << " turned on";
243 return false; 255 return false;
244 } 256 }
245 257
246 for (size_t i = 0; i < displays.size(); ++i) { 258 for (size_t i = 0; i < states.size(); ++i) {
247 const DisplayConfigurator::DisplayState* state = &displays[i]; 259 const DisplayState* state = &states[i];
248 (*requests)[i].mode = display_power[i] ? state->selected_mode : NULL; 260 (*requests)[i].mode = display_power[i] ? state->selected_mode : NULL;
249 261
250 if (display_power[i] || displays.size() == 1) { 262 if (display_power[i] || states.size() == 1) {
251 const DisplayMode* mode_info = state->selected_mode; 263 const DisplayMode* mode_info = state->selected_mode;
252 if (!mode_info) { 264 if (!mode_info) {
253 LOG(WARNING) << "No selected mode when configuring display: " 265 LOG(WARNING) << "No selected mode when configuring display: "
254 << state->display->ToString(); 266 << state->display->ToString();
255 return false; 267 return false;
256 } 268 }
257 if (mode_info->size() == gfx::Size(1024, 768)) { 269 if (mode_info->size() == gfx::Size(1024, 768)) {
258 VLOG(1) << "Potentially misdetecting display(1024x768):" 270 VLOG(1) << "Potentially misdetecting display(1024x768):"
259 << " displays size=" << displays.size() 271 << " displays size=" << states.size()
260 << ", num_on_displays=" << num_on_displays 272 << ", num_on_displays=" << num_on_displays
261 << ", current size:" << size.width() << "x" << size.height() 273 << ", current size:" << size.width() << "x" << size.height()
262 << ", i=" << i << ", display=" << state->display->ToString() 274 << ", i=" << i << ", display=" << state->display->ToString()
263 << ", display_mode=" << mode_info->ToString(); 275 << ", display_mode=" << mode_info->ToString();
264 } 276 }
265 size = mode_info->size(); 277 size = mode_info->size();
266 } 278 }
267 } 279 }
268 break; 280 break;
269 } 281 }
270 case MULTIPLE_DISPLAY_STATE_DUAL_MIRROR: { 282 case MULTIPLE_DISPLAY_STATE_DUAL_MIRROR: {
271 if (displays.size() != 2 || 283 if (states.size() != 2 ||
272 (num_on_displays != 0 && num_on_displays != 2)) { 284 (num_on_displays != 0 && num_on_displays != 2)) {
273 LOG(WARNING) << "Ignoring request to enter mirrored mode with " 285 LOG(WARNING) << "Ignoring request to enter mirrored mode with "
274 << displays.size() << " connected display(s) and " 286 << states.size() << " connected display(s) and "
275 << num_on_displays << " turned on"; 287 << num_on_displays << " turned on";
276 return false; 288 return false;
277 } 289 }
278 290
279 const DisplayMode* mode_info = displays[0].mirror_mode; 291 const DisplayMode* mode_info = states[0].mirror_mode;
280 if (!mode_info) { 292 if (!mode_info) {
281 LOG(WARNING) << "No mirror mode when configuring display: " 293 LOG(WARNING) << "No mirror mode when configuring display: "
282 << displays[0].display->ToString(); 294 << states[0].display->ToString();
283 return false; 295 return false;
284 } 296 }
285 size = mode_info->size(); 297 size = mode_info->size();
286 298
287 for (size_t i = 0; i < displays.size(); ++i) { 299 for (size_t i = 0; i < states.size(); ++i) {
288 const DisplayConfigurator::DisplayState* state = &displays[i]; 300 const DisplayState* state = &states[i];
289 (*requests)[i].mode = display_power[i] ? state->mirror_mode : NULL; 301 (*requests)[i].mode = display_power[i] ? state->mirror_mode : NULL;
290 } 302 }
291 break; 303 break;
292 } 304 }
293 case MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED: 305 case MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED:
294 case MULTIPLE_DISPLAY_STATE_MULTI_EXTENDED: { 306 case MULTIPLE_DISPLAY_STATE_MULTI_EXTENDED: {
295 if ((new_display_state == MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED && 307 if ((new_display_state == MULTIPLE_DISPLAY_STATE_DUAL_EXTENDED &&
296 displays.size() != 2) || 308 states.size() != 2) ||
297 (new_display_state == MULTIPLE_DISPLAY_STATE_MULTI_EXTENDED && 309 (new_display_state == MULTIPLE_DISPLAY_STATE_MULTI_EXTENDED &&
298 displays.size() <= 2) || 310 states.size() <= 2) ||
299 (num_on_displays != 0 && 311 (num_on_displays != 0 &&
300 num_on_displays != static_cast<int>(displays.size()))) { 312 num_on_displays != static_cast<int>(displays.size()))) {
301 LOG(WARNING) << "Ignoring request to enter extended mode with " 313 LOG(WARNING) << "Ignoring request to enter extended mode with "
302 << displays.size() << " connected display(s) and " 314 << states.size() << " connected display(s) and "
303 << num_on_displays << " turned on"; 315 << num_on_displays << " turned on";
304 return false; 316 return false;
305 } 317 }
306 318
307 for (size_t i = 0; i < displays.size(); ++i) { 319 for (size_t i = 0; i < states.size(); ++i) {
308 const DisplayConfigurator::DisplayState* state = &displays[i]; 320 const DisplayState* state = &states[i];
309 (*requests)[i].origin.set_y(size.height() ? size.height() + kVerticalGap 321 (*requests)[i].origin.set_y(size.height() ? size.height() + kVerticalGap
310 : 0); 322 : 0);
311 (*requests)[i].mode = display_power[i] ? state->selected_mode : NULL; 323 (*requests)[i].mode = display_power[i] ? state->selected_mode : NULL;
312 324
313 // Retain the full screen size even if all displays are off so the 325 // Retain the full screen size even if all displays are off so the
314 // same desktop configuration can be restored when the displays are 326 // same desktop configuration can be restored when the displays are
315 // turned back on. 327 // turned back on.
316 const DisplayMode* mode_info = displays[i].selected_mode; 328 const DisplayMode* mode_info = states[i].selected_mode;
317 if (!mode_info) { 329 if (!mode_info) {
318 LOG(WARNING) << "No selected mode when configuring display: " 330 LOG(WARNING) << "No selected mode when configuring display: "
319 << state->display->ToString(); 331 << state->display->ToString();
320 return false; 332 return false;
321 } 333 }
322 334
323 size.set_width(std::max<int>(size.width(), mode_info->size().width())); 335 size.set_width(std::max<int>(size.width(), mode_info->size().width()));
324 size.set_height(size.height() + (size.height() ? kVerticalGap : 0) + 336 size.set_height(size.height() + (size.height() ? kVerticalGap : 0) +
325 mode_info->size().height()); 337 mode_info->size().height());
326 } 338 }
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 configuration_task_->Run(); 551 configuration_task_->Run();
540 } 552 }
541 553
542 bool DisplayConfigurator::IsMirroring() const { 554 bool DisplayConfigurator::IsMirroring() const {
543 return current_display_state_ == MULTIPLE_DISPLAY_STATE_DUAL_MIRROR || 555 return current_display_state_ == MULTIPLE_DISPLAY_STATE_DUAL_MIRROR ||
544 (mirroring_controller_ && 556 (mirroring_controller_ &&
545 mirroring_controller_->SoftwareMirroringEnabled()); 557 mirroring_controller_->SoftwareMirroringEnabled());
546 } 558 }
547 559
548 bool DisplayConfigurator::ApplyProtections(const ContentProtections& requests) { 560 bool DisplayConfigurator::ApplyProtections(const ContentProtections& requests) {
549 for (DisplayStateList::const_iterator it = cached_displays_.begin(); 561 for (DisplayStateList::const_iterator it = cached_displays_.begin();
dnicoara 2015/03/18 20:01:49 I was thinking of converting these for-loops to c+
oshima 2015/03/18 23:02:45 sg
550 it != cached_displays_.end(); 562 it != cached_displays_.end();
551 ++it) { 563 ++it) {
552 uint32_t all_desired = 0; 564 uint32_t all_desired = 0;
553 565
554 // In mirror mode, protection request of all displays need to be fulfilled. 566 // In mirror mode, protection request of all displays need to be fulfilled.
555 // In non-mirror mode, only request of client's display needs to be 567 // In non-mirror mode, only request of client's display needs to be
556 // fulfilled. 568 // fulfilled.
557 ContentProtections::const_iterator request_it; 569 ContentProtections::const_iterator request_it;
558 if (IsMirroring()) { 570 if (IsMirroring()) {
559 for (request_it = requests.begin(); 571 for (request_it = requests.begin();
560 request_it != requests.end(); 572 request_it != requests.end();
561 ++request_it) 573 ++request_it)
562 all_desired |= request_it->second; 574 all_desired |= request_it->second;
563 } else { 575 } else {
564 request_it = requests.find(it->display->display_id()); 576 request_it = requests.find((*it)->display_id());
565 if (request_it != requests.end()) 577 if (request_it != requests.end())
566 all_desired = request_it->second; 578 all_desired = request_it->second;
567 } 579 }
568 580
569 switch (it->display->type()) { 581 switch ((*it)->type()) {
570 case DISPLAY_CONNECTION_TYPE_UNKNOWN: 582 case DISPLAY_CONNECTION_TYPE_UNKNOWN:
571 return false; 583 return false;
572 // DisplayPort, DVI, and HDMI all support HDCP. 584 // DisplayPort, DVI, and HDMI all support HDCP.
573 case DISPLAY_CONNECTION_TYPE_DISPLAYPORT: 585 case DISPLAY_CONNECTION_TYPE_DISPLAYPORT:
574 case DISPLAY_CONNECTION_TYPE_DVI: 586 case DISPLAY_CONNECTION_TYPE_DVI:
575 case DISPLAY_CONNECTION_TYPE_HDMI: { 587 case DISPLAY_CONNECTION_TYPE_HDMI: {
576 HDCPState current_state; 588 HDCPState current_state;
577 // Need to poll the driver for updates since other applications may 589 // Need to poll the driver for updates since other applications may
578 // have updated the state. 590 // have updated the state.
579 if (!native_display_delegate_->GetHDCPState(*it->display, 591 if (!native_display_delegate_->GetHDCPState(**it, &current_state))
580 &current_state))
581 return false; 592 return false;
582 bool current_desired = (current_state != HDCP_STATE_UNDESIRED); 593 bool current_desired = (current_state != HDCP_STATE_UNDESIRED);
583 bool new_desired = (all_desired & CONTENT_PROTECTION_METHOD_HDCP); 594 bool new_desired = (all_desired & CONTENT_PROTECTION_METHOD_HDCP);
584 // Don't enable again if HDCP is already active. Some buggy drivers 595 // Don't enable again if HDCP is already active. Some buggy drivers
585 // may disable and enable if setting "desired" in active state. 596 // may disable and enable if setting "desired" in active state.
586 if (current_desired != new_desired) { 597 if (current_desired != new_desired) {
587 HDCPState new_state = 598 HDCPState new_state =
588 new_desired ? HDCP_STATE_DESIRED : HDCP_STATE_UNDESIRED; 599 new_desired ? HDCP_STATE_DESIRED : HDCP_STATE_UNDESIRED;
589 if (!native_display_delegate_->SetHDCPState(*it->display, new_state)) 600 if (!native_display_delegate_->SetHDCPState(**it, new_state))
590 return false; 601 return false;
591 } 602 }
592 break; 603 break;
593 } 604 }
594 case DISPLAY_CONNECTION_TYPE_INTERNAL: 605 case DISPLAY_CONNECTION_TYPE_INTERNAL:
595 case DISPLAY_CONNECTION_TYPE_VGA: 606 case DISPLAY_CONNECTION_TYPE_VGA:
596 case DISPLAY_CONNECTION_TYPE_NETWORK: 607 case DISPLAY_CONNECTION_TYPE_NETWORK:
597 // No protections for these types. Do nothing. 608 // No protections for these types. Do nothing.
598 break; 609 break;
599 case DISPLAY_CONNECTION_TYPE_NONE: 610 case DISPLAY_CONNECTION_TYPE_NONE:
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 if (!configure_display_ || display_externally_controlled_) 651 if (!configure_display_ || display_externally_controlled_)
641 return false; 652 return false;
642 653
643 uint32_t enabled = 0; 654 uint32_t enabled = 0;
644 uint32_t unfulfilled = 0; 655 uint32_t unfulfilled = 0;
645 *link_mask = 0; 656 *link_mask = 0;
646 for (DisplayStateList::const_iterator it = cached_displays_.begin(); 657 for (DisplayStateList::const_iterator it = cached_displays_.begin();
647 it != cached_displays_.end(); 658 it != cached_displays_.end();
648 ++it) { 659 ++it) {
649 // Query display if it is in mirror mode or client on the same display. 660 // Query display if it is in mirror mode or client on the same display.
650 if (!IsMirroring() && it->display->display_id() != display_id) 661 if (!IsMirroring() && (*it)->display_id() != display_id)
651 continue; 662 continue;
652 663
653 *link_mask |= it->display->type(); 664 *link_mask |= (*it)->type();
654 switch (it->display->type()) { 665 switch ((*it)->type()) {
655 case DISPLAY_CONNECTION_TYPE_UNKNOWN: 666 case DISPLAY_CONNECTION_TYPE_UNKNOWN:
656 return false; 667 return false;
657 // DisplayPort, DVI, and HDMI all support HDCP. 668 // DisplayPort, DVI, and HDMI all support HDCP.
658 case DISPLAY_CONNECTION_TYPE_DISPLAYPORT: 669 case DISPLAY_CONNECTION_TYPE_DISPLAYPORT:
659 case DISPLAY_CONNECTION_TYPE_DVI: 670 case DISPLAY_CONNECTION_TYPE_DVI:
660 case DISPLAY_CONNECTION_TYPE_HDMI: { 671 case DISPLAY_CONNECTION_TYPE_HDMI: {
661 HDCPState state; 672 HDCPState state;
662 if (!native_display_delegate_->GetHDCPState(*it->display, &state)) 673 if (!native_display_delegate_->GetHDCPState(**it, &state))
663 return false; 674 return false;
664 if (state == HDCP_STATE_ENABLED) 675 if (state == HDCP_STATE_ENABLED)
665 enabled |= CONTENT_PROTECTION_METHOD_HDCP; 676 enabled |= CONTENT_PROTECTION_METHOD_HDCP;
666 else 677 else
667 unfulfilled |= CONTENT_PROTECTION_METHOD_HDCP; 678 unfulfilled |= CONTENT_PROTECTION_METHOD_HDCP;
668 break; 679 break;
669 } 680 }
670 case DISPLAY_CONNECTION_TYPE_INTERNAL: 681 case DISPLAY_CONNECTION_TYPE_INTERNAL:
671 case DISPLAY_CONNECTION_TYPE_VGA: 682 case DISPLAY_CONNECTION_TYPE_VGA:
672 case DISPLAY_CONNECTION_TYPE_NETWORK: 683 case DISPLAY_CONNECTION_TYPE_NETWORK:
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
728 } 739 }
729 740
730 return true; 741 return true;
731 } 742 }
732 743
733 std::vector<ui::ColorCalibrationProfile> 744 std::vector<ui::ColorCalibrationProfile>
734 DisplayConfigurator::GetAvailableColorCalibrationProfiles(int64_t display_id) { 745 DisplayConfigurator::GetAvailableColorCalibrationProfiles(int64_t display_id) {
735 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( 746 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
736 switches::kDisableDisplayColorCalibration)) { 747 switches::kDisableDisplayColorCalibration)) {
737 for (size_t i = 0; i < cached_displays_.size(); ++i) { 748 for (size_t i = 0; i < cached_displays_.size(); ++i) {
738 if (cached_displays_[i].display && 749 if (cached_displays_[i]->display_id() == display_id) {
739 cached_displays_[i].display->display_id() == display_id) {
740 return native_display_delegate_->GetAvailableColorCalibrationProfiles( 750 return native_display_delegate_->GetAvailableColorCalibrationProfiles(
741 *cached_displays_[i].display); 751 *cached_displays_[i]);
742 } 752 }
743 } 753 }
744 } 754 }
745 755
746 return std::vector<ui::ColorCalibrationProfile>(); 756 return std::vector<ui::ColorCalibrationProfile>();
747 } 757 }
748 758
749 bool DisplayConfigurator::SetColorCalibrationProfile( 759 bool DisplayConfigurator::SetColorCalibrationProfile(
750 int64_t display_id, 760 int64_t display_id,
751 ui::ColorCalibrationProfile new_profile) { 761 ui::ColorCalibrationProfile new_profile) {
752 for (size_t i = 0; i < cached_displays_.size(); ++i) { 762 for (size_t i = 0; i < cached_displays_.size(); ++i) {
753 if (cached_displays_[i].display && 763 if (cached_displays_[i]->display_id() == display_id) {
754 cached_displays_[i].display->display_id() == display_id) {
755 return native_display_delegate_->SetColorCalibrationProfile( 764 return native_display_delegate_->SetColorCalibrationProfile(
756 *cached_displays_[i].display, new_profile); 765 *cached_displays_[i], new_profile);
757 } 766 }
758 } 767 }
759 768
760 return false; 769 return false;
761 } 770 }
762 771
763 void DisplayConfigurator::PrepareForExit() { 772 void DisplayConfigurator::PrepareForExit() {
764 configure_display_ = false; 773 configure_display_ = false;
765 } 774 }
766 775
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 requested_display_state_ = MULTIPLE_DISPLAY_STATE_INVALID; 927 requested_display_state_ = MULTIPLE_DISPLAY_STATE_INVALID;
919 928
920 DCHECK(in_progress_configuration_callbacks_.empty()); 929 DCHECK(in_progress_configuration_callbacks_.empty());
921 in_progress_configuration_callbacks_.swap(queued_configuration_callbacks_); 930 in_progress_configuration_callbacks_.swap(queued_configuration_callbacks_);
922 931
923 configuration_task_->Run(); 932 configuration_task_->Run();
924 } 933 }
925 934
926 void DisplayConfigurator::OnConfigured( 935 void DisplayConfigurator::OnConfigured(
927 bool success, 936 bool success,
928 const std::vector<DisplayState>& displays, 937 const std::vector<DisplaySnapshot*>& displays,
929 const gfx::Size& framebuffer_size, 938 const gfx::Size& framebuffer_size,
930 MultipleDisplayState new_display_state, 939 MultipleDisplayState new_display_state,
931 chromeos::DisplayPowerState new_power_state) { 940 chromeos::DisplayPowerState new_power_state) {
932 VLOG(1) << "OnConfigured: success=" << success << " new_display_state=" 941 VLOG(1) << "OnConfigured: success=" << success << " new_display_state="
933 << MultipleDisplayStateToString(new_display_state) 942 << MultipleDisplayStateToString(new_display_state)
934 << " new_power_state=" << DisplayPowerStateToString(new_power_state); 943 << " new_power_state=" << DisplayPowerStateToString(new_power_state);
935 944
936 cached_displays_ = displays; 945 cached_displays_ = displays;
937 if (success) { 946 if (success) {
938 current_display_state_ = new_display_state; 947 current_display_state_ = new_display_state;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1007 FOR_EACH_OBSERVER( 1016 FOR_EACH_OBSERVER(
1008 Observer, observers_, OnDisplayModeChanged(cached_displays_)); 1017 Observer, observers_, OnDisplayModeChanged(cached_displays_));
1009 } else { 1018 } else {
1010 FOR_EACH_OBSERVER( 1019 FOR_EACH_OBSERVER(
1011 Observer, observers_, OnDisplayModeChangeFailed(cached_displays_, 1020 Observer, observers_, OnDisplayModeChangeFailed(cached_displays_,
1012 attempted_state)); 1021 attempted_state));
1013 } 1022 }
1014 } 1023 }
1015 1024
1016 } // namespace ui 1025 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698