| 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/manager/chromeos/display_configurator.h" | 5 #include "ui/display/manager/chromeos/display_configurator.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/sys_info.h" | 14 #include "base/sys_info.h" |
| 15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 16 #include "ui/display/display.h" | 16 #include "ui/display/display.h" |
| 17 #include "ui/display/display_switches.h" | 17 #include "ui/display/display_switches.h" |
| 18 #include "ui/display/manager/chromeos/apply_content_protection_task.h" | 18 #include "ui/display/manager/chromeos/apply_content_protection_task.h" |
| 19 #include "ui/display/manager/chromeos/display_layout_manager.h" | 19 #include "ui/display/manager/chromeos/display_layout_manager.h" |
| 20 #include "ui/display/manager/chromeos/display_snapshot_virtual.h" | 20 #include "ui/display/manager/chromeos/display_snapshot_virtual.h" |
| 21 #include "ui/display/manager/chromeos/display_util.h" | 21 #include "ui/display/manager/chromeos/display_util.h" |
| 22 #include "ui/display/manager/chromeos/update_display_configuration_task.h" | 22 #include "ui/display/manager/chromeos/update_display_configuration_task.h" |
| 23 #include "ui/display/types/display_mode.h" | 23 #include "ui/display/types/display_mode.h" |
| 24 #include "ui/display/types/display_snapshot.h" | 24 #include "ui/display/types/display_snapshot.h" |
| 25 #include "ui/display/types/native_display_delegate.h" | 25 #include "ui/display/types/native_display_delegate.h" |
| 26 #include "ui/display/util/display_util.h" | 26 #include "ui/display/util/display_util.h" |
| 27 | 27 |
| 28 namespace ui { | 28 namespace display { |
| 29 | 29 |
| 30 namespace { | 30 namespace { |
| 31 | 31 |
| 32 typedef std::vector<const DisplayMode*> DisplayModeList; | 32 typedef std::vector<const DisplayMode*> DisplayModeList; |
| 33 | 33 |
| 34 // The EDID specification marks the top bit of the manufacturer id as reserved. | 34 // The EDID specification marks the top bit of the manufacturer id as reserved. |
| 35 const int16_t kReservedManufacturerID = static_cast<int16_t>(1 << 15); | 35 const int16_t kReservedManufacturerID = static_cast<int16_t>(1 << 15); |
| 36 | 36 |
| 37 struct DisplayState { | 37 struct DisplayState { |
| 38 DisplaySnapshot* display = nullptr; // Not owned. | 38 DisplaySnapshot* display = nullptr; // Not owned. |
| (...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 804 } | 804 } |
| 805 } else { | 805 } else { |
| 806 client_protection_requests_[client_id][display_id] = desired_method_mask; | 806 client_protection_requests_[client_id][display_id] = desired_method_mask; |
| 807 } | 807 } |
| 808 | 808 |
| 809 callback.Run(true); | 809 callback.Run(true); |
| 810 if (!content_protection_tasks_.empty()) | 810 if (!content_protection_tasks_.empty()) |
| 811 content_protection_tasks_.front().Run(); | 811 content_protection_tasks_.front().Run(); |
| 812 } | 812 } |
| 813 | 813 |
| 814 std::vector<ui::ColorCalibrationProfile> | 814 std::vector<ColorCalibrationProfile> |
| 815 DisplayConfigurator::GetAvailableColorCalibrationProfiles(int64_t display_id) { | 815 DisplayConfigurator::GetAvailableColorCalibrationProfiles(int64_t display_id) { |
| 816 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 816 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 817 switches::kDisableDisplayColorCalibration)) { | 817 switches::kDisableDisplayColorCalibration)) { |
| 818 for (const DisplaySnapshot* display : cached_displays_) { | 818 for (const DisplaySnapshot* display : cached_displays_) { |
| 819 if (display->display_id() == display_id && | 819 if (display->display_id() == display_id && |
| 820 IsPhysicalDisplayType(display->type())) { | 820 IsPhysicalDisplayType(display->type())) { |
| 821 return native_display_delegate_->GetAvailableColorCalibrationProfiles( | 821 return native_display_delegate_->GetAvailableColorCalibrationProfiles( |
| 822 *display); | 822 *display); |
| 823 } | 823 } |
| 824 } | 824 } |
| 825 } | 825 } |
| 826 | 826 |
| 827 return std::vector<ui::ColorCalibrationProfile>(); | 827 return std::vector<ColorCalibrationProfile>(); |
| 828 } | 828 } |
| 829 | 829 |
| 830 bool DisplayConfigurator::SetColorCalibrationProfile( | 830 bool DisplayConfigurator::SetColorCalibrationProfile( |
| 831 int64_t display_id, | 831 int64_t display_id, |
| 832 ui::ColorCalibrationProfile new_profile) { | 832 ColorCalibrationProfile new_profile) { |
| 833 for (const DisplaySnapshot* display : cached_displays_) { | 833 for (const DisplaySnapshot* display : cached_displays_) { |
| 834 if (display->display_id() == display_id && | 834 if (display->display_id() == display_id && |
| 835 IsPhysicalDisplayType(display->type())) { | 835 IsPhysicalDisplayType(display->type())) { |
| 836 return native_display_delegate_->SetColorCalibrationProfile(*display, | 836 return native_display_delegate_->SetColorCalibrationProfile(*display, |
| 837 new_profile); | 837 new_profile); |
| 838 } | 838 } |
| 839 } | 839 } |
| 840 | 840 |
| 841 return false; | 841 return false; |
| 842 } | 842 } |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1151 } | 1151 } |
| 1152 | 1152 |
| 1153 void DisplayConfigurator::NotifyPowerStateObservers() { | 1153 void DisplayConfigurator::NotifyPowerStateObservers() { |
| 1154 for (Observer& observer : observers_) | 1154 for (Observer& observer : observers_) |
| 1155 observer.OnPowerStateChanged(current_power_state_); | 1155 observer.OnPowerStateChanged(current_power_state_); |
| 1156 } | 1156 } |
| 1157 | 1157 |
| 1158 int64_t DisplayConfigurator::AddVirtualDisplay(const gfx::Size& display_size) { | 1158 int64_t DisplayConfigurator::AddVirtualDisplay(const gfx::Size& display_size) { |
| 1159 if (last_virtual_display_id_ == 0xff) { | 1159 if (last_virtual_display_id_ == 0xff) { |
| 1160 LOG(WARNING) << "Exceeded virtual display id limit"; | 1160 LOG(WARNING) << "Exceeded virtual display id limit"; |
| 1161 return display::kInvalidDisplayId; | 1161 return kInvalidDisplayId; |
| 1162 } | 1162 } |
| 1163 | 1163 |
| 1164 DisplaySnapshotVirtual* virtual_snapshot = new DisplaySnapshotVirtual( | 1164 DisplaySnapshotVirtual* virtual_snapshot = |
| 1165 display::GenerateDisplayID(kReservedManufacturerID, 0x0, | 1165 new DisplaySnapshotVirtual(GenerateDisplayID(kReservedManufacturerID, 0x0, |
| 1166 ++last_virtual_display_id_), | 1166 ++last_virtual_display_id_), |
| 1167 display_size); | 1167 display_size); |
| 1168 virtual_display_snapshots_.push_back(virtual_snapshot); | 1168 virtual_display_snapshots_.push_back(virtual_snapshot); |
| 1169 ConfigureDisplays(); | 1169 ConfigureDisplays(); |
| 1170 | 1170 |
| 1171 return virtual_snapshot->display_id(); | 1171 return virtual_snapshot->display_id(); |
| 1172 } | 1172 } |
| 1173 | 1173 |
| 1174 bool DisplayConfigurator::RemoveVirtualDisplay(int64_t display_id) { | 1174 bool DisplayConfigurator::RemoveVirtualDisplay(int64_t display_id) { |
| 1175 bool display_found = false; | 1175 bool display_found = false; |
| 1176 for (auto it = virtual_display_snapshots_.begin(); | 1176 for (auto it = virtual_display_snapshots_.begin(); |
| 1177 it != virtual_display_snapshots_.end(); ++it) { | 1177 it != virtual_display_snapshots_.end(); ++it) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1191 max_display_id = std::max(max_display_id, display->display_id()); | 1191 max_display_id = std::max(max_display_id, display->display_id()); |
| 1192 last_virtual_display_id_ = max_display_id & 0xff; | 1192 last_virtual_display_id_ = max_display_id & 0xff; |
| 1193 | 1193 |
| 1194 return true; | 1194 return true; |
| 1195 } | 1195 } |
| 1196 | 1196 |
| 1197 bool DisplayConfigurator::IsDisplayOn() const { | 1197 bool DisplayConfigurator::IsDisplayOn() const { |
| 1198 return current_power_state_ != chromeos::DISPLAY_POWER_ALL_OFF; | 1198 return current_power_state_ != chromeos::DISPLAY_POWER_ALL_OFF; |
| 1199 } | 1199 } |
| 1200 | 1200 |
| 1201 } // namespace ui | 1201 } // namespace display |
| OLD | NEW |