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/host/drm_display_host_manager.h" | 5 #include "ui/ozone/platform/drm/host/drm_display_host_manager.h" |
6 | 6 |
7 #include <fcntl.h> | 7 #include <fcntl.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <xf86drm.h> | 9 #include <xf86drm.h> |
10 | 10 |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 } | 138 } |
139 | 139 |
140 device_manager_->AddObserver(this); | 140 device_manager_->AddObserver(this); |
141 proxy_->RegisterHandlerForDrmDisplayHostManager(this); | 141 proxy_->RegisterHandlerForDrmDisplayHostManager(this); |
142 proxy_->AddGpuThreadObserver(this); | 142 proxy_->AddGpuThreadObserver(this); |
143 | 143 |
144 ScopedVector<HardwareDisplayControllerInfo> display_infos = | 144 ScopedVector<HardwareDisplayControllerInfo> display_infos = |
145 GetAvailableDisplayControllerInfos(primary_drm_device_handle_->fd()); | 145 GetAvailableDisplayControllerInfos(primary_drm_device_handle_->fd()); |
146 has_dummy_display_ = !display_infos.empty(); | 146 has_dummy_display_ = !display_infos.empty(); |
147 for (size_t i = 0; i < display_infos.size(); ++i) { | 147 for (size_t i = 0; i < display_infos.size(); ++i) { |
148 displays_.push_back(base::WrapUnique(new DrmDisplayHost( | 148 displays_.push_back(base::MakeUnique<DrmDisplayHost>( |
149 proxy_, CreateDisplaySnapshotParams( | 149 proxy_, CreateDisplaySnapshotParams( |
150 display_infos[i], primary_drm_device_handle_->fd(), | 150 display_infos[i], primary_drm_device_handle_->fd(), |
151 primary_drm_device_handle_->sys_path(), 0, gfx::Point()), | 151 primary_drm_device_handle_->sys_path(), 0, gfx::Point()), |
152 true /* is_dummy */))); | 152 true /* is_dummy */)); |
153 } | 153 } |
154 } | 154 } |
155 | 155 |
156 DrmDisplayHostManager::~DrmDisplayHostManager() { | 156 DrmDisplayHostManager::~DrmDisplayHostManager() { |
157 device_manager_->RemoveObserver(this); | 157 device_manager_->RemoveObserver(this); |
158 proxy_->UnRegisterHandlerForDrmDisplayHostManager(); | 158 proxy_->UnRegisterHandlerForDrmDisplayHostManager(); |
159 } | 159 } |
160 | 160 |
161 DrmDisplayHost* DrmDisplayHostManager::GetDisplay(int64_t display_id) { | 161 DrmDisplayHost* DrmDisplayHostManager::GetDisplay(int64_t display_id) { |
162 auto it = std::find_if(displays_.begin(), displays_.end(), | 162 auto it = std::find_if(displays_.begin(), displays_.end(), |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 void DrmDisplayHostManager::OnGpuThreadRetired() {} | 357 void DrmDisplayHostManager::OnGpuThreadRetired() {} |
358 | 358 |
359 void DrmDisplayHostManager::GpuHasUpdatedNativeDisplays( | 359 void DrmDisplayHostManager::GpuHasUpdatedNativeDisplays( |
360 const std::vector<DisplaySnapshot_Params>& params) { | 360 const std::vector<DisplaySnapshot_Params>& params) { |
361 std::vector<std::unique_ptr<DrmDisplayHost>> old_displays; | 361 std::vector<std::unique_ptr<DrmDisplayHost>> old_displays; |
362 displays_.swap(old_displays); | 362 displays_.swap(old_displays); |
363 for (size_t i = 0; i < params.size(); ++i) { | 363 for (size_t i = 0; i < params.size(); ++i) { |
364 auto it = std::find_if(old_displays.begin(), old_displays.end(), | 364 auto it = std::find_if(old_displays.begin(), old_displays.end(), |
365 FindDrmDisplayHostById(params[i].display_id)); | 365 FindDrmDisplayHostById(params[i].display_id)); |
366 if (it == old_displays.end()) { | 366 if (it == old_displays.end()) { |
367 displays_.push_back(base::WrapUnique( | 367 displays_.push_back(base::MakeUnique<DrmDisplayHost>( |
368 new DrmDisplayHost(proxy_, params[i], false /* is_dummy */))); | 368 proxy_, params[i], false /* is_dummy */)); |
369 } else { | 369 } else { |
370 (*it)->UpdateDisplaySnapshot(params[i]); | 370 (*it)->UpdateDisplaySnapshot(params[i]); |
371 displays_.push_back(std::move(*it)); | 371 displays_.push_back(std::move(*it)); |
372 old_displays.erase(it); | 372 old_displays.erase(it); |
373 } | 373 } |
374 } | 374 } |
375 | 375 |
376 if (!get_displays_callback_.is_null()) { | 376 if (!get_displays_callback_.is_null()) { |
377 base::ThreadTaskRunnerHandle::Get()->PostTask( | 377 base::ThreadTaskRunnerHandle::Get()->PostTask( |
378 FROM_HERE, | 378 FROM_HERE, |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 | 458 |
459 callback.Run(snapshots); | 459 callback.Run(snapshots); |
460 } | 460 } |
461 | 461 |
462 void DrmDisplayHostManager::NotifyDisplayDelegate() const { | 462 void DrmDisplayHostManager::NotifyDisplayDelegate() const { |
463 if (delegate_) | 463 if (delegate_) |
464 delegate_->OnConfigurationChanged(); | 464 delegate_->OnConfigurationChanged(); |
465 } | 465 } |
466 | 466 |
467 } // namespace ui | 467 } // namespace ui |
OLD | NEW |