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" |
11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
12 #include "ui/display/chromeos/apply_content_protection_task.h" | 12 #include "ui/display/chromeos/apply_content_protection_task.h" |
13 #include "ui/display/chromeos/display_layout_manager.h" | 13 #include "ui/display/chromeos/display_layout_manager.h" |
14 #include "ui/display/chromeos/display_snapshot_virtual.h" | |
14 #include "ui/display/chromeos/display_util.h" | 15 #include "ui/display/chromeos/display_util.h" |
15 #include "ui/display/chromeos/update_display_configuration_task.h" | 16 #include "ui/display/chromeos/update_display_configuration_task.h" |
16 #include "ui/display/display_switches.h" | 17 #include "ui/display/display_switches.h" |
17 #include "ui/display/types/display_mode.h" | 18 #include "ui/display/types/display_mode.h" |
18 #include "ui/display/types/display_snapshot.h" | 19 #include "ui/display/types/display_snapshot.h" |
19 #include "ui/display/types/native_display_delegate.h" | 20 #include "ui/display/types/native_display_delegate.h" |
21 #include "ui/display/util/display_util.h" | |
22 #include "ui/gfx/display.h" | |
20 | 23 |
21 namespace ui { | 24 namespace ui { |
22 | 25 |
23 namespace { | 26 namespace { |
24 | 27 |
25 typedef std::vector<const DisplayMode*> DisplayModeList; | 28 typedef std::vector<const DisplayMode*> DisplayModeList; |
26 | 29 |
27 // The delay to perform configuration after RRNotify. See the comment for | 30 // The delay to perform configuration after RRNotify. See the comment for |
28 // |configure_timer_|. | 31 // |configure_timer_|. |
29 const int kConfigureDelayMs = 500; | 32 const int kConfigureDelayMs = 500; |
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
654 enable_protection_callbacks_.pop(); | 657 enable_protection_callbacks_.pop(); |
655 | 658 |
656 if (!content_protection_tasks_.empty()) | 659 if (!content_protection_tasks_.empty()) |
657 content_protection_tasks_.front().Run(); | 660 content_protection_tasks_.front().Run(); |
658 } | 661 } |
659 | 662 |
660 void DisplayConfigurator::QueryContentProtectionStatus( | 663 void DisplayConfigurator::QueryContentProtectionStatus( |
661 ContentProtectionClientId client_id, | 664 ContentProtectionClientId client_id, |
662 int64_t display_id, | 665 int64_t display_id, |
663 const QueryProtectionCallback& callback) { | 666 const QueryProtectionCallback& callback) { |
667 // Exclude virtual displays. | |
oshima
2015/12/02 20:34:27
please mention the possibility to be recaptured.
robert.bradford
2015/12/03 18:44:57
Done.
| |
668 for (const DisplaySnapshot* display : cached_displays_) { | |
669 if (display->display_id() == display_id && | |
670 !IsPhysicalDisplayType(display->type())) { | |
671 callback.Run(QueryProtectionResponse()); | |
672 return; | |
673 } | |
674 } | |
675 | |
664 if (!configure_display_ || display_externally_controlled_) { | 676 if (!configure_display_ || display_externally_controlled_) { |
665 callback.Run(QueryProtectionResponse()); | 677 callback.Run(QueryProtectionResponse()); |
666 return; | 678 return; |
667 } | 679 } |
668 | 680 |
669 query_protection_callbacks_.push(callback); | 681 query_protection_callbacks_.push(callback); |
670 QueryContentProtectionTask* task = new QueryContentProtectionTask( | 682 QueryContentProtectionTask* task = new QueryContentProtectionTask( |
671 layout_manager_.get(), native_display_delegate_.get(), display_id, | 683 layout_manager_.get(), native_display_delegate_.get(), display_id, |
672 base::Bind(&DisplayConfigurator::OnContentProtectionQueried, | 684 base::Bind(&DisplayConfigurator::OnContentProtectionQueried, |
673 weak_ptr_factory_.GetWeakPtr(), client_id, display_id)); | 685 weak_ptr_factory_.GetWeakPtr(), client_id, display_id)); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
772 callback.Run(true); | 784 callback.Run(true); |
773 if (!content_protection_tasks_.empty()) | 785 if (!content_protection_tasks_.empty()) |
774 content_protection_tasks_.front().Run(); | 786 content_protection_tasks_.front().Run(); |
775 } | 787 } |
776 | 788 |
777 std::vector<ui::ColorCalibrationProfile> | 789 std::vector<ui::ColorCalibrationProfile> |
778 DisplayConfigurator::GetAvailableColorCalibrationProfiles(int64_t display_id) { | 790 DisplayConfigurator::GetAvailableColorCalibrationProfiles(int64_t display_id) { |
779 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 791 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
780 switches::kDisableDisplayColorCalibration)) { | 792 switches::kDisableDisplayColorCalibration)) { |
781 for (const DisplaySnapshot* display : cached_displays_) { | 793 for (const DisplaySnapshot* display : cached_displays_) { |
782 if (display->display_id() == display_id) { | 794 if (display->display_id() == display_id && |
795 IsPhysicalDisplayType(display->type())) { | |
783 return native_display_delegate_->GetAvailableColorCalibrationProfiles( | 796 return native_display_delegate_->GetAvailableColorCalibrationProfiles( |
784 *display); | 797 *display); |
785 } | 798 } |
786 } | 799 } |
787 } | 800 } |
788 | 801 |
789 return std::vector<ui::ColorCalibrationProfile>(); | 802 return std::vector<ui::ColorCalibrationProfile>(); |
790 } | 803 } |
791 | 804 |
792 bool DisplayConfigurator::SetColorCalibrationProfile( | 805 bool DisplayConfigurator::SetColorCalibrationProfile( |
793 int64_t display_id, | 806 int64_t display_id, |
794 ui::ColorCalibrationProfile new_profile) { | 807 ui::ColorCalibrationProfile new_profile) { |
795 for (const DisplaySnapshot* display : cached_displays_) { | 808 for (const DisplaySnapshot* display : cached_displays_) { |
796 if (display->display_id() == display_id) { | 809 if (display->display_id() == display_id && |
810 IsPhysicalDisplayType(display->type())) { | |
797 return native_display_delegate_->SetColorCalibrationProfile(*display, | 811 return native_display_delegate_->SetColorCalibrationProfile(*display, |
798 new_profile); | 812 new_profile); |
799 } | 813 } |
800 } | 814 } |
801 | 815 |
802 return false; | 816 return false; |
803 } | 817 } |
804 | 818 |
805 bool DisplayConfigurator::SetGammaRamp( | 819 bool DisplayConfigurator::SetGammaRamp( |
806 int64_t display_id, | 820 int64_t display_id, |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
957 " requested"; | 971 " requested"; |
958 CallAndClearQueuedCallbacks(true); | 972 CallAndClearQueuedCallbacks(true); |
959 return; | 973 return; |
960 } | 974 } |
961 | 975 |
962 configuration_task_.reset(new UpdateDisplayConfigurationTask( | 976 configuration_task_.reset(new UpdateDisplayConfigurationTask( |
963 native_display_delegate_.get(), layout_manager_.get(), | 977 native_display_delegate_.get(), layout_manager_.get(), |
964 requested_display_state_, requested_power_state_, requested_power_flags_, | 978 requested_display_state_, requested_power_state_, requested_power_flags_, |
965 0, force_configure_, base::Bind(&DisplayConfigurator::OnConfigured, | 979 0, force_configure_, base::Bind(&DisplayConfigurator::OnConfigured, |
966 weak_ptr_factory_.GetWeakPtr()))); | 980 weak_ptr_factory_.GetWeakPtr()))); |
981 configuration_task_->set_virtual_display_snapshots( | |
982 virtual_display_snapshots_.get()); | |
967 | 983 |
968 // Reset the flags before running the task; otherwise it may end up scheduling | 984 // Reset the flags before running the task; otherwise it may end up scheduling |
969 // another configuration. | 985 // another configuration. |
970 force_configure_ = false; | 986 force_configure_ = false; |
971 requested_power_flags_ = kSetDisplayPowerNoFlags; | 987 requested_power_flags_ = kSetDisplayPowerNoFlags; |
972 requested_power_state_change_ = false; | 988 requested_power_state_change_ = false; |
973 requested_display_state_ = MULTIPLE_DISPLAY_STATE_INVALID; | 989 requested_display_state_ = MULTIPLE_DISPLAY_STATE_INVALID; |
974 | 990 |
975 DCHECK(in_progress_configuration_callbacks_.empty()); | 991 DCHECK(in_progress_configuration_callbacks_.empty()); |
976 in_progress_configuration_callbacks_.swap(queued_configuration_callbacks_); | 992 in_progress_configuration_callbacks_.swap(queued_configuration_callbacks_); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1072 if (success) { | 1088 if (success) { |
1073 FOR_EACH_OBSERVER( | 1089 FOR_EACH_OBSERVER( |
1074 Observer, observers_, OnDisplayModeChanged(cached_displays_)); | 1090 Observer, observers_, OnDisplayModeChanged(cached_displays_)); |
1075 } else { | 1091 } else { |
1076 FOR_EACH_OBSERVER( | 1092 FOR_EACH_OBSERVER( |
1077 Observer, observers_, OnDisplayModeChangeFailed(cached_displays_, | 1093 Observer, observers_, OnDisplayModeChangeFailed(cached_displays_, |
1078 attempted_state)); | 1094 attempted_state)); |
1079 } | 1095 } |
1080 } | 1096 } |
1081 | 1097 |
1098 int64_t DisplayConfigurator::AddVirtualDisplay(gfx::Size display_size) { | |
1099 if (last_virtual_display_id_ == 0xff) { | |
1100 LOG(WARNING) << "Exceeded virtual display id limit"; | |
1101 return gfx::Display::kInvalidDisplayID; | |
1102 } | |
1103 | |
1104 DisplaySnapshotVirtual* virtual_snapshot = new DisplaySnapshotVirtual( | |
1105 GetDisplayID(0x8000, 0x0, ++last_virtual_display_id_), display_size); | |
robert.bradford
2015/11/26 16:29:41
Would you prefer a kReservedManufacturerID constan
oshima
2015/12/02 20:34:27
Yes, and you can put it in the anonymous namespace
robert.bradford
2015/12/03 18:44:57
Done. And I used 1 << 15 to further clarify.
| |
1106 virtual_display_snapshots_.push_back(virtual_snapshot); | |
1107 ConfigureDisplays(); | |
1108 | |
1109 return virtual_snapshot->display_id(); | |
1110 } | |
1111 | |
1112 bool DisplayConfigurator::RemoveVirtualDisplay(int64_t display_id) { | |
1113 for (auto it = virtual_display_snapshots_.begin(); | |
1114 it != virtual_display_snapshots_.end(); ++it) { | |
1115 if ((*it)->display_id() == display_id) { | |
1116 if ((display_id & 0xff) == last_virtual_display_id_) | |
1117 last_virtual_display_id_--; | |
oshima
2015/12/02 20:34:27
can you walk through the list (after erase) and se
robert.bradford
2015/12/03 18:44:57
Done.
| |
1118 virtual_display_snapshots_.erase(it); | |
1119 ConfigureDisplays(); | |
1120 return true; | |
1121 } | |
1122 } | |
1123 return false; | |
1124 } | |
1125 | |
1082 } // namespace ui | 1126 } // namespace ui |
OLD | NEW |