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 <xf86drm.h> | 8 #include <xf86drm.h> |
9 | 9 |
10 #include "base/files/file_enumerator.h" | 10 #include "base/files/file_enumerator.h" |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 has_dummy_display_ = !display_infos.empty(); | 148 has_dummy_display_ = !display_infos.empty(); |
149 for (size_t i = 0; i < display_infos.size(); ++i) { | 149 for (size_t i = 0; i < display_infos.size(); ++i) { |
150 displays_.push_back(new DrmDisplayHost( | 150 displays_.push_back(new DrmDisplayHost( |
151 proxy_, CreateDisplaySnapshotParams(display_infos[i], | 151 proxy_, CreateDisplaySnapshotParams(display_infos[i], |
152 primary_drm_device_handle_->fd(), i, | 152 primary_drm_device_handle_->fd(), i, |
153 gfx::Point()), | 153 gfx::Point()), |
154 true /* is_dummy */)); | 154 true /* is_dummy */)); |
155 } | 155 } |
156 } | 156 } |
157 | 157 |
| 158 base::FileDescriptor DrmDisplayHostManager::DupVgemFd() { |
| 159 if (vgem_card_path_.empty()) |
| 160 return base::FileDescriptor(); |
| 161 |
| 162 int duped_handle = -1; |
| 163 { |
| 164 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 165 duped_handle = HANDLE_EINTR(dup(vgem_card_device_file_.get())); |
| 166 } |
| 167 if (duped_handle < 0) { |
| 168 PLOG(ERROR) << "dup() failed."; |
| 169 return base::FileDescriptor(); |
| 170 } |
| 171 |
| 172 return base::FileDescriptor(duped_handle, true); |
| 173 } |
| 174 |
158 DrmDisplayHostManager::~DrmDisplayHostManager() { | 175 DrmDisplayHostManager::~DrmDisplayHostManager() { |
159 device_manager_->RemoveObserver(this); | 176 device_manager_->RemoveObserver(this); |
160 proxy_->UnregisterHandler(this); | 177 proxy_->UnregisterHandler(this); |
161 } | 178 } |
162 | 179 |
163 DrmDisplayHost* DrmDisplayHostManager::GetDisplay(int64_t display_id) { | 180 DrmDisplayHost* DrmDisplayHostManager::GetDisplay(int64_t display_id) { |
164 auto it = std::find_if(displays_.begin(), displays_.end(), | 181 auto it = std::find_if(displays_.begin(), displays_.end(), |
165 FindDrmDisplayHostById(display_id)); | 182 FindDrmDisplayHostById(display_id)); |
166 if (it == displays_.end()) | 183 if (it == displays_.end()) |
167 return nullptr; | 184 return nullptr; |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 | 491 |
475 callback.Run(snapshots); | 492 callback.Run(snapshots); |
476 } | 493 } |
477 | 494 |
478 void DrmDisplayHostManager::NotifyDisplayDelegate() const { | 495 void DrmDisplayHostManager::NotifyDisplayDelegate() const { |
479 if (delegate_) | 496 if (delegate_) |
480 delegate_->OnConfigurationChanged(); | 497 delegate_->OnConfigurationChanged(); |
481 } | 498 } |
482 | 499 |
483 } // namespace ui | 500 } // namespace ui |
OLD | NEW |