| 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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 DCHECK(!delegate_); | 170 DCHECK(!delegate_); |
| 171 delegate_ = delegate; | 171 delegate_ = delegate; |
| 172 } | 172 } |
| 173 | 173 |
| 174 void DrmDisplayHostManager::RemoveDelegate(DrmNativeDisplayDelegate* delegate) { | 174 void DrmDisplayHostManager::RemoveDelegate(DrmNativeDisplayDelegate* delegate) { |
| 175 DCHECK_EQ(delegate_, delegate); | 175 DCHECK_EQ(delegate_, delegate); |
| 176 delegate_ = nullptr; | 176 delegate_ = nullptr; |
| 177 } | 177 } |
| 178 | 178 |
| 179 void DrmDisplayHostManager::TakeDisplayControl( | 179 void DrmDisplayHostManager::TakeDisplayControl( |
| 180 const DisplayControlCallback& callback) { | 180 const display::DisplayControlCallback& callback) { |
| 181 if (display_control_change_pending_) { | 181 if (display_control_change_pending_) { |
| 182 LOG(ERROR) << "TakeDisplayControl called while change already pending"; | 182 LOG(ERROR) << "TakeDisplayControl called while change already pending"; |
| 183 callback.Run(false); | 183 callback.Run(false); |
| 184 return; | 184 return; |
| 185 } | 185 } |
| 186 | 186 |
| 187 if (!display_externally_controlled_) { | 187 if (!display_externally_controlled_) { |
| 188 LOG(ERROR) << "TakeDisplayControl called while display already owned"; | 188 LOG(ERROR) << "TakeDisplayControl called while display already owned"; |
| 189 callback.Run(true); | 189 callback.Run(true); |
| 190 return; | 190 return; |
| 191 } | 191 } |
| 192 | 192 |
| 193 take_display_control_callback_ = callback; | 193 take_display_control_callback_ = callback; |
| 194 display_control_change_pending_ = true; | 194 display_control_change_pending_ = true; |
| 195 | 195 |
| 196 if (!proxy_->GpuTakeDisplayControl()) | 196 if (!proxy_->GpuTakeDisplayControl()) |
| 197 GpuTookDisplayControl(false); | 197 GpuTookDisplayControl(false); |
| 198 } | 198 } |
| 199 | 199 |
| 200 void DrmDisplayHostManager::RelinquishDisplayControl( | 200 void DrmDisplayHostManager::RelinquishDisplayControl( |
| 201 const DisplayControlCallback& callback) { | 201 const display::DisplayControlCallback& callback) { |
| 202 if (display_control_change_pending_) { | 202 if (display_control_change_pending_) { |
| 203 LOG(ERROR) | 203 LOG(ERROR) |
| 204 << "RelinquishDisplayControl called while change already pending"; | 204 << "RelinquishDisplayControl called while change already pending"; |
| 205 callback.Run(false); | 205 callback.Run(false); |
| 206 return; | 206 return; |
| 207 } | 207 } |
| 208 | 208 |
| 209 if (display_externally_controlled_) { | 209 if (display_externally_controlled_) { |
| 210 LOG(ERROR) << "RelinquishDisplayControl called while display not owned"; | 210 LOG(ERROR) << "RelinquishDisplayControl called while display not owned"; |
| 211 callback.Run(true); | 211 callback.Run(true); |
| 212 return; | 212 return; |
| 213 } | 213 } |
| 214 | 214 |
| 215 relinquish_display_control_callback_ = callback; | 215 relinquish_display_control_callback_ = callback; |
| 216 display_control_change_pending_ = true; | 216 display_control_change_pending_ = true; |
| 217 | 217 |
| 218 if (!proxy_->GpuRelinquishDisplayControl()) | 218 if (!proxy_->GpuRelinquishDisplayControl()) |
| 219 GpuRelinquishedDisplayControl(false); | 219 GpuRelinquishedDisplayControl(false); |
| 220 } | 220 } |
| 221 | 221 |
| 222 void DrmDisplayHostManager::UpdateDisplays( | 222 void DrmDisplayHostManager::UpdateDisplays( |
| 223 const GetDisplaysCallback& callback) { | 223 const display::GetDisplaysCallback& callback) { |
| 224 get_displays_callback_ = callback; | 224 get_displays_callback_ = callback; |
| 225 if (!proxy_->GpuRefreshNativeDisplays()) { | 225 if (!proxy_->GpuRefreshNativeDisplays()) { |
| 226 get_displays_callback_.Reset(); | 226 get_displays_callback_.Reset(); |
| 227 RunUpdateDisplaysCallback(callback); | 227 RunUpdateDisplaysCallback(callback); |
| 228 } | 228 } |
| 229 } | 229 } |
| 230 | 230 |
| 231 void DrmDisplayHostManager::OnDeviceEvent(const DeviceEvent& event) { | 231 void DrmDisplayHostManager::OnDeviceEvent(const DeviceEvent& event) { |
| 232 if (event.device_type() != DeviceEvent::DISPLAY) | 232 if (event.device_type() != DeviceEvent::DISPLAY) |
| 233 return; | 233 return; |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 bool status) { | 389 bool status) { |
| 390 DrmDisplayHost* display = GetDisplay(display_id); | 390 DrmDisplayHost* display = GetDisplay(display_id); |
| 391 if (display) | 391 if (display) |
| 392 display->OnDisplayConfigured(status); | 392 display->OnDisplayConfigured(status); |
| 393 else | 393 else |
| 394 LOG(ERROR) << "Couldn't find display with id=" << display_id; | 394 LOG(ERROR) << "Couldn't find display with id=" << display_id; |
| 395 } | 395 } |
| 396 | 396 |
| 397 void DrmDisplayHostManager::GpuReceivedHDCPState(int64_t display_id, | 397 void DrmDisplayHostManager::GpuReceivedHDCPState(int64_t display_id, |
| 398 bool status, | 398 bool status, |
| 399 HDCPState state) { | 399 display::HDCPState state) { |
| 400 DrmDisplayHost* display = GetDisplay(display_id); | 400 DrmDisplayHost* display = GetDisplay(display_id); |
| 401 if (display) | 401 if (display) |
| 402 display->OnHDCPStateReceived(status, state); | 402 display->OnHDCPStateReceived(status, state); |
| 403 else | 403 else |
| 404 LOG(ERROR) << "Couldn't find display with id=" << display_id; | 404 LOG(ERROR) << "Couldn't find display with id=" << display_id; |
| 405 } | 405 } |
| 406 | 406 |
| 407 void DrmDisplayHostManager::GpuUpdatedHDCPState(int64_t display_id, | 407 void DrmDisplayHostManager::GpuUpdatedHDCPState(int64_t display_id, |
| 408 bool status) { | 408 bool status) { |
| 409 DrmDisplayHost* display = GetDisplay(display_id); | 409 DrmDisplayHost* display = GetDisplay(display_id); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 display_externally_controlled_ = true; | 447 display_externally_controlled_ = true; |
| 448 } | 448 } |
| 449 | 449 |
| 450 base::ThreadTaskRunnerHandle::Get()->PostTask( | 450 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 451 FROM_HERE, base::Bind(relinquish_display_control_callback_, status)); | 451 FROM_HERE, base::Bind(relinquish_display_control_callback_, status)); |
| 452 relinquish_display_control_callback_.Reset(); | 452 relinquish_display_control_callback_.Reset(); |
| 453 display_control_change_pending_ = false; | 453 display_control_change_pending_ = false; |
| 454 } | 454 } |
| 455 | 455 |
| 456 void DrmDisplayHostManager::RunUpdateDisplaysCallback( | 456 void DrmDisplayHostManager::RunUpdateDisplaysCallback( |
| 457 const GetDisplaysCallback& callback) const { | 457 const display::GetDisplaysCallback& callback) const { |
| 458 std::vector<DisplaySnapshot*> snapshots; | 458 std::vector<display::DisplaySnapshot*> snapshots; |
| 459 for (const auto& display : displays_) | 459 for (const auto& display : displays_) |
| 460 snapshots.push_back(display->snapshot()); | 460 snapshots.push_back(display->snapshot()); |
| 461 | 461 |
| 462 callback.Run(snapshots); | 462 callback.Run(snapshots); |
| 463 } | 463 } |
| 464 | 464 |
| 465 void DrmDisplayHostManager::NotifyDisplayDelegate() const { | 465 void DrmDisplayHostManager::NotifyDisplayDelegate() const { |
| 466 if (delegate_) | 466 if (delegate_) |
| 467 delegate_->OnConfigurationChanged(); | 467 delegate_->OnConfigurationChanged(); |
| 468 } | 468 } |
| 469 | 469 |
| 470 } // namespace ui | 470 } // namespace ui |
| OLD | NEW |