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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 | 216 |
217 relinquish_display_control_callback_ = callback; | 217 relinquish_display_control_callback_ = callback; |
218 display_control_change_pending_ = true; | 218 display_control_change_pending_ = true; |
219 | 219 |
220 if (!proxy_->RelinquishDisplayControl()) | 220 if (!proxy_->RelinquishDisplayControl()) |
221 OnRelinquishDisplayControl(false); | 221 OnRelinquishDisplayControl(false); |
222 } | 222 } |
223 | 223 |
224 void DrmDisplayHostManager::UpdateDisplays( | 224 void DrmDisplayHostManager::UpdateDisplays( |
225 const GetDisplaysCallback& callback) { | 225 const GetDisplaysCallback& callback) { |
| 226 DCHECK(get_displays_callback_.is_null()); |
226 get_displays_callback_ = callback; | 227 get_displays_callback_ = callback; |
227 if (!proxy_->RefreshNativeDisplays()) { | 228 if (!proxy_->RefreshNativeDisplays()) { |
228 get_displays_callback_.Reset(); | 229 get_displays_callback_.Reset(); |
229 RunUpdateDisplaysCallback(callback); | 230 RunUpdateDisplaysCallback(callback); |
230 } | 231 } |
231 } | 232 } |
232 | 233 |
233 void DrmDisplayHostManager::OnDeviceEvent(const DeviceEvent& event) { | 234 void DrmDisplayHostManager::OnDeviceEvent(const DeviceEvent& event) { |
234 if (event.device_type() != DeviceEvent::DISPLAY) | 235 if (event.device_type() != DeviceEvent::DISPLAY) |
235 return; | 236 return; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 } | 302 } |
302 | 303 |
303 void DrmDisplayHostManager::OnRemoveGraphicsDevice(const base::FilePath& path) { | 304 void DrmDisplayHostManager::OnRemoveGraphicsDevice(const base::FilePath& path) { |
304 proxy_->RemoveGraphicsDevice(path); | 305 proxy_->RemoveGraphicsDevice(path); |
305 NotifyDisplayDelegate(); | 306 NotifyDisplayDelegate(); |
306 task_pending_ = false; | 307 task_pending_ = false; |
307 ProcessEvent(); | 308 ProcessEvent(); |
308 } | 309 } |
309 | 310 |
310 void DrmDisplayHostManager::OnChannelEstablished(int host_id) { | 311 void DrmDisplayHostManager::OnChannelEstablished(int host_id) { |
311 // If in the middle of a configuration, just respond with the old list of | 312 // If in the middle of a configuration - don't respond here. |
312 // displays. This is fine, since after the DRM resources are initialized and | 313 // Chromium does so, but that causes a problem: |
313 // IPC-ed to the GPU NotifyDisplayDelegate() is called to let the display | 314 // NotifyDisplayDelegate, below, triggers a new update display request which |
314 // delegate know that the display configuration changed and it needs to | 315 // is |
315 // update it again. | 316 // fulfilled by the results from the first request. That result is empty |
316 if (!get_displays_callback_.is_null()) { | 317 // because |
317 base::ThreadTaskRunnerHandle::Get()->PostTask( | 318 // we haven't added a drm device yet). |
318 FROM_HERE, | 319 // The second update display request generates non empty results, |
319 base::Bind(&DrmDisplayHostManager::RunUpdateDisplaysCallback, | 320 // but those won't be forwarded to the observer because there is no longer |
320 weak_ptr_factory_.GetWeakPtr(), get_displays_callback_)); | 321 // an outstanding request. |
321 get_displays_callback_.Reset(); | |
322 } | |
323 | 322 |
324 // Signal that we're taking DRM master since we're going through the | 323 // Signal that we're taking DRM master since we're going through the |
325 // initialization process again and we'll take all the available resources. | 324 // initialization process again and we'll take all the available resources. |
326 if (!take_display_control_callback_.is_null()) | 325 if (!take_display_control_callback_.is_null()) |
327 OnTakeDisplayControl(true); | 326 OnTakeDisplayControl(true); |
328 | 327 |
329 if (!relinquish_display_control_callback_.is_null()) | 328 if (!relinquish_display_control_callback_.is_null()) |
330 OnRelinquishDisplayControl(false); | 329 OnRelinquishDisplayControl(false); |
331 | 330 |
332 drm_devices_.clear(); | 331 drm_devices_.clear(); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 | 451 |
453 callback.Run(snapshots); | 452 callback.Run(snapshots); |
454 } | 453 } |
455 | 454 |
456 void DrmDisplayHostManager::NotifyDisplayDelegate() const { | 455 void DrmDisplayHostManager::NotifyDisplayDelegate() const { |
457 if (delegate_) | 456 if (delegate_) |
458 delegate_->OnConfigurationChanged(); | 457 delegate_->OnConfigurationChanged(); |
459 } | 458 } |
460 | 459 |
461 } // namespace ui | 460 } // namespace ui |
OLD | NEW |