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/ozone/platform/drm/gpu/drm_gpu_display_manager.h" | 5 #include "ui/ozone/platform/drm/gpu/drm_gpu_display_manager.h" |
6 | 6 |
7 #include "ui/display/types/gamma_ramp_rgb_entry.h" | 7 #include "ui/display/types/gamma_ramp_rgb_entry.h" |
8 #include "ui/ozone/common/display_util.h" | 8 #include "ui/ozone/common/display_util.h" |
9 #include "ui/ozone/platform/drm/common/drm_util.h" | 9 #include "ui/ozone/platform/drm/common/drm_util.h" |
10 #include "ui/ozone/platform/drm/gpu/drm_device.h" | 10 #include "ui/ozone/platform/drm/gpu/drm_device.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 : screen_manager_(screen_manager), drm_device_manager_(drm_device_manager) { | 62 : screen_manager_(screen_manager), drm_device_manager_(drm_device_manager) { |
63 } | 63 } |
64 | 64 |
65 DrmGpuDisplayManager::~DrmGpuDisplayManager() { | 65 DrmGpuDisplayManager::~DrmGpuDisplayManager() { |
66 } | 66 } |
67 | 67 |
68 std::vector<DisplaySnapshot_Params> DrmGpuDisplayManager::GetDisplays() { | 68 std::vector<DisplaySnapshot_Params> DrmGpuDisplayManager::GetDisplays() { |
69 ScopedVector<DrmDisplay> old_displays(displays_.Pass()); | 69 ScopedVector<DrmDisplay> old_displays(displays_.Pass()); |
70 std::vector<DisplaySnapshot_Params> params_list; | 70 std::vector<DisplaySnapshot_Params> params_list; |
71 | 71 |
72 const DrmDeviceVector& devices = drm_device_manager_->GetDrmDevices(); | 72 DrmDeviceVector devices = drm_device_manager_->GetDrmDevices(); |
73 // Unique identifier used to create the display id. | 73 // Unique identifier used to create the display id. |
74 size_t index = 0; | 74 size_t index = 0; |
75 for (const auto& drm : devices) { | 75 for (const auto& drm : devices) { |
76 ScopedVector<HardwareDisplayControllerInfo> display_infos = | 76 ScopedVector<HardwareDisplayControllerInfo> display_infos = |
77 GetAvailableDisplayControllerInfos(drm->get_fd()); | 77 GetAvailableDisplayControllerInfos(drm->get_fd()); |
78 for (auto* display_info : display_infos) { | 78 for (auto* display_info : display_infos) { |
79 auto it = std::find_if( | 79 auto it = std::find_if( |
80 old_displays.begin(), old_displays.end(), | 80 old_displays.begin(), old_displays.end(), |
81 DisplayComparator(drm, display_info->crtc()->crtc_id, | 81 DisplayComparator(drm, display_info->crtc()->crtc_id, |
82 display_info->connector()->connector_id)); | 82 display_info->connector()->connector_id)); |
83 if (it != old_displays.end()) { | 83 if (it != old_displays.end()) { |
84 displays_.push_back(*it); | 84 displays_.push_back(*it); |
85 old_displays.weak_erase(it); | 85 old_displays.weak_erase(it); |
86 } else { | 86 } else { |
87 displays_.push_back(new DrmDisplay(screen_manager_, drm)); | 87 displays_.push_back(new DrmDisplay(screen_manager_, drm)); |
88 } | 88 } |
89 | 89 |
90 params_list.push_back(displays_.back()->Update(display_info, index++)); | 90 params_list.push_back(displays_.back()->Update(display_info, index++)); |
91 } | 91 } |
92 } | 92 } |
93 | 93 |
94 NotifyScreenManager(displays_.get(), old_displays.get()); | 94 NotifyScreenManager(displays_.get(), old_displays.get()); |
95 return params_list; | 95 return params_list; |
96 } | 96 } |
97 | 97 |
98 bool DrmGpuDisplayManager::TakeDisplayControl() { | 98 bool DrmGpuDisplayManager::TakeDisplayControl() { |
99 const DrmDeviceVector& devices = drm_device_manager_->GetDrmDevices(); | 99 DrmDeviceVector devices = drm_device_manager_->GetDrmDevices(); |
100 for (const auto& drm : devices) { | 100 for (const auto& drm : devices) { |
101 if (!drm->SetMaster()) { | 101 if (!drm->SetMaster()) { |
102 LOG(ERROR) << "Failed to take control of the display"; | 102 LOG(ERROR) << "Failed to take control of the display"; |
103 return false; | 103 return false; |
104 } | 104 } |
105 } | 105 } |
106 | 106 |
107 return true; | 107 return true; |
108 } | 108 } |
109 | 109 |
110 bool DrmGpuDisplayManager::RelinquishDisplayControl() { | 110 bool DrmGpuDisplayManager::RelinquishDisplayControl() { |
111 const DrmDeviceVector& devices = drm_device_manager_->GetDrmDevices(); | 111 DrmDeviceVector devices = drm_device_manager_->GetDrmDevices(); |
112 for (const auto& drm : devices) { | 112 for (const auto& drm : devices) { |
113 if (!drm->DropMaster()) { | 113 if (!drm->DropMaster()) { |
114 LOG(ERROR) << "Failed to relinquish control of the display"; | 114 LOG(ERROR) << "Failed to relinquish control of the display"; |
115 return false; | 115 return false; |
116 } | 116 } |
117 } | 117 } |
118 | 118 |
119 return true; | 119 return true; |
120 } | 120 } |
121 | 121 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 | 224 |
225 if (it == old_displays.end()) { | 225 if (it == old_displays.end()) { |
226 screen_manager_->AddDisplayController(new_displays[i]->drm(), | 226 screen_manager_->AddDisplayController(new_displays[i]->drm(), |
227 new_displays[i]->crtc(), | 227 new_displays[i]->crtc(), |
228 new_displays[i]->connector()); | 228 new_displays[i]->connector()); |
229 } | 229 } |
230 } | 230 } |
231 } | 231 } |
232 | 232 |
233 } // namespace ui | 233 } // namespace ui |
OLD | NEW |