Chromium Code Reviews| 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/sys_info.h" | 10 #include "base/sys_info.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 Loading... | |
| 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 Loading... | |
| 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 if (!selected_mode) | |
| 344 selected_mode = display.native_mode(); | |
|
oshima
2015/03/19 19:11:01
nit: return selected_mode ? selected_mode : displa
dnicoara
2015/03/19 19:27:01
Done.
| |
| 345 | |
| 346 return selected_mode; | |
| 347 } | |
| 348 | |
| 344 bool DisplayConfigurator::DisplayLayoutManagerImpl::FindMirrorMode( | 349 bool DisplayConfigurator::DisplayLayoutManagerImpl::FindMirrorMode( |
| 345 DisplayState* internal_display, | 350 DisplayState* internal_display, |
| 346 DisplayState* external_display, | 351 DisplayState* external_display, |
| 347 bool try_panel_fitting, | 352 bool try_panel_fitting, |
| 348 bool preserve_aspect) const { | 353 bool preserve_aspect) const { |
| 349 const DisplayMode* internal_native_info = | 354 const DisplayMode* internal_native_info = |
| 350 internal_display->display->native_mode(); | 355 internal_display->display->native_mode(); |
| 351 const DisplayMode* external_native_info = | 356 const DisplayMode* external_native_info = |
| 352 external_display->display->native_mode(); | 357 external_display->display->native_mode(); |
| 353 if (!internal_native_info || !external_native_info) | 358 if (!internal_native_info || !external_native_info) |
| 354 return false; | 359 return false; |
| 355 | 360 |
| 356 // Check if some external display resolution can be mirrored on internal. | 361 // Check if some external display resolution can be mirrored on internal. |
| 357 // Prefer the modes in the order they're present in DisplaySnapshot, assuming | 362 // 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. | 363 // this is the order in which they look better on the monitor. |
| 359 for (DisplayModeList::const_iterator external_it = | 364 for (auto external_mode : external_display->display->modes()) { |
|
oshima
2015/03/19 19:11:01
const auto* (I'd prefer to have type here, if it f
dnicoara
2015/03/19 19:27:01
Replaced with const auto*
I would have liked the
| |
| 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 = | 365 bool is_native_aspect_ratio = |
| 364 external_native_info->size().width() * external_info.size().height() == | 366 external_native_info->size().width() * external_mode->size().height() == |
| 365 external_native_info->size().height() * external_info.size().width(); | 367 external_native_info->size().height() * external_mode->size().width(); |
| 366 if (preserve_aspect && !is_native_aspect_ratio) | 368 if (preserve_aspect && !is_native_aspect_ratio) |
| 367 continue; // Allow only aspect ratio preserving modes for mirroring. | 369 continue; // Allow only aspect ratio preserving modes for mirroring. |
| 368 | 370 |
| 369 // Try finding an exact match. | 371 // Try finding an exact match. |
| 370 for (DisplayModeList::const_iterator internal_it = | 372 for (auto internal_mode : internal_display->display->modes()) { |
| 371 internal_display->display->modes().begin(); | 373 if (internal_mode->size() == external_mode->size() && |
| 372 internal_it != internal_display->display->modes().end(); | 374 internal_mode->is_interlaced() == external_mode->is_interlaced()) { |
| 373 ++internal_it) { | 375 internal_display->mirror_mode = internal_mode; |
| 374 const DisplayMode& internal_info = **internal_it; | 376 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. | 377 return true; // Mirror mode found. |
| 381 } | 378 } |
| 382 } | 379 } |
| 383 | 380 |
| 384 // Try to create a matching internal display mode by panel fitting. | 381 // Try to create a matching internal display mode by panel fitting. |
| 385 if (try_panel_fitting) { | 382 if (try_panel_fitting) { |
| 386 // We can downscale by 1.125, and upscale indefinitely. Downscaling looks | 383 // We can downscale by 1.125, and upscale indefinitely. Downscaling looks |
| 387 // ugly, so, can fit == can upscale. Also, internal panels don't support | 384 // ugly, so, can fit == can upscale. Also, internal panels don't support |
| 388 // fitting interlaced modes. | 385 // fitting interlaced modes. |
| 389 bool can_fit = internal_native_info->size().width() >= | 386 bool can_fit = internal_native_info->size().width() >= |
| 390 external_info.size().width() && | 387 external_mode->size().width() && |
| 391 internal_native_info->size().height() >= | 388 internal_native_info->size().height() >= |
| 392 external_info.size().height() && | 389 external_mode->size().height() && |
| 393 !external_info.is_interlaced(); | 390 !external_mode->is_interlaced(); |
| 394 if (can_fit) { | 391 if (can_fit) { |
| 395 configurator_->native_display_delegate_->AddMode( | 392 configurator_->native_display_delegate_->AddMode( |
| 396 *internal_display->display, *external_it); | 393 *internal_display->display, external_mode); |
| 397 internal_display->display->add_mode(*external_it); | 394 internal_display->display->add_mode(external_mode); |
| 398 internal_display->mirror_mode = *external_it; | 395 internal_display->mirror_mode = external_mode; |
| 399 external_display->mirror_mode = *external_it; | 396 external_display->mirror_mode = external_mode; |
| 400 return true; // Mirror mode created. | 397 return true; // Mirror mode created. |
| 401 } | 398 } |
| 402 } | 399 } |
| 403 } | 400 } |
| 404 | 401 |
| 405 return false; | 402 return false; |
| 406 } | 403 } |
| 407 | 404 |
| 408 //////////////////////////////////////////////////////////////////////////////// | 405 //////////////////////////////////////////////////////////////////////////////// |
| 409 // DisplayConfigurator implementation | 406 // DisplayConfigurator implementation |
| 410 | 407 |
| 411 // static | 408 // static |
| 412 const DisplayMode* DisplayConfigurator::FindDisplayModeMatchingSize( | 409 const DisplayMode* DisplayConfigurator::FindDisplayModeMatchingSize( |
| 413 const DisplaySnapshot& display, | 410 const DisplaySnapshot& display, |
| 414 const gfx::Size& size) { | 411 const gfx::Size& size) { |
| 415 const DisplayMode* best_mode = NULL; | 412 const DisplayMode* best_mode = NULL; |
| 416 for (DisplayModeList::const_iterator it = display.modes().begin(); | 413 for (const DisplayMode* mode : display.modes()) { |
| 417 it != display.modes().end(); | |
| 418 ++it) { | |
| 419 const DisplayMode* mode = *it; | |
| 420 | |
| 421 if (mode->size() != size) | 414 if (mode->size() != size) |
| 422 continue; | 415 continue; |
| 423 | 416 |
| 424 if (mode == display.native_mode()) { | 417 if (mode == display.native_mode()) { |
| 425 best_mode = mode; | 418 best_mode = mode; |
| 426 break; | 419 break; |
| 427 } | 420 } |
| 428 | 421 |
| 429 if (!best_mode) { | 422 if (!best_mode) { |
| 430 best_mode = mode; | 423 best_mode = mode; |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 548 configuration_task_->Run(); | 541 configuration_task_->Run(); |
| 549 } | 542 } |
| 550 | 543 |
| 551 bool DisplayConfigurator::IsMirroring() const { | 544 bool DisplayConfigurator::IsMirroring() const { |
| 552 return current_display_state_ == MULTIPLE_DISPLAY_STATE_DUAL_MIRROR || | 545 return current_display_state_ == MULTIPLE_DISPLAY_STATE_DUAL_MIRROR || |
| 553 (mirroring_controller_ && | 546 (mirroring_controller_ && |
| 554 mirroring_controller_->SoftwareMirroringEnabled()); | 547 mirroring_controller_->SoftwareMirroringEnabled()); |
| 555 } | 548 } |
| 556 | 549 |
| 557 bool DisplayConfigurator::ApplyProtections(const ContentProtections& requests) { | 550 bool DisplayConfigurator::ApplyProtections(const ContentProtections& requests) { |
| 558 for (DisplayStateList::const_iterator it = cached_displays_.begin(); | 551 for (const DisplaySnapshot* display : cached_displays_) { |
| 559 it != cached_displays_.end(); | |
| 560 ++it) { | |
| 561 uint32_t all_desired = 0; | 552 uint32_t all_desired = 0; |
| 562 | 553 |
| 563 // In mirror mode, protection request of all displays need to be fulfilled. | 554 // 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 | 555 // In non-mirror mode, only request of client's display needs to be |
| 565 // fulfilled. | 556 // fulfilled. |
| 566 ContentProtections::const_iterator request_it; | |
| 567 if (IsMirroring()) { | 557 if (IsMirroring()) { |
| 568 for (request_it = requests.begin(); | 558 for (const auto& protections_pair : requests) |
| 569 request_it != requests.end(); | 559 all_desired |= protections_pair.second; |
| 570 ++request_it) | |
| 571 all_desired |= request_it->second; | |
| 572 } else { | 560 } else { |
| 573 request_it = requests.find((*it)->display_id()); | 561 ContentProtections::const_iterator request_it = |
| 562 requests.find(display->display_id()); | |
| 574 if (request_it != requests.end()) | 563 if (request_it != requests.end()) |
| 575 all_desired = request_it->second; | 564 all_desired = request_it->second; |
| 576 } | 565 } |
| 577 | 566 |
| 578 switch ((*it)->type()) { | 567 switch (display->type()) { |
| 579 case DISPLAY_CONNECTION_TYPE_UNKNOWN: | 568 case DISPLAY_CONNECTION_TYPE_UNKNOWN: |
| 580 return false; | 569 return false; |
| 581 // DisplayPort, DVI, and HDMI all support HDCP. | 570 // DisplayPort, DVI, and HDMI all support HDCP. |
| 582 case DISPLAY_CONNECTION_TYPE_DISPLAYPORT: | 571 case DISPLAY_CONNECTION_TYPE_DISPLAYPORT: |
| 583 case DISPLAY_CONNECTION_TYPE_DVI: | 572 case DISPLAY_CONNECTION_TYPE_DVI: |
| 584 case DISPLAY_CONNECTION_TYPE_HDMI: { | 573 case DISPLAY_CONNECTION_TYPE_HDMI: { |
| 585 HDCPState current_state; | 574 HDCPState current_state; |
| 586 // Need to poll the driver for updates since other applications may | 575 // Need to poll the driver for updates since other applications may |
| 587 // have updated the state. | 576 // have updated the state. |
| 588 if (!native_display_delegate_->GetHDCPState(**it, ¤t_state)) | 577 if (!native_display_delegate_->GetHDCPState(*display, ¤t_state)) |
| 589 return false; | 578 return false; |
| 590 bool current_desired = (current_state != HDCP_STATE_UNDESIRED); | 579 bool current_desired = (current_state != HDCP_STATE_UNDESIRED); |
| 591 bool new_desired = (all_desired & CONTENT_PROTECTION_METHOD_HDCP); | 580 bool new_desired = (all_desired & CONTENT_PROTECTION_METHOD_HDCP); |
| 592 // Don't enable again if HDCP is already active. Some buggy drivers | 581 // Don't enable again if HDCP is already active. Some buggy drivers |
| 593 // may disable and enable if setting "desired" in active state. | 582 // may disable and enable if setting "desired" in active state. |
| 594 if (current_desired != new_desired) { | 583 if (current_desired != new_desired) { |
| 595 HDCPState new_state = | 584 HDCPState new_state = |
| 596 new_desired ? HDCP_STATE_DESIRED : HDCP_STATE_UNDESIRED; | 585 new_desired ? HDCP_STATE_DESIRED : HDCP_STATE_UNDESIRED; |
| 597 if (!native_display_delegate_->SetHDCPState(**it, new_state)) | 586 if (!native_display_delegate_->SetHDCPState(*display, new_state)) |
| 598 return false; | 587 return false; |
| 599 } | 588 } |
| 600 break; | 589 break; |
| 601 } | 590 } |
| 602 case DISPLAY_CONNECTION_TYPE_INTERNAL: | 591 case DISPLAY_CONNECTION_TYPE_INTERNAL: |
| 603 case DISPLAY_CONNECTION_TYPE_VGA: | 592 case DISPLAY_CONNECTION_TYPE_VGA: |
| 604 case DISPLAY_CONNECTION_TYPE_NETWORK: | 593 case DISPLAY_CONNECTION_TYPE_NETWORK: |
| 605 // No protections for these types. Do nothing. | 594 // No protections for these types. Do nothing. |
| 606 break; | 595 break; |
| 607 case DISPLAY_CONNECTION_TYPE_NONE: | 596 case DISPLAY_CONNECTION_TYPE_NONE: |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 619 return kInvalidClientId; | 608 return kInvalidClientId; |
| 620 | 609 |
| 621 return next_display_protection_client_id_++; | 610 return next_display_protection_client_id_++; |
| 622 } | 611 } |
| 623 | 612 |
| 624 void DisplayConfigurator::UnregisterContentProtectionClient( | 613 void DisplayConfigurator::UnregisterContentProtectionClient( |
| 625 ContentProtectionClientId client_id) { | 614 ContentProtectionClientId client_id) { |
| 626 client_protection_requests_.erase(client_id); | 615 client_protection_requests_.erase(client_id); |
| 627 | 616 |
| 628 ContentProtections protections; | 617 ContentProtections protections; |
| 629 for (ProtectionRequests::const_iterator it = | 618 for (const auto& requests_pair : client_protection_requests_) { |
| 630 client_protection_requests_.begin(); | 619 for (const auto& protections_pair : requests_pair.second) { |
| 631 it != client_protection_requests_.end(); | 620 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 } | 621 } |
| 638 } | 622 } |
| 639 | 623 |
| 640 ApplyProtections(protections); | 624 ApplyProtections(protections); |
| 641 } | 625 } |
| 642 | 626 |
| 643 bool DisplayConfigurator::QueryContentProtectionStatus( | 627 bool DisplayConfigurator::QueryContentProtectionStatus( |
| 644 ContentProtectionClientId client_id, | 628 ContentProtectionClientId client_id, |
| 645 int64_t display_id, | 629 int64_t display_id, |
| 646 uint32_t* link_mask, | 630 uint32_t* link_mask, |
| 647 uint32_t* protection_mask) { | 631 uint32_t* protection_mask) { |
| 648 if (!configure_display_ || display_externally_controlled_) | 632 if (!configure_display_ || display_externally_controlled_) |
| 649 return false; | 633 return false; |
| 650 | 634 |
| 651 uint32_t enabled = 0; | 635 uint32_t enabled = 0; |
| 652 uint32_t unfulfilled = 0; | 636 uint32_t unfulfilled = 0; |
| 653 *link_mask = 0; | 637 *link_mask = 0; |
| 654 for (DisplayStateList::const_iterator it = cached_displays_.begin(); | 638 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. | 639 // Query display if it is in mirror mode or client on the same display. |
| 658 if (!IsMirroring() && (*it)->display_id() != display_id) | 640 if (!IsMirroring() && display->display_id() != display_id) |
| 659 continue; | 641 continue; |
| 660 | 642 |
| 661 *link_mask |= (*it)->type(); | 643 *link_mask |= display->type(); |
| 662 switch ((*it)->type()) { | 644 switch (display->type()) { |
| 663 case DISPLAY_CONNECTION_TYPE_UNKNOWN: | 645 case DISPLAY_CONNECTION_TYPE_UNKNOWN: |
| 664 return false; | 646 return false; |
| 665 // DisplayPort, DVI, and HDMI all support HDCP. | 647 // DisplayPort, DVI, and HDMI all support HDCP. |
| 666 case DISPLAY_CONNECTION_TYPE_DISPLAYPORT: | 648 case DISPLAY_CONNECTION_TYPE_DISPLAYPORT: |
| 667 case DISPLAY_CONNECTION_TYPE_DVI: | 649 case DISPLAY_CONNECTION_TYPE_DVI: |
| 668 case DISPLAY_CONNECTION_TYPE_HDMI: { | 650 case DISPLAY_CONNECTION_TYPE_HDMI: { |
| 669 HDCPState state; | 651 HDCPState state; |
| 670 if (!native_display_delegate_->GetHDCPState(**it, &state)) | 652 if (!native_display_delegate_->GetHDCPState(*display, &state)) |
| 671 return false; | 653 return false; |
| 672 if (state == HDCP_STATE_ENABLED) | 654 if (state == HDCP_STATE_ENABLED) |
| 673 enabled |= CONTENT_PROTECTION_METHOD_HDCP; | 655 enabled |= CONTENT_PROTECTION_METHOD_HDCP; |
| 674 else | 656 else |
| 675 unfulfilled |= CONTENT_PROTECTION_METHOD_HDCP; | 657 unfulfilled |= CONTENT_PROTECTION_METHOD_HDCP; |
| 676 break; | 658 break; |
| 677 } | 659 } |
| 678 case DISPLAY_CONNECTION_TYPE_INTERNAL: | 660 case DISPLAY_CONNECTION_TYPE_INTERNAL: |
| 679 case DISPLAY_CONNECTION_TYPE_VGA: | 661 case DISPLAY_CONNECTION_TYPE_VGA: |
| 680 case DISPLAY_CONNECTION_TYPE_NETWORK: | 662 case DISPLAY_CONNECTION_TYPE_NETWORK: |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 700 } | 682 } |
| 701 | 683 |
| 702 bool DisplayConfigurator::EnableContentProtection( | 684 bool DisplayConfigurator::EnableContentProtection( |
| 703 ContentProtectionClientId client_id, | 685 ContentProtectionClientId client_id, |
| 704 int64_t display_id, | 686 int64_t display_id, |
| 705 uint32_t desired_method_mask) { | 687 uint32_t desired_method_mask) { |
| 706 if (!configure_display_ || display_externally_controlled_) | 688 if (!configure_display_ || display_externally_controlled_) |
| 707 return false; | 689 return false; |
| 708 | 690 |
| 709 ContentProtections protections; | 691 ContentProtections protections; |
| 710 for (ProtectionRequests::const_iterator it = | 692 for (const auto& requests_pair : client_protection_requests_) { |
| 711 client_protection_requests_.begin(); | 693 for (const auto& protections_pair : requests_pair.second) { |
| 712 it != client_protection_requests_.end(); | 694 if (requests_pair.first == client_id && |
| 713 ++it) { | 695 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; | 696 continue; |
| 719 protections[it2->first] |= it2->second; | 697 |
| 698 protections[protections_pair.first] |= protections_pair.second; | |
| 720 } | 699 } |
| 721 } | 700 } |
| 722 protections[display_id] |= desired_method_mask; | 701 protections[display_id] |= desired_method_mask; |
| 723 | 702 |
| 724 if (!ApplyProtections(protections)) | 703 if (!ApplyProtections(protections)) |
| 725 return false; | 704 return false; |
| 726 | 705 |
| 727 if (desired_method_mask == CONTENT_PROTECTION_METHOD_NONE) { | 706 if (desired_method_mask == CONTENT_PROTECTION_METHOD_NONE) { |
| 728 if (client_protection_requests_.find(client_id) != | 707 if (client_protection_requests_.find(client_id) != |
| 729 client_protection_requests_.end()) { | 708 client_protection_requests_.end()) { |
| 730 client_protection_requests_[client_id].erase(display_id); | 709 client_protection_requests_[client_id].erase(display_id); |
| 731 if (client_protection_requests_[client_id].size() == 0) | 710 if (client_protection_requests_[client_id].size() == 0) |
| 732 client_protection_requests_.erase(client_id); | 711 client_protection_requests_.erase(client_id); |
| 733 } | 712 } |
| 734 } else { | 713 } else { |
| 735 client_protection_requests_[client_id][display_id] = desired_method_mask; | 714 client_protection_requests_[client_id][display_id] = desired_method_mask; |
| 736 } | 715 } |
| 737 | 716 |
| 738 return true; | 717 return true; |
| 739 } | 718 } |
| 740 | 719 |
| 741 std::vector<ui::ColorCalibrationProfile> | 720 std::vector<ui::ColorCalibrationProfile> |
| 742 DisplayConfigurator::GetAvailableColorCalibrationProfiles(int64_t display_id) { | 721 DisplayConfigurator::GetAvailableColorCalibrationProfiles(int64_t display_id) { |
| 743 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 722 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 744 switches::kDisableDisplayColorCalibration)) { | 723 switches::kDisableDisplayColorCalibration)) { |
| 745 for (size_t i = 0; i < cached_displays_.size(); ++i) { | 724 for (const DisplaySnapshot* display : cached_displays_) { |
| 746 if (cached_displays_[i]->display_id() == display_id) { | 725 if (display->display_id() == display_id) { |
| 747 return native_display_delegate_->GetAvailableColorCalibrationProfiles( | 726 return native_display_delegate_->GetAvailableColorCalibrationProfiles( |
| 748 *cached_displays_[i]); | 727 *display); |
| 749 } | 728 } |
| 750 } | 729 } |
| 751 } | 730 } |
| 752 | 731 |
| 753 return std::vector<ui::ColorCalibrationProfile>(); | 732 return std::vector<ui::ColorCalibrationProfile>(); |
| 754 } | 733 } |
| 755 | 734 |
| 756 bool DisplayConfigurator::SetColorCalibrationProfile( | 735 bool DisplayConfigurator::SetColorCalibrationProfile( |
| 757 int64_t display_id, | 736 int64_t display_id, |
| 758 ui::ColorCalibrationProfile new_profile) { | 737 ui::ColorCalibrationProfile new_profile) { |
| 759 for (size_t i = 0; i < cached_displays_.size(); ++i) { | 738 for (const DisplaySnapshot* display : cached_displays_) { |
| 760 if (cached_displays_[i]->display_id() == display_id) { | 739 if (display->display_id() == display_id) { |
| 761 return native_display_delegate_->SetColorCalibrationProfile( | 740 return native_display_delegate_->SetColorCalibrationProfile(*display, |
| 762 *cached_displays_[i], new_profile); | 741 new_profile); |
| 763 } | 742 } |
| 764 } | 743 } |
| 765 | 744 |
| 766 return false; | 745 return false; |
| 767 } | 746 } |
| 768 | 747 |
| 769 void DisplayConfigurator::PrepareForExit() { | 748 void DisplayConfigurator::PrepareForExit() { |
| 770 configure_display_ = false; | 749 configure_display_ = false; |
| 771 } | 750 } |
| 772 | 751 |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1013 FOR_EACH_OBSERVER( | 992 FOR_EACH_OBSERVER( |
| 1014 Observer, observers_, OnDisplayModeChanged(cached_displays_)); | 993 Observer, observers_, OnDisplayModeChanged(cached_displays_)); |
| 1015 } else { | 994 } else { |
| 1016 FOR_EACH_OBSERVER( | 995 FOR_EACH_OBSERVER( |
| 1017 Observer, observers_, OnDisplayModeChangeFailed(cached_displays_, | 996 Observer, observers_, OnDisplayModeChangeFailed(cached_displays_, |
| 1018 attempted_state)); | 997 attempted_state)); |
| 1019 } | 998 } |
| 1020 } | 999 } |
| 1021 | 1000 |
| 1022 } // namespace ui | 1001 } // namespace ui |
| OLD | NEW |