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

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

Issue 1026443002: Update DisplayConfigurator to use c++11 style for-loops (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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 gfx::Size* framebuffer_size) const override; 83 gfx::Size* framebuffer_size) const override;
84 84
85 private: 85 private:
86 // Parses the |displays| into a list of DisplayStates. This effectively adds 86 // Parses the |displays| into a list of DisplayStates. This effectively adds
87 // |mirror_mode| and |selected_mode| to the returned results. 87 // |mirror_mode| and |selected_mode| to the returned results.
88 // TODO(dnicoara): Break this into GetSelectedMode() and GetMirrorMode() and 88 // TODO(dnicoara): Break this into GetSelectedMode() and GetMirrorMode() and
89 // remove DisplayState. 89 // remove DisplayState.
90 std::vector<DisplayState> ParseDisplays( 90 std::vector<DisplayState> ParseDisplays(
91 const std::vector<DisplaySnapshot*>& displays) const; 91 const std::vector<DisplaySnapshot*>& displays) const;
92 92
93 const DisplayMode* GetUserSelectedMode(const DisplaySnapshot& display) const;
94
93 // Helper method for ParseDisplays() that initializes the passed-in 95 // Helper method for ParseDisplays() that initializes the passed-in
94 // displays' |mirror_mode| fields by looking for a mode in |internal_display| 96 // displays' |mirror_mode| fields by looking for a mode in |internal_display|
95 // and |external_display| having the same resolution. Returns false if a 97 // and |external_display| having the same resolution. Returns false if a
96 // shared mode wasn't found or created. 98 // shared mode wasn't found or created.
97 // 99 //
98 // |try_panel_fitting| allows creating a panel-fitting mode for 100 // |try_panel_fitting| allows creating a panel-fitting mode for
99 // |internal_display| instead of only searching for a matching mode (note that 101 // |internal_display| instead of only searching for a matching mode (note that
100 // it may lead to a crash if |internal_display| is not capable of panel 102 // it may lead to a crash if |internal_display| is not capable of panel
101 // fitting). 103 // fitting).
102 // 104 //
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 return configurator_->current_power_state_; 143 return configurator_->current_power_state_;
142 } 144 }
143 145
144 std::vector<DisplayState> 146 std::vector<DisplayState>
145 DisplayConfigurator::DisplayLayoutManagerImpl::ParseDisplays( 147 DisplayConfigurator::DisplayLayoutManagerImpl::ParseDisplays(
146 const std::vector<DisplaySnapshot*>& snapshots) const { 148 const std::vector<DisplaySnapshot*>& snapshots) const {
147 std::vector<DisplayState> cached_displays; 149 std::vector<DisplayState> cached_displays;
148 for (auto snapshot : snapshots) { 150 for (auto snapshot : snapshots) {
149 DisplayState display_state; 151 DisplayState display_state;
150 display_state.display = snapshot; 152 display_state.display = snapshot;
153 display_state.selected_mode = GetUserSelectedMode(*snapshot);
151 cached_displays.push_back(display_state); 154 cached_displays.push_back(display_state);
152 } 155 }
153 156
154 // Set |selected_mode| fields.
155 for (size_t i = 0; i < cached_displays.size(); ++i) {
156 DisplayState* display_state = &cached_displays[i];
157 gfx::Size size;
158 if (GetStateController() &&
159 GetStateController()->GetResolutionForDisplayId(
160 display_state->display->display_id(), &size)) {
161 display_state->selected_mode =
162 FindDisplayModeMatchingSize(*display_state->display, size);
163 }
164
165 // Fall back to native mode.
166 if (!display_state->selected_mode)
167 display_state->selected_mode = display_state->display->native_mode();
168 }
169
170 // Set |mirror_mode| fields. 157 // Set |mirror_mode| fields.
171 if (cached_displays.size() == 2) { 158 if (cached_displays.size() == 2) {
172 bool one_is_internal = 159 bool one_is_internal =
173 cached_displays[0].display->type() == DISPLAY_CONNECTION_TYPE_INTERNAL; 160 cached_displays[0].display->type() == DISPLAY_CONNECTION_TYPE_INTERNAL;
174 bool two_is_internal = 161 bool two_is_internal =
175 cached_displays[1].display->type() == DISPLAY_CONNECTION_TYPE_INTERNAL; 162 cached_displays[1].display->type() == DISPLAY_CONNECTION_TYPE_INTERNAL;
176 int internal_displays = 163 int internal_displays =
177 (one_is_internal ? 1 : 0) + (two_is_internal ? 1 : 0); 164 (one_is_internal ? 1 : 0) + (two_is_internal ? 1 : 0);
178 DCHECK_LT(internal_displays, 2); 165 DCHECK_LT(internal_displays, 2);
179 LOG_IF(WARNING, internal_displays >= 2) 166 LOG_IF(WARNING, internal_displays >= 2)
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 mode_info->size().height()); 321 mode_info->size().height());
335 } 322 }
336 break; 323 break;
337 } 324 }
338 } 325 }
339 326
340 *framebuffer_size = size; 327 *framebuffer_size = size;
341 return true; 328 return true;
342 } 329 }
343 330
331 const DisplayMode*
332 DisplayConfigurator::DisplayLayoutManagerImpl::GetUserSelectedMode(
333 const DisplaySnapshot& display) const {
334 gfx::Size size;
335 const DisplayMode* selected_mode = nullptr;
336 if (GetStateController() &&
337 GetStateController()->GetResolutionForDisplayId(display.display_id(),
338 &size)) {
339 selected_mode = FindDisplayModeMatchingSize(display, size);
340 }
341
342 // Fall back to native mode.
343 return selected_mode ? selected_mode : display.native_mode();
344 }
345
344 bool DisplayConfigurator::DisplayLayoutManagerImpl::FindMirrorMode( 346 bool DisplayConfigurator::DisplayLayoutManagerImpl::FindMirrorMode(
345 DisplayState* internal_display, 347 DisplayState* internal_display,
346 DisplayState* external_display, 348 DisplayState* external_display,
347 bool try_panel_fitting, 349 bool try_panel_fitting,
348 bool preserve_aspect) const { 350 bool preserve_aspect) const {
349 const DisplayMode* internal_native_info = 351 const DisplayMode* internal_native_info =
350 internal_display->display->native_mode(); 352 internal_display->display->native_mode();
351 const DisplayMode* external_native_info = 353 const DisplayMode* external_native_info =
352 external_display->display->native_mode(); 354 external_display->display->native_mode();
353 if (!internal_native_info || !external_native_info) 355 if (!internal_native_info || !external_native_info)
354 return false; 356 return false;
355 357
356 // Check if some external display resolution can be mirrored on internal. 358 // Check if some external display resolution can be mirrored on internal.
357 // Prefer the modes in the order they're present in DisplaySnapshot, assuming 359 // Prefer the modes in the order they're present in DisplaySnapshot, assuming
358 // this is the order in which they look better on the monitor. 360 // this is the order in which they look better on the monitor.
359 for (DisplayModeList::const_iterator external_it = 361 for (const auto* external_mode : external_display->display->modes()) {
360 external_display->display->modes().begin();
361 external_it != external_display->display->modes().end(); ++external_it) {
362 const DisplayMode& external_info = **external_it;
363 bool is_native_aspect_ratio = 362 bool is_native_aspect_ratio =
364 external_native_info->size().width() * external_info.size().height() == 363 external_native_info->size().width() * external_mode->size().height() ==
365 external_native_info->size().height() * external_info.size().width(); 364 external_native_info->size().height() * external_mode->size().width();
366 if (preserve_aspect && !is_native_aspect_ratio) 365 if (preserve_aspect && !is_native_aspect_ratio)
367 continue; // Allow only aspect ratio preserving modes for mirroring. 366 continue; // Allow only aspect ratio preserving modes for mirroring.
368 367
369 // Try finding an exact match. 368 // Try finding an exact match.
370 for (DisplayModeList::const_iterator internal_it = 369 for (const auto* internal_mode : internal_display->display->modes()) {
371 internal_display->display->modes().begin(); 370 if (internal_mode->size() == external_mode->size() &&
372 internal_it != internal_display->display->modes().end(); 371 internal_mode->is_interlaced() == external_mode->is_interlaced()) {
373 ++internal_it) { 372 internal_display->mirror_mode = internal_mode;
374 const DisplayMode& internal_info = **internal_it; 373 external_display->mirror_mode = external_mode;
375 if (internal_info.size().width() == external_info.size().width() &&
376 internal_info.size().height() == external_info.size().height() &&
377 internal_info.is_interlaced() == external_info.is_interlaced()) {
378 internal_display->mirror_mode = *internal_it;
379 external_display->mirror_mode = *external_it;
380 return true; // Mirror mode found. 374 return true; // Mirror mode found.
381 } 375 }
382 } 376 }
383 377
384 // Try to create a matching internal display mode by panel fitting. 378 // Try to create a matching internal display mode by panel fitting.
385 if (try_panel_fitting) { 379 if (try_panel_fitting) {
386 // We can downscale by 1.125, and upscale indefinitely. Downscaling looks 380 // We can downscale by 1.125, and upscale indefinitely. Downscaling looks
387 // ugly, so, can fit == can upscale. Also, internal panels don't support 381 // ugly, so, can fit == can upscale. Also, internal panels don't support
388 // fitting interlaced modes. 382 // fitting interlaced modes.
389 bool can_fit = internal_native_info->size().width() >= 383 bool can_fit = internal_native_info->size().width() >=
390 external_info.size().width() && 384 external_mode->size().width() &&
391 internal_native_info->size().height() >= 385 internal_native_info->size().height() >=
392 external_info.size().height() && 386 external_mode->size().height() &&
393 !external_info.is_interlaced(); 387 !external_mode->is_interlaced();
394 if (can_fit) { 388 if (can_fit) {
395 configurator_->native_display_delegate_->AddMode( 389 configurator_->native_display_delegate_->AddMode(
396 *internal_display->display, *external_it); 390 *internal_display->display, external_mode);
397 internal_display->display->add_mode(*external_it); 391 internal_display->display->add_mode(external_mode);
398 internal_display->mirror_mode = *external_it; 392 internal_display->mirror_mode = external_mode;
399 external_display->mirror_mode = *external_it; 393 external_display->mirror_mode = external_mode;
400 return true; // Mirror mode created. 394 return true; // Mirror mode created.
401 } 395 }
402 } 396 }
403 } 397 }
404 398
405 return false; 399 return false;
406 } 400 }
407 401
408 //////////////////////////////////////////////////////////////////////////////// 402 ////////////////////////////////////////////////////////////////////////////////
409 // DisplayConfigurator implementation 403 // DisplayConfigurator implementation
410 404
411 // static 405 // static
412 const DisplayMode* DisplayConfigurator::FindDisplayModeMatchingSize( 406 const DisplayMode* DisplayConfigurator::FindDisplayModeMatchingSize(
413 const DisplaySnapshot& display, 407 const DisplaySnapshot& display,
414 const gfx::Size& size) { 408 const gfx::Size& size) {
415 const DisplayMode* best_mode = NULL; 409 const DisplayMode* best_mode = NULL;
416 for (DisplayModeList::const_iterator it = display.modes().begin(); 410 for (const DisplayMode* mode : display.modes()) {
417 it != display.modes().end();
418 ++it) {
419 const DisplayMode* mode = *it;
420
421 if (mode->size() != size) 411 if (mode->size() != size)
422 continue; 412 continue;
423 413
424 if (mode == display.native_mode()) { 414 if (mode == display.native_mode()) {
425 best_mode = mode; 415 best_mode = mode;
426 break; 416 break;
427 } 417 }
428 418
429 if (!best_mode) { 419 if (!best_mode) {
430 best_mode = mode; 420 best_mode = mode;
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 configuration_task_->Run(); 538 configuration_task_->Run();
549 } 539 }
550 540
551 bool DisplayConfigurator::IsMirroring() const { 541 bool DisplayConfigurator::IsMirroring() const {
552 return current_display_state_ == MULTIPLE_DISPLAY_STATE_DUAL_MIRROR || 542 return current_display_state_ == MULTIPLE_DISPLAY_STATE_DUAL_MIRROR ||
553 (mirroring_controller_ && 543 (mirroring_controller_ &&
554 mirroring_controller_->SoftwareMirroringEnabled()); 544 mirroring_controller_->SoftwareMirroringEnabled());
555 } 545 }
556 546
557 bool DisplayConfigurator::ApplyProtections(const ContentProtections& requests) { 547 bool DisplayConfigurator::ApplyProtections(const ContentProtections& requests) {
558 for (DisplayStateList::const_iterator it = cached_displays_.begin(); 548 for (const DisplaySnapshot* display : cached_displays_) {
559 it != cached_displays_.end();
560 ++it) {
561 uint32_t all_desired = 0; 549 uint32_t all_desired = 0;
562 550
563 // In mirror mode, protection request of all displays need to be fulfilled. 551 // In mirror mode, protection request of all displays need to be fulfilled.
564 // In non-mirror mode, only request of client's display needs to be 552 // In non-mirror mode, only request of client's display needs to be
565 // fulfilled. 553 // fulfilled.
566 ContentProtections::const_iterator request_it;
567 if (IsMirroring()) { 554 if (IsMirroring()) {
568 for (request_it = requests.begin(); 555 for (const auto& protections_pair : requests)
569 request_it != requests.end(); 556 all_desired |= protections_pair.second;
570 ++request_it)
571 all_desired |= request_it->second;
572 } else { 557 } else {
573 request_it = requests.find((*it)->display_id()); 558 ContentProtections::const_iterator request_it =
559 requests.find(display->display_id());
574 if (request_it != requests.end()) 560 if (request_it != requests.end())
575 all_desired = request_it->second; 561 all_desired = request_it->second;
576 } 562 }
577 563
578 switch ((*it)->type()) { 564 switch (display->type()) {
579 case DISPLAY_CONNECTION_TYPE_UNKNOWN: 565 case DISPLAY_CONNECTION_TYPE_UNKNOWN:
580 return false; 566 return false;
581 // DisplayPort, DVI, and HDMI all support HDCP. 567 // DisplayPort, DVI, and HDMI all support HDCP.
582 case DISPLAY_CONNECTION_TYPE_DISPLAYPORT: 568 case DISPLAY_CONNECTION_TYPE_DISPLAYPORT:
583 case DISPLAY_CONNECTION_TYPE_DVI: 569 case DISPLAY_CONNECTION_TYPE_DVI:
584 case DISPLAY_CONNECTION_TYPE_HDMI: { 570 case DISPLAY_CONNECTION_TYPE_HDMI: {
585 HDCPState current_state; 571 HDCPState current_state;
586 // Need to poll the driver for updates since other applications may 572 // Need to poll the driver for updates since other applications may
587 // have updated the state. 573 // have updated the state.
588 if (!native_display_delegate_->GetHDCPState(**it, &current_state)) 574 if (!native_display_delegate_->GetHDCPState(*display, &current_state))
589 return false; 575 return false;
590 bool current_desired = (current_state != HDCP_STATE_UNDESIRED); 576 bool current_desired = (current_state != HDCP_STATE_UNDESIRED);
591 bool new_desired = (all_desired & CONTENT_PROTECTION_METHOD_HDCP); 577 bool new_desired = (all_desired & CONTENT_PROTECTION_METHOD_HDCP);
592 // Don't enable again if HDCP is already active. Some buggy drivers 578 // Don't enable again if HDCP is already active. Some buggy drivers
593 // may disable and enable if setting "desired" in active state. 579 // may disable and enable if setting "desired" in active state.
594 if (current_desired != new_desired) { 580 if (current_desired != new_desired) {
595 HDCPState new_state = 581 HDCPState new_state =
596 new_desired ? HDCP_STATE_DESIRED : HDCP_STATE_UNDESIRED; 582 new_desired ? HDCP_STATE_DESIRED : HDCP_STATE_UNDESIRED;
597 if (!native_display_delegate_->SetHDCPState(**it, new_state)) 583 if (!native_display_delegate_->SetHDCPState(*display, new_state))
598 return false; 584 return false;
599 } 585 }
600 break; 586 break;
601 } 587 }
602 case DISPLAY_CONNECTION_TYPE_INTERNAL: 588 case DISPLAY_CONNECTION_TYPE_INTERNAL:
603 case DISPLAY_CONNECTION_TYPE_VGA: 589 case DISPLAY_CONNECTION_TYPE_VGA:
604 case DISPLAY_CONNECTION_TYPE_NETWORK: 590 case DISPLAY_CONNECTION_TYPE_NETWORK:
605 // No protections for these types. Do nothing. 591 // No protections for these types. Do nothing.
606 break; 592 break;
607 case DISPLAY_CONNECTION_TYPE_NONE: 593 case DISPLAY_CONNECTION_TYPE_NONE:
(...skipping 11 matching lines...) Expand all
619 return kInvalidClientId; 605 return kInvalidClientId;
620 606
621 return next_display_protection_client_id_++; 607 return next_display_protection_client_id_++;
622 } 608 }
623 609
624 void DisplayConfigurator::UnregisterContentProtectionClient( 610 void DisplayConfigurator::UnregisterContentProtectionClient(
625 ContentProtectionClientId client_id) { 611 ContentProtectionClientId client_id) {
626 client_protection_requests_.erase(client_id); 612 client_protection_requests_.erase(client_id);
627 613
628 ContentProtections protections; 614 ContentProtections protections;
629 for (ProtectionRequests::const_iterator it = 615 for (const auto& requests_pair : client_protection_requests_) {
630 client_protection_requests_.begin(); 616 for (const auto& protections_pair : requests_pair.second) {
631 it != client_protection_requests_.end(); 617 protections[protections_pair.first] |= protections_pair.second;
632 ++it) {
633 for (ContentProtections::const_iterator it2 = it->second.begin();
634 it2 != it->second.end();
635 ++it2) {
636 protections[it2->first] |= it2->second;
637 } 618 }
638 } 619 }
639 620
640 ApplyProtections(protections); 621 ApplyProtections(protections);
641 } 622 }
642 623
643 bool DisplayConfigurator::QueryContentProtectionStatus( 624 bool DisplayConfigurator::QueryContentProtectionStatus(
644 ContentProtectionClientId client_id, 625 ContentProtectionClientId client_id,
645 int64_t display_id, 626 int64_t display_id,
646 uint32_t* link_mask, 627 uint32_t* link_mask,
647 uint32_t* protection_mask) { 628 uint32_t* protection_mask) {
648 if (!configure_display_ || display_externally_controlled_) 629 if (!configure_display_ || display_externally_controlled_)
649 return false; 630 return false;
650 631
651 uint32_t enabled = 0; 632 uint32_t enabled = 0;
652 uint32_t unfulfilled = 0; 633 uint32_t unfulfilled = 0;
653 *link_mask = 0; 634 *link_mask = 0;
654 for (DisplayStateList::const_iterator it = cached_displays_.begin(); 635 for (const DisplaySnapshot* display : cached_displays_) {
655 it != cached_displays_.end();
656 ++it) {
657 // Query display if it is in mirror mode or client on the same display. 636 // Query display if it is in mirror mode or client on the same display.
658 if (!IsMirroring() && (*it)->display_id() != display_id) 637 if (!IsMirroring() && display->display_id() != display_id)
659 continue; 638 continue;
660 639
661 *link_mask |= (*it)->type(); 640 *link_mask |= display->type();
662 switch ((*it)->type()) { 641 switch (display->type()) {
663 case DISPLAY_CONNECTION_TYPE_UNKNOWN: 642 case DISPLAY_CONNECTION_TYPE_UNKNOWN:
664 return false; 643 return false;
665 // DisplayPort, DVI, and HDMI all support HDCP. 644 // DisplayPort, DVI, and HDMI all support HDCP.
666 case DISPLAY_CONNECTION_TYPE_DISPLAYPORT: 645 case DISPLAY_CONNECTION_TYPE_DISPLAYPORT:
667 case DISPLAY_CONNECTION_TYPE_DVI: 646 case DISPLAY_CONNECTION_TYPE_DVI:
668 case DISPLAY_CONNECTION_TYPE_HDMI: { 647 case DISPLAY_CONNECTION_TYPE_HDMI: {
669 HDCPState state; 648 HDCPState state;
670 if (!native_display_delegate_->GetHDCPState(**it, &state)) 649 if (!native_display_delegate_->GetHDCPState(*display, &state))
671 return false; 650 return false;
672 if (state == HDCP_STATE_ENABLED) 651 if (state == HDCP_STATE_ENABLED)
673 enabled |= CONTENT_PROTECTION_METHOD_HDCP; 652 enabled |= CONTENT_PROTECTION_METHOD_HDCP;
674 else 653 else
675 unfulfilled |= CONTENT_PROTECTION_METHOD_HDCP; 654 unfulfilled |= CONTENT_PROTECTION_METHOD_HDCP;
676 break; 655 break;
677 } 656 }
678 case DISPLAY_CONNECTION_TYPE_INTERNAL: 657 case DISPLAY_CONNECTION_TYPE_INTERNAL:
679 case DISPLAY_CONNECTION_TYPE_VGA: 658 case DISPLAY_CONNECTION_TYPE_VGA:
680 case DISPLAY_CONNECTION_TYPE_NETWORK: 659 case DISPLAY_CONNECTION_TYPE_NETWORK:
(...skipping 19 matching lines...) Expand all
700 } 679 }
701 680
702 bool DisplayConfigurator::EnableContentProtection( 681 bool DisplayConfigurator::EnableContentProtection(
703 ContentProtectionClientId client_id, 682 ContentProtectionClientId client_id,
704 int64_t display_id, 683 int64_t display_id,
705 uint32_t desired_method_mask) { 684 uint32_t desired_method_mask) {
706 if (!configure_display_ || display_externally_controlled_) 685 if (!configure_display_ || display_externally_controlled_)
707 return false; 686 return false;
708 687
709 ContentProtections protections; 688 ContentProtections protections;
710 for (ProtectionRequests::const_iterator it = 689 for (const auto& requests_pair : client_protection_requests_) {
711 client_protection_requests_.begin(); 690 for (const auto& protections_pair : requests_pair.second) {
712 it != client_protection_requests_.end(); 691 if (requests_pair.first == client_id &&
713 ++it) { 692 protections_pair.first == display_id)
714 for (ContentProtections::const_iterator it2 = it->second.begin();
715 it2 != it->second.end();
716 ++it2) {
717 if (it->first == client_id && it2->first == display_id)
718 continue; 693 continue;
719 protections[it2->first] |= it2->second; 694
695 protections[protections_pair.first] |= protections_pair.second;
720 } 696 }
721 } 697 }
722 protections[display_id] |= desired_method_mask; 698 protections[display_id] |= desired_method_mask;
723 699
724 if (!ApplyProtections(protections)) 700 if (!ApplyProtections(protections))
725 return false; 701 return false;
726 702
727 if (desired_method_mask == CONTENT_PROTECTION_METHOD_NONE) { 703 if (desired_method_mask == CONTENT_PROTECTION_METHOD_NONE) {
728 if (client_protection_requests_.find(client_id) != 704 if (client_protection_requests_.find(client_id) !=
729 client_protection_requests_.end()) { 705 client_protection_requests_.end()) {
730 client_protection_requests_[client_id].erase(display_id); 706 client_protection_requests_[client_id].erase(display_id);
731 if (client_protection_requests_[client_id].size() == 0) 707 if (client_protection_requests_[client_id].size() == 0)
732 client_protection_requests_.erase(client_id); 708 client_protection_requests_.erase(client_id);
733 } 709 }
734 } else { 710 } else {
735 client_protection_requests_[client_id][display_id] = desired_method_mask; 711 client_protection_requests_[client_id][display_id] = desired_method_mask;
736 } 712 }
737 713
738 return true; 714 return true;
739 } 715 }
740 716
741 std::vector<ui::ColorCalibrationProfile> 717 std::vector<ui::ColorCalibrationProfile>
742 DisplayConfigurator::GetAvailableColorCalibrationProfiles(int64_t display_id) { 718 DisplayConfigurator::GetAvailableColorCalibrationProfiles(int64_t display_id) {
743 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( 719 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
744 switches::kDisableDisplayColorCalibration)) { 720 switches::kDisableDisplayColorCalibration)) {
745 for (size_t i = 0; i < cached_displays_.size(); ++i) { 721 for (const DisplaySnapshot* display : cached_displays_) {
746 if (cached_displays_[i]->display_id() == display_id) { 722 if (display->display_id() == display_id) {
747 return native_display_delegate_->GetAvailableColorCalibrationProfiles( 723 return native_display_delegate_->GetAvailableColorCalibrationProfiles(
748 *cached_displays_[i]); 724 *display);
749 } 725 }
750 } 726 }
751 } 727 }
752 728
753 return std::vector<ui::ColorCalibrationProfile>(); 729 return std::vector<ui::ColorCalibrationProfile>();
754 } 730 }
755 731
756 bool DisplayConfigurator::SetColorCalibrationProfile( 732 bool DisplayConfigurator::SetColorCalibrationProfile(
757 int64_t display_id, 733 int64_t display_id,
758 ui::ColorCalibrationProfile new_profile) { 734 ui::ColorCalibrationProfile new_profile) {
759 for (size_t i = 0; i < cached_displays_.size(); ++i) { 735 for (const DisplaySnapshot* display : cached_displays_) {
760 if (cached_displays_[i]->display_id() == display_id) { 736 if (display->display_id() == display_id) {
761 return native_display_delegate_->SetColorCalibrationProfile( 737 return native_display_delegate_->SetColorCalibrationProfile(*display,
762 *cached_displays_[i], new_profile); 738 new_profile);
763 } 739 }
764 } 740 }
765 741
766 return false; 742 return false;
767 } 743 }
768 744
769 void DisplayConfigurator::PrepareForExit() { 745 void DisplayConfigurator::PrepareForExit() {
770 configure_display_ = false; 746 configure_display_ = false;
771 } 747 }
772 748
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
1013 FOR_EACH_OBSERVER( 989 FOR_EACH_OBSERVER(
1014 Observer, observers_, OnDisplayModeChanged(cached_displays_)); 990 Observer, observers_, OnDisplayModeChanged(cached_displays_));
1015 } else { 991 } else {
1016 FOR_EACH_OBSERVER( 992 FOR_EACH_OBSERVER(
1017 Observer, observers_, OnDisplayModeChangeFailed(cached_displays_, 993 Observer, observers_, OnDisplayModeChangeFailed(cached_displays_,
1018 attempted_state)); 994 attempted_state));
1019 } 995 }
1020 } 996 }
1021 997
1022 } // namespace ui 998 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698