| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 mode_params.refresh_rate == params.refresh_rate && | 48 mode_params.refresh_rate == params.refresh_rate && |
| 49 mode_params.is_interlaced == params.is_interlaced) { | 49 mode_params.is_interlaced == params.is_interlaced) { |
| 50 *mode = m; | 50 *mode = m; |
| 51 return true; | 51 return true; |
| 52 } | 52 } |
| 53 } | 53 } |
| 54 | 54 |
| 55 return false; | 55 return false; |
| 56 } | 56 } |
| 57 | 57 |
| 58 std::vector<drmModeModeInfo> GetDrmModeVector(drmModeConnector* connector) { | |
| 59 std::vector<drmModeModeInfo> modes; | |
| 60 for (int i = 0; i < connector->count_modes; ++i) | |
| 61 modes.push_back(connector->modes[i]); | |
| 62 | |
| 63 return modes; | |
| 64 } | |
| 65 | |
| 66 } // namespace | 58 } // namespace |
| 67 | 59 |
| 68 DrmGpuDisplayManager::DrmGpuDisplayManager(ScreenManager* screen_manager, | 60 DrmGpuDisplayManager::DrmGpuDisplayManager(ScreenManager* screen_manager, |
| 69 DrmDeviceManager* drm_device_manager) | 61 DrmDeviceManager* drm_device_manager) |
| 70 : screen_manager_(screen_manager), drm_device_manager_(drm_device_manager) { | 62 : screen_manager_(screen_manager), drm_device_manager_(drm_device_manager) { |
| 71 } | 63 } |
| 72 | 64 |
| 73 DrmGpuDisplayManager::~DrmGpuDisplayManager() { | 65 DrmGpuDisplayManager::~DrmGpuDisplayManager() { |
| 74 } | 66 } |
| 75 | 67 |
| 76 std::vector<DisplaySnapshot_Params> DrmGpuDisplayManager::GetDisplays() { | 68 std::vector<DisplaySnapshot_Params> DrmGpuDisplayManager::GetDisplays() { |
| 77 ScopedVector<DrmDisplay> old_displays(displays_.Pass()); | 69 ScopedVector<DrmDisplay> old_displays(displays_.Pass()); |
| 78 std::vector<DisplaySnapshot_Params> params_list; | 70 std::vector<DisplaySnapshot_Params> params_list; |
| 79 | 71 |
| 80 const DrmDeviceVector& devices = drm_device_manager_->GetDrmDevices(); | 72 const DrmDeviceVector& devices = drm_device_manager_->GetDrmDevices(); |
| 81 // Unique identifier used to create the display id. | 73 // Unique identifier used to create the display id. |
| 82 size_t index = 0; | 74 size_t index = 0; |
| 83 for (const auto& drm : devices) { | 75 for (const auto& drm : devices) { |
| 84 ScopedVector<HardwareDisplayControllerInfo> display_infos = | 76 ScopedVector<HardwareDisplayControllerInfo> display_infos = |
| 85 GetAvailableDisplayControllerInfos(drm->get_fd()); | 77 GetAvailableDisplayControllerInfos(drm->get_fd()); |
| 86 for (auto* display_info : display_infos) { | 78 for (auto* display_info : display_infos) { |
| 87 DisplaySnapshot_Params params = | 79 auto it = std::find_if( |
| 88 CreateDisplaySnapshotParams(display_info, drm->get_fd(), index++); | 80 old_displays.begin(), old_displays.end(), |
| 89 params_list.push_back(params); | 81 DisplayComparator(drm, display_info->crtc()->crtc_id, |
| 82 display_info->connector()->connector_id)); |
| 83 if (it != old_displays.end()) { |
| 84 displays_.push_back(*it); |
| 85 old_displays.weak_erase(it); |
| 86 } else { |
| 87 displays_.push_back(new DrmDisplay(screen_manager_, drm)); |
| 88 } |
| 90 | 89 |
| 91 displays_.push_back( | 90 params_list.push_back(displays_.back()->Update(display_info, index++)); |
| 92 new DrmDisplay(screen_manager_, params.display_id, drm, | |
| 93 display_info->crtc()->crtc_id, | |
| 94 display_info->connector()->connector_id, | |
| 95 GetDrmModeVector(display_info->connector()))); | |
| 96 } | 91 } |
| 97 } | 92 } |
| 98 | 93 |
| 99 NotifyScreenManager(displays_.get(), old_displays.get()); | 94 NotifyScreenManager(displays_.get(), old_displays.get()); |
| 100 return params_list; | 95 return params_list; |
| 101 } | 96 } |
| 102 | 97 |
| 103 bool DrmGpuDisplayManager::TakeDisplayControl() { | 98 bool DrmGpuDisplayManager::TakeDisplayControl() { |
| 104 const DrmDeviceVector& devices = drm_device_manager_->GetDrmDevices(); | 99 const DrmDeviceVector& devices = drm_device_manager_->GetDrmDevices(); |
| 105 for (const auto& drm : devices) { | 100 for (const auto& drm : devices) { |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 | 224 |
| 230 if (it == old_displays.end()) { | 225 if (it == old_displays.end()) { |
| 231 screen_manager_->AddDisplayController(new_displays[i]->drm(), | 226 screen_manager_->AddDisplayController(new_displays[i]->drm(), |
| 232 new_displays[i]->crtc(), | 227 new_displays[i]->crtc(), |
| 233 new_displays[i]->connector()); | 228 new_displays[i]->connector()); |
| 234 } | 229 } |
| 235 } | 230 } |
| 236 } | 231 } |
| 237 | 232 |
| 238 } // namespace ui | 233 } // namespace ui |
| OLD | NEW |