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